diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TypedNode.java @ 9213:c3ec5230967a

Added default execute methods for Truffle-SL.
author Christian Humer <christian.humer@gmail.com>
date Mon, 08 Apr 2013 18:15:53 +0200
parents 33e08aca06ff
children 1964871a642d
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TypedNode.java	Mon Apr 08 17:02:55 2013 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/TypedNode.java	Mon Apr 08 18:15:53 2013 +0200
@@ -26,6 +26,7 @@
 
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.sl.*;
 
 public abstract class TypedNode extends ConditionNode {
 
@@ -38,15 +39,28 @@
         }
     }
 
-    public abstract boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException;
+    public abstract Object executeGeneric(VirtualFrame frame);
 
-    public abstract int executeInteger(VirtualFrame frame) throws UnexpectedResultException;
+    public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectBoolean(executeGeneric(frame));
+    }
+
+    public int executeInteger(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectInteger(executeGeneric(frame));
+    }
 
-    public abstract BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException;
+    public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectBigInteger(executeGeneric(frame));
+    }
 
-    public abstract String executeString(VirtualFrame frame) throws UnexpectedResultException;
+    public String executeString(VirtualFrame frame) throws UnexpectedResultException {
+        return SLTypesGen.SLTYPES.expectString(executeGeneric(frame));
+    }
 
-    public abstract Object executeGeneric(VirtualFrame frame);
+    @Override
+    public void executeVoid(VirtualFrame frame) {
+        executeGeneric(frame);
+    }
 
     public boolean isString(Object a, Object b) {
         return a instanceof String || b instanceof String;