Use accept for all compiler traversal

This commit is contained in:
kpdecker
2013-07-30 10:24:09 -05:00
parent a1edab6ef5
commit 14ef86f9ca
+3 -4
View File
@@ -72,6 +72,7 @@ Compiler.prototype = {
guid: 0,
compile: function(program, options) {
this.opcodes = [];
this.children = [];
this.depths = {list: []};
this.options = options;
@@ -93,7 +94,7 @@ Compiler.prototype = {
}
}
return this.program(program);
return this.accept(program);
},
accept: function(node) {
@@ -102,11 +103,9 @@ Compiler.prototype = {
program: function(program) {
var statements = program.statements, statement;
this.opcodes = [];
for(var i=0, l=statements.length; i<l; i++) {
statement = statements[i];
this[statement.type](statement);
this.accept(statements[i]);
}
this.isSimple = l === 1;