Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java @ 18758:3912400fc33a
Truffle-DSL: remove type system singleton
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Dec 2014 23:38:42 +0100 |
parents | 59953a46c56f |
children | 3ea386a1036f |
comparison
equal
deleted
inserted
replaced
18757:0ec5f5a2e720 | 18758:3912400fc33a |
---|---|
24 | 24 |
25 import java.math.*; | 25 import java.math.*; |
26 | 26 |
27 import com.oracle.truffle.api.*; | 27 import com.oracle.truffle.api.*; |
28 import com.oracle.truffle.api.dsl.*; | 28 import com.oracle.truffle.api.dsl.*; |
29 import com.oracle.truffle.api.dsl.internal.*; | |
29 import com.oracle.truffle.api.frame.*; | 30 import com.oracle.truffle.api.frame.*; |
30 import com.oracle.truffle.api.nodes.*; | 31 import com.oracle.truffle.api.nodes.*; |
31 import com.oracle.truffle.api.source.*; | 32 import com.oracle.truffle.api.source.*; |
32 | 33 |
33 public class TypeSystemTest { | 34 public class TypeSystemTest { |
34 | 35 |
35 @TypeSystem({int.class, long.class, double.class, boolean.class, BigInteger.class, String.class, CallTarget.class, BExtendsAbstract.class, CExtendsAbstract.class, Abstract.class, Interface.class, | 36 @TypeSystem({int.class, long.class, double.class, boolean.class, BigInteger.class, String.class, CallTarget.class, BExtendsAbstract.class, CExtendsAbstract.class, Abstract.class, Interface.class, |
36 Object[].class}) | 37 Object[].class}) |
38 @DSLOptions(useNewLayout = true) | |
37 static class SimpleTypes { | 39 static class SimpleTypes { |
38 | 40 |
39 static int intCheck; | 41 static int intCheck; |
40 static int intCast; | 42 static int intCast; |
41 | 43 |
42 @TypeCheck | 44 @TypeCheck |
43 public boolean isInteger(Object value) { | 45 public static boolean isInteger(Object value) { |
44 intCheck++; | 46 intCheck++; |
45 return value instanceof Integer; | 47 return value instanceof Integer; |
46 } | 48 } |
47 | 49 |
48 @TypeCast | 50 @TypeCast |
49 public int asInteger(Object value) { | 51 public static int asInteger(Object value) { |
50 intCast++; | 52 intCast++; |
51 return (int) value; | 53 return (int) value; |
52 } | 54 } |
53 | 55 |
54 @ImplicitCast | 56 @ImplicitCast |
55 public double castDouble(int value) { | 57 public static double castDouble(int value) { |
56 return value; | 58 return value; |
57 } | 59 } |
58 | 60 |
59 @ImplicitCast | 61 @ImplicitCast |
60 public long castLong(int value) { | 62 public static long castLong(int value) { |
61 return value; | 63 return value; |
62 } | 64 } |
63 | 65 |
64 @ImplicitCast | 66 @ImplicitCast |
65 public BigInteger castBigInteger(int value) { | 67 public static BigInteger castBigInteger(int value) { |
66 return BigInteger.valueOf(value); | 68 return BigInteger.valueOf(value); |
67 } | 69 } |
68 | 70 |
69 } | 71 } |
70 | 72 |
79 public ValueNode(SourceSection sourceSection) { | 81 public ValueNode(SourceSection sourceSection) { |
80 super(sourceSection); | 82 super(sourceSection); |
81 } | 83 } |
82 | 84 |
83 public int executeInt(VirtualFrame frame) throws UnexpectedResultException { | 85 public int executeInt(VirtualFrame frame) throws UnexpectedResultException { |
84 return SimpleTypesGen.SIMPLETYPES.expectInteger(execute(frame)); | 86 return SimpleTypesGen.expectInteger(execute(frame)); |
85 } | 87 } |
86 | 88 |
87 public long executeLong(VirtualFrame frame) throws UnexpectedResultException { | 89 public long executeLong(VirtualFrame frame) throws UnexpectedResultException { |
88 return SimpleTypesGen.SIMPLETYPES.expectLong(execute(frame)); | 90 return SimpleTypesGen.expectLong(execute(frame)); |
89 } | 91 } |
90 | 92 |
91 public String executeString(VirtualFrame frame) throws UnexpectedResultException { | 93 public String executeString(VirtualFrame frame) throws UnexpectedResultException { |
92 return SimpleTypesGen.SIMPLETYPES.expectString(execute(frame)); | 94 return SimpleTypesGen.expectString(execute(frame)); |
93 } | 95 } |
94 | 96 |
95 public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { | 97 public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { |
96 return SimpleTypesGen.SIMPLETYPES.expectBoolean(execute(frame)); | 98 return SimpleTypesGen.expectBoolean(execute(frame)); |
97 } | 99 } |
98 | 100 |
99 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { | 101 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { |
100 return SimpleTypesGen.SIMPLETYPES.expectObjectArray(execute(frame)); | 102 return SimpleTypesGen.expectObjectArray(execute(frame)); |
101 } | 103 } |
102 | 104 |
103 public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException { | 105 public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException { |
104 return SimpleTypesGen.SIMPLETYPES.expectBigInteger(execute(frame)); | 106 return SimpleTypesGen.expectBigInteger(execute(frame)); |
105 } | 107 } |
106 | 108 |
107 public BExtendsAbstract executeBExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { | 109 public BExtendsAbstract executeBExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { |
108 return SimpleTypesGen.SIMPLETYPES.expectBExtendsAbstract(execute(frame)); | 110 return SimpleTypesGen.expectBExtendsAbstract(execute(frame)); |
109 } | 111 } |
110 | 112 |
111 public CExtendsAbstract executeCExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { | 113 public CExtendsAbstract executeCExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { |
112 return SimpleTypesGen.SIMPLETYPES.expectCExtendsAbstract(execute(frame)); | 114 return SimpleTypesGen.expectCExtendsAbstract(execute(frame)); |
113 } | 115 } |
114 | 116 |
115 public Abstract executeAbstract(VirtualFrame frame) throws UnexpectedResultException { | 117 public Abstract executeAbstract(VirtualFrame frame) throws UnexpectedResultException { |
116 return SimpleTypesGen.SIMPLETYPES.expectAbstract(execute(frame)); | 118 return SimpleTypesGen.expectAbstract(execute(frame)); |
117 } | 119 } |
118 | 120 |
119 public double executeDouble(VirtualFrame frame) throws UnexpectedResultException { | 121 public double executeDouble(VirtualFrame frame) throws UnexpectedResultException { |
120 return SimpleTypesGen.SIMPLETYPES.expectDouble(execute(frame)); | 122 return SimpleTypesGen.expectDouble(execute(frame)); |
121 } | 123 } |
122 | 124 |
123 public Interface executeInterface(VirtualFrame frame) throws UnexpectedResultException { | 125 public Interface executeInterface(VirtualFrame frame) throws UnexpectedResultException { |
124 return SimpleTypesGen.SIMPLETYPES.expectInterface(execute(frame)); | 126 return SimpleTypesGen.expectInterface(execute(frame)); |
125 } | 127 } |
126 | 128 |
127 public Object execute(@SuppressWarnings("unused") VirtualFrame frame) { | 129 public Object execute(@SuppressWarnings("unused") VirtualFrame frame) { |
128 throw new UnsupportedOperationException(); | 130 throw new UnsupportedOperationException(); |
129 } | 131 } |