mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Add isGeneratedScript to DebuggableScript and its implementations to allow debuger to distinguish between scripts and functions coming from external files or ones defined vvia exec or new Function()
This commit is contained in:
parent
f24613dd00
commit
5c85c4f1ae
@ -351,7 +351,9 @@ public class BaseFunction extends IdScriptable implements Function {
|
||||
filename = "<eval'ed string>";
|
||||
linep[0] = 1;
|
||||
}
|
||||
String sourceName = filename+'#'+linep[0]+"(Function)";
|
||||
|
||||
String sourceName = ScriptRuntime.
|
||||
makeUrlForGeneratedScript(false, filename, linep[0]);
|
||||
|
||||
Scriptable global = ScriptableObject.getTopLevelScope(scope);
|
||||
|
||||
|
@ -89,6 +89,10 @@ final class InterpretedFunction extends NativeFunction
|
||||
return itsData.itsSourceFile;
|
||||
}
|
||||
|
||||
public boolean isGeneratedScript() {
|
||||
return ScriptRuntime.isGeneratedScript(itsData.itsSourceFile);
|
||||
}
|
||||
|
||||
public int[] getLineNumbers() {
|
||||
return Interpreter.getLineNumbers(itsData);
|
||||
}
|
||||
|
@ -78,6 +78,10 @@ final class InterpretedScript extends NativeScript
|
||||
return itsData.itsSourceFile;
|
||||
}
|
||||
|
||||
public boolean isGeneratedScript() {
|
||||
return ScriptRuntime.isGeneratedScript(itsData.itsSourceFile);
|
||||
}
|
||||
|
||||
public int[] getLineNumbers() {
|
||||
return Interpreter.getLineNumbers(itsData);
|
||||
}
|
||||
|
@ -502,7 +502,8 @@ public class NativeGlobal implements IdFunctionMaster {
|
||||
filename = "";
|
||||
}
|
||||
}
|
||||
String sourceName = filename+'#'+lineNumber+"(eval)";
|
||||
String sourceName = ScriptRuntime.
|
||||
makeUrlForGeneratedScript(true, filename, lineNumber);
|
||||
|
||||
try {
|
||||
StringReader in = new StringReader((String) x);
|
||||
|
@ -2066,6 +2066,23 @@ public class ScriptRuntime {
|
||||
return false;
|
||||
}
|
||||
|
||||
static String makeUrlForGeneratedScript
|
||||
(boolean isEval, String masterScriptUrl, int masterScriptLine)
|
||||
{
|
||||
if (isEval) {
|
||||
return masterScriptUrl+'#'+masterScriptLine+"(eval)";
|
||||
} else {
|
||||
return masterScriptUrl+'#'+masterScriptLine+"(Function)";
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isGeneratedScript(String sourceUrl) {
|
||||
// ALERT: this may clash with a valid URL containing (eval) or
|
||||
// (Function)
|
||||
return sourceUrl.indexOf("(eval)") >= 0
|
||||
|| sourceUrl.indexOf("(Function)") >= 0;
|
||||
}
|
||||
|
||||
private static RuntimeException errorWithClassName(String msg, Object val)
|
||||
{
|
||||
return Context.reportRuntimeError1(msg, val.getClass().getName());
|
||||
|
@ -64,6 +64,12 @@ public interface DebuggableScript {
|
||||
*/
|
||||
public String getSourceName();
|
||||
|
||||
/**
|
||||
* Retutns true for functions constructed via <tt>Function(...)</tt>
|
||||
* or eval scripts or any function defined by such functions or scripts
|
||||
*/
|
||||
public boolean isGeneratedScript();
|
||||
|
||||
/**
|
||||
* Get array containing the line numbers that
|
||||
* that can be passed to <code>DebugFrame.onLineChange()<code>.
|
||||
|
Loading…
x
Reference in New Issue
Block a user