ast+js: Allow scripts to opt into stuck checking (#10)

This commit is contained in:
Thomas Weber committed 2020-08-28 23:35:44 -05:00
1 parent 5434b0a252
commit c2ea3f4efb
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -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');