Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineLocationToSourceSectionCollectionMap.java @ 17078:c4b1cf38002b
Truffle: TruffleCompilationExceptionsAreThrown option to get OptimizationFailedException on compiler error.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Tue, 09 Sep 2014 20:19:23 +0100 |
parents | a1427e40deaf |
children | c88ab4f1f04a |
rev | line source |
---|---|
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
1 /* |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
4 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
10 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
16 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
20 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
23 * questions. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
24 */ |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.instrument.impl; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
26 |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
27 import java.io.*; |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
29 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.instrument.*; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.source.*; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
32 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
33 /** |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
34 * A mapping from {@link LineLocation} (a line number in a specific piece of {@link Source} code) to |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
35 * a collection of {@link SourceSection}s that exist on that line. This class assumes that all nodes |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
36 * are instrumented as it uses the {@link ProbeListener} interface to determine the source sections |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
37 * that exist in the file. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
38 */ |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
39 public class LineLocationToSourceSectionCollectionMap implements ProbeListener { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
40 |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
41 private static final boolean TRACE = false; |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
42 private static final PrintStream OUT = System.out; |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
43 |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
44 /** |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
45 * Map: Source line ==> source sections that exist on the line. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
46 */ |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
47 private final Map<LineLocation, Collection<SourceSection>> lineToSourceSectionsMap = new HashMap<>(); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
48 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
49 public LineLocationToSourceSectionCollectionMap() { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
50 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
51 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
52 public void newProbeInserted(SourceSection sourceSection, Probe probe) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
53 if (sourceSection != null && !(sourceSection instanceof NullSourceSection)) { |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
54 final LineLocation lineLocation = sourceSection.getLineLocation(); |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
55 if (TRACE) { |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
56 OUT.println("LineLocationToSourceSectionCollectionMap: adding " + lineLocation + " Probe=" + probe); |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
57 } |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
58 this.addSourceSectionToLine(lineLocation, sourceSection); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
59 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
60 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
61 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
62 public void probeTaggedAs(Probe probe, SyntaxTag tag) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
63 // This map ignores tags, but this subclasses can override this method to operate on tags. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
64 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
65 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
66 /** |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
67 * Adds a source section to the given line. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
68 * <p> |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
69 * If the line already exists in the internal {@link #lineToSourceSectionsMap}, this source |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
70 * section will be added to the existing collection. If no line already exists in the internal |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
71 * map, then a new key is added along with a new collection containing the source section. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
72 * <p> |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
73 * This class does not check if a source section has already been added to a line. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
74 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
75 * @param line The {@link LineLocation} to attach the source section to. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
76 * @param sourceSection The {@link SourceSection} to attach for that line location. |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
77 */ |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
78 protected void addSourceSectionToLine(LineLocation line, SourceSection sourceSection) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
79 if (!lineToSourceSectionsMap.containsKey(line)) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
80 // Key does not exist, add new source section list |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
81 final ArrayList<SourceSection> newSourceSectionList = new ArrayList<>(2); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
82 newSourceSectionList.add(sourceSection); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
83 lineToSourceSectionsMap.put(line, newSourceSectionList); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
84 } else { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
85 // Source section list exists, add to existing |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
86 final Collection<SourceSection> existingSourceSectionList = lineToSourceSectionsMap.get(line); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
87 existingSourceSectionList.add(sourceSection); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
88 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
89 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
90 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
91 /** |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
92 * Returns a collection of {@link SourceSection}s at the given {@link LineLocation}, an empty |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
93 * list if none. |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
94 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
95 * @param line The line to check. |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
96 * @return the source sections at the given line. |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
97 */ |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
98 public Collection<SourceSection> getSourceSectionsAtLine(LineLocation line) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
99 Collection<SourceSection> sourceSectionList = lineToSourceSectionsMap.get(line); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
100 |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
101 if (sourceSectionList == null) { |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
102 return Collections.emptyList(); |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
103 } |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
104 return sourceSectionList; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
105 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
106 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
107 /** |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
108 * Convenience method to get source sections according to a int line number. Returns a |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
109 * collection of {@link SourceSection}s at the given line number. If there are no source |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
110 * sections at that line, an empty list is returned. |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
111 * |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
112 * @param lineNumber The line number to check. |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
113 * @return A collection of source sections at the given line. |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
114 */ |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
115 public Collection<SourceSection> getSourceSectionsAtLineNumber(int lineNumber) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
116 |
16961
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
117 final Set<LineLocation> keySet = lineToSourceSectionsMap.keySet(); |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
118 if (keySet.size() == 0) { |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
119 return Collections.emptyList(); |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
120 } |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
121 |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
122 final ArrayList<SourceSection> sourceSections = new ArrayList<>(); |
a1427e40deaf
Truffle/Instrumentation: some Javadoc revistions; minor code cleanups; remove one redundant operation; add tracing to the LineLocation maps.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16880
diff
changeset
|
123 for (LineLocation line : keySet) { |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
124 if (line.getLineNumber() == lineNumber) |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
125 sourceSections.addAll(lineToSourceSectionsMap.get(line)); |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
126 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
127 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
128 return sourceSections; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
129 } |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
130 } |