changeset 22377:a765d165e7ec

Give languages a chance to separate (and optimize) parsing and evaluation.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Mon, 16 Nov 2015 15:58:03 +0100
parents 72545ac338eb
children 06bdf4a43126
files truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java	Mon Nov 16 15:51:36 2015 +0100
+++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java	Mon Nov 16 15:58:03 2015 +0100
@@ -391,13 +391,12 @@
          * .
          * 
          * @param source the source to evaluate
-         * @return the result of the evaluation
+         * @return the call target representing the parsed result
          * @throws IOException if the parsing or evaluation fails for some reason
          */
-        public Object eval(Source source) throws IOException {
+        public CallTarget parse(Source source) throws IOException {
             TruffleLanguage<?> language = API.findLanguageImpl(vm, null, source.getMimeType());
-            CallTarget call = language.parse(source, null);
-            return call.call();
+            return language.parse(source, null);
         }
 
         /**
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Mon Nov 16 15:51:36 2015 +0100
+++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Mon Nov 16 15:58:03 2015 +0100
@@ -235,6 +235,6 @@
     }
 
     public Object evalAny(Source source) throws IOException {
-        return env.eval(source);
+        return env.parse(source).call();
     }
 }