Ejemplo n.º 1
0
    /** Performs the action given by {@link #type}. */
    public Object run(Context cx) {
      switch (type) {
        case IPROXY_COMPILE_SCRIPT:
          cx.compileString(text, url, 1, null);
          break;

        case IPROXY_EVAL_SCRIPT:
          {
            Scriptable scope = null;
            if (dim.scopeProvider != null) {
              scope = dim.scopeProvider.getScope();
            }
            if (scope == null) {
              scope = new ImporterTopLevel(cx);
            }
            cx.evaluateString(scope, text, url, 1, null);
          }
          break;

        case IPROXY_STRING_IS_COMPILABLE:
          booleanResult = cx.stringIsCompilableUnit(text);
          break;

        case IPROXY_OBJECT_TO_STRING:
          if (object == Undefined.instance) {
            stringResult = "undefined";
          } else if (object == null) {
            stringResult = "null";
          } else if (object instanceof NativeCall) {
            stringResult = "[object Call]";
          } else {
            stringResult = Context.toString(object);
          }
          break;

        case IPROXY_OBJECT_PROPERTY:
          objectResult = dim.getObjectPropertyImpl(cx, object, id);
          break;

        case IPROXY_OBJECT_IDS:
          objectArrayResult = dim.getObjectIdsImpl(cx, object);
          break;

        default:
          throw Kit.codeBug();
      }
      return null;
    }
Ejemplo n.º 2
0
 /** Called when the stack frame is entered. */
 public void onEnter(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
   contextData.pushFrame(this);
   this.scope = scope;
   this.thisObj = thisObj;
   if (dim.breakOnEnter) {
     dim.handleBreakpointHit(this, cx);
   }
 }
Ejemplo n.º 3
0
    /** Called when compilation is finished. */
    public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, String source) {
      if (type != IPROXY_DEBUG) Kit.codeBug();

      if (!fnOrScript.isTopLevel()) {
        return;
      }
      dim.registerTopScript(fnOrScript, source);
    }
Ejemplo n.º 4
0
    /** Returns a StackFrame for the given function or script. */
    public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript) {
      if (type != IPROXY_DEBUG) Kit.codeBug();

      FunctionSource item = dim.getFunctionSource(fnOrScript);
      if (item == null) {
        // Can not debug if source is not available
        return null;
      }
      return new StackFrame(cx, dim, item);
    }
Ejemplo n.º 5
0
    /** Called when the current position has changed. */
    public void onLineChange(Context cx, int lineno) {
      this.lineNumber = lineno;

      if (!breakpoints[lineno] && !dim.breakFlag) {
        boolean lineBreak = contextData.breakNextLine;
        if (lineBreak && contextData.stopAtFrameDepth >= 0) {
          lineBreak = (contextData.frameCount() <= contextData.stopAtFrameDepth);
        }
        if (!lineBreak) {
          return;
        }
        contextData.stopAtFrameDepth = -1;
        contextData.breakNextLine = false;
      }

      dim.handleBreakpointHit(this, cx);
    }
Ejemplo n.º 6
0
 /** Called when a 'debugger' statement is executed. */
 public void onDebuggerStatement(Context cx) {
   dim.handleBreakpointHit(this, cx);
 }
Ejemplo n.º 7
0
 /** Called when the stack frame has been left. */
 public void onExit(Context cx, boolean byThrow, Object resultOrException) {
   if (dim.breakOnReturn && !byThrow) {
     dim.handleBreakpointHit(this, cx);
   }
   contextData.popFrame();
 }
Ejemplo n.º 8
0
 /** Called when an exception has been thrown. */
 public void onExceptionThrown(Context cx, Throwable exception) {
   dim.handleExceptionThrown(cx, exception, this);
 }