annotate graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/ExecuteEvaluatedTest.java @ 9229:76a6e7907b67

Minor cleanup.
author Christian Humer <christian.humer@gmail.com>
date Mon, 22 Apr 2013 16:39:47 +0200
parents 5f7f0d3e3638
children 8e3a1635cc9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.codegen.test;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import com.oracle.truffle.api.*;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26 import com.oracle.truffle.api.codegen.*;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import com.oracle.truffle.api.codegen.test.TypeSystemTest.ValueNode;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import com.oracle.truffle.api.frame.*;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30 public class ExecuteEvaluatedTest {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32 /* Represents target[element] */
9229
76a6e7907b67 Minor cleanup.
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
33 @NodeChildren({@NodeChild("target"), @NodeChild("element")})
76a6e7907b67 Minor cleanup.
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
34 abstract static class ReadElementNode extends ValueNode {
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 @Specialization
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 int getInt(Object[] target, int element) {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 return (int) target[element];
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 public abstract Object executeWith(VirtualFrame frame, Object targetValue);
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 /* Represents target[element]() */
9229
76a6e7907b67 Minor cleanup.
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
45 @NodeChildren({@NodeChild("target"), @NodeChild(value = "element", type = ReadElementNode.class, executeWith = "target")})
76a6e7907b67 Minor cleanup.
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
46 abstract static class ElementCallNode extends ValueNode {
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 @Specialization
9229
76a6e7907b67 Minor cleanup.
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
49 Object call(Object receiver, Object callTarget) {
76a6e7907b67 Minor cleanup.
Christian Humer <christian.humer@gmail.com>
parents: 9223
diff changeset
50 return ((CallTarget) callTarget).call(new TestArguments(receiver));
9223
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 public static class TestArguments extends Arguments {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 private final Object receiver;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 public TestArguments(Object receiver) {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60 this.receiver = receiver;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
61 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
62
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
63 public Object getReceiver() {
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64 return receiver;
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
65 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
66
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
67 }
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
68
5f7f0d3e3638 Updated codegen tests to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
69 }