comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java @ 15167:258e3e0b5e2e

Change RootCallTarget from an abstract class into an interface.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 16 Apr 2014 18:51:54 +0200
parents 2ed720ce9273
children
comparison
equal deleted inserted replaced
15166:7bc92bdfd322 15167:258e3e0b5e2e
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.api; 25 package com.oracle.truffle.api;
26 26
27 import com.oracle.truffle.api.frame.*;
28 import com.oracle.truffle.api.nodes.*; 27 import com.oracle.truffle.api.nodes.*;
29 28
30 /** 29 /**
31 * Represents the target of a call to a {@link RootNode}, i.e., to another tree of nodes. Instances 30 * Represents the target of a call to a {@link RootNode}, i.e., to another tree of nodes. Instances
32 * of this class can be created using {@link TruffleRuntime#createCallTarget(RootNode)}. 31 * of this class can be created using {@link TruffleRuntime#createCallTarget(RootNode)}.
33 */ 32 */
34 public abstract class RootCallTarget implements CallTarget { 33 public interface RootCallTarget extends CallTarget {
35 34
36 private final RootNode rootNode; 35 RootNode getRootNode();
37
38 public RootCallTarget(RootNode function) {
39 this.rootNode = function;
40 this.rootNode.adoptChildren();
41 this.rootNode.setCallTarget(this);
42 }
43
44 @Override
45 public String toString() {
46 return rootNode.toString();
47 }
48
49 public final RootNode getRootNode() {
50 return rootNode;
51 }
52
53 protected final Object callProxy(VirtualFrame frame) {
54 try {
55 return getRootNode().execute(frame);
56 } finally {
57 // this assertion is needed to keep the values from being cleared as non-live locals
58 assert frame != null && this != null;
59 }
60 }
61 } 36 }