/** * Changes the current condition on the breakpoint as specified by the breakpoint ID * * @param breakpointID The ID of the breakpoint of which to change the condition on * @param condition The new condition to set */ public void changeBreakPointCondition(final int breakpointID, final String condition) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); parameters.push(condition); try { debugObject.executeVoidFunction(CHANGE_BREAK_POINT_CONDITION, parameters); } finally { parameters.close(); } }
/** * Registers a breakpoint given a scriptID and line number. The breakpoint * will be 'hit' when the script is executed and the given line is reached. * * @param scriptID The ID of the script on which to set the breakpoint. * @param lineNumber The line number on which to set the breakpoint. * @return The berakpointID. */ public int setScriptBreakpoint(final String scriptID, final int lineNumber) { V8Array parameters = new V8Array(runtime); parameters.push(scriptID); parameters.push(lineNumber); try { return debugObject.executeIntegerFunction(SET_SCRIPT_BREAK_POINT_BY_NAME, parameters); } finally { parameters.close(); } }
@Override public Object invoke(final V8Object receiver, final V8Array parameters) { V8Array requireParams = new V8Array(v8); try { requireParams.push(file.getAbsolutePath()); return require.call(null, requireParams); } finally { requireParams.close(); } } });
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final double value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final boolean value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final V8Value value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final int value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Sets the value of a variable in this scope. * * @param name The name of the variable * @param value The value */ public void setVariableValue(final String name, final String value) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(name); parameters.push(value); try { v8Object.executeVoidFunction(SET_VARIABLE_VALUE, parameters); } finally { parameters.close(); } }
/** * Enables a breakpoint. * * @param breakpointID The breakpoint to enable. */ public void enableScriptBreakPoint(final int breakpointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); try { debugObject.executeVoidFunction(ENABLE_SCRIPT_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Disables a breakpoint. * * @param breakpointID The breakpoint to disable */ public void disableScriptBreakPoint(final int breakpointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); try { debugObject.executeVoidFunction(DISABLE_SCRIPT_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Removes a Breakpoint. * * @param breakpointID The ID of the breakpoint to remove. */ public void clearBreakPoint(final int breakpointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakpointID); try { debugObject.executeVoidFunction(CLEAR_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Registers a function breakpoint. When the JavaScript function * is invoked, the breakpoint will be 'hit'. * * @param function The function on which to register the breakpoint. * @return The berakpointID. */ public int setBreakpoint(final V8Function function) { V8Array parameters = new V8Array(runtime); parameters.push(function); try { return debugObject.executeIntegerFunction(SET_BREAK_POINT, parameters); } finally { parameters.close(); } }
/** * Invokes NodeJS require() on the specified file. This will load the module, execute * it and return the exports object to the caller. The exports object must be released. * * @param file The module to load. * @return The exports object. */ public V8Object require(final File file) { v8.checkThread(); V8Array requireParams = new V8Array(v8); try { requireParams.push(file.getAbsolutePath()); return (V8Object) require.call(null, requireParams); } finally { requireParams.close(); } }
/** * Returns the name of the local variable at the given index. * * @param index The index of the local variable name to return. * @return The name of local variable at the given index. */ public String getLocalName(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); try { return v8Object.executeStringFunction(LOCAL_NAME, parameters); } finally { parameters.close(); } }
/** * Returns the name of the argument at the given index. * * @param index The index of the argument name to return. * @return The name of argument at the given index. */ public String getArgumentName(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); try { return v8Object.executeStringFunction(ARGUMENT_NAME, parameters); } finally { parameters.close(); } }
/** * Sets a condition to be evaluated before determining if * the breakpoint event should be fired. * * @param condition A JavaScript condition to be evaluated. */ public void setCondition(final String condition) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(condition); try { v8Object.executeVoidFunction(SET_CONDITION, parameters); } finally { parameters.close(); } }
/** * Indicates to the debugger how to proceed. If not called, * the debugger will continue running until the next breakpoint * is hit. * * @param action The step action to use. */ public void prepareStep(final StepAction action) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(action.index); try { v8Object.executeVoidFunction(PREPARE_STEP, parameters); } finally { parameters.close(); } }
/** * Returns the Frame at a given index * * @param index The stack index * @return The stack frame at a given index */ public Frame getFrame(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); V8Object frame = null; try { frame = v8Object.executeObjectFunction(FRAME, parameters); return new Frame(frame); } finally { parameters.close(); if (frame != null) { frame.close(); } } }
/** * Returns the scope at a given index. * * @param index The index * @return The scope */ public Scope getScope(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); V8Object scope = null; try { scope = v8Object.executeObjectFunction(SCOPE, parameters); return new Scope(scope); } finally { parameters.close(); if (scope != null) { scope.close(); } } }
private void setupBreakpointHandler() { BreakpointHandler handler = new BreakpointHandler(); debugObject.registerJavaMethod(handler, DEBUG_BREAK_HANDLER); V8Function debugHandler = null; V8Array parameters = null; try { debugHandler = (V8Function) debugObject.getObject(DEBUG_BREAK_HANDLER); parameters = new V8Array(runtime); parameters.push(debugHandler); debugObject.executeFunction(SET_LISTENER, parameters); } finally { if ((debugHandler != null) && !debugHandler.isReleased()) { debugHandler.close(); } if ((parameters != null) && !parameters.isReleased()) { parameters.close(); } } }