handlebars-compiler-compiler.js revision abdaa6ad2027c0c8fe48867813c314c400a83e3d
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
// BEGIN(BROWSER)
Handlebars.Compiler = function() {};
Handlebars.JavaScriptCompiler = function() {};
(function(Compiler, JavaScriptCompiler) {
Compiler.OPCODE_MAP = {
appendContent: 1,
getContext: 2,
lookup: 4,
append: 5,
invokeMustache: 6,
appendEscaped: 7,
pushString: 8,
truthyOrFallback: 9,
functionOrFallback: 10,
invokeProgram: 11,
invokePartial: 12,
push: 13,
assignToHash: 15,
pushStringParam: 16
};
appendContent: 1,
getContext: 1,
lookup: 1,
invokeMustache: 3,
pushString: 1,
truthyOrFallback: 1,
invokeProgram: 3,
invokePartial: 1,
push: 1,
assignToHash: 1,
};
Compiler.DISASSEMBLE_MAP = {};
}
};
disassemble: function() {
if(opcode === 'DECLARE') {
} else {
var codes = [];
for(var j=0; j<extraParams; j++) {
if(typeof nextCode === "string") {
}
}
}
}
},
guid: 0,
this.children = [];
// These changes will propagate to the other compiler components
this.options.knownHelpers = {
'helperMissing': true,
'blockHelperMissing': true,
'each': true,
'if': true,
'unless': true,
'with': true,
'log': true
};
if (knownHelpers) {
for (var name in knownHelpers) {
}
}
},
},
this.opcodes = [];
statement = statements[i];
}
this.isSimple = l === 1;
return a - b;
});
return this;
},
compileProgram: function(program) {
if(depth < 2) { continue; }
}
return guid;
},
}
this.declare('inverse', null);
this.opcode('append');
},
this.opcode('append');
},
}
},
this.usePartial = true;
} else {
}
this.opcode('append');
},
},
this.opcode('appendEscaped');
} else {
this.opcode('append');
}
},
}
},
},
},
},
comment: function() {},
// HELPERS
pushParams: function(params) {
while(i--) {
if(this.options.stringParams) {
}
} else {
}
}
},
},
},
if(depth === 0) { return; }
}
},
setupStackForMustache: function(mustache) {
this.pushParams(params);
}
return params;
}
};
// PUBLIC API: You can override these methods in a subclass to provide
// alternative compiled forms for name lookup and buffering semantics
}
else {
}
},
appendToBuffer: function(string) {
if (this.environment.isSimple) {
} else {
}
},
initializeBuffer: function() {
return this.quotedString("");
},
// END PUBLIC API
this.environment = environment;
programs: [],
};
this.preamble();
this.stackSlot = 0;
this.stackVars = [];
this.i = 0;
this.i = this.i + 2;
} else {
}
}
return this.createFunctionContext(asObject);
},
nextOpcode: function(n) {
var extraParams, codes;
if(opcode === 'DECLARE') {
} else {
codes = [];
for(var j=0; j<extraParams; j++) {
}
}
},
},
preamble: function() {
var out = [];
if (!this.isChild) {
var copies = "helpers = helpers || Handlebars.helpers;";
if(this.environment.usePartial) { copies = copies + " partials = partials || Handlebars.partials;"; }
} else {
}
if (!this.environment.isSimple) {
} else {
}
// track the last context pushed into place to allow skipping the
// getContext opcode when it would be a noop
this.lastContext = 0;
},
createFunctionContext: function(asObject) {
if (!this.isChild) {
}
}
// Generate minimizer alias mappings
if (!this.isChild) {
var aliases = []
}
}
if (this.source[1]) {
}
// Merge children
if (!this.isChild) {
}
if (!this.environment.isSimple) {
}
var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
}
if (asObject) {
} else {
var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + this.source.join("\n ") + '}';
return functionSource;
}
},
appendContent: function(content) {
},
append: function() {
this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
if (this.environment.isSimple) {
}
},
appendEscaped: function() {
}
},
getContext: function(depth) {
if(this.lastContext !== depth) {
this.lastContext = depth;
}
},
if(name) {
this.usingKnownHelper = false;
var toPush;
this.usingKnownHelper = true;
} else {
+ " || "
}
toPush += ';';
} else {
}
},
this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " +
},
pushStringParam: function(string) {
this.pushString(string);
},
pushString: function(string) {
},
},
this.populateParams(paramSize, this.quotedString(original), "{}", null, hasHash, function(nextStack, helperMissingString, id) {
if (!this.usingKnownHelper) {
this.source.push("else if(" + id + "=== undef) { " + nextStack + " = helperMissing.call(" + helperMissingString + "); }");
}
}
});
},
this.populateParams(paramSize, null, mainProgram, inverse, hasHash, function(nextStack, helperMissingString, id) {
if (!this.usingKnownHelper) {
this.source.push("else { " + nextStack + " = blockHelperMissing.call(" + helperMissingString + "); }");
}
});
},
if (needsRegister) {
stringOptions = 'tmp1';
} else {
stringOptions = '{ hash: {} }';
}
if (needsRegister) {
}
if(this.options.stringParams) {
}
for(var i=0; i<paramSize; i++) {
if(this.options.stringParams) {
}
}
if(inverse) {
}
}
},
if (this.usingKnownHelper) {
} else {
this.source.push("if(typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }");
}
this.usingKnownHelper = false;
},
invokePartial: function(context) {
this.pushStack("self.invokePartial(" + this.nameLookup('partials', context, 'partial') + ", '" + context + "', " + this.popStack() + ", helpers, partials);");
},
assignToHash: function(key) {
},
// HELPERS
}
},
programExpression: function(guid) {
if(guid == null) { return "self.noop"; }
}
} else {
}
},
this.useRegister(name);
},
useRegister: function(name) {
}
},
return "stack" + this.stackSlot;
},
nextStack: function() {
this.stackSlot++;
return "stack" + this.stackSlot;
},
popStack: function() {
return "stack" + this.stackSlot--;
},
topStack: function() {
return "stack" + this.stackSlot;
},
quotedString: function(str) {
return '"' + str
.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r') + '"';
}
};
var reservedWords = ("break case catch continue default delete do else finally " +
"for function if in instanceof new return switch this throw " +
"try typeof var void while with null true false").split(" ");
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
for(var i=0, l=reservedWords.length; i<l; i++) {
compilerWords[reservedWords[i]] = true;
}
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
return true;
}
return false;
}
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
Handlebars.precompile = function(string, options) {
options = options || {};
var ast = Handlebars.parse(string);
var environment = new Handlebars.Compiler().compile(ast, options);
return new Handlebars.JavaScriptCompiler().compile(environment, options);
};
Handlebars.compile = function(string, options) {
options = options || {};
var compiled;
function compile() {
var ast = Handlebars.parse(string);
var environment = new Handlebars.Compiler().compile(ast, options);
var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
return Handlebars.template(templateSpec);
}
// Template is only compiled on first use and cached after that point.
return function(context, options) {
if (!compiled) {
compiled = compile();
}
return compiled.call(this, context, options);
};
};
// END(BROWSER)