Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLNull.java @ 21689:ed234a3178af
Behavior of null-like values is now part of the TCK
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 10:17:19 +0200 |
parents | 1d3c23e675ed |
children | c76742cc2c6f |
comparison
equal
deleted
inserted
replaced
21688:889b45a0dedd | 21689:ed234a3178af |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.runtime; | 23 package com.oracle.truffle.sl.runtime; |
24 | 24 |
25 import com.oracle.truffle.api.interop.ForeignAccessFactory; | |
26 import com.oracle.truffle.api.interop.TruffleObject; | |
27 | |
25 /** | 28 /** |
26 * The SL type for a {@code null} (i.e., undefined) value. In Truffle, it is generally discouraged | 29 * The SL type for a {@code null} (i.e., undefined) value. In Truffle, it is generally discouraged |
27 * to use the Java {@code null} value to represent the guest language {@code null} value. It is not | 30 * to use the Java {@code null} value to represent the guest language {@code null} value. It is not |
28 * possible to specialize on Java {@code null} (since you cannot ask it for the Java class), and | 31 * possible to specialize on Java {@code null} (since you cannot ask it for the Java class), and |
29 * there is always the danger of a spurious {@link NullPointerException}. Representing the guest | 32 * there is always the danger of a spurious {@link NullPointerException}. Representing the guest |
30 * language {@code null} as a singleton, as in {@link #SINGLETON this class}, is the recommended | 33 * language {@code null} as a singleton, as in {@link #SINGLETON this class}, is the recommended |
31 * practice. | 34 * practice. |
32 */ | 35 */ |
33 public final class SLNull { | 36 public final class SLNull implements TruffleObject { |
34 | 37 |
35 /** | 38 /** |
36 * The canonical value to represent {@code null} in SL. | 39 * The canonical value to represent {@code null} in SL. |
37 */ | 40 */ |
38 public static final SLNull SINGLETON = new SLNull(); | 41 public static final SLNull SINGLETON = new SLNull(); |
50 */ | 53 */ |
51 @Override | 54 @Override |
52 public String toString() { | 55 public String toString() { |
53 return "null"; | 56 return "null"; |
54 } | 57 } |
58 | |
59 @Override | |
60 public ForeignAccessFactory getForeignAccessFactory() { | |
61 return SLFunctionForeignAccess.INSTANCE; | |
62 } | |
55 } | 63 } |