Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java @ 19283:08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 23 Jan 2015 02:55:23 +0100 |
parents | 2db61eddcb97 |
children | 259a416388d7 |
comparison
equal
deleted
inserted
replaced
19282:ae81dd154fb6 | 19283:08aa0372dad4 |
---|---|
34 | 34 |
35 @ImportGuards(Imports0.class) | 35 @ImportGuards(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") | 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 @ImportGuards(Imports0.class) |
47 static class ImportGuards1 extends ValueNode { | 47 static class ImportGuards1 extends ValueNode { |
48 | 48 |
49 @ExpectError("No compatible guard with method name 'nonStaticGuard' found.") | 49 @ExpectError("Error parsing expression 'nonStaticGuard(a)': The method nonStaticGuard is undefined for the enclosing scope.") |
50 @Specialization(guards = "nonStaticGuard") | 50 @Specialization(guards = "nonStaticGuard(a)") |
51 int f1(int a) { | 51 int f1(int a) { |
52 return a; | 52 return a; |
53 } | 53 } |
54 | 54 |
55 @ExpectError("No compatible guard with method name 'protectedGuard' found.") | 55 @ExpectError("Error parsing expression 'protectedGuard(a)': The method protectedGuard is undefined for the enclosing scope.") |
56 @Specialization(guards = "protectedGuard") | 56 @Specialization(guards = "protectedGuard(a)") |
57 int f2(int a) { | 57 int f2(int a) { |
58 return a; | 58 return a; |
59 } | 59 } |
60 | 60 |
61 @ExpectError("No compatible guard with method name 'packageGuard' found.") | 61 @ExpectError("Error parsing expression 'packageGuard(a)': The method packageGuard is undefined for the enclosing scope.") |
62 @Specialization(guards = "packageGuard") | 62 @Specialization(guards = "packageGuard(a)") |
63 int f3(int a) { | 63 int f3(int a) { |
64 return a; | 64 return a; |
65 } | 65 } |
66 | 66 |
67 @ExpectError("No compatible guard with method name 'privateGuard' found.") | 67 @ExpectError("Error parsing expression 'privateGuard(a)': The method privateGuard is undefined for the enclosing scope.") |
68 @Specialization(guards = "privateGuard") | 68 @Specialization(guards = "privateGuard(a)") |
69 int f4(int a) { | 69 int f4(int a) { |
70 return a; | 70 return a; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
157 | 157 |
158 static boolean staticGuard(int a) { | 158 static boolean staticGuard(int a) { |
159 return a == 1; | 159 return a == 1; |
160 } | 160 } |
161 | 161 |
162 @Specialization(guards = "staticGuard") | 162 @Specialization(guards = "staticGuard(a)") |
163 int f0(int a) { | 163 int f0(int a) { |
164 return a; | 164 return a; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |