Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java @ 16595:618d92152d3c
SL: Added support for instrumentation.
author | David Piorkowski <david.piorkowski@oracle.com> |
---|---|
date | Thu, 24 Jul 2014 16:14:44 -0700 |
parents | abe7128ca473 |
children | 2a5ec181dad4 |
comparison
equal
deleted
inserted
replaced
16592:8084d44c78d3 | 16595:618d92152d3c |
---|---|
27 import com.oracle.truffle.api.*; | 27 import com.oracle.truffle.api.*; |
28 import com.oracle.truffle.api.dsl.*; | 28 import com.oracle.truffle.api.dsl.*; |
29 import com.oracle.truffle.api.frame.*; | 29 import com.oracle.truffle.api.frame.*; |
30 import com.oracle.truffle.api.instrument.*; | 30 import com.oracle.truffle.api.instrument.*; |
31 import com.oracle.truffle.api.nodes.*; | 31 import com.oracle.truffle.api.nodes.*; |
32 import com.oracle.truffle.api.source.*; | |
33 import com.oracle.truffle.sl.*; | |
32 import com.oracle.truffle.sl.builtins.*; | 34 import com.oracle.truffle.sl.builtins.*; |
33 import com.oracle.truffle.sl.nodes.*; | 35 import com.oracle.truffle.sl.nodes.*; |
36 import com.oracle.truffle.sl.nodes.instrument.*; | |
34 import com.oracle.truffle.sl.nodes.local.*; | 37 import com.oracle.truffle.sl.nodes.local.*; |
35 import com.oracle.truffle.sl.parser.*; | 38 import com.oracle.truffle.sl.parser.*; |
36 | 39 |
37 /** | 40 /** |
38 * The run-time state of SL during execution. One context is instantiated before any source code is | 41 * The run-time state of SL during execution. One context is instantiated before any source code is |
47 public final class SLContext extends ExecutionContext { | 50 public final class SLContext extends ExecutionContext { |
48 private final BufferedReader input; | 51 private final BufferedReader input; |
49 private final PrintStream output; | 52 private final PrintStream output; |
50 private final SLFunctionRegistry functionRegistry; | 53 private final SLFunctionRegistry functionRegistry; |
51 private SourceCallback sourceCallback = null; | 54 private SourceCallback sourceCallback = null; |
55 private SLASTProber astProber; | |
52 | 56 |
53 public SLContext(BufferedReader input, PrintStream output) { | 57 public SLContext(BufferedReader input, PrintStream output) { |
54 this.input = input; | 58 this.input = input; |
55 this.output = output; | 59 this.output = output; |
56 this.functionRegistry = new SLFunctionRegistry(); | 60 this.functionRegistry = new SLFunctionRegistry(); |
131 SLRootNode rootNode = new SLRootNode(new FrameDescriptor(), builtinBodyNode, name); | 135 SLRootNode rootNode = new SLRootNode(new FrameDescriptor(), builtinBodyNode, name); |
132 | 136 |
133 /* Register the builtin function in our function registry. */ | 137 /* Register the builtin function in our function registry. */ |
134 getFunctionRegistry().register(name, rootNode); | 138 getFunctionRegistry().register(name, rootNode); |
135 } | 139 } |
140 | |
141 public void executeMain(Source source) { | |
142 | |
143 if (sourceCallback != null) { | |
144 sourceCallback.startLoading(source); | |
145 } | |
146 | |
147 Parser.parseSL(this, source, astProber); | |
148 | |
149 if (sourceCallback != null) { | |
150 sourceCallback.endLoading(source); | |
151 } | |
152 | |
153 SLFunction main = getFunctionRegistry().lookup("main"); | |
154 if (main.getCallTarget() == null) { | |
155 throw new SLException("No function main() defined in SL source file."); | |
156 } | |
157 main.getCallTarget().call(); | |
158 } | |
159 | |
160 public void setASTNodeProber(SLASTProber astProber) { | |
161 // TODO Auto-generated method stub | |
162 this.astProber = astProber; | |
163 } | |
136 } | 164 } |