public void detach( Context cx ) { if ( !isTerminated( ) ) { terminate( ); } Debugger dbg = cx.getDebugger( ); if ( dbg instanceof JsDebugger ) { cx.setDebugger( null, null ); } isAttached = false; if ( jsDebugger != null ) { jsDebugger.dispose( ); jsDebugger = null; } if ( factoryListener != null ) { cx.getFactory( ).removeListener( factoryListener ); factoryListener = null; } }
static boolean check( String source, int lineNumber ) { Context cx = Context.enter( ); Debugger oldDebugger = cx.getDebugger( ); Object oldContext = cx.getDebuggerContextData( ); boolean oldGenerate = cx.isGeneratingDebug( ); int oldLevel = cx.getOptimizationLevel( ); try { BreakableSourceChecker checker = new BreakableSourceChecker( ); checker.lineNumber = lineNumber + 2; cx.setDebugger( checker, null ); cx.setGeneratingDebug( true ); cx.setOptimizationLevel( -1 ); cx.compileString( addHeader( source ), "<check>", 1, null ); //$NON-NLS-1$ return checker.breakable; } catch ( Exception e ) { return false; } finally { cx.setDebugger( oldDebugger, oldContext ); cx.setGeneratingDebug( oldGenerate ); cx.setOptimizationLevel( oldLevel ); Context.exit( ); } }
/** * Return the current debugger. * @return the debugger, or null if none is attached. */ public final Debugger getDebugger() { return debugger; }
public void addDebugger(Debugger debugger) { rhino.setDebugger(debugger, scope); }
public synchronized VMValue evaluate( String expression ) { int currentState = debugger.currentState( ); if ( currentState == VM_TERMINATED ) { return null; } JsValue result = null; Debugger oldDebugger = cx.getDebugger( ); Object oldContextData = cx.getDebuggerContextData( ); int oldLevel = cx.getOptimizationLevel( ); cx.setDebugger( null, null ); cx.setOptimizationLevel( -1 ); cx.setGeneratingDebug( false ); try { Callable script = (Callable) cx.compileString( expression, EVALUATOR_LITERAL, 0, null ); Object val = script.call( cx, scope, thisObj, ScriptRuntime.emptyArgs ); if ( val == Undefined.instance ) { result = new JsValue( UNDEFINED_LITERAL, UNDEFINED_TYPE ); } else { result = new JsValue( val ); } } catch ( Exception ex ) { result = new JsValue( ex.getMessage( ), EXCEPTION_TYPE ); } finally { cx.setGeneratingDebug( true ); cx.setOptimizationLevel( oldLevel ); cx.setDebugger( oldDebugger, oldContextData ); } return result; }
/** * Set the associated debugger. * @param debugger the debugger to be used on callbacks from * the engine. * @param contextData arbitrary object that debugger can use to store * per Context data. */ public final void setDebugger(Debugger debugger, Object contextData) { if (sealed) onSealedMutation(); this.debugger = debugger; debuggerData = contextData; }