mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-09 18:30:59 +00:00
Add setCode to Executable; use toMarkedString() in compiler; more robust function wrapper stripping in compressor
This commit is contained in:
1 parent
7837e1ad81
commit
04529897dc
2 files changed
+34
-39
No files matched your search
+28
-23
@@ -41,29 +41,7 @@ function Executable(/*String*/ aCode, /*Array*/ fileDependencies, /*String*/ aSc
|
||||
if (this._function)
|
||||
return;
|
||||
|
||||
var code = this._code;
|
||||
|
||||
#if COMMONJS
|
||||
code = "function(" + this.functionParameters().join(" , ") + "){" + code + "/**/\n}";
|
||||
|
||||
if (typeof system !== "undefined" && system.engine === "rhino")
|
||||
this._function = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, code, this._scope, 0, NULL);
|
||||
else
|
||||
this._function = eval("(" + code + ")");
|
||||
#else
|
||||
// "//@ sourceURL=" at the end lets us name our eval'd files for debuggers, etc.
|
||||
// * WebKit: http://pmuellr.blogspot.com/2009/06/debugger-friendly.html
|
||||
// * Firebug: http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/
|
||||
//if (YES) {
|
||||
code += "/**/\n//@ sourceURL=" + this._scope;
|
||||
this._function = new Function(this.functionParameters(), code);
|
||||
//} else {
|
||||
// // Firebug only does it for "eval()", not "new Function()". Ugh. Slower.
|
||||
// var functionText = "(function(){"+GET_CODE(aFragment)+"/**/\n})\n//@ sourceURL="+GET_FILE(aFragment).path;
|
||||
// compiled = eval(functionText);
|
||||
//}
|
||||
this._function.displayName = this._scope;
|
||||
#endif
|
||||
this.setCode(aCode);
|
||||
}
|
||||
|
||||
Executable.prototype.path = function()
|
||||
@@ -156,6 +134,33 @@ Executable.prototype.code = function()
|
||||
return this._code;
|
||||
}
|
||||
|
||||
Executable.prototype.setCode = function(code)
|
||||
{
|
||||
this._code = code;
|
||||
|
||||
#if COMMONJS
|
||||
code = "function(" + this.functionParameters().join(" , ") + "){" + code + "/**/\n}";
|
||||
|
||||
if (typeof system !== "undefined" && system.engine === "rhino")
|
||||
this._function = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, code, this._scope, 0, NULL);
|
||||
else
|
||||
this._function = eval("(" + code + ")");
|
||||
#else
|
||||
// "//@ sourceURL=" at the end lets us name our eval'd files for debuggers, etc.
|
||||
// * WebKit: http://pmuellr.blogspot.com/2009/06/debugger-friendly.html
|
||||
// * Firebug: http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/
|
||||
//if (YES) {
|
||||
code += "/**/\n//@ sourceURL=" + this._scope;
|
||||
this._function = new Function(this.functionParameters(), code);
|
||||
//} else {
|
||||
// // Firebug only does it for "eval()", not "new Function()". Ugh. Slower.
|
||||
// var functionText = "(function(){"+GET_CODE(aFragment)+"/**/\n})\n//@ sourceURL="+GET_FILE(aFragment).path;
|
||||
// compiled = eval(functionText);
|
||||
//}
|
||||
this._function.displayName = this._scope;
|
||||
#endif
|
||||
}
|
||||
|
||||
Executable.prototype.fileDependencies = function()
|
||||
{
|
||||
return this._fileDependencies;
|
||||
|
||||
Reference in new issue
Block a user