Fix stack id "leak" on replaceStack

This commit is contained in:
kpdecker
2013-12-31 21:17:50 -06:00
parent f4d337d252
commit ddfe457abf
@@ -688,6 +688,7 @@ JavaScriptCompiler.prototype = {
var prefix = '',
inline = this.isInline(),
stack,
createdStack,
usedLiteral;
// If we are currently inline then we want to merge the inline statement into the
@@ -701,7 +702,8 @@ JavaScriptCompiler.prototype = {
usedLiteral = true;
} else {
// Get or create the current stack name for use by the inline
var name = this.stackSlot ? this.topStackName() : this.incrStack();
createdStack = !this.stackSlot;
var name = !createdStack ? this.topStackName() : this.incrStack();
prefix = '(' + this.push(name) + ' = ' + top + '),';
stack = this.topStack();
@@ -716,6 +718,9 @@ JavaScriptCompiler.prototype = {
if (!usedLiteral) {
this.popStack();
}
if (createdStack) {
this.stackSlot--;
}
this.push('(' + prefix + item + ')');
} else {
// Prevent modification of the context depth variable. Through replaceStack