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 = '', var prefix = '',
inline = this.isInline(), inline = this.isInline(),
stack, stack,
createdStack,
usedLiteral; usedLiteral;
// If we are currently inline then we want to merge the inline statement into the // If we are currently inline then we want to merge the inline statement into the
@@ -701,7 +702,8 @@ JavaScriptCompiler.prototype = {
usedLiteral = true; usedLiteral = true;
} else { } else {
// Get or create the current stack name for use by the inline // 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 + '),'; prefix = '(' + this.push(name) + ' = ' + top + '),';
stack = this.topStack(); stack = this.topStack();
@@ -716,6 +718,9 @@ JavaScriptCompiler.prototype = {
if (!usedLiteral) { if (!usedLiteral) {
this.popStack(); this.popStack();
} }
if (createdStack) {
this.stackSlot--;
}
this.push('(' + prefix + item + ')'); this.push('(' + prefix + item + ')');
} else { } else {
// Prevent modification of the context depth variable. Through replaceStack // Prevent modification of the context depth variable. Through replaceStack