Mercurial > hg > truffle
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLTypes.java @ 12752:71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Nov 2013 21:34:44 +0100 |
parents | 3faec5ab0696 |
children |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLTypes.java Thu Nov 07 20:55:13 2013 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLTypes.java Mon Nov 11 21:34:44 2013 +0100 @@ -24,26 +24,22 @@ import java.math.*; +import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.sl.runtime.*; -@TypeSystem({int.class, BigInteger.class, boolean.class, String.class}) +@TypeSystem({int.class, BigInteger.class, boolean.class, String.class, CallTarget.class, SLNull.class, Object[].class}) public class SLTypes { @TypeCheck - public boolean isInteger(Object value) { - return value instanceof Integer || (value instanceof BigInteger && ((BigInteger) value).bitLength() < Integer.SIZE); + public boolean isSLNull(Object value) { + return SLNull.INSTANCE == value; } @TypeCast - public int asInteger(Object value) { - assert isInteger(value); - if (value instanceof Integer) { - return (int) value; - } else { - int result = ((BigInteger) value).intValue(); - assert BigInteger.valueOf(result).equals(value) : "Losing precision"; - return result; - } + public SLNull asSLNull(Object value) { + assert isSLNull(value); + return SLNull.INSTANCE; } @ImplicitCast