Add stack handling sanity checks

This commit is contained in:
kpdecker
2013-12-31 21:18:42 -06:00
parent ddfe457abf
commit cd885bf855
@@ -1,4 +1,5 @@
import { COMPILER_REVISION, REVISION_CHANGES, log } from "../base";
import Exception from "../exception";
function Literal(value) {
this.value = value;
@@ -104,6 +105,10 @@ JavaScriptCompiler.prototype = {
// Flush any trailing content that might be pending.
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);
},
@@ -771,6 +776,9 @@ JavaScriptCompiler.prototype = {
return item.value;
} else {
if (!inline) {
if (!this.stackSlot) {
throw new Exception('Invalid stack pop');
}
this.stackSlot--;
}
return item;