Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java @ 17190:9ff6aee72c8b
Change class hierarchy of ValueProxy that should only be transparent during graph building
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 23 Sep 2014 19:22:01 -0700 |
parents | 64dcb92ee75a |
children | a665483c3881 |
rev | line source |
---|---|
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import org.junit.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.dsl.*; |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
29 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.DoubleEvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
30 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.EvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
31 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedGenerationFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
32 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs0Factory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs1Factory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
34 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs2Factory; |
13272
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs3Factory; |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs4Factory; |
13273
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs5Factory; |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.UseDoubleEvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
39 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.UseEvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
40 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
41 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
42 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
43 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 import com.oracle.truffle.api.frame.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 import com.oracle.truffle.api.nodes.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 public class ExecuteEvaluatedTest { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 @Test |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 public void testSingleEvaluated() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 ArgumentNode arg0 = new ArgumentNode(0); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 CallTarget callTarget = TestHelper.createCallTarget(UseEvaluatedNodeFactory.create(arg0, EvaluatedNodeFactory.create(null))); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13273
diff
changeset
|
54 Assert.assertEquals(43, callTarget.call(new Object[]{42})); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 Assert.assertEquals(1, arg0.getInvocationCount()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 @NodeChild("exp") |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 abstract static class EvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 int doExecuteWith(int exp) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 return exp + 1; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 public abstract Object executeEvaluated(VirtualFrame frame, Object targetValue); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 public abstract int executeIntEvaluated(VirtualFrame frame, Object targetValue) throws UnexpectedResultException; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 @NodeChildren({@NodeChild("exp0"), @NodeChild(value = "exp1", type = EvaluatedNode.class, executeWith = "exp0")}) |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 abstract static class UseEvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 int call(int exp0, int exp1) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 Assert.assertEquals(exp0 + 1, exp1); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 return exp1; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 @Test |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 public void testDoubleEvaluated() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 ArgumentNode arg0 = new ArgumentNode(0); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 ArgumentNode arg1 = new ArgumentNode(1); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 CallTarget callTarget = TestHelper.createCallTarget(UseDoubleEvaluatedNodeFactory.create(arg0, arg1, DoubleEvaluatedNodeFactory.create(null, null))); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13273
diff
changeset
|
87 Assert.assertEquals(85, callTarget.call(new Object[]{42, 43})); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 Assert.assertEquals(1, arg0.getInvocationCount()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 Assert.assertEquals(1, arg1.getInvocationCount()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 @NodeChildren({@NodeChild("exp0"), @NodeChild("exp1")}) |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 abstract static class DoubleEvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 int doExecuteWith(int exp0, int exp1) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 return exp0 + exp1; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 public abstract Object executeEvaluated(VirtualFrame frame, Object exp0, Object exp1); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 public abstract int executeIntEvaluated(VirtualFrame frame, Object exp0, Object exp1) throws UnexpectedResultException; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 @NodeChildren({@NodeChild("exp0"), @NodeChild("exp1"), @NodeChild(value = "exp2", type = DoubleEvaluatedNode.class, executeWith = {"exp0", "exp1"})}) |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 abstract static class UseDoubleEvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 int call(int exp0, int exp1, int exp2) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 Assert.assertEquals(exp0 + exp1, exp2); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 return exp2; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 |
11445
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
115 @Test |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
116 public void testEvaluatedGeneration() throws UnexpectedResultException { |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
117 TestRootNode<TestEvaluatedGeneration> root = TestHelper.createRoot(TestEvaluatedGenerationFactory.getInstance()); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
118 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
119 Assert.assertEquals(42, root.getNode().executeEvaluated1(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
120 Assert.assertEquals(42, root.getNode().executeEvaluated2(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
121 Assert.assertEquals(42, root.getNode().executeEvaluated3(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
122 Assert.assertEquals(42, root.getNode().executeEvaluated4(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
123 } |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
124 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
125 @NodeChildren({@NodeChild("exp0")}) |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
126 abstract static class TestEvaluatedGeneration extends ValueNode { |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
127 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
128 public abstract Object executeEvaluated1(VirtualFrame frame, Object value); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
129 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
130 public abstract Object executeEvaluated2(VirtualFrame frame, int value); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
131 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
132 public abstract int executeEvaluated3(VirtualFrame frame, Object value) throws UnexpectedResultException; |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
133 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
134 public abstract int executeEvaluated4(VirtualFrame frame, int value) throws UnexpectedResultException; |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
135 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
136 @Specialization |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
137 int call(int exp0) { |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
138 return exp0; |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
139 } |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
140 } |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
141 |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
142 @Test |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
143 public void test0VarArgs1() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
144 TestRootNode<TestEvaluatedVarArgs0> root = TestHelper.createRoot(TestEvaluatedVarArgs0Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
145 Assert.assertEquals(42, root.getNode().execute1(null)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
146 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
147 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
148 abstract static class TestEvaluatedVarArgs0 extends ChildrenNode { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
149 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
150 public abstract Object execute1(VirtualFrame frame, Object... value); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
151 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
152 @Specialization |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
153 int call() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
154 return 42; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
155 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
156 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
157 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
158 @Test |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
159 public void test1VarArgs1() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
160 TestRootNode<TestEvaluatedVarArgs1> root = TestHelper.createRoot(TestEvaluatedVarArgs1Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
161 Assert.assertEquals(42, root.getNode().execute1(null, 42)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
162 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
163 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
164 @Test(expected = AssertionError.class) |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
165 public void test1VarArgs2() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
166 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
167 Assert.assertEquals(-1, root.getNode().execute1(null)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
168 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
169 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
170 abstract static class TestEvaluatedVarArgs1 extends ChildrenNode { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
171 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
172 public abstract Object execute1(VirtualFrame frame, Object... value); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
173 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
174 @Specialization |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
175 int call(int exp0) { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
176 return exp0; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
177 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
178 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
179 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
180 @Test |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
181 public void test2VarArgs1() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
182 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
183 Assert.assertEquals(42, root.getNode().execute1(null, 21, 21)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
184 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
185 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
186 @Test(expected = AssertionError.class) |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
187 public void test2VarArgs2() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
188 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
189 Assert.assertEquals(-1, root.getNode().execute1(null, 42)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
190 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
191 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
192 @Test(expected = AssertionError.class) |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
193 public void test2VarArgs3() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
194 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
195 Assert.assertEquals(-1, root.getNode().execute1(null)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
196 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
197 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
198 abstract static class TestEvaluatedVarArgs2 extends ChildrenNode { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
199 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
200 public abstract Object execute1(VirtualFrame frame, Object... value); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
201 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
202 @Specialization |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
203 int call(int exp0, int exp1) { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
204 return exp0 + exp1; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
205 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
206 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
207 |
13272
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
208 @Test |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
209 public void test3VarArgs1() { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
210 TestRootNode<TestEvaluatedVarArgs3> root = TestHelper.createRoot(TestEvaluatedVarArgs3Factory.getInstance()); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
211 Assert.assertEquals(42, root.getNode().execute1(null, 42)); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
212 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
213 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
214 @NodeChild |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
215 abstract static class TestEvaluatedVarArgs3 extends ValueNode { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
216 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
217 public abstract Object execute1(VirtualFrame frame, Object... value); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
218 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
219 @Specialization |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
220 int call(int exp0) { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
221 return exp0; |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
222 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
223 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
224 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
225 @Test |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
226 public void test4VarArgs1() { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
227 TestRootNode<TestEvaluatedVarArgs4> root = TestHelper.createRoot(TestEvaluatedVarArgs4Factory.getInstance()); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
228 Assert.assertEquals(42, root.getNode().execute1(null, 21, 21)); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
229 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
230 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
231 @NodeChildren({@NodeChild, @NodeChild}) |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
232 abstract static class TestEvaluatedVarArgs4 extends ValueNode { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
233 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
234 public abstract Object execute1(VirtualFrame frame, Object... value); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
235 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
236 @Specialization |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
237 int call(int exp0, int exp1) { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
238 return exp0 + exp1; |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
239 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
240 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
241 |
13273
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
242 @Test |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
243 public void test5VarArgs1() { |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
244 TestRootNode<TestEvaluatedVarArgs5> root = TestHelper.createRoot(TestEvaluatedVarArgs5Factory.getInstance()); |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
245 Assert.assertEquals(42, root.getNode().execute1(null)); |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
246 } |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
247 |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
248 abstract static class TestEvaluatedVarArgs5 extends ValueNode { |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
249 |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
250 public abstract Object execute1(VirtualFrame frame, Object... value); |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
251 |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
252 @Specialization |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
253 int call() { |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
254 return 42; |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
255 } |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
256 } |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
257 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
258 } |