Add stack handling sanity checks
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { COMPILER_REVISION, REVISION_CHANGES, log } from "../base";
|
import { COMPILER_REVISION, REVISION_CHANGES, log } from "../base";
|
||||||
|
import Exception from "../exception";
|
||||||
|
|
||||||
function Literal(value) {
|
function Literal(value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@@ -104,6 +105,10 @@ JavaScriptCompiler.prototype = {
|
|||||||
// Flush any trailing content that might be pending.
|
// Flush any trailing content that might be pending.
|
||||||
this.pushSource('');
|
this.pushSource('');
|
||||||
|
|
||||||
|
if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
|
||||||
|
throw new Exception('Compile completed with content left on stack');
|
||||||
|
}
|
||||||
|
|
||||||
return this.createFunctionContext(asObject);
|
return this.createFunctionContext(asObject);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -771,6 +776,9 @@ JavaScriptCompiler.prototype = {
|
|||||||
return item.value;
|
return item.value;
|
||||||
} else {
|
} else {
|
||||||
if (!inline) {
|
if (!inline) {
|
||||||
|
if (!this.stackSlot) {
|
||||||
|
throw new Exception('Invalid stack pop');
|
||||||
|
}
|
||||||
this.stackSlot--;
|
this.stackSlot--;
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
|||||||
Reference in New Issue
Block a user