comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java @ 19285:259a416388d7

Truffle-DSL: rename @ImportGuards to @ImportStatic
author Christian Humer <christian.humer@gmail.com>
date Tue, 03 Feb 2015 15:07:03 +0100
parents 08aa0372dad4
children
comparison
equal deleted inserted replaced
19284:b339d723a06b 19285:259a416388d7
30 import com.oracle.truffle.api.dsl.test.ImportGuardsTestFactory.ImportGuards6Factory; 30 import com.oracle.truffle.api.dsl.test.ImportGuardsTestFactory.ImportGuards6Factory;
31 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; 31 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
32 32
33 public class ImportGuardsTest { 33 public class ImportGuardsTest {
34 34
35 @ImportGuards(Imports0.class) 35 @ImportStatic(Imports0.class)
36 @NodeChild("a") 36 @NodeChild("a")
37 static class ImportGuards0 extends ValueNode { 37 static class ImportGuards0 extends ValueNode {
38 38
39 @Specialization(guards = "staticGuard(a)") 39 @Specialization(guards = "staticGuard(a)")
40 int f0(int a) { 40 int f0(int a) {
41 return a; 41 return a;
42 } 42 }
43 } 43 }
44 44
45 @NodeChild("a") 45 @NodeChild("a")
46 @ImportGuards(Imports0.class) 46 @ImportStatic(Imports0.class)
47 static class ImportGuards1 extends ValueNode { 47 static class ImportGuards1 extends ValueNode {
48 48
49 @ExpectError("Error parsing expression 'nonStaticGuard(a)': The method nonStaticGuard is undefined for the enclosing scope.") 49 @ExpectError("Error parsing expression 'nonStaticGuard(a)': The method nonStaticGuard is undefined for the enclosing scope.")
50 @Specialization(guards = "nonStaticGuard(a)") 50 @Specialization(guards = "nonStaticGuard(a)")
51 int f1(int a) { 51 int f1(int a) {
95 95
96 } 96 }
97 97
98 @ExpectError("The specified import guard class 'com.oracle.truffle.api.dsl.test.ImportGuardsTest.Imports1' must be public.") 98 @ExpectError("The specified import guard class 'com.oracle.truffle.api.dsl.test.ImportGuardsTest.Imports1' must be public.")
99 @NodeChild("a") 99 @NodeChild("a")
100 @ImportGuards(Imports1.class) 100 @ImportStatic(Imports1.class)
101 static class ImportGuards2 extends ValueNode { 101 static class ImportGuards2 extends ValueNode {
102 102
103 int do1(int a) { 103 int do1(int a) {
104 return a; 104 return a;
105 } 105 }
109 109
110 } 110 }
111 111
112 @ExpectError("The specified import guard class 'com.oracle.truffle.api.dsl.test.ImportGuardsTest.Imports2' must be public.") 112 @ExpectError("The specified import guard class 'com.oracle.truffle.api.dsl.test.ImportGuardsTest.Imports2' must be public.")
113 @NodeChild("a") 113 @NodeChild("a")
114 @ImportGuards(Imports2.class) 114 @ImportStatic(Imports2.class)
115 static class ImportGuards3 extends ValueNode { 115 static class ImportGuards3 extends ValueNode {
116 116
117 int do1(int a) { 117 int do1(int a) {
118 return a; 118 return a;
119 } 119 }
120 } 120 }
121 121
122 @ExpectError("The specified import guard class 'boolean' is not a declared type.") 122 @ExpectError("The specified import guard class 'boolean' is not a declared type.")
123 @NodeChild("a") 123 @NodeChild("a")
124 @ImportGuards(boolean.class) 124 @ImportStatic(boolean.class)
125 static class ImportGuards4 extends ValueNode { 125 static class ImportGuards4 extends ValueNode {
126 126
127 int do1(int a) { 127 int do1(int a) {
128 return a; 128 return a;
129 } 129 }
133 133
134 } 134 }
135 135
136 @ExpectError("At least import guard classes must be specified.") 136 @ExpectError("At least import guard classes must be specified.")
137 @NodeChild("a") 137 @NodeChild("a")
138 @ImportGuards({}) 138 @ImportStatic({})
139 static class ImportGuards5 extends ValueNode { 139 static class ImportGuards5 extends ValueNode {
140 140
141 int do1(int a) { 141 int do1(int a) {
142 return a; 142 return a;
143 } 143 }
149 assertRuns(ImportGuards6Factory.getInstance(), // 149 assertRuns(ImportGuards6Factory.getInstance(), //
150 array(1, 1), // 150 array(1, 1), //
151 array(1, 1)); 151 array(1, 1));
152 } 152 }
153 153
154 @ImportGuards(Imports0.class) 154 @ImportStatic(Imports0.class)
155 @NodeChild("a") 155 @NodeChild("a")
156 static class ImportGuards6 extends ValueNode { 156 static class ImportGuards6 extends ValueNode {
157 157
158 static boolean staticGuard(int a) { 158 static boolean staticGuard(int a) {
159 return a == 1; 159 return a == 1;