@Override public void close() { debugObject.close(); }
@Override public void close() { if (!v8Object.isReleased()) { v8Object.close(); } }
@Override public void close() { if ((v8Object != null) && !v8Object.isReleased()) { v8Object.close(); v8Object = null; } }
@Override public void close() { if ((v8Object != null) && !v8Object.isReleased()) { v8Object.close(); v8Object = null; } }
@Override public void close() { if ((v8Object != null) && !v8Object.isReleased()) { v8Object.close(); v8Object = null; } }
public void stop() { try { server.close(); synchronized (clientLock) { if (client != null) { client.close(); client = null; } } } catch (IOException e) { logError(e); } //release resources if (runningStateDcp != null) { runningStateDcp.close(); runningStateDcp = null; } if (debugObject != null) { debugObject.close(); debugObject = null; } if (stoppedStateDcp != null) { stoppedStateDcp.close(); stoppedStateDcp = null; } };
private static V8Object toV8Object(final V8 v8, final Map<String, ? extends Object> map, final Map<Object, V8Value> cache) { if (cache.containsKey(map)) { return (V8Object) cache.get(map); } V8Object result = new V8Object(v8); cache.put(map, result); try { for (Entry<String, ? extends Object> entry : map.entrySet()) { setValue(v8, result, entry.getKey(), entry.getValue(), cache); } } catch (IllegalStateException e) { result.close(); throw e; } return result; }
private void setupDebugObject(final V8 runtime) { V8Object outerDebug = runtime.getObject(DEBUG_OBJECT_NAME); try { debugObject = outerDebug.getObject(V8_DEBUG_OBJECT); } finally { outerDebug.close(); } }
/** * Returns the value of this property. * * @return The value of this property. */ public Mirror getValue() { V8Object mirror = v8Object.executeObjectFunction("value", null); try { return createMirror(mirror); } finally { mirror.close(); } }
/** * Returns the PropertyMiror at a given index. * * @param index The index of the property * @return The property at the given index */ public PropertyMirror getProperty(final int index) { V8Object result = v8Array.getObject(index); try { return new PropertyMirror(result); } finally { result.close(); } }
/** * Returns the name of the Script associated with * this FunctionMirror. * * @return The name of the script. */ public String getScriptName() { V8Object script = v8Object.executeObjectFunction(SCRIPT, null); try { return script.executeStringFunction(NAME, null); } finally { script.close(); } }
/** * Returns the underlying V8Object that represents this scope. * * @return The underlying V8Object that represents this scope. */ public ObjectMirror getScopeObject() { V8Object mirror = null; try { mirror = v8Object.executeObjectFunction(SCOPE_OBJECT, null); return (ObjectMirror) createMirror(mirror); } finally { if ( mirror != null ) { mirror.close(); } } }
/** * Returns the Function associated with this particular debug frame. * * @return The Function for this debug frame. */ public FunctionMirror getFunction() { V8Object function = null; try { function = v8Object.executeObjectFunction(FUNC, null); return new FunctionMirror(function); } finally { if (function != null) { function.close(); } } }
private void sendCompileEvent(final V8Object eventData) throws IOException { if (!isConnected()) { return; } //send event to debugger int type = eventData.getInteger("type_"); V8Object script = eventData.getObject("script_"); V8Object event = null; V8Array params = new V8Array(runtime); try { params.push(script); params.push(type); event = debugObject.executeObjectFunction(MAKE_COMPILE_EVENT, params); String json = event.executeStringFunction("toJSONProtocol", null); if (traceCommunication) { System.out.println("Sending event (CompileEvent):\n" + json.substring(0, Math.min(json.length(), 1000))); } if (json.length() > 0) { sendJson(json); } } finally { params.close(); script.close(); if (event != null) { event.close(); } } }
/** * Returns the value of the argument at the given index. * * @param index The index of the argument value to return. * @return The value of argument at the given index. */ public ValueMirror getArgumentValue(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); V8Object result = null; try { result = v8Object.executeObjectFunction(ARGUMENT_VALUE, parameters); if (!isValue(result)) { throw new IllegalStateException("Argument value is not a ValueMirror"); } return new ValueMirror(result); } finally { parameters.close(); if (result != null) { result.close(); } } }
/** * Returns the value of the local variable at the given index. * * @param index The index of the local to return. * @return The value of local at the given index. */ public ValueMirror getLocalValue(final int index) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(index); V8Object result = null; try { result = v8Object.executeObjectFunction(LOCAL_VALUE, parameters); if (!isValue(result)) { throw new IllegalStateException("Local value is not a ValueMirror"); } return createMirror(result); } finally { parameters.close(); if (result != null) { result.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(); } } }
/** * Get the BreakPoint as referenced by the given ID. * * @param breakPointID The BreakPoint ID. * @return The BreakPoint as referenced by the given ID. */ public ScriptBreakPoint getScriptBreakPoint(final int breakPointID) { V8Array parameters = new V8Array(runtime); parameters.push(breakPointID); parameters.push(false); V8Object scriptBreakPoint = null; try { scriptBreakPoint = debugObject.executeObjectFunction(FIND_SCRIPT_BREAK_POINT, parameters); return new ScriptBreakPoint(scriptBreakPoint); } finally { parameters.close(); if (scriptBreakPoint != null) { scriptBreakPoint.close(); } } }
/** * Get all the BreakPoint IDs as an array. * * @return A list of BreakPoint IDs. */ public int[] getScriptBreakPointIDs() { V8Array breakPoints = debugObject.executeArrayFunction(SCRIPT_BREAK_POINTS, null); try { int[] result = new int[breakPoints.length()]; for (int i = 0; i < breakPoints.length(); i++) { V8Object breakPoint = breakPoints.getObject(i); try { result[i] = breakPoint.executeIntegerFunction(NUMBER, null); } finally { breakPoint.close(); } } return result; } finally { breakPoints.close(); } }