From 1a8062fbbc9db286311f5c07abb86289f90a331f Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Fri, 18 Sep 2009 03:27:58 -0700 Subject: [PATCH] Added support for the "//@ sourceName" convention tell debuggers our file names. http://pmuellr.blogspot.com/2009/06/debugger-friendly.html --- Objective-J/evaluate.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Objective-J/evaluate.js b/Objective-J/evaluate.js index e48817b06..6bd4d6979 100644 --- a/Objective-J/evaluate.js +++ b/Objective-J/evaluate.js @@ -164,7 +164,17 @@ function fragment_evaluate_code(aFragment) else compiled = eval(functionText); #else - compiled = new Function(GET_CODE(aFragment)); + // "//@ 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 (true) { + var functionText = GET_CODE(aFragment)+"/**/\n//@ sourceURL="+GET_FILE(aFragment).path; + compiled = new Function(functionText); + //} 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); + //} compiled.displayName = GET_FILE(aFragment).path; #endif }