Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFieldTest.java @ 22548:6b76a24fffbd default tip
Use all variables: a, b, u,v and x, y
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Thu, 14 Jan 2016 14:20:57 +0100 |
parents | 5309cc9668e3 |
children |
rev | line source |
---|---|
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
26 import static org.junit.Assert.assertEquals; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
27 |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
28 import org.junit.Test; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
29 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
30 import com.oracle.truffle.api.dsl.NodeField; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
31 import com.oracle.truffle.api.dsl.NodeFields; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
32 import com.oracle.truffle.api.dsl.Specialization; |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.IntFieldNoGetterTestNodeFactory; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
34 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.IntFieldTestNodeFactory; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.MultipleFieldsTestNodeFactory; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.ObjectContainerNodeFactory; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.RewriteTestNodeFactory; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.StringFieldTestNodeFactory; |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
39 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.TestContainerFactory; |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 public class NodeFieldTest { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 @Test |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 public void testIntField() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 assertEquals(42, createCallTarget(IntFieldTestNodeFactory.create(42)).call()); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 @NodeField(name = "field", type = int.class) |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 abstract static class IntFieldTestNode extends ValueNode { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 public abstract int getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 @Specialization |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 int intField() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 return getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 @Test |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 public void testIntFieldNoGetter() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 assertEquals(42, createCallTarget(IntFieldNoGetterTestNodeFactory.create(42)).call()); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 @NodeField(name = "field", type = int.class) |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 abstract static class IntFieldNoGetterTestNode extends ValueNode { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 @Specialization |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 int intField(int field) { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 return field; |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 @Test |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 public void testMultipleFields() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 assertEquals(42, createCallTarget(MultipleFieldsTestNodeFactory.create(21, 21)).call()); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 @NodeFields({@NodeField(name = "field0", type = int.class), @NodeField(name = "field1", type = int.class)}) |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 abstract static class MultipleFieldsTestNode extends ValueNode { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 public abstract int getField0(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 public abstract int getField1(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 @Specialization |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 int intField() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 return getField0() + getField1(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 @Test |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 public void testStringField() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 assertEquals("42", createCallTarget(StringFieldTestNodeFactory.create("42")).call()); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 @NodeField(name = "field", type = String.class) |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 abstract static class StringFieldTestNode extends ValueNode { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 public abstract String getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 @Specialization |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 String stringField() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 return getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 @Test |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 public void testRewrite() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 assertEquals("42", createCallTarget(RewriteTestNodeFactory.create("42")).call()); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
117 @NodeField(name = "field", type = String.class) |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 abstract static class RewriteTestNode extends ValueNode { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 public abstract String getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
13528
diff
changeset
|
122 @Specialization(rewriteOn = RuntimeException.class) |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 String alwaysRewrite() { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 throw new RuntimeException(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
125 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
126 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
13528
diff
changeset
|
127 @Specialization(contains = "alwaysRewrite") |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
16756
diff
changeset
|
128 Object returnField() { |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
129 return getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
131 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 @Test |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 public void testStringContainer() { |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
135 assertEquals(42, createCallTarget(TestContainerFactory.create("42")).call()); |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
137 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
138 @NodeField(name = "field", type = int.class) |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
139 abstract static class IntContainerNode extends ValueNode { |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
140 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
141 public abstract int getField(); |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
142 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
143 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
144 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
145 @NodeField(name = "anotherField", type = String.class) |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
146 abstract static class TestContainer extends ValueNode { |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
147 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
148 @Specialization |
13528
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
149 int containerField(String field) { |
5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
Christian Humer <christian.humer@gmail.com>
parents:
11509
diff
changeset
|
150 return field.equals("42") ? 42 : -1; |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
151 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
152 |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
153 } |
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
154 |
11509
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
155 @Test |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
156 public void testObjectContainer() { |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
157 assertEquals("42", createCallTarget(ObjectContainerNodeFactory.create("42")).call()); |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
158 } |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
159 |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
160 @NodeField(name = "object", type = Object.class) |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
161 abstract static class ObjectContainerNode extends ValueNode { |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
162 |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
163 public abstract Object getObject(); |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
164 |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
165 @Specialization |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
166 Object containerField() { |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
167 return getObject(); |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
168 } |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
169 |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
170 } |
dcaf879d4a7e
Truffle-DSL: fixed a compiler warning for fields of type java.lang.Object. (GRAAL-434 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
11187
diff
changeset
|
171 |
11187
7a8835ec5e7d
Truffle-DSL: Added new @NodeField and @NodeFields annotation. Which can be used to avoid the cumbersome definition of copy constructors.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 } |