protected static ValueMirror createMirror(final V8Object mirror) { if (isNull(mirror)) { return new NullMirror(mirror); } else if (isUndefined(mirror)) { return new UndefinedMirror(mirror); } else if (isFunction(mirror)) { return new FunctionMirror(mirror); } else if (isArray(mirror)) { return new ArrayMirror(mirror); } else if (isObject(mirror)) { return new ObjectMirror(mirror); } else if (isString(mirror)) { return new StringMirror(mirror); } else if (isNumber(mirror)) { return new NumberMirror(mirror); } else if (isBoolean(mirror)) { return new BooleanMirror(mirror); } return new ValueMirror(mirror); }
@Override @Deprecated public void release() { close(); }
@Override @Deprecated public void release() { close(); }
FunctionMirror function = getFunction(); String functionScriptName = function.getScriptName(); try { String scriptName = null; scriptName = "undefined"; return new SourceLocation(scriptName, sourceLocation.getInteger(POSITION), sourceLocation.getInteger(LINE), sourceLocation.getString(SOURCE_TEXT)); } finally { function.close(); sourceLocation.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(); } } }
@Override public void onBreak(final DebugEvent event, final ExecutionState state, final EventData eventData, final V8Object data) { Frame frame = state.getFrame(0); ValueMirror arrayValue = frame.getLocalValue(3); result = arrayValue.isValue() && arrayValue.isObject() && arrayValue.isArray(); result = (Boolean) result && (((ArrayMirror) arrayValue).length() == 3); arrayValue.close(); frame.close(); } });
@Override public void onBreak(final DebugEvent event, final ExecutionState state, final EventData eventData, final V8Object data) { Frame frame = state.getFrame(0); Scope scope = frame.getScope(0); scope.setVariableValue("z", false); scope.close(); frame.close(); } });
@Override public void onBreak(final DebugEvent event, final ExecutionState state, final EventData eventData, final V8Object data) { Frame frame = state.getFrame(0); ValueMirror nullValue = frame.getLocalValue(5); result = nullValue.isValue() && nullValue.isNull(); nullValue.close(); frame.close(); } });
/** * Returns the type of this scope. * * @return The type of scope. */ public ScopeType getType() { return ScopeType.values()[v8Object.executeIntegerFunction(SCOPE_TYPE, null)]; }
/** * 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 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(); } } }
/** * 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 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(); } } }
/** * Return the properties for this object as an array of PropertyMirror objects. * * @param kind Indicate whether named, indexed or both kinds of properties are requested * @param limit Limit the number of properties returned to the specified value * @return {Array} Property mirrors for this object */ public PropertiesArray getProperties(final PropertyKind kind, final int limit) { V8Array parameters = new V8Array(v8Object.getRuntime()); parameters.push(kind.index); parameters.push(limit); V8Array result = null; try { result = v8Object.executeArrayFunction(PROPERTIES, parameters); return new PropertiesArray(result); } finally { parameters.close(); if ((result != null) && !result.isReleased()) { result.close(); result = null; } } }
@Override public void onBreak(final DebugEvent event, final ExecutionState state, final EventData eventData, final V8Object data) { Frame frame = state.getFrame(0); ValueMirror objectValue1 = frame.getLocalValue(2); ValueMirror objectValue2 = frame.getLocalValue(1); result = objectValue1.equals(objectValue2); objectValue1.close(); objectValue2.close(); frame.close(); } });
@Override public void onBreak(final DebugEvent event, final ExecutionState state, final EventData eventData, final V8Object data) { Frame frame = state.getFrame(0); Scope scope = frame.getScope(0); scope.setVariableValue("z", "someString"); scope.close(); frame.close(); } });