comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLTypes.java @ 18782:3ea386a1036f

Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
author Christian Humer <christian.humer@gmail.com>
date Mon, 05 Jan 2015 20:23:22 +0100
parents 924bf48a5d6a
children 894f82515e38
comparison
equal deleted inserted replaced
18781:941761f6b736 18782:3ea386a1036f
43 * Example of a manually specified type check that replaces the automatically generated type 43 * Example of a manually specified type check that replaces the automatically generated type
44 * check that the Truffle DSL would generate. For {@link SLNull}, we do not need an 44 * check that the Truffle DSL would generate. For {@link SLNull}, we do not need an
45 * {@code instanceof} check, because we know that there is only a {@link SLNull#SINGLETON 45 * {@code instanceof} check, because we know that there is only a {@link SLNull#SINGLETON
46 * singleton} instance. 46 * singleton} instance.
47 */ 47 */
48 @TypeCheck 48 @TypeCheck(SLNull.class)
49 public static boolean isSLNull(Object value) { 49 public static boolean isSLNull(Object value) {
50 return value == SLNull.SINGLETON; 50 return value == SLNull.SINGLETON;
51 } 51 }
52 52
53 /** 53 /**
54 * Example of a manually specified type cast that replaces the automatically generated type cast 54 * Example of a manually specified type cast that replaces the automatically generated type cast
55 * that the Truffle DSL would generate. For {@link SLNull}, we do not need an actual cast, 55 * that the Truffle DSL would generate. For {@link SLNull}, we do not need an actual cast,
56 * because we know that there is only a {@link SLNull#SINGLETON singleton} instance. 56 * because we know that there is only a {@link SLNull#SINGLETON singleton} instance.
57 */ 57 */
58 @TypeCast 58 @TypeCast(SLNull.class)
59 public static SLNull asSLNull(Object value) { 59 public static SLNull asSLNull(Object value) {
60 assert isSLNull(value); 60 assert isSLNull(value);
61 return SLNull.SINGLETON; 61 return SLNull.SINGLETON;
62 } 62 }
63 63