Mercurial > hg > graal-compiler
diff 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 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java Thu Jul 24 12:22:54 2014 -0700 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java Thu Jul 24 16:14:44 2014 -0700 @@ -29,8 +29,11 @@ import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.instrument.*; import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.api.source.*; +import com.oracle.truffle.sl.*; import com.oracle.truffle.sl.builtins.*; import com.oracle.truffle.sl.nodes.*; +import com.oracle.truffle.sl.nodes.instrument.*; import com.oracle.truffle.sl.nodes.local.*; import com.oracle.truffle.sl.parser.*; @@ -49,6 +52,7 @@ private final PrintStream output; private final SLFunctionRegistry functionRegistry; private SourceCallback sourceCallback = null; + private SLASTProber astProber; public SLContext(BufferedReader input, PrintStream output) { this.input = input; @@ -133,4 +137,28 @@ /* Register the builtin function in our function registry. */ getFunctionRegistry().register(name, rootNode); } + + public void executeMain(Source source) { + + if (sourceCallback != null) { + sourceCallback.startLoading(source); + } + + Parser.parseSL(this, source, astProber); + + if (sourceCallback != null) { + sourceCallback.endLoading(source); + } + + SLFunction main = getFunctionRegistry().lookup("main"); + if (main.getCallTarget() == null) { + throw new SLException("No function main() defined in SL source file."); + } + main.getCallTarget().call(); + } + + public void setASTNodeProber(SLASTProber astProber) { + // TODO Auto-generated method stub + this.astProber = astProber; + } }