annotate graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/TestHelper.java @ 9135:c5fa76a20868

Remove unused field.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 16 Apr 2013 13:21:22 +0200
parents 6ef9fc7375c7
children 5f7f0d3e3638
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8596
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.codegen.test;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import java.util.*;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import com.oracle.truffle.api.*;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import com.oracle.truffle.api.codegen.*;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 import com.oracle.truffle.api.codegen.test.TypeSystemTest.*;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31 /**
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32 * Utility class to provide some test helper functions.
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 */
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 class TestHelper {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 private static ArgumentNode[] arguments(int count) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 ArgumentNode[] nodes = new ArgumentNode[count];
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 for (int i = 0; i < nodes.length; i++) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 nodes[i] = new ArgumentNode(i);
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 return nodes;
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 static <E extends ValueNode> TestRootNode<E> create(NodeFactory<E> factory, Object... constants) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45 ArgumentNode[] argumentNodes = arguments(factory.getExecutionSignature().size());
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 List<Object> argumentList = new ArrayList<>();
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 argumentList.addAll(Arrays.asList(constants));
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49 if (ChildrenNode.class.isAssignableFrom(factory.getNodeClass())) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50 argumentList.add(argumentNodes);
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 } else {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 argumentList.addAll(Arrays.asList(argumentNodes));
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54 return new TestRootNode<>(factory.createNode(argumentList.toArray(new Object[argumentList.size()])));
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 static <E> Object executeWith(TestRootNode<? extends ValueNode> node, Object... values) {
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 return Truffle.getRuntime().createCallTarget(node).call(new TestArguments(values));
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 }
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60
6ef9fc7375c7 Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
61 }