Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java @ 11195:4f52b08bd2f9
Truffle-DSL: Implemented specialization grouping for generic cases.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 01 Aug 2013 20:53:54 +0200 |
parents | 79041ab43660 |
children | d6a5ab791b0d |
comparison
equal
deleted
inserted
replaced
11194:14d5ff4683e0 | 11195:4f52b08bd2f9 |
---|---|
30 | 30 |
31 public class TypeSystemTest { | 31 public class TypeSystemTest { |
32 | 32 |
33 @TypeSystem({int.class, boolean.class, String.class, Str.class, CallTarget.class, Object[].class}) | 33 @TypeSystem({int.class, boolean.class, String.class, Str.class, CallTarget.class, Object[].class}) |
34 static class SimpleTypes { | 34 static class SimpleTypes { |
35 | |
36 static int intCheck; | |
37 static int intCast; | |
38 | |
39 @TypeCheck | |
40 public boolean isInteger(Object value) { | |
41 intCheck++; | |
42 return value instanceof Integer; | |
43 } | |
44 | |
45 @TypeCast | |
46 public int asInteger(Object value) { | |
47 intCast++; | |
48 return (int) value; | |
49 } | |
50 | |
35 } | 51 } |
36 | 52 |
37 @TypeSystemReference(SimpleTypes.class) | 53 @TypeSystemReference(SimpleTypes.class) |
38 public abstract static class ValueNode extends Node { | 54 public abstract static class ValueNode extends Node { |
39 | 55 |
124 public Object execute(VirtualFrame frame) { | 140 public Object execute(VirtualFrame frame) { |
125 invocationCount++; | 141 invocationCount++; |
126 return frame.getArguments(TestArguments.class).get(index); | 142 return frame.getArguments(TestArguments.class).get(index); |
127 } | 143 } |
128 | 144 |
145 @Override | |
146 public int executeInt(VirtualFrame frame) throws UnexpectedResultException { | |
147 // avoid casts for some tests | |
148 Object o = frame.getArguments(TestArguments.class).get(index); | |
149 if (o instanceof Integer) { | |
150 return (int) o; | |
151 } | |
152 throw new UnexpectedResultException(o); | |
153 } | |
154 | |
129 } | 155 } |
130 | 156 |
131 } | 157 } |