Simplify flushInline implementation

This commit is contained in:
kpdecker
2014-11-05 23:23:43 -06:00
parent 9665379cdc
commit d3bd1a523d
+10 -19
View File
@@ -697,7 +697,7 @@ JavaScriptCompiler.prototype = {
},
pushStackLiteral: function(item) {
return this.push(new Literal(item));
this.push(new Literal(item));
},
pushSource: function(source) {
@@ -711,15 +711,6 @@ JavaScriptCompiler.prototype = {
}
},
pushStack: function(item) {
this.flushInline();
var stack = this.incrStack();
this.pushSource(stack + " = " + item + ";");
this.compileStack.push(stack);
return stack;
},
replaceStack: function(callback) {
var prefix = '',
inline = this.isInline(),
@@ -769,15 +760,15 @@ JavaScriptCompiler.prototype = {
},
flushInline: function() {
var inlineStack = this.inlineStack;
if (inlineStack.length) {
this.inlineStack = [];
for (var i = 0, len = inlineStack.length; i < len; i++) {
var entry = inlineStack[i];
if (entry instanceof Literal) {
this.compileStack.push(entry);
} else {
this.pushStack(entry);
}
this.inlineStack = [];
for (var i = 0, len = inlineStack.length; i < len; i++) {
var entry = inlineStack[i];
if (entry instanceof Literal) {
this.compileStack.push(entry);
} else {
var stack = this.incrStack();
this.pushSource(stack + " = " + entry + ";");
this.compileStack.push(stack);
}
}
},