Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFieldTest.java @ 12488:1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 18 Oct 2013 18:23:14 +0200 |
parents | dcaf879d4a7e |
children | 5a0c694ef735 |
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 |
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
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*; |
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
|
26 import static org.junit.Assert.*; |
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
|
27 |
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
|
28 import org.junit.*; |
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
|
29 |
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
|
30 import com.oracle.truffle.api.dsl.*; |
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
|
31 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.*; |
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
|
32 import com.oracle.truffle.api.dsl.test.NodeFieldTestFactory.TestContainerFactory.TestContainerContainerFieldFactory; |
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
|
33 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
|
34 |
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
|
35 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
|
36 |
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
|
37 @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
|
38 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
|
39 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
|
40 } |
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 @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
|
43 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
|
44 |
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 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
|
46 |
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 @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
|
48 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
|
49 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
|
50 } |
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 } |
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 @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
|
55 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
|
56 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
|
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 @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
|
60 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
|
61 |
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 @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
|
63 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
|
64 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
|
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 |
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 } |
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 @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
|
70 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
|
71 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
|
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 @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
|
75 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
|
76 |
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 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
|
78 |
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 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
|
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 @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
|
82 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
|
83 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
|
84 } |
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 } |
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 @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
|
89 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
|
90 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
|
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 @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
|
94 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
|
95 |
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 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
|
97 |
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 @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
|
99 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
|
100 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
|
101 } |
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 } |
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 @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
|
106 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
|
107 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
|
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 @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
|
111 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
|
112 |
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 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
|
114 |
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 @Specialization(order = 1, rewriteOn = RuntimeException.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
|
116 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
|
117 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
|
118 } |
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 @Specialization(order = 2) |
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 String returnField() { |
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
|
122 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
|
123 } |
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 } |
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 @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
|
127 public void testStringContainer() { |
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
|
128 assertEquals(42, createCallTarget(TestContainerContainerFieldFactory.create(42, "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
|
129 } |
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 @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
|
132 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
|
133 |
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 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
|
135 |
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 @NodeContainer(IntContainerNode.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 @NodeField(name = "anotherField", 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
|
140 abstract static class TestContainer { |
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 |
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 @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
|
143 static int containerField(int field, String anotherField) { |
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 return anotherField.equals("42") ? field : -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
|
145 } |
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
|
146 |
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 |
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
|
149 @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
|
150 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
|
151 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
|
152 } |
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
|
153 |
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
|
154 @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
|
155 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
|
156 |
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 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
|
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 @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
|
160 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
|
161 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
|
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 |
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 |
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
|
166 } |