Mercurial > hg > truffle
diff truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java @ 22139:597953a8e6f0
Testing behavior of primitive types returned from an interop method.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 09 Sep 2015 19:18:44 +0200 |
parents | e70b20f4bb00 |
children | dc83cc1f94f2 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java Wed Sep 09 18:53:14 2015 +0200 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java Wed Sep 09 19:18:44 2015 +0200 @@ -53,6 +53,7 @@ import com.oracle.truffle.sl.nodes.*; import com.oracle.truffle.sl.nodes.local.*; import com.oracle.truffle.sl.parser.*; +import java.math.BigInteger; /** * The run-time state of SL during execution. One context is instantiated before any source code is @@ -198,4 +199,13 @@ public static DynamicObject castSLObject(Object value) { return LAYOUT.getType().cast(value); } + + public static Object fromForeignValue(Object a) { + if (a instanceof Long || a instanceof BigInteger) { + return a; + } else if (a instanceof Number) { + return ((Number) a).longValue(); + } + return a; + } }