Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/TypeSystemTest.java @ 8466:c7a2a937233f
added @Alias annotation for accessing fields and methods otherwise inaccessible due to Java access rules
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 Mar 2013 22:35:42 +0100 |
parents | aad7e9f4f71c |
children | a80bf36c6a1e |
rev | line source |
---|---|
8249
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
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 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import com.oracle.truffle.api.codegen.*; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 import com.oracle.truffle.api.codegen.test.RuntimeStringTest.RuntimeString; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.frame.*; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.nodes.*; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 public class TypeSystemTest { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 @TypeSystem({int.class, RuntimeString.class}) |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 static class SimpleTypes { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 } |
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 @TypeSystemReference(SimpleTypes.class) |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 abstract static class ValueNode extends Node { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 int executeInt() throws UnexpectedResultException { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 return SimpleTypesGen.SIMPLETYPES.expectInteger(execute()); |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 } |
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 RuntimeString executeString() { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 return new RuntimeString(execute().toString()); |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 } |
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 @SuppressWarnings("static-method") |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 final long executeSpecial() { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 return 42L; |
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 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 abstract Object execute(); |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 @TypeSystemReference(SimpleTypes.class) |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 static class TestRootNode extends RootNode { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 @Child private ValueNode node; |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 public TestRootNode(ValueNode node) { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 this.node = adoptChild(node); |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 @Override |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 public Object execute(VirtualFrame frame) { |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 return node.execute(); |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 } |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 |
aad7e9f4f71c
A few additions to codegen tests.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 } |