org.mozilla.javascript.debug.Debugger Java Examples

The following examples show how to use org.mozilla.javascript.debug.Debugger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReportVM.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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;
	}
}
 
Example #2
Source File: JsUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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( );
	}
}
 
Example #3
Source File: Context.java    From JsDroidCmd with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Return the current debugger.
 * @return the debugger, or null if none is attached.
 */
public final Debugger getDebugger()
{
    return debugger;
}
 
Example #4
Source File: AppRunnerInterpreter.java    From PHONK with GNU General Public License v3.0 4 votes vote down vote up
public void addDebugger(Debugger debugger) {
    rhino.setDebugger(debugger, scope);
}
 
Example #5
Source File: Context.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the current debugger.
 * @return the debugger, or null if none is attached.
 */
public final Debugger getDebugger()
{
    return debugger;
}
 
Example #6
Source File: JsDebugFrame.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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;
}
 
Example #7
Source File: Context.java    From JsDroidCmd with Mozilla Public License 2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: Context.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}