Move compileProgram out of visitor methods

This commit is contained in:
kpdecker
2014-11-28 23:56:41 -06:00
parent 5b0efc7e91
commit b6ba2dcdb0
+18 -18
View File
@@ -91,6 +91,24 @@ Compiler.prototype = {
return this.accept(program);
},
compileProgram: function(program) {
var result = new this.compiler().compile(program, this.options);
var guid = this.guid++, depth;
this.usePartial = this.usePartial || result.usePartial;
this.children[guid] = result;
for(var i=0, l=result.depths.list.length; i<l; i++) {
depth = result.depths.list[i];
if(depth < 2) { continue; }
else { this.addDepth(depth - 1); }
}
return guid;
},
accept: function(node) {
this.sourceNode.unshift(node);
var ret = this[node.type](node);
@@ -114,24 +132,6 @@ Compiler.prototype = {
return this;
},
compileProgram: function(program) {
var result = new this.compiler().compile(program, this.options);
var guid = this.guid++, depth;
this.usePartial = this.usePartial || result.usePartial;
this.children[guid] = result;
for(var i=0, l=result.depths.list.length; i<l; i++) {
depth = result.depths.list[i];
if(depth < 2) { continue; }
else { this.addDepth(depth - 1); }
}
return guid;
},
BlockStatement: function(block) {
var sexpr = block.sexpr,
program = block.program,