annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.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 3c7d543d758d
children 62c43fcf5be2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.dsl.test;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26 import static org.junit.Assert.*;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import org.junit.*;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30 import com.oracle.truffle.api.dsl.*;
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
31 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.Guard1Factory;
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
32 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.Guard2Factory;
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardWithBaseClassFactory;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardWithBoxedPrimitiveFactory;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardWithObjectFactory;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.TestAbstractGuard1Factory;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.TestGuardResolve1Factory;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.TestGuardResolve2Factory;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.TestGuardResolve3Factory;
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
40 import com.oracle.truffle.api.dsl.test.TypeSystemTest.Abstract;
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
41 import com.oracle.truffle.api.dsl.test.TypeSystemTest.BExtendsAbstract;
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
42 import com.oracle.truffle.api.dsl.test.TypeSystemTest.CExtendsAbstract;
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
43 import com.oracle.truffle.api.dsl.test.TypeSystemTest.Interface;
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
44 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
45 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 @SuppressWarnings("unused")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 public class MethodGuardsTest {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50 private static final Object NULL = new Object();
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 @Test
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
53 public void testInvocations() {
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
54 TestRootNode<Guard1> root = createRoot(Guard1Factory.getInstance());
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
56 assertEquals(Integer.MAX_VALUE, executeWith(root, Integer.MAX_VALUE - 1));
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
57 assertEquals(1, Guard1.specializedInvocations);
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
58 assertEquals(0, Guard1.genericInvocations);
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
60 assertEquals(42, executeWith(root, Integer.MAX_VALUE));
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
61 assertEquals(1, Guard1.specializedInvocations);
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
62 assertEquals(1, Guard1.genericInvocations);
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
63 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
65 @NodeChild
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
66 static class Guard1 extends ValueNode {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
67
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
68 static int specializedInvocations = 0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
69 static int genericInvocations = 0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
70
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
71 boolean g(int value0) {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
72 return value0 != Integer.MAX_VALUE;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
73 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
74
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
75 @Specialization(guards = "g(value0)")
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
76 int f1(int value0) {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
77 specializedInvocations++;
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
78 return value0 + 1;
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
79 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
80
16760
9f38d222fa6c Truffle-DSL: renamed @Generic to @Fallback.
Christian Humer <christian.humer@gmail.com>
parents: 16756
diff changeset
81 @Fallback
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
82 int f2(Object value0) {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
83 genericInvocations++;
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
84 return 42;
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
85 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
86 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
87
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
88 @Test
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
89 public void testGuardSideEffect() {
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
90 TestRootNode<Guard2> root = createRoot(Guard2Factory.getInstance());
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
91
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
92 assertEquals(42, executeWith(root, NULL));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
93
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
94 Guard2.globalFlag = true;
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
95 assertEquals(41, executeWith(root, NULL));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
96
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
97 Guard2.globalFlag = false;
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
98 assertEquals(42, executeWith(root, NULL));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
99 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
100
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
101 @NodeChild
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
102 static class Guard2 extends ValueNode {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
103
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
104 static boolean globalFlag = false;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
105
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
106 static boolean globalFlagGuard() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
107 return globalFlag;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
108 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
109
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
110 @Specialization(guards = "globalFlagGuard()")
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
111 int f1(Object value0) {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
112 return 41;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
113 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
114
16760
9f38d222fa6c Truffle-DSL: renamed @Generic to @Fallback.
Christian Humer <christian.humer@gmail.com>
parents: 16756
diff changeset
115 @Fallback
18784
3c7d543d758d Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
116 int f2(Object value0) {
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
117 return 42; // the generic answer to all questions
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
118 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
119 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
120
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
121 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
122 public void testGuardWithBaseClass() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
123 TestRootNode<?> root = createRoot(GuardWithBaseClassFactory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
124
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
125 assertEquals(42, executeWith(root, new BExtendsAbstract()));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
126 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
127
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
128 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
129 public abstract static class GuardWithBaseClass extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
130
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
131 boolean baseGuard(Abstract base) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
132 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
133 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
134
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
135 @Specialization(guards = "baseGuard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
136 int doSpecialized(BExtendsAbstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
137 return 42;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
138 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
139 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
140
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
141 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
142 public abstract static class GuardWithBaseInterface extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
143
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
144 boolean baseGuard(CharSequence base) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
145 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
146 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
147
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
148 @Specialization(guards = "baseGuard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
149 int doSpecialized(String value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
150 return 42;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
151 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
152 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
153
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
154 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
155 public void testGuardWithPrimitive() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
156 TestRootNode<?> root = createRoot(GuardWithBoxedPrimitiveFactory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
157
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
158 assertEquals(42, executeWith(root, 42));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
159 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
160
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
161 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
162 public abstract static class GuardWithBoxedPrimitive extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
163
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
164 boolean baseGuard(Integer primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
165 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
166 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
167
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
168 @Specialization(guards = "baseGuard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
169 int doSpecialized(int value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
170 return value0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
171 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
172 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
173
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
174 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
175 public void testGuardWithObject() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
176 TestRootNode<?> root = createRoot(GuardWithObjectFactory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
177
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
178 assertEquals(42, executeWith(root, 42));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
179 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
180
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
181 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
182 public abstract static class GuardWithObject extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
183
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
184 boolean baseGuard(Object primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
185 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
186 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
187
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
188 @Specialization(guards = "baseGuard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
189 int doSpecialized(int value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
190 return value0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
191 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
192 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
193
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
194 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
195 public void testGuardResolve1() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
196 TestRootNode<?> root = createRoot(TestGuardResolve1Factory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
197
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
198 assertEquals(42, executeWith(root, 42));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
199 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
200
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
201 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
202 public abstract static class TestGuardResolve1 extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
203
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
204 boolean guard(Object primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
205 return false;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
206 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
207
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
208 boolean guard(int primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
209 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
210 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
211
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
212 @Specialization(guards = "guard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
213 int doSpecialized(int value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
214 return value0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
215 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
216 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
217
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
218 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
219 public void testGuardResolve2() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
220 TestRootNode<?> root = createRoot(TestGuardResolve2Factory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
221 assertEquals(42, executeWith(root, new BExtendsAbstract()));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
222 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
223
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
224 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
225 public abstract static class TestGuardResolve2 extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
226
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
227 boolean guard(Object primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
228 return false;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
229 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
230
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
231 boolean guard(Abstract primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
232 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
233 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
234
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
235 @Specialization(guards = "guard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
236 int doSpecialized(BExtendsAbstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
237 return 42;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
238 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
239 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
240
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
241 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
242 public void testGuardResolve3() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
243 TestRootNode<?> root = createRoot(TestGuardResolve3Factory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
244
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
245 assertEquals(42, executeWith(root, new BExtendsAbstract()));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
246 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
247
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
248 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
249 public abstract static class TestGuardResolve3 extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
250
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
251 boolean guard(Object primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
252 return false;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
253 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
254
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
255 boolean guard(Abstract primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
256 return false;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
257 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
258
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
259 boolean guard(BExtendsAbstract primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
260 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
261 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
262
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
263 @Specialization(guards = "guard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
264 int doSpecialized(BExtendsAbstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
265 return 42;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
266 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
267 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
268
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
269 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
270 public abstract static class TestGuardResolve4 extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
271
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
272 boolean guard(Abstract primitive) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
273 return false;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
274 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
275
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
276 @Specialization(guards = "guard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
277 int doSpecialized(BExtendsAbstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
278 return 42;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
279 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
280 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
281
16830
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
282 @NodeChildren({@NodeChild("a"), @NodeChild("b")})
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
283 abstract static class TestGuardResolve5 extends ValueNode {
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
284
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
285 @Specialization(guards = "guard(left, right)")
16830
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
286 int add(Interface left, Interface right) {
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
287 return 42;
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
288 }
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
289
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
290 boolean guard(Interface left, Object right) {
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
291 return true;
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
292 }
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
293 }
c3c07046a74b Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents: 16760
diff changeset
294
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
295 @Test
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
296 public void testAbstractGuard1() {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
297 TestRootNode<?> root = createRoot(TestAbstractGuard1Factory.getInstance());
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
298
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
299 assertEquals(BExtendsAbstract.INSTANCE, executeWith(root, BExtendsAbstract.INSTANCE));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
300 assertEquals(CExtendsAbstract.INSTANCE, executeWith(root, CExtendsAbstract.INSTANCE));
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
301 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
302
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
303 @NodeChild("expression")
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
304 public abstract static class TestAbstractGuard1 extends ValueNode {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
305
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
306 boolean guard(Abstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
307 return true;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
308 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
309
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
310 @Specialization(guards = "guard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
311 BExtendsAbstract do1(BExtendsAbstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
312 return value0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
313 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
314
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 18784
diff changeset
315 @Specialization(guards = "guard(value0)")
16756
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
316 CExtendsAbstract do2(CExtendsAbstract value0) {
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
317 return value0;
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
318 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
319 }
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
320
5148aab962af Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
321 }