Extending omj.debug.DebuggableScript interface with functions to access nested functions and check if it is top-level script.

git-svn-id: svn://10.0.0.236/trunk@147478 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
igor%mir2.org
2003-10-01 11:55:55 +00:00
parent 42e9a432a3
commit c13e11b967
3 changed files with 41 additions and 12 deletions

View File

@@ -122,6 +122,7 @@ public class Interpreter
itsData = new InterpreterData(securityDomain, cx.getLanguageVersion());
itsData.itsSourceFile = scriptOrFn.getSourceName();
itsData.encodedSource = encodedSource;
itsData.topLevel = true;
if (tree instanceof FunctionNode) {
generateFunctionICode(cx);
return createFunction(cx, scope, itsData, false);
@@ -147,13 +148,12 @@ public class Interpreter
private static void notifyDebugger_r(Context cx, InterpreterData idata,
String debugSource)
{
cx.debugger.handleCompilationDone(cx, idata, debugSource);
if (idata.itsNestedFunctions != null) {
for (int i = 0; i != idata.itsNestedFunctions.length; ++i) {
notifyDebugger_r(cx, idata.itsNestedFunctions[i], debugSource);
}
}
cx.debugger.handleCompilationDone(cx, idata, debugSource);
}
private void generateFunctionICode(Context cx)
@@ -1703,8 +1703,8 @@ public class Interpreter
}
} else {
scope = ScriptRuntime.initScript(cx, scope, fnOrScript, thisObj,
idata.itsFromEvalCode);
ScriptRuntime.initScript(cx, scope, fnOrScript, thisObj,
idata.itsFromEvalCode);
}
if (idata.itsNestedFunctions != null) {

View File

@@ -40,7 +40,8 @@ import java.io.Serializable;
import org.mozilla.javascript.debug.DebuggableScript;
final class InterpreterData implements Serializable, DebuggableScript {
final class InterpreterData implements Serializable, DebuggableScript
{
static final long serialVersionUID = 4815333329084415557L;
@@ -48,7 +49,8 @@ final class InterpreterData implements Serializable, DebuggableScript {
static final int INITIAL_STRINGTABLE_SIZE = 64;
static final int INITIAL_NUMBERTABLE_SIZE = 64;
InterpreterData(Object securityDomain, int languageVersion) {
InterpreterData(Object securityDomain, int languageVersion)
{
itsICodeTop = INITIAL_MAX_ICODE_LENGTH;
itsICode = new byte[itsICodeTop];
@@ -96,24 +98,45 @@ final class InterpreterData implements Serializable, DebuggableScript {
boolean useDynamicScope;
public boolean isFunction() {
boolean topLevel;
public boolean isTopLevel()
{
return topLevel;
}
public boolean isFunction()
{
return itsFunctionType != 0;
}
public String getFunctionName() {
public String getFunctionName()
{
return itsName;
}
public String getSourceName() {
public String getSourceName()
{
return itsSourceFile;
}
public boolean isGeneratedScript() {
public boolean isGeneratedScript()
{
return ScriptRuntime.isGeneratedScript(itsSourceFile);
}
public int[] getLineNumbers() {
public int[] getLineNumbers()
{
return Interpreter.getLineNumbers(this);
}
public int getFunctionCount()
{
return (itsNestedFunctions == null) ? 0 : itsNestedFunctions.length;
}
public DebuggableScript getFunction(int index)
{
return itsNestedFunctions[index];
}
}

View File

@@ -45,7 +45,9 @@ import java.util.Enumeration;
* This interface exposes debugging information from executable
* code (either functions or top-level scripts).
*/
public interface DebuggableScript {
public interface DebuggableScript
{
public boolean isTopLevel();
/**
* Returns true if this is a function, false if it is a script.
@@ -77,4 +79,8 @@ public interface DebuggableScript {
*/
public int[] getLineNumbers();
public int getFunctionCount();
public DebuggableScript getFunction(int index);
}