Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
22138:a583d7ffd285 | 22139:597953a8e6f0 |
---|---|
51 import com.oracle.truffle.sl.SLLanguage; | 51 import com.oracle.truffle.sl.SLLanguage; |
52 import com.oracle.truffle.sl.builtins.*; | 52 import com.oracle.truffle.sl.builtins.*; |
53 import com.oracle.truffle.sl.nodes.*; | 53 import com.oracle.truffle.sl.nodes.*; |
54 import com.oracle.truffle.sl.nodes.local.*; | 54 import com.oracle.truffle.sl.nodes.local.*; |
55 import com.oracle.truffle.sl.parser.*; | 55 import com.oracle.truffle.sl.parser.*; |
56 import java.math.BigInteger; | |
56 | 57 |
57 /** | 58 /** |
58 * The run-time state of SL during execution. One context is instantiated before any source code is | 59 * The run-time state of SL during execution. One context is instantiated before any source code is |
59 * parsed, and this context is passed around to all methods that need access to it. For example, the | 60 * parsed, and this context is passed around to all methods that need access to it. For example, the |
60 * context is used during {@link SLNodeFactory parsing} and by {@link SLBuiltinNode#getContext() | 61 * context is used during {@link SLNodeFactory parsing} and by {@link SLBuiltinNode#getContext() |
196 } | 197 } |
197 | 198 |
198 public static DynamicObject castSLObject(Object value) { | 199 public static DynamicObject castSLObject(Object value) { |
199 return LAYOUT.getType().cast(value); | 200 return LAYOUT.getType().cast(value); |
200 } | 201 } |
202 | |
203 public static Object fromForeignValue(Object a) { | |
204 if (a instanceof Long || a instanceof BigInteger) { | |
205 return a; | |
206 } else if (a instanceof Number) { | |
207 return ((Number) a).longValue(); | |
208 } | |
209 return a; | |
210 } | |
201 } | 211 } |