ast+js: Allow scripts to opt into stuck checking (#10)
This commit is contained in:
2 files changed
+8
-2
No files matched your search
@@ -15,6 +15,7 @@ const compatBlocks = require('./compat-blocks');
|
||||
* @property {boolean} hasArguments
|
||||
* @property {boolean} isWarp
|
||||
* @property {boolean} yields
|
||||
* @property {boolean} loopStuckChecking
|
||||
* @property {Array<string>} dependedProcedures The list of procedure codes that this tree directly depends on. Does not include dependencies of dependencies, etc.
|
||||
* @property {*} cachedCompileResult
|
||||
*/
|
||||
@@ -70,6 +71,8 @@ class ScriptTreeGenerator {
|
||||
this.isWarp = false;
|
||||
/** @private */
|
||||
this.yields = true;
|
||||
/** @private */
|
||||
this.loopStuckChecking = this.target.runtime.compilerOptions.loopStuckChecking;
|
||||
|
||||
/**
|
||||
* The names of the arguments accepted by this script, in order.
|
||||
@@ -1272,7 +1275,7 @@ class ScriptTreeGenerator {
|
||||
}
|
||||
|
||||
analyzeLoop () {
|
||||
if (!this.isWarp || this.target.runtime.compilerOptions.loopStuckChecking) {
|
||||
if (!this.isWarp || this.loopStuckChecking) {
|
||||
this.yields = true;
|
||||
}
|
||||
}
|
||||
@@ -1296,6 +1299,9 @@ class ScriptTreeGenerator {
|
||||
switch (flag) {
|
||||
case 'nocompile':
|
||||
throw new Error('Script explicitly disables compilation');
|
||||
case 'stuck':
|
||||
this.loopStuckChecking = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class ScriptCompiler {
|
||||
|
||||
this.isWarp = script.isWarp;
|
||||
this.isProcedure = script.isProcedure;
|
||||
this.loopStuckChecking = this.target.runtime.compilerOptions.loopStuckChecking;
|
||||
this.loopStuckChecking = script.loopStuckChecking;
|
||||
|
||||
this.localVariables = new VariablePool('a');
|
||||
this._setupVariablesPool = new VariablePool('b');
|
||||
|
||||
Reference in new issue
Block a user