Fix incorrect stack pop when replacing literals

This commit is contained in:
kpdecker
2013-12-31 21:17:16 -06:00
parent cbfec5b9e9
commit f4d337d252
@@ -687,7 +687,8 @@ JavaScriptCompiler.prototype = {
replaceStack: function(callback) {
var prefix = '',
inline = this.isInline(),
stack;
stack,
usedLiteral;
// If we are currently inline then we want to merge the inline statement into the
// replacement statement via ','
@@ -697,6 +698,7 @@ JavaScriptCompiler.prototype = {
if (top instanceof Literal) {
// Literals do not need to be inlined
stack = top.value;
usedLiteral = true;
} else {
// Get or create the current stack name for use by the inline
var name = this.stackSlot ? this.topStackName() : this.incrStack();
@@ -711,7 +713,7 @@ JavaScriptCompiler.prototype = {
var item = callback.call(this, stack);
if (inline) {
if (this.inlineStack.length || this.compileStack.length) {
if (!usedLiteral) {
this.popStack();
}
this.push('(' + prefix + item + ')');