fixup script stopping blocks
This commit is contained in:
2 files changed
+24
-8
No files matched your search
@@ -111,18 +111,23 @@ const deleteClone = /** @param {StatementUtil} util */ (util) => {
|
||||
util.writeLn(`if (!target.isOriginal) {`)
|
||||
util.writeLn(` runtime.disposeTarget(target);`);
|
||||
util.writeLn(` runtime.stopForTarget(target);`);
|
||||
util.writeLn(` return;`);
|
||||
util.retire();
|
||||
util.writeLn(`}`);
|
||||
};
|
||||
|
||||
const stop = /** @param {StatementUtil} util */ (util) => {
|
||||
const STOP_OPTION = util.fieldValueUnsafe('STOP_OPTION');
|
||||
if (STOP_OPTION === 'all') {
|
||||
util.writeLn('target.runtime.stopAll();');
|
||||
util.writeLn('runtime.stopAll();');
|
||||
util.retire();
|
||||
} else if (STOP_OPTION === 'other scripts in sprite' || STOP_OPTION === 'other scripts in stage') {
|
||||
util.writeLn('target.runtime.stopForTarget(target, thread);');
|
||||
util.writeLn('runtime.stopForTarget(target, thread);');
|
||||
} else if (STOP_OPTION === 'this script') {
|
||||
util.writeLn('endCall(); return;');
|
||||
if (util.hints.isProcedure) {
|
||||
util.writeLn('endCall(); return;');
|
||||
} else {
|
||||
util.retire();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -229,6 +229,13 @@ class StatementUtil extends BlockUtil {
|
||||
this.writeLn('/* no-op */');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop this thread.
|
||||
*/
|
||||
retire() {
|
||||
this.writeLn('retire(); yield;');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a local variable.
|
||||
*/
|
||||
@@ -471,15 +478,19 @@ class Compiler {
|
||||
// Increase warp level
|
||||
if (hints.isWarp) {
|
||||
script += 'thread.warp++;\n';
|
||||
} else {
|
||||
} else if (hints.isProcedure) {
|
||||
script += 'if (thread.warp) thread.warp++;\n';
|
||||
}
|
||||
|
||||
script += this.compileStack(topBlock);
|
||||
|
||||
// Decrease warp level
|
||||
script += 'endCall();';
|
||||
script += '\n}';
|
||||
if (hints.isProcedure) {
|
||||
script += 'endCall();\n';
|
||||
} else {
|
||||
script += 'retire();\n';
|
||||
}
|
||||
|
||||
script += '}';
|
||||
|
||||
const fn = execute.createScriptFactory(script);
|
||||
log.info(`[${this.target.getName()}] compiled script`, script);
|
||||
|
||||
Reference in new issue
Block a user