js: Improve yieldNotWarpOrStuck

This commit is contained in:
Thomas Weber committed 2020-08-13 00:04:51 -05:00
1 parent a68665b542
commit 5aff90af0d
1 file changed
+6 -1
+6 -1
View File
@@ -599,7 +599,11 @@ class ScriptCompiler {
* Write JS to yield the current thread if warp mode is disabled or if the script seems to be stuck.
*/
yieldNotWarpOrStuck () {
this.source += 'if (thread.warp === 0 || isStuck()) yield;\n';
if (this.isWarp) {
this.source += 'if (isStuck()) yield;\n';
} else {
this.source += 'if (thread.warp === 0 || isStuck()) yield;\n';
}
}
/**
@@ -660,6 +664,7 @@ class ScriptCompiler {
// Setup the factory
script += `(function ${factoryName}(target) { `;
script += 'const runtime = target.runtime; ';
script += 'const t = runtime.sequencer.timer; ';
script += 'const stage = runtime.getTargetForStage();\n';
for (const varValue of Object.keys(this._setupVariables)) {
const varName = this._setupVariables[varValue];