Merge pull request #1619 from mzgoddard/execution-order-2

Execution order 2
This commit is contained in:
Karishma Chadha 2018-10-09 23:00:33 -04:00 committed by GitHub
commit fa52014650
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 24 additions and 4 deletions

View file

@ -109,7 +109,12 @@ class Scratch3EventBlocks {
}
// We've run before; check if the wait is still going on.
const instance = this;
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
// Scratch 2 considers threads to be waiting if they are still in
// runtime.threads. Threads that have run all their blocks, or are
// marked done but still in runtime.threads are still considered to
// be waiting.
const waiting = util.stackFrame.startedThreads
.some(thread => instance.runtime.threads.indexOf(thread) !== -1);
if (waiting) {
// If all threads are waiting for the next tick or later yield
// for a tick as well. Otherwise yield until the next loop of

View file

@ -415,7 +415,12 @@ class Scratch3LooksBlocks {
}
// We've run before; check if the wait is still going on.
const instance = this;
const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread));
// Scratch 2 considers threads to be waiting if they are still in
// runtime.threads. Threads that have run all their blocks, or are
// marked done but still in runtime.threads are still considered to
// be waiting.
const waiting = util.stackFrame.startedThreads
.some(thread => instance.runtime.threads.indexOf(thread) !== -1);
if (waiting) {
// If all threads are waiting for the next tick or later yield
// for a tick as well. Otherwise yield until the next loop of

View file

@ -900,6 +900,8 @@ class RenderedTarget extends Target {
// of what layers are present
this.renderer.setDrawableOrder(this.drawableID, Infinity, StageLayering.SPRITE_LAYER);
}
this.runtime.setExecutablePosition(this, Infinity);
}
/**
@ -911,6 +913,8 @@ class RenderedTarget extends Target {
// of what layers are present
this.renderer.setDrawableOrder(this.drawableID, -Infinity, StageLayering.SPRITE_LAYER, false);
}
this.runtime.setExecutablePosition(this, -Infinity);
}
/**
@ -921,6 +925,8 @@ class RenderedTarget extends Target {
if (this.renderer) {
this.renderer.setDrawableOrder(this.drawableID, nLayers, StageLayering.SPRITE_LAYER, true);
}
this.runtime.moveExecutable(this, nLayers);
}
/**
@ -931,6 +937,8 @@ class RenderedTarget extends Target {
if (this.renderer) {
this.renderer.setDrawableOrder(this.drawableID, -nLayers, StageLayering.SPRITE_LAYER, true);
}
this.runtime.moveExecutable(this, -nLayers);
}
/**

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -74,6 +74,7 @@ test('#760 - broadcastAndWait', t => {
// does not yield once all threads are done
th.status = Thread.STATUS_RUNNING;
rt.threads[1].status = Thread.STATUS_DONE;
rt.threads.splice(1, 1);
e.broadcastAndWait({BROADCAST_OPTION: {id: 'testBroadcastID', name: 'message'}}, util);
t.strictEqual(th.status, Thread.STATUS_RUNNING);
@ -82,7 +83,7 @@ test('#760 - broadcastAndWait', t => {
util.thread = th;
e.broadcastAndWait({BROADCAST_OPTION: {id: 'testBroadcastID', name: 'message'}}, util);
t.strictEqual(rt.threads.length, 3);
t.strictEqual(rt.threads[1].status, Thread.STATUS_RUNNING);
t.strictEqual(rt.threads[2].status, Thread.STATUS_RUNNING);
t.strictEqual(th.status, Thread.STATUS_YIELD);
// yields when some restarted thread is active
th.status = Thread.STATUS_RUNNING;
@ -90,7 +91,8 @@ test('#760 - broadcastAndWait', t => {
t.strictEqual(th.status, Thread.STATUS_YIELD);
// does not yield once all threads are done
th.status = Thread.STATUS_RUNNING;
rt.threads[1].status = Thread.STATUS_DONE;
rt.threads[2].status = Thread.STATUS_DONE;
rt.threads.splice(2, 1);
e.broadcastAndWait({BROADCAST_OPTION: {id: 'testBroadcastID', name: 'message'}}, util);
t.strictEqual(th.status, Thread.STATUS_RUNNING);