| const BlockUtility = require('../engine/block-utility'); |
|
|
| class CompatibilityLayerBlockUtility extends BlockUtility { |
| constructor () { |
| super(); |
| this._startedBranch = null; |
| } |
|
|
| get stackFrame () { |
| return this.thread.compatibilityStackFrame; |
| } |
|
|
| startBranch (branchNumber, isLoop, onEnd) { |
| if (this._branchInfo && onEnd) this._branchInfo.onEnd.push(onEnd); |
| this._startedBranch = [branchNumber, isLoop]; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| startProcedure (proccode, args) { |
| if (!args) |
| return this.thread.procedures[proccode](); |
| if (!(typeof args === 'object')) |
| throw new Error(`procedure arguments can only be of type undefined|object. instead got "${typeof args}"`); |
| let evaluate = `this.thread.procedures[proccode](`; |
| const inputs = []; |
| for (const arg in args) { |
| inputs.push(String(args[arg])); |
| } |
| evaluate += `${inputs.join(',')})`; |
| return new Function(`Procedure ${proccode}`, evaluate)(); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| init (thread, fakeBlockId, stackFrame, branchInfo) { |
| this.thread = thread; |
| this.sequencer = thread.target.runtime.sequencer; |
| this._startedBranch = null; |
| this._branchInfo = branchInfo; |
| thread.stack[0] = fakeBlockId; |
| thread.compatibilityStackFrame = stackFrame; |
| } |
| } |
|
|
| |
| module.exports = new CompatibilityLayerBlockUtility(); |
|
|