Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InterfaceChildFieldTest.java @ 18266:ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 05 Nov 2014 21:55:55 +0100 |
parents | c88ab4f1f04a |
children | 65a160d9d259 |
rev | line source |
---|---|
17275
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
1 /* |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
4 * |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
8 * |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
14 * |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
18 * |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
21 * questions. |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
22 */ |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.test; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
24 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
25 import java.util.*; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
26 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
27 import org.junit.*; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
28 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.*; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.frame.*; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.nodes.*; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
32 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
33 /** |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
34 * Test child fields declared with interface types instead of {@link Node} subclasses. |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
35 */ |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
36 public class InterfaceChildFieldTest { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
37 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
38 @Test |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
39 public void testChild() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
40 TruffleRuntime runtime = Truffle.getRuntime(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
41 TestChildInterface leftChild = new TestLeafNode(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
42 TestChildInterface rightChild = new TestLeafNode(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
43 TestChildNode parent = new TestChildNode(leftChild, rightChild); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
44 TestRootNode rootNode = new TestRootNode(parent); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
45 CallTarget target = runtime.createCallTarget(rootNode); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
46 Iterator<Node> iterator = parent.getChildren().iterator(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
47 Assert.assertEquals(leftChild, iterator.next()); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
48 Assert.assertEquals(rightChild, iterator.next()); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
49 Assert.assertFalse(iterator.hasNext()); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
50 Object result = target.call(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
51 Assert.assertEquals(42, result); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
52 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
53 Assert.assertEquals(4, NodeUtil.countNodes(rootNode)); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
54 Assert.assertEquals(4, NodeUtil.countNodes(NodeUtil.cloneNode(rootNode))); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
55 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
56 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
57 @Test |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
58 public void testChildren() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
59 TruffleRuntime runtime = Truffle.getRuntime(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
60 TestChildInterface[] children = new TestChildInterface[5]; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
61 for (int i = 0; i < children.length; i++) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
62 children[i] = new TestLeafNode(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
63 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
64 TestChildrenNode parent = new TestChildrenNode(children); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
65 TestRootNode rootNode = new TestRootNode(parent); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
66 CallTarget target = runtime.createCallTarget(rootNode); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
67 Iterator<Node> iterator = parent.getChildren().iterator(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
68 for (int i = 0; i < children.length; i++) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
69 Assert.assertEquals(children[i], iterator.next()); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
70 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
71 Assert.assertFalse(iterator.hasNext()); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
72 Object result = target.call(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
73 Assert.assertEquals(105, result); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
74 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
75 Assert.assertEquals(2 + children.length, NodeUtil.countNodes(rootNode)); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
76 Assert.assertEquals(2 + children.length, NodeUtil.countNodes(NodeUtil.cloneNode(rootNode))); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
77 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
78 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
79 class TestRootNode extends RootNode { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
80 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
81 @Child private TestChildInterface child; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
82 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
83 public TestRootNode(TestChildInterface child) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
84 super(null); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
85 this.child = child; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
86 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
87 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
88 @Override |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
89 public Object execute(VirtualFrame frame) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
90 return child.executeIntf(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
91 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
92 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
93 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
94 interface TestChildInterface { |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17275
diff
changeset
|
95 int executeIntf(); |
17275
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
96 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
97 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
98 class TestLeafNode extends Node implements TestChildInterface { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
99 public TestLeafNode() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
100 super(null); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
101 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
102 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
103 public int executeIntf() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
104 return this.replace(new TestLeaf2Node()).executeIntf(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
105 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
106 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
107 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
108 class TestLeaf2Node extends Node implements TestChildInterface { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
109 public TestLeaf2Node() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
110 super(null); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
111 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
112 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
113 public int executeIntf() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
114 return 21; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
115 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
116 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
117 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
118 class TestChildNode extends Node implements TestChildInterface { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
119 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
120 @Child private TestChildInterface left; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
121 @Child private TestChildInterface right; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
122 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
123 public TestChildNode(TestChildInterface left, TestChildInterface right) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
124 super(null); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
125 this.left = left; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
126 this.right = right; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
127 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
128 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
129 @Override |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
130 public int executeIntf() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
131 return left.executeIntf() + right.executeIntf(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
132 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
133 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
134 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
135 class TestChildrenNode extends Node implements TestChildInterface { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
136 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
137 @Children private final TestChildInterface[] children; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
138 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
139 public TestChildrenNode(TestChildInterface[] children) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
140 super(null); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
141 this.children = children; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
142 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
143 |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
144 @Override |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
145 public int executeIntf() { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
146 int sum = 0; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
147 for (int i = 0; i < children.length; ++i) { |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
148 sum += children[i].executeIntf(); |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
149 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
150 return sum; |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
151 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
152 } |
846c059e3ecf
Truffle: allow interface types in child fields
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
153 } |