Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/TypeSystemTest.java @ 9223:5f7f0d3e3638
Updated codegen tests to new codegen API.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sat, 20 Apr 2013 12:17:47 +0200 |
parents | 6ef9fc7375c7 |
children | 8e3a1635cc9e |
comparison
equal
deleted
inserted
replaced
9222:aa9ffb3a715e | 9223:5f7f0d3e3638 |
---|---|
28 import com.oracle.truffle.api.frame.*; | 28 import com.oracle.truffle.api.frame.*; |
29 import com.oracle.truffle.api.nodes.*; | 29 import com.oracle.truffle.api.nodes.*; |
30 | 30 |
31 public class TypeSystemTest { | 31 public class TypeSystemTest { |
32 | 32 |
33 @TypeSystem({int.class, Str.class}) | 33 @TypeSystem({int.class, Str.class, CallTarget.class, Object[].class}) |
34 static class SimpleTypes { | 34 static class SimpleTypes { |
35 } | 35 } |
36 | 36 |
37 @TypeSystemReference(SimpleTypes.class) | 37 @TypeSystemReference(SimpleTypes.class) |
38 abstract static class ValueNode extends Node { | 38 public abstract static class ValueNode extends Node { |
39 | 39 |
40 int executeInt(VirtualFrame frame) throws UnexpectedResultException { | 40 public int executeInt(VirtualFrame frame) throws UnexpectedResultException { |
41 return SimpleTypesGen.SIMPLETYPES.expectInteger(execute(frame)); | 41 return SimpleTypesGen.SIMPLETYPES.expectInteger(execute(frame)); |
42 } | 42 } |
43 | 43 |
44 Str executeStr(VirtualFrame frame) throws UnexpectedResultException { | 44 public Str executeStr(VirtualFrame frame) throws UnexpectedResultException { |
45 return SimpleTypesGen.SIMPLETYPES.expectStr(execute(frame)); | 45 return SimpleTypesGen.SIMPLETYPES.expectStr(execute(frame)); |
46 } | 46 } |
47 | 47 |
48 abstract Object execute(VirtualFrame frame); | 48 public Object[] executeIntArray(VirtualFrame frame) throws UnexpectedResultException { |
49 return SimpleTypesGen.SIMPLETYPES.expectObjectArray(execute(frame)); | |
50 } | |
51 | |
52 public abstract Object execute(VirtualFrame frame); | |
53 | |
54 @Override | |
55 public ValueNode copy() { | |
56 return (ValueNode) super.copy(); | |
57 } | |
49 } | 58 } |
50 | 59 |
51 @TypeSystemReference(SimpleTypes.class) | 60 @NodeChild(value = "children", type = ValueNode[].class) |
52 abstract static class ChildrenNode extends ValueNode { | 61 public abstract static class ChildrenNode extends ValueNode { |
53 | |
54 @Children protected ValueNode[] children; | |
55 | |
56 public ChildrenNode(ValueNode... children) { | |
57 this.children = adoptChildren(children); | |
58 } | |
59 | |
60 public ChildrenNode(ChildrenNode node) { | |
61 this(node.children); | |
62 } | |
63 | 62 |
64 } | 63 } |
65 | 64 |
66 @TypeSystemReference(SimpleTypes.class) | 65 @TypeSystemReference(SimpleTypes.class) |
67 static class TestRootNode<E extends ValueNode> extends RootNode { | 66 public static class TestRootNode<E extends ValueNode> extends RootNode { |
68 | 67 |
69 @Child private E node; | 68 @Child private E node; |
70 | 69 |
71 public TestRootNode(E node) { | 70 public TestRootNode(E node) { |
72 this.node = adoptChild(node); | 71 this.node = adoptChild(node); |
80 public E getNode() { | 79 public E getNode() { |
81 return node; | 80 return node; |
82 } | 81 } |
83 } | 82 } |
84 | 83 |
85 static class TestArguments extends Arguments { | 84 public static class TestArguments extends Arguments { |
86 | 85 |
87 private final Object[] values; | 86 private final Object[] values; |
88 | 87 |
89 public TestArguments(Object... values) { | 88 public TestArguments(Object... values) { |
90 this.values = values; | 89 this.values = values; |
98 return values[index]; | 97 return values[index]; |
99 } | 98 } |
100 | 99 |
101 } | 100 } |
102 | 101 |
103 static class ArgumentNode extends ValueNode { | 102 public static class ArgumentNode extends ValueNode { |
104 | 103 |
105 final int index; | 104 final int index; |
106 | 105 |
107 public ArgumentNode(int index) { | 106 public ArgumentNode(int index) { |
108 this.index = index; | 107 this.index = index; |
109 } | 108 } |
110 | 109 |
111 @Override | 110 @Override |
112 Object execute(VirtualFrame frame) { | 111 public Object execute(VirtualFrame frame) { |
113 return ((TestArguments) frame.getArguments()).get(index); | 112 return ((TestArguments) frame.getArguments()).get(index); |
114 } | 113 } |
115 | 114 |
116 } | 115 } |
117 | 116 |