mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #1619 from mzgoddard/execution-order-2
Execution order 2
This commit is contained in:
commit
fa52014650
18 changed files with 24 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
BIN
test/fixtures/execute/events-broadcast-and-wait-yields-a-tick.sb2
vendored
Normal file
BIN
test/fixtures/execute/events-broadcast-and-wait-yields-a-tick.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-back-2-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-back-2-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-and-wait-repeat-message.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-and-wait-repeat-message.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-and-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-and-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-no-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-no-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-backwards-2-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-backwards-2-continuous.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-backwards-2-continuous.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-backwards-2-threads-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-backwards-2-threads-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-forewards-2-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-forewards-2-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-changes-front-2-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-changes-front-2-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-clones-backwards-2-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-clones-backwards-2-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-clones-backwards-broadcast-wait.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-clones-backwards-broadcast-wait.sb2
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/execute/order-immobile-stage.sb2
vendored
Normal file
BIN
test/fixtures/execute/order-immobile-stage.sb2
vendored
Normal file
Binary file not shown.
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue