Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/TypeSystemTest.java @ 9191:700f6a63763a
removed unused has_debug_info parameter
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 19 Apr 2013 10:48:36 +0200 |
parents | 6ef9fc7375c7 |
children | 5f7f0d3e3638 |
rev | line source |
---|---|
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.codegen.test; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
25 import com.oracle.truffle.api.*; |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 import com.oracle.truffle.api.codegen.*; |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
27 import com.oracle.truffle.api.codegen.test.BuiltinTest.Str; |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.frame.*; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.nodes.*; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 public class TypeSystemTest { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
33 @TypeSystem({int.class, Str.class}) |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 static class SimpleTypes { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 @TypeSystemReference(SimpleTypes.class) |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 abstract static class ValueNode extends Node { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
40 int executeInt(VirtualFrame frame) throws UnexpectedResultException { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
41 return SimpleTypesGen.SIMPLETYPES.expectInteger(execute(frame)); |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
44 Str executeStr(VirtualFrame frame) throws UnexpectedResultException { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
45 return SimpleTypesGen.SIMPLETYPES.expectStr(execute(frame)); |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
48 abstract Object execute(VirtualFrame frame); |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 @TypeSystemReference(SimpleTypes.class) |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
52 abstract static class ChildrenNode extends ValueNode { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
53 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
54 @Children protected ValueNode[] children; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
55 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
56 public ChildrenNode(ValueNode... children) { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
57 this.children = adoptChildren(children); |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
58 } |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
60 public ChildrenNode(ChildrenNode node) { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
61 this(node.children); |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
62 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
63 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
64 } |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
66 @TypeSystemReference(SimpleTypes.class) |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
67 static class TestRootNode<E extends ValueNode> extends RootNode { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
68 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
69 @Child private E node; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
70 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
71 public TestRootNode(E node) { |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 this.node = adoptChild(node); |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 @Override |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 public Object execute(VirtualFrame frame) { |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
77 return node.execute(frame); |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
78 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
79 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
80 public E getNode() { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
81 return node; |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 |
8596
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
85 static class TestArguments extends Arguments { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
86 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
87 private final Object[] values; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
88 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
89 public TestArguments(Object... values) { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
90 this.values = values; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
91 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
92 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
93 public Object[] getValues() { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
94 return values; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
95 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
96 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
97 public Object get(int index) { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
98 return values[index]; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
99 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
100 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
101 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
102 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
103 static class ArgumentNode extends ValueNode { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
104 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
105 final int index; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
106 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
107 public ArgumentNode(int index) { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
108 this.index = index; |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
109 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
110 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
111 @Override |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
112 Object execute(VirtualFrame frame) { |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
113 return ((TestArguments) frame.getArguments()).get(index); |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
114 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
115 |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
116 } |
6ef9fc7375c7
Updated codegen tests for guards and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
117 |
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 } |