Clean up debug APIs

This commit is contained in:
nboyd%atg.com 2000-11-07 03:20:56 +00:00
parent e875395364
commit 629043f2b8
8 changed files with 110 additions and 14 deletions

View File

@ -40,8 +40,7 @@ import org.mozilla.javascript.debug.DebuggableScript;
class InterpretedFunction extends NativeFunction implements DebuggableScript {
InterpretedFunction(InterpreterData theData, Context cx)
{
InterpretedFunction(InterpreterData theData, Context cx) {
itsData = theData;
init(cx);
}
@ -83,6 +82,10 @@ class InterpretedFunction extends NativeFunction implements DebuggableScript {
return Interpreter.interpret(cx, scope, thisObj, args, this, itsData);
}
public boolean isFunction() {
return true;
}
public Scriptable getScriptable() {
return this;
}

View File

@ -67,6 +67,10 @@ public class InterpretedScript extends NativeScript implements DebuggableScript
return Interpreter.interpret(cx, scope, thisObj, args, this, itsData);
}
public boolean isFunction() {
return false;
}
public Scriptable getScriptable() {
return this;
}

View File

@ -40,15 +40,53 @@ package org.mozilla.javascript.debug;
public interface DebuggableEngine {
public void setLineStep(boolean isLineStep);
/**
* Set whether the engine should break when it encounters
* the next line.
* <p>
* The engine will call the attached debugger's handleBreakpointHit
* method on the next line it executes if isLineStep is true.
* May be used from another thread to interrupt execution.
*
* @param isLineStep if true, break next line
*/
public void setBreakNextLine(boolean isLineStep);
public boolean getLineStep();
/**
* Return the value of the breakNextLine flag.
* @return true if the engine will break on execution of the
* next line.
*/
public boolean getBreakNextLine();
/**
* Set the associated debugger.
* @param debugger the debugger to be used on callbacks from
* the engine.
*/
public void setDebugger(Debugger debugger);
/**
* Return the current debugger.
* @return the debugger, or null if none is attached.
*/
public Debugger getDebugger();
public Frame getFrame(int frameNumber);
/**
* Return the number of frames in current execution.
* @return the count of current frames
*/
public int getFrameCount();
//public void haltExecution();
/**
* Return a frame from the current execution.
* Frames are numbered starting from 0 for the innermost
* frame.
* @param frameNumber the number of the frame in the range
* [0,frameCount-1]
* @return the relevant Frame, or null if frameNumber is out
* of range or the engine isn't currently saving
* frames
*/
public Frame getFrame(int frameNumber);
}

View File

@ -47,7 +47,10 @@ import java.util.Enumeration;
*/
public interface DebuggableScript {
//public boolean isFunction(); // XXX
/**
* Returns true if this is a function, false if it is a script.
*/
public boolean isFunction();
/**
* Get the Scriptable object (Function or Script) that is

View File

@ -40,8 +40,7 @@ import org.mozilla.javascript.debug.DebuggableScript;
class InterpretedFunction extends NativeFunction implements DebuggableScript {
InterpretedFunction(InterpreterData theData, Context cx)
{
InterpretedFunction(InterpreterData theData, Context cx) {
itsData = theData;
init(cx);
}
@ -83,6 +82,10 @@ class InterpretedFunction extends NativeFunction implements DebuggableScript {
return Interpreter.interpret(cx, scope, thisObj, args, this, itsData);
}
public boolean isFunction() {
return true;
}
public Scriptable getScriptable() {
return this;
}

View File

@ -67,6 +67,10 @@ public class InterpretedScript extends NativeScript implements DebuggableScript
return Interpreter.interpret(cx, scope, thisObj, args, this, itsData);
}
public boolean isFunction() {
return false;
}
public Scriptable getScriptable() {
return this;
}

View File

@ -40,15 +40,53 @@ package org.mozilla.javascript.debug;
public interface DebuggableEngine {
public void setLineStep(boolean isLineStep);
/**
* Set whether the engine should break when it encounters
* the next line.
* <p>
* The engine will call the attached debugger's handleBreakpointHit
* method on the next line it executes if isLineStep is true.
* May be used from another thread to interrupt execution.
*
* @param isLineStep if true, break next line
*/
public void setBreakNextLine(boolean isLineStep);
public boolean getLineStep();
/**
* Return the value of the breakNextLine flag.
* @return true if the engine will break on execution of the
* next line.
*/
public boolean getBreakNextLine();
/**
* Set the associated debugger.
* @param debugger the debugger to be used on callbacks from
* the engine.
*/
public void setDebugger(Debugger debugger);
/**
* Return the current debugger.
* @return the debugger, or null if none is attached.
*/
public Debugger getDebugger();
public Frame getFrame(int frameNumber);
/**
* Return the number of frames in current execution.
* @return the count of current frames
*/
public int getFrameCount();
//public void haltExecution();
/**
* Return a frame from the current execution.
* Frames are numbered starting from 0 for the innermost
* frame.
* @param frameNumber the number of the frame in the range
* [0,frameCount-1]
* @return the relevant Frame, or null if frameNumber is out
* of range or the engine isn't currently saving
* frames
*/
public Frame getFrame(int frameNumber);
}

View File

@ -47,7 +47,10 @@ import java.util.Enumeration;
*/
public interface DebuggableScript {
//public boolean isFunction(); // XXX
/**
* Returns true if this is a function, false if it is a script.
*/
public boolean isFunction();
/**
* Get the Scriptable object (Function or Script) that is