public DebugFrame getFrame( Context arg0, DebuggableScript arg1 ) { if ( disposed ) { return null; } JsFunctionSource src = (JsFunctionSource) scripts.get( arg1 ); if ( src == null ) { // this is not debuggable return null; } System.out.println( ">>>> Frame Source Name: " + src.getSourceName( ) ); //$NON-NLS-1$ System.out.println( ">>>> Frame Function Name: " + src.getFunctionName( ) ); //$NON-NLS-1$ return new JsDebugFrame( arg0, this, arg1, src ); }
private void checkBreakable( DebuggableScript script ) { int[] nums = script.getLineNumbers( ); if ( nums != null && nums.length > 0 ) { for ( int i = 0; i < nums.length; i++ ) { if ( nums[i] == lineNumber ) { breakable = true; return; } } } for ( int i = 0; i < script.getFunctionCount( ); i++ ) { checkBreakable( script.getFunction( i ) ); if ( breakable ) { return; } } }
private void createStubs(final String prefix, final DebuggableScript fnOrScript) { final FunctionStub stub = new FunctionStub(scriptName, prefix); newStubsToFunctions.put(stub, fnOrScript); newFunctionsToStubs.put(fnOrScript, stub); final int l = fnOrScript.getFunctionCount(); for (int i = 0; i < l; ++i) { createStubs(prefix + i + ".", fnOrScript.getFunction(i)); } }
/** * Return DebuggableScript instance if any associated with the script. * If callable supports DebuggableScript implementation, the method * returns it. Otherwise null is returned. */ public static DebuggableScript getDebuggableView(Script script) { if (script instanceof NativeFunction) { return ((NativeFunction)script).getDebuggableView(); } return null; }
private static void notifyDebugger_r(Context cx, DebuggableScript dscript, String debugSource) { cx.debugger.handleCompilationDone(cx, dscript, debugSource); for (int i = 0; i != dscript.getFunctionCount(); ++i) { notifyDebugger_r(cx, dscript.getFunction(i), debugSource); } }
@Override public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript) { if (debugFrame == null) { debugFrame = new ObservingDebugFrame(isDisconnected); } return debugFrame; }
public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript) { if(debugFrame == null){ debugFrame = new ObservingDebugFrame(mStop); } return debugFrame; }
public static DebuggableScript[] getAllFunctions(DebuggableScript function) { ObjArray functions = new ObjArray(); collectFunctions(function, functions); DebuggableScript[] result = new DebuggableScript[functions.size()]; functions.toArray(result); return result; }
private static void collectFunctions(DebuggableScript function, ObjArray array) { array.add(function); for (int i = 0; i != function.getFunctionCount(); ++i) { collectFunctions(function.getFunction(i), array); } }
private FunctionSource getFunctionSource(DebuggableScript fnOrScript) { int firstLine = -1; int[] lineNumbers = fnOrScript.getLineNumbers(); if (lineNumbers != null && lineNumbers.length > 0) { firstLine = lineNumbers[0]; for (int j = 1; j != lineNumbers.length; ++j) { int line = lineNumbers[j]; if (line < firstLine) { firstLine = line; } } } SourceFile file = null; String sourceName = fnOrScript.getSourceName(); if (sourceName == null || sourceName.equals(this.file.getFilePath())) { file = this.file; } else { file = getSourceFile(sourceName); } if (file == null) { file = this.file; } return new FunctionSource(file, firstLine, fnOrScript.getFunctionName()); }
public void handleCompilationDone( Context arg0, DebuggableScript arg1, String arg2 ) { if ( disposed || !arg1.isTopLevel( ) ) { return; } // check debuggable scripts if ( arg1.getSourceName( ) == null || arg1.getSourceName( ).equals( ScriptExpression.defaultID ) ) { // skip default scripts, which is only used internally. // System.out.println( ">>>> Skipped Source: " //$NON-NLS-1$ // + arg1.getSourceName( ) // + "\r\n" //$NON-NLS-1$ // + arg2 // + "\r\n>>>> Skipped." ); //$NON-NLS-1$ return; } registerTopLevelScripts( arg1, arg2 ); System.out.println( ">>>> Compiled Source: " //$NON-NLS-1$ + arg1.getSourceName( ) + "\r\n" //$NON-NLS-1$ + arg2 + "\r\n>>>> end compilation." ); //$NON-NLS-1$ }
private void registerTopLevelScripts( DebuggableScript script, String source ) { List functions = new ArrayList( ); collectFunctions( script, functions ); registerFunctions( source, functions ); }
private void registerFunctions( String source, List functions ) { for ( int i = 0; i < functions.size( ); i++ ) { DebuggableScript function = (DebuggableScript) functions.get( i ); int firstLineNumber = getMinNumber( function.getLineNumbers( ) ); if ( firstLineNumber == -1 ) { continue; } String funcName = function.getFunctionName( ); if ( funcName == null ) { funcName = ""; //$NON-NLS-1$ } scripts.put( function, new JsFunctionSource( function.getSourceName( ), funcName, source, firstLineNumber ) ); } }
private void collectFunctions( DebuggableScript function, List holder ) { holder.add( function ); for ( int i = 0; i < function.getFunctionCount( ); i++ ) { collectFunctions( function.getFunction( i ), holder ); } }
public JsDebugFrame( Context cx, JsDebugger debugger, DebuggableScript script, JsFunctionSource src ) { this.cx = cx; this.debugger = debugger; this.script = script; this.src = src; }
public void handleCompilationDone( Context arg0, DebuggableScript arg1, String arg2 ) { if ( !arg1.isTopLevel( ) ) { return; } breakable = false; checkBreakable( arg1 ); }
@Override public DebuggableScript getDebuggableView() { return idata; }
public DebuggableScript getDebuggableView() { return null; }
public DebuggableScript getFunction(int index) { return itsNestedFunctions[index]; }