Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java @ 21373:e5df47e0efb8
Bugfix: ForeignCallNode needs bci
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 14 May 2015 15:57:55 -0700 |
parents | 08aa0372dad4 |
children |
rev | line source |
---|---|
16851
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import org.junit.*; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.dsl.*; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArguments0Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArguments1Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsDouble0Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsDouble1Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsDouble2Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsDouble3Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.MethodGuardsWithArgumentsTestFactory.MArgumentsSingle2Factory; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 public class MethodGuardsWithArgumentsTest { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 public void testMArguments0() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 TestRootNode<MArguments0> root = createRoot(MArguments0Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 Assert.assertEquals(42, executeWith(root)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 abstract static class MArguments0 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 @Specialization(guards = "guard()") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 int do1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 return 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 public void testMArguments1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 TestRootNode<MArguments1> root = createRoot(MArguments1Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 Assert.assertEquals(42, executeWith(root)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 abstract static class MArguments1 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
72 @Specialization(guards = "guard()") |
16851
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 int do1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 return 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 public void testMArgumentsSingle0() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 TestRootNode<MArguments1> root = createRoot(MArguments1Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 Assert.assertEquals(42, executeWith(root, 42)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 @NodeChild("a") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 abstract static class MArgumentsSingle0 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 @Specialization(guards = "guard()") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 int do1(int a) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 public void testMArgumentsSingle1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 TestRootNode<MArguments1> root = createRoot(MArguments1Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 Assert.assertEquals(42, executeWith(root, 42)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 @NodeChild("a") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 abstract static class MArgumentsSingle1 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 static boolean guard(int a) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 return a == 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 @Specialization(guards = "guard(a)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 int do1(int a) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
117 public void testMArgumentsSingle2() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 TestRootNode<MArgumentsSingle2> root = createRoot(MArgumentsSingle2Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 Assert.assertEquals(42, executeWith(root, 42)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 @NodeChild("a") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 abstract static class MArgumentsSingle2 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
125 static boolean guard(int a1, int a2) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
126 return a1 == 42 && a2 == 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
127 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
128 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
129 @Specialization(guards = "guard(a,a)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 int do1(int a) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
131 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
135 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 public void testMArgumentsDouble0() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
137 TestRootNode<MArgumentsDouble0> root = createRoot(MArgumentsDouble0Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
138 Assert.assertEquals(42, executeWith(root, 42, 0)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
139 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
140 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
141 @NodeChild("a") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
142 abstract static class MArgumentsDouble0 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
143 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
144 static boolean guard(int a1, Object a2) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
145 return a1 == 42 && a2.equals(new Integer(42)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
146 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
147 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
148 @Specialization(guards = "guard(a,a)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
149 int do1(int a) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
150 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
151 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
152 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
153 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
154 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
155 public void testMArgumentsDouble1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
156 TestRootNode<MArgumentsDouble1> root = createRoot(MArgumentsDouble1Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
157 Assert.assertEquals(42, executeWith(root, 42, 41)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
158 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
159 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
160 @NodeChildren({@NodeChild("a"), @NodeChild("b")}) |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
161 abstract static class MArgumentsDouble1 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
162 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
163 static boolean guard(int a1, double a2) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
164 return a1 == 42 && a2 == 41; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
165 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
166 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
167 @Specialization(guards = "guard(a,b)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
168 int do1(int a, @SuppressWarnings("unused") double b) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
169 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 public void testMArgumentsDouble2() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 TestRootNode<MArgumentsDouble2> root = createRoot(MArgumentsDouble2Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 Assert.assertEquals(42, executeWith(root, 42, 41.0)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
179 @NodeChildren({@NodeChild("a"), @NodeChild("b")}) |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
180 abstract static class MArgumentsDouble2 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
181 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
182 static boolean guard(double a1, int a2) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
183 return a1 == 41 && a2 == 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
184 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 @Specialization(guards = "guard(b,a)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
187 int do1(int a, @SuppressWarnings("unused") double b) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
188 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
189 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
192 @Test |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 public void testMArgumentsDouble3() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
194 TestRootNode<MArgumentsDouble3> root = createRoot(MArgumentsDouble3Factory.getInstance()); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
195 Assert.assertEquals(42, executeWith(root, 42, 41.0)); |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
198 @NodeChildren({@NodeChild("a"), @NodeChild("b")}) |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 abstract static class MArgumentsDouble3 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
201 static boolean guard(Object a1, double a2) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
202 return new Double(41.0).equals(a1) && a2 == 41; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
203 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
204 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
205 @Specialization(guards = "guard(b,b)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
206 int do1(int a, @SuppressWarnings("unused") double b) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
207 return a; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
208 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
209 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
210 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
211 abstract static class MArgumentsError0 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
212 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
213 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
214 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
215 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
216 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
217 @ExpectError("Error parsing expression 'guard(': -- line 1 col 7: \")\" expected%") |
16851
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
218 @Specialization(guards = "guard(") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
219 int do1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
220 return 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
221 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
222 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
223 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
224 abstract static class MArgumentsError1 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
225 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
226 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
227 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
228 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
229 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
230 @ExpectError("Error parsing expression 'guard)': -- line 1 col 6: EOF expected%") |
16851
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
231 @Specialization(guards = "guard)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
232 int do1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
233 return 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
234 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
235 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
236 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
237 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
238 abstract static class MArgumentsError2 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
239 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
240 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
241 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
242 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
243 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
244 @ExpectError("Error parsing expression 'guard(a)': a cannot be resolved.") |
16851
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
245 @Specialization(guards = "guard(a)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
246 int do1() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
247 return 42; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
248 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
249 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
250 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
251 @NodeChild("b") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
252 abstract static class MArgumentsError3 extends ValueNode { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
253 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
254 static boolean guard() { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
255 return true; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
256 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
257 |
19283
08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
258 @ExpectError("Error parsing expression 'guard(a)': a cannot be resolved.") |
16851
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
259 @Specialization(guards = "guard(a)") |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
260 int do1(int b) { |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
261 return b; |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
262 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
263 } |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
264 |
2db61eddcb97
Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
265 } |