Skip to content

Commit 30a614d

Browse files
committed
Expose compatibility layer stack frame on thread
For #212
1 parent dff3c2f commit 30a614d

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Diff for: src/compiler/compat-block-utility.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ const BlockUtility = require('../engine/block-utility');
33
class CompatibilityLayerBlockUtility extends BlockUtility {
44
constructor () {
55
super();
6-
this._stackFrame = {};
76
this._startedBranch = null;
87
}
98

109
get stackFrame () {
11-
return this._stackFrame;
10+
return this.thread.compatibilityStackFrame;
1211
}
1312

1413
startBranch (branchNumber, isLoop) {
@@ -33,9 +32,9 @@ class CompatibilityLayerBlockUtility extends BlockUtility {
3332
init (thread, fakeBlockId, stackFrame) {
3433
this.thread = thread;
3534
this.sequencer = thread.target.runtime.sequencer;
36-
this._stackFrame = stackFrame;
3735
this._startedBranch = null;
3836
thread.stack[0] = fakeBlockId;
37+
thread.compatibilityStackFrame = stackFrame;
3938
}
4039
}
4140

Diff for: src/engine/thread.js

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class Thread {
215215
*/
216216
this.procedures = null;
217217
this.executableHat = false;
218+
this.compatibilityStackFrame = null;
218219
}
219220

220221
/**

Diff for: test/fixtures/tw-glide.sb3

2.51 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const {test} = require('tap');
2+
const fs = require('fs');
3+
const path = require('path');
4+
const VM = require('../../src/virtual-machine');
5+
const Timer = require('../../src/util/timer');
6+
7+
test('compatibility stack frame is exposed on thread', t => {
8+
const vm = new VM();
9+
vm.loadProject(fs.readFileSync(path.join(__dirname, '../fixtures/tw-glide.sb3'))).then(() => {
10+
vm.greenFlag();
11+
vm.runtime._step();
12+
t.ok(vm.runtime.threads[0].compatibilityStackFrame.timer instanceof Timer);
13+
t.end();
14+
});
15+
});

0 commit comments

Comments
 (0)