Replace getScriptable() by getFunctionName() in omj/debug/DebuggableScript.java as the debugger used DebuggableScript.getScriptable() only to query function names.

It allows to implement the DebuggableScript interface only  by omj/InterpreterData instead of 2 identical implementations by InterpretedFunction and InterpretedScript.
This commit is contained in:
igor%mir2.org 2002-11-14 21:12:36 +00:00
Родитель 5a6ccfaf39
Коммит 9be5d10e5c
6 изменённых файлов: 34 добавлений и 59 удалений

Просмотреть файл

@ -36,10 +36,9 @@
package org.mozilla.javascript;
import java.io.Serializable;
import org.mozilla.javascript.debug.DebuggableScript;
final class InterpretedFunction extends NativeFunction
implements DebuggableScript, Serializable
implements Serializable
{
static final long serialVersionUID = -6235150451107527319L;
@ -77,26 +76,6 @@ final class InterpretedFunction extends NativeFunction
this, itsData);
}
public boolean isFunction() {
return true;
}
public Scriptable getScriptable() {
return this;
}
public String getSourceName() {
return itsData.itsSourceFile;
}
public boolean isGeneratedScript() {
return ScriptRuntime.isGeneratedScript(itsData.itsSourceFile);
}
public int[] getLineNumbers() {
return Interpreter.getLineNumbers(itsData);
}
InterpreterData itsData;
}

Просмотреть файл

@ -35,12 +35,9 @@
package org.mozilla.javascript;
import org.mozilla.javascript.debug.*;
import java.util.*;
final class InterpretedScript extends NativeScript
implements DebuggableScript
{
InterpretedScript(Context cx, InterpreterData theData)
@ -66,26 +63,6 @@ final class InterpretedScript extends NativeScript
this, itsData);
}
public boolean isFunction() {
return false;
}
public Scriptable getScriptable() {
return this;
}
public String getSourceName() {
return itsData.itsSourceFile;
}
public boolean isGeneratedScript() {
return ScriptRuntime.isGeneratedScript(itsData.itsSourceFile);
}
public int[] getLineNumbers() {
return Interpreter.getLineNumbers(itsData);
}
InterpreterData itsData;
}

Просмотреть файл

@ -106,7 +106,7 @@ public class Interpreter {
InterpretedScript result = new InterpretedScript(cx, itsData);
setArgNames(result);
if (cx.debugger != null) {
cx.debugger.handleCompilationDone(cx, result, debugSource);
cx.debugger.handleCompilationDone(cx, itsData, debugSource);
}
return result;
}
@ -140,7 +140,7 @@ public class Interpreter {
InterpretedFunction result = new InterpretedFunction(cx, itsData);
setArgNames(result);
if (cx.debugger != null) {
cx.debugger.handleCompilationDone(cx, result, debugSource);
cx.debugger.handleCompilationDone(cx, itsData, debugSource);
}
debugSource = savedSource;
return result;
@ -1597,8 +1597,7 @@ public class Interpreter {
DebugFrame debuggerFrame = null;
if (cx.debugger != null) {
DebuggableScript dscript = (DebuggableScript)fnOrScript;
debuggerFrame = cx.debugger.getFrame(cx, dscript);
debuggerFrame = cx.debugger.getFrame(cx, idata);
}
if (idata.itsFunctionType != 0) {

Просмотреть файл

@ -38,7 +38,9 @@ package org.mozilla.javascript;
import java.io.Serializable;
class InterpreterData implements Serializable {
import org.mozilla.javascript.debug.DebuggableScript;
final class InterpreterData implements Serializable, DebuggableScript {
static final long serialVersionUID = 4815333329084415557L;
@ -82,4 +84,25 @@ class InterpreterData implements Serializable {
int itsMaxCalleeArgs;
Object securityDomain;
public boolean isFunction() {
return itsFunctionType != 0;
}
public String getFunctionName() {
return itsName;
}
public String getSourceName() {
return itsSourceFile;
}
public boolean isGeneratedScript() {
return ScriptRuntime.isGeneratedScript(itsSourceFile);
}
public int[] getLineNumbers() {
return Interpreter.getLineNumbers(this);
}
}

Просмотреть файл

@ -53,10 +53,10 @@ public interface DebuggableScript {
public boolean isFunction();
/**
* Get the Scriptable object (Function or Script) that is
* described by this DebuggableScript object.
* Get name of the function described by this script.
* Return null or an empty string if this script is not function.
*/
public Scriptable getScriptable();
public String getFunctionName();
/**
* Get the name of the source (usually filename or URL)

Просмотреть файл

@ -2453,12 +2453,9 @@ public class Main extends JFrame implements Debugger, ContextListener {
scriptItems.put(fnOrScript, item);
if (fnOrScript.getScriptable() instanceof NativeFunction) {
NativeFunction f = (NativeFunction)fnOrScript.getScriptable();
String name = f.getFunctionName();
if (name.length() > 0 && !name.equals("anonymous")) {
functionNames.put(name, item);
}
String name = fnOrScript.getFunctionName();
if (name != null && name.length() > 0 && !name.equals("anonymous")) {
functionNames.put(name, item);
}
loadedFile(si);
}