private int indexByKey(RecordArray mapping, GeneratedLocation location) { int index = binarySearchLocation(mapping, location.getLine(), location.getColumn()); return index >= 0 ? index : -index - 2; }
@Override public void visit(DebuggerStaticCallSite callSite) { for (GeneratedLocation loc : debugInfo.getMethodEntrances(callSite.getMethod())) { loc = debugInfo.getStatementLocation(loc); locations.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn())); } } }
private boolean addFollowing(DebugInformation debugInfo, SourceLocation location, String script, Set<SourceLocation> visited, Set<JavaScriptLocation> successors) { if (!visited.add(location)) { return false; } SourceLocation[] following = debugInfo.getFollowingLines(location); boolean exits = false; if (following != null) { for (SourceLocation successor : following) { if (successor == null) { exits = true; } else { Collection<GeneratedLocation> genLocations = debugInfo.getGeneratedLocations(successor); if (!genLocations.isEmpty()) { for (GeneratedLocation loc : genLocations) { loc = debugInfo.getStatementLocation(loc); successors.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn())); } } else { exits |= addFollowing(debugInfo, successor, script, visited, successors); } } } } return exits; }
private Promise<Void> updateInternalBreakpoints(Breakpoint breakpoint) { if (breakpoint.isDestroyed()) { return Promise.VOID; } List<Promise<Void>> promises = new ArrayList<>(); for (JavaScriptBreakpoint jsBreakpoint : breakpoint.jsBreakpoints) { breakpointMap.remove(jsBreakpoint); promises.add(jsBreakpoint.destroy()); } List<JavaScriptBreakpoint> jsBreakpoints = new ArrayList<>(); SourceLocation location = breakpoint.getLocation(); for (DebugInformation debugInformation : debugInformationBySource(location.getFileName())) { Collection<GeneratedLocation> locations = debugInformation.getGeneratedLocations(location); for (GeneratedLocation genLocation : locations) { JavaScriptLocation jsLocation = new JavaScriptLocation(scriptMap.get(debugInformation), genLocation.getLine(), genLocation.getColumn()); promises.add(javaScriptDebugger.createBreakpoint(jsLocation).thenVoid(jsBreakpoint -> { jsBreakpoints.add(jsBreakpoint); breakpointMap.put(jsBreakpoint, breakpoint); })); } } breakpoint.jsBreakpoints = jsBreakpoints; return Promise.allVoid(promises); }
@Override public void visit(DebuggerVirtualCallSite callSite) { for (MethodReference potentialMethod : debugInfo.getOverridingMethods(callSite.getMethod())) { for (GeneratedLocation loc : debugInfo.getMethodEntrances(potentialMethod)) { loc = debugInfo.getStatementLocation(loc); locations.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn())); } } }
private void writeSegment(GeneratedLocation loc, int sourceFile, int sourceLine) throws IOException { while (loc.getLine() > lastLine) { output.write(';'); ++lastLine; first = true; lastColumn = 0; } if (!first) { output.write(','); } writeVLQ(loc.getColumn() - lastColumn); if (sourceFile >= 0 && sourceLine >= 0) { writeVLQ(sourceFile - lastSourceFile); writeVLQ(sourceLine - lastSourceLine); writeVLQ(0); lastSourceFile = sourceFile; lastSourceLine = sourceLine; } lastColumn = loc.getColumn(); first = false; }
public Promise<Void> continueToLocation(String fileName, int line) { if (!javaScriptDebugger.isSuspended()) { return Promise.VOID; } List<Promise<Void>> promises = new ArrayList<>(); for (DebugInformation debugInformation : debugInformationBySource(fileName)) { Collection<GeneratedLocation> locations = debugInformation.getGeneratedLocations(fileName, line); for (GeneratedLocation location : locations) { JavaScriptLocation jsLocation = new JavaScriptLocation(scriptMap.get(debugInformation), location.getLine(), location.getColumn()); promises.add(javaScriptDebugger.createBreakpoint(jsLocation).thenVoid(temporaryBreakpoints::add)); } } return Promise.allVoid(promises).thenAsync(v -> javaScriptDebugger.resume()); }
void rebuildFileDescriptions() { RecordArrayBuilder[] builders = new RecordArrayBuilder[fileNames.length]; for (int i = 0; i < builders.length; ++i) { builders[i] = new RecordArrayBuilder(0, 1); } for (SourceLocationIterator iter = iterateOverSourceLocations(); !iter.isEndReached(); iter.next()) { if (iter.getFileNameId() >= 0 && iter.getLine() >= 0) { RecordArrayBuilder builder = builders[iter.getFileNameId()]; while (builder.size() <= iter.getLine()) { builder.add(); } GeneratedLocation loc = iter.getLocation(); RecordArrayBuilder.SubArray array = builder.get(iter.getLine()).getArray(0); array.add(loc.getLine()); array.add(loc.getColumn()); } } fileDescriptions = new RecordArray[builders.length]; for (int i = 0; i < fileDescriptions.length; ++i) { fileDescriptions[i] = builders[i].build(); } }
GeneratedLocation firstLineLoc = key(lineMapping.get(lineIndex)); RecordArrayBuilder.SubArray array = builder.get(prevMethodId).getArray(0); array.add(firstLineLoc.getLine()); array.add(firstLineLoc.getColumn()); break;
private int indexByKey(RecordArray mapping, GeneratedLocation location) { int index = binarySearchLocation(mapping, location.getLine(), location.getColumn()); return index >= 0 ? index : -index - 2; }
@Override public void visit(DebuggerStaticCallSite callSite) { for (GeneratedLocation loc : debugInfo.getMethodEntrances(callSite.getMethod())) { loc = debugInfo.getStatementLocation(loc); locations.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn())); } } }
@Override public void visit(DebuggerVirtualCallSite callSite) { for (MethodReference potentialMethod : debugInfo.getOverridingMethods(callSite.getMethod())) { for (GeneratedLocation loc : debugInfo.getMethodEntrances(potentialMethod)) { loc = debugInfo.getStatementLocation(loc); locations.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn())); } } }
private void updateInternalBreakpoints(Breakpoint breakpoint) { if (breakpoint.isDestroyed()) { return; } for (JavaScriptBreakpoint jsBreakpoint : breakpoint.jsBreakpoints) { breakpointMap.remove(jsBreakpoint); jsBreakpoint.destroy(); } List<JavaScriptBreakpoint> jsBreakpoints = new ArrayList<>(); SourceLocation location = breakpoint.getLocation(); for (DebugInformation debugInformation : debugInformationBySource(location.getFileName())) { Collection<GeneratedLocation> locations = debugInformation.getGeneratedLocations(location); for (GeneratedLocation genLocation : locations) { JavaScriptLocation jsLocation = new JavaScriptLocation(scriptMap.get(debugInformation), genLocation.getLine(), genLocation.getColumn()); JavaScriptBreakpoint jsBreakpoint = javaScriptDebugger.createBreakpoint(jsLocation); jsBreakpoints.add(jsBreakpoint); breakpointMap.put(jsBreakpoint, breakpoint); } } breakpoint.jsBreakpoints = jsBreakpoints; }
private boolean addFollowing(DebugInformation debugInfo, SourceLocation location, String script, Set<SourceLocation> visited, Set<JavaScriptLocation> successors) { if (!visited.add(location)) { return false; } SourceLocation[] following = debugInfo.getFollowingLines(location); boolean exits = false; if (following != null) { for (SourceLocation successor : following) { if (successor == null) { exits = true; } else { Collection<GeneratedLocation> genLocations = debugInfo.getGeneratedLocations(successor); if (!genLocations.isEmpty()) { for (GeneratedLocation loc : genLocations) { loc = debugInfo.getStatementLocation(loc); successors.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn())); } } else { exits |= addFollowing(debugInfo, successor, script, visited, successors); } } } } return exits; }
private void writeSegment(GeneratedLocation loc, int sourceFile, int sourceLine) throws IOException { while (loc.getLine() > lastLine) { output.write(';'); ++lastLine; first = true; lastColumn = 0; } if (!first) { output.write(','); } writeVLQ(loc.getColumn() - lastColumn); if (sourceFile >= 0 && sourceLine >= 0) { writeVLQ(sourceFile - lastSourceFile); writeVLQ(sourceLine - lastSourceLine); writeVLQ(0); lastSourceFile = sourceFile; lastSourceLine = sourceLine; } lastColumn = loc.getColumn(); first = false; }
public void continueToLocation(String fileName, int line) { if (!javaScriptDebugger.isSuspended()) { return; } for (DebugInformation debugInformation : debugInformationBySource(fileName)) { Collection<GeneratedLocation> locations = debugInformation.getGeneratedLocations(fileName, line); for (GeneratedLocation location : locations) { JavaScriptLocation jsLocation = new JavaScriptLocation(scriptMap.get(debugInformation), location.getLine(), location.getColumn()); JavaScriptBreakpoint jsBreakpoint = javaScriptDebugger.createBreakpoint(jsLocation); if (jsBreakpoint != null) { temporaryBreakpoints.add(jsBreakpoint); } } } javaScriptDebugger.resume(); }
void rebuildFileDescriptions() { RecordArrayBuilder[] builders = new RecordArrayBuilder[fileNames.length]; for (int i = 0; i < builders.length; ++i) { builders[i] = new RecordArrayBuilder(0, 1); } for (SourceLocationIterator iter = iterateOverSourceLocations(); !iter.isEndReached(); iter.next()) { if (iter.getFileNameId() >= 0 && iter.getLine() >= 0) { RecordArrayBuilder builder = builders[iter.getFileNameId()]; while (builder.size() <= iter.getLine()) { builder.add(); } GeneratedLocation loc = iter.getLocation(); RecordArrayBuilder.SubArray array = builder.get(iter.getLine()).getArray(0); array.add(loc.getLine()); array.add(loc.getColumn()); } } fileDescriptions = new RecordArray[builders.length]; for (int i = 0; i < fileDescriptions.length; ++i) { fileDescriptions[i] = builders[i].build(); } }
GeneratedLocation firstLineLoc = key(lineMapping.get(lineIndex)); RecordArrayBuilder.SubArray array = builder.get(prevMethodId).getArray(0); array.add(firstLineLoc.getLine()); array.add(firstLineLoc.getColumn()); break;