Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultDebugManager.java @ 13732:fbf448929260
Ruby: remove some prototyping code no longer needed
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Sat, 18 Jan 2014 22:12:42 -0800 |
parents | |
children | 4d47e9c0df23 |
comparison
equal
deleted
inserted
replaced
13684:72f85504e79e | 13732:fbf448929260 |
---|---|
1 /* | |
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. Oracle designates this | |
8 * particular file as subject to the "Classpath" exception as provided | |
9 * by Oracle in the LICENSE file that accompanied this code. | |
10 * | |
11 * This code is distributed in the hope that it will be useful, but WITHOUT | |
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 * version 2 for more details (a copy is included in the LICENSE file that | |
15 * accompanied this code). | |
16 * | |
17 * You should have received a copy of the GNU General Public License version | |
18 * 2 along with this work; if not, write to the Free Software Foundation, | |
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 * | |
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
22 * or visit www.oracle.com if you need additional information or have any | |
23 * questions. | |
24 */ | |
25 package com.oracle.truffle.api.impl; | |
26 | |
27 import java.util.*; | |
28 | |
29 import com.oracle.truffle.api.*; | |
30 import com.oracle.truffle.api.frame.*; | |
31 import com.oracle.truffle.api.nodes.*; | |
32 import com.oracle.truffle.api.nodes.instrument.InstrumentationProbeNode.ProbeChain; | |
33 import com.oracle.truffle.api.source.*; | |
34 | |
35 public final class DefaultDebugManager implements DebugManager { | |
36 | |
37 private final Set<Source> loadedSources = new HashSet<>(); | |
38 | |
39 private Source beingLoaded = null; | |
40 | |
41 /** | |
42 * Map: SourceSection ==> probe chain associated with that source section in an AST. | |
43 */ | |
44 private final Map<SourceSection, ProbeChain> srcToProbeChain = new HashMap<>(); | |
45 | |
46 /** | |
47 * Map: Source lines ==> probe chains associated with source sections starting on the line. | |
48 */ | |
49 private final Map<SourceLineLocation, Set<ProbeChain>> lineToProbeChains = new HashMap<>(); | |
50 | |
51 private final ExecutionContext context; | |
52 | |
53 public DefaultDebugManager(ExecutionContext context) { | |
54 this.context = context; | |
55 } | |
56 | |
57 /** | |
58 * Gets the {@linkplain ProbeChain probe} associated with a particular {@link SourceSection | |
59 * source location}, creating a new one if needed. There should only be one probe associated | |
60 * with each {@linkplain SourceSection source location}. | |
61 */ | |
62 public ProbeChain getProbeChain(SourceSection sourceSection) { | |
63 assert sourceSection != null; | |
64 assert sourceSection.getSource().equals(beingLoaded); | |
65 | |
66 ProbeChain probeChain = srcToProbeChain.get(sourceSection); | |
67 | |
68 if (probeChain != null) { | |
69 return probeChain; | |
70 } | |
71 probeChain = new ProbeChain(context, sourceSection, null); | |
72 | |
73 // Register new ProbeChain by unique SourceSection | |
74 srcToProbeChain.put(sourceSection, probeChain); | |
75 | |
76 // Register new ProbeChain by source line, there may be more than one | |
77 // Create line location for map key | |
78 final SourceLineLocation lineLocation = new SourceLineLocation(sourceSection.getSource(), sourceSection.getStartLine()); | |
79 | |
80 Set<ProbeChain> probeChains = lineToProbeChains.get(lineLocation); | |
81 if (probeChains == null) { | |
82 probeChains = new HashSet<>(); | |
83 lineToProbeChains.put(lineLocation, probeChains); | |
84 } | |
85 probeChains.add(probeChain); | |
86 | |
87 return probeChain; | |
88 } | |
89 | |
90 @Override | |
91 public void notifyStartLoading(Source source) { | |
92 assert beingLoaded == null; | |
93 beingLoaded = source; | |
94 } | |
95 | |
96 @Override | |
97 public void notifyFinishedLoading(Source source) { | |
98 assert source == beingLoaded; | |
99 loadedSources.add(source); | |
100 beingLoaded = null; | |
101 } | |
102 | |
103 public void haltedAt(Node astNode, MaterializedFrame frame) { | |
104 } | |
105 | |
106 } |