diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java @ 13760:a12017c18d5d

Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 24 Jan 2014 18:13:38 -0800
parents ac5b0f31f7a2
children 64dcb92ee75a
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Fri Jan 24 18:34:18 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Fri Jan 24 18:13:38 2014 -0800
@@ -28,27 +28,19 @@
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
 
-public class DefaultCallTarget extends CallTarget {
-
-    protected final RootNode rootNode;
+/**
+ * This is an implementation-specific class. Do not use or instantiate it. Instead, use
+ * {@link TruffleRuntime#createCallTarget(RootNode)} to create a {@link RootCallTarget}.
+ */
+public class DefaultCallTarget extends RootCallTarget {
 
-    public DefaultCallTarget(RootNode function) {
-        this.rootNode = function;
-        this.rootNode.setCallTarget(this);
-    }
-
-    @Override
-    public String toString() {
-        return rootNode.toString();
+    protected DefaultCallTarget(RootNode function) {
+        super(function);
     }
 
     @Override
     public Object call(PackedFrame caller, Arguments args) {
-        VirtualFrame frame = new DefaultVirtualFrame(rootNode.getFrameDescriptor(), caller, args);
-        return rootNode.execute(frame);
-    }
-
-    public RootNode getRootNode() {
-        return rootNode;
+        VirtualFrame frame = new DefaultVirtualFrame(getRootNode().getFrameDescriptor(), caller, args);
+        return getRootNode().execute(frame);
     }
 }