Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java @ 16756:5148aab962af
Truffle-DSL: updated tests for the new generation layout.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:53:05 +0200 |
parents | 64dcb92ee75a |
children | c3c07046a74b |
comparison
equal
deleted
inserted
replaced
16755:bd28da642eea | 16756:5148aab962af |
---|---|
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.api.dsl.test; | 23 package com.oracle.truffle.api.dsl.test; |
24 | 24 |
25 import java.math.*; | |
26 | |
25 import com.oracle.truffle.api.*; | 27 import com.oracle.truffle.api.*; |
26 import com.oracle.truffle.api.dsl.*; | 28 import com.oracle.truffle.api.dsl.*; |
27 import com.oracle.truffle.api.frame.*; | 29 import com.oracle.truffle.api.frame.*; |
28 import com.oracle.truffle.api.nodes.*; | 30 import com.oracle.truffle.api.nodes.*; |
29 | 31 |
30 public class TypeSystemTest { | 32 public class TypeSystemTest { |
31 | 33 |
32 @TypeSystem({int.class, boolean.class, String.class, CallTarget.class, BExtendsAbstract.class, CExtendsAbstract.class, Abstract.class, Object[].class}) | 34 @TypeSystem({int.class, double.class, boolean.class, BigInteger.class, String.class, CallTarget.class, BExtendsAbstract.class, CExtendsAbstract.class, Abstract.class, Object[].class}) |
33 static class SimpleTypes { | 35 static class SimpleTypes { |
34 | 36 |
35 static int intCheck; | 37 static int intCheck; |
36 static int intCast; | 38 static int intCast; |
37 | 39 |
45 public int asInteger(Object value) { | 47 public int asInteger(Object value) { |
46 intCast++; | 48 intCast++; |
47 return (int) value; | 49 return (int) value; |
48 } | 50 } |
49 | 51 |
52 @ImplicitCast | |
53 public double castDouble(int value) { | |
54 return value; | |
55 } | |
56 | |
57 @ImplicitCast | |
58 public BigInteger castBigInteger(int value) { | |
59 return BigInteger.valueOf(value); | |
60 } | |
61 | |
50 } | 62 } |
51 | 63 |
52 @TypeSystemReference(SimpleTypes.class) | 64 @TypeSystemReference(SimpleTypes.class) |
53 public abstract static class ValueNode extends Node { | 65 public static class ValueNode extends Node { |
54 | 66 |
55 public ValueNode() { | 67 public ValueNode() { |
56 super(null); | 68 super(null); |
57 } | 69 } |
58 | 70 |
70 | 82 |
71 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { | 83 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { |
72 return SimpleTypesGen.SIMPLETYPES.expectObjectArray(execute(frame)); | 84 return SimpleTypesGen.SIMPLETYPES.expectObjectArray(execute(frame)); |
73 } | 85 } |
74 | 86 |
87 public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException { | |
88 return SimpleTypesGen.SIMPLETYPES.expectBigInteger(execute(frame)); | |
89 } | |
90 | |
75 public BExtendsAbstract executeBExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { | 91 public BExtendsAbstract executeBExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { |
76 return SimpleTypesGen.SIMPLETYPES.expectBExtendsAbstract(execute(frame)); | 92 return SimpleTypesGen.SIMPLETYPES.expectBExtendsAbstract(execute(frame)); |
77 } | 93 } |
78 | 94 |
79 public CExtendsAbstract executeCExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { | 95 public CExtendsAbstract executeCExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException { |
80 return SimpleTypesGen.SIMPLETYPES.expectCExtendsAbstract(execute(frame)); | 96 return SimpleTypesGen.SIMPLETYPES.expectCExtendsAbstract(execute(frame)); |
81 } | 97 } |
82 | 98 |
83 public abstract Object execute(VirtualFrame frame); | 99 public Abstract executeAbstract(VirtualFrame frame) throws UnexpectedResultException { |
100 return SimpleTypesGen.SIMPLETYPES.expectAbstract(execute(frame)); | |
101 } | |
102 | |
103 public double executeDouble(VirtualFrame frame) throws UnexpectedResultException { | |
104 return SimpleTypesGen.SIMPLETYPES.expectDouble(execute(frame)); | |
105 } | |
106 | |
107 public Object execute(@SuppressWarnings("unused") VirtualFrame frame) { | |
108 throw new UnsupportedOperationException(); | |
109 } | |
84 | 110 |
85 @Override | 111 @Override |
86 public ValueNode copy() { | 112 public ValueNode copy() { |
87 return (ValueNode) super.copy(); | 113 return (ValueNode) super.copy(); |
88 } | 114 } |