Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.java @ 21951:9c8c0937da41
Moving all sources into truffle subdirectory
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 17 Jun 2015 10:58:08 +0200 |
parents | graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.java@08aa0372dad4 |
children | dc83cc1f94f2 |
comparison
equal
deleted
inserted
replaced
21950:2a5011c7e641 | 21951:9c8c0937da41 |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.api.dsl.test; | |
24 | |
25 import com.oracle.truffle.api.dsl.*; | |
26 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; | |
27 | |
28 public class InsertBeforeTest { | |
29 | |
30 @NodeChild("a") | |
31 static class InsertBefore1Base extends ValueNode { | |
32 | |
33 @Specialization(guards = "a == 1") | |
34 int f1(int a) { | |
35 return a; | |
36 } | |
37 | |
38 @Specialization(guards = "a == 2") | |
39 int f3(int a) { | |
40 return a; | |
41 } | |
42 | |
43 } | |
44 | |
45 @NodeChild("a") | |
46 static class InsertBefore1T1 extends InsertBefore1Base { | |
47 | |
48 @Specialization | |
49 int f0(int a) { | |
50 return a; | |
51 } | |
52 | |
53 } | |
54 | |
55 @NodeChild("a") | |
56 static class InsertBefore1T2 extends InsertBefore1Base { | |
57 | |
58 @Specialization(guards = "a == 0", insertBefore = "f1") | |
59 int f0(int a) { | |
60 return a; | |
61 } | |
62 | |
63 } | |
64 | |
65 @NodeChild("a") | |
66 static class InsertBefore1T3 extends InsertBefore1Base { | |
67 | |
68 @Specialization(guards = "a == 0", insertBefore = "f3") | |
69 int f0(int a) { | |
70 return a; | |
71 } | |
72 | |
73 } | |
74 | |
75 @NodeChild("a") | |
76 @ExpectError({"Method f3(int) at annotation @Specialization is erroneous: Specialization is not reachable. It is shadowed by f0(int).", | |
77 "Method f1(int) at annotation @Specialization is erroneous: Specialization is not reachable. It is shadowed by f0(int)."}) | |
78 static class InsertBefore1T4 extends InsertBefore1Base { | |
79 | |
80 @Specialization(insertBefore = "f1") | |
81 int f0(int a) { | |
82 return a; | |
83 } | |
84 | |
85 } | |
86 | |
87 @NodeChild("a") | |
88 @ExpectError({"Method f3(int) at annotation @Specialization is erroneous: Specialization is not reachable. It is shadowed by f0(int)."}) | |
89 static class InsertBefore1T5 extends InsertBefore1Base { | |
90 | |
91 boolean g0(int a) { | |
92 return a == 0; | |
93 } | |
94 | |
95 @Specialization(insertBefore = "f3") | |
96 int f0(int a) { | |
97 return a; | |
98 } | |
99 | |
100 } | |
101 | |
102 @NodeChild("a") | |
103 static class InsertBefore1T6part1 extends InsertBefore1Base { | |
104 | |
105 boolean g0(int a) { | |
106 return a == 0; | |
107 } | |
108 | |
109 @Specialization(insertBefore = "f1", guards = "a == 0") | |
110 int f0(int a) { | |
111 return a; | |
112 } | |
113 | |
114 } | |
115 | |
116 @NodeChild("a") | |
117 static class InsertBefore1T6part2 extends InsertBefore1T6part1 { | |
118 | |
119 @Specialization(insertBefore = "f0", guards = "a == 3") | |
120 int f(int a) { | |
121 return a; | |
122 } | |
123 | |
124 } | |
125 | |
126 @NodeChild("a") | |
127 static class InsertBefore1Error1 extends InsertBefore1Base { | |
128 | |
129 @ExpectError("Specializations can only be inserted before specializations in superclasses.") | |
130 @Specialization(insertBefore = "f0") | |
131 int f0(int a) { | |
132 return a; | |
133 } | |
134 | |
135 } | |
136 | |
137 @NodeChild("a") | |
138 static class InsertBefore1Error2 extends InsertBefore1Base { | |
139 | |
140 @ExpectError("The referenced specialization 'asdf' could not be found.") | |
141 @Specialization(insertBefore = "asdf") | |
142 int f0(int a) { | |
143 return a; | |
144 } | |
145 | |
146 } | |
147 | |
148 } |