Skip to content
Snippets Groups Projects
Commit 032bd561 authored by Michael Haupt's avatar Michael Haupt
Browse files

source code printing for builtins (prototype)

parent afb07722
No related branches found
No related tags found
No related merge requests found
......@@ -42,4 +42,9 @@ public abstract class RRootNode extends RootNode {
public int getParameterCount() {
return parameterNames.length;
}
public String getSourceCode() {
return getSourceSection().getCode();
}
}
......@@ -25,6 +25,7 @@ package com.oracle.truffle.r.nodes.builtin;
import com.oracle.truffle.api.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.impl.*;
import com.oracle.truffle.api.nodes.*;
import com.oracle.truffle.r.nodes.*;
import com.oracle.truffle.r.nodes.access.*;
......@@ -37,6 +38,10 @@ import com.oracle.truffle.r.runtime.data.*;
@NodeChild(value = "arguments", type = RNode[].class)
public abstract class RBuiltinNode extends CallNode {
public String getSourceCode() {
return "<builtin>";
}
public abstract RNode[] getArguments();
public abstract RBuiltinFactory getBuiltin();
......@@ -234,6 +239,11 @@ public abstract class RBuiltinNode extends CallNode {
return builtin;
}
@Override
public String getSourceCode() {
return "<custom builtin>";
}
}
public static class RSnippetNode extends RCustomBuiltinNode {
......@@ -243,11 +253,17 @@ public abstract class RBuiltinNode extends CallNode {
public RSnippetNode(RNode[] arguments, RBuiltinFactory builtin, FunctionExpressionNode function) {
super(arguments, builtin);
snippetCall = adoptChild(CallNode.createCall(function, CallArgumentsNode.create(getArguments(), new String[]{})));
assignSourceSection(((DefaultCallTarget) ((FunctionExpressionNode.StaticFunctionExpressionNode) function).getFunction().getTarget()).getRootNode().getSourceSection());
}
@Override
public Object execute(VirtualFrame frame) {
return snippetCall.execute(frame);
}
@Override
public String getSourceCode() {
return getSourceSection().getCode();
}
}
}
......@@ -43,4 +43,10 @@ public final class RBuiltinRootNode extends RRootNode {
public CallNode inline(CallArgumentsNode args) {
return builtin.inline(args);
}
@Override
public String getSourceCode() {
return builtin.getSourceCode();
}
}
......@@ -56,7 +56,7 @@ public class RLibraryLoader {
WriteVariableNode.UnresolvedWriteLocalVariableNode fnDef = (WriteVariableNode.UnresolvedWriteLocalVariableNode) libNode;
String builtinName = fnDef.getSymbol().toString();
FunctionExpressionNode.DynamicFunctionExpressionNode builtinExpr = (FunctionExpressionNode.DynamicFunctionExpressionNode) fnDef.getRhs();
builtinDefs.put(builtinName, new FunctionExpressionNode.StaticFunctionExpressionNode(new RFunction("", builtinExpr.getCallTarget(), false)));
builtinDefs.put(builtinName, new FunctionExpressionNode.StaticFunctionExpressionNode(new RFunction(builtinName, builtinExpr.getCallTarget(), false)));
}
}
return builtinDefs;
......
......@@ -100,7 +100,7 @@ public abstract class PrettyPrinterNode extends RNode {
@Specialization
public String prettyPrint(RFunction operand) {
return ((DefaultCallTarget) operand.getTarget()).getRootNode().getSourceSection().getCode();
return ((RRootNode) ((DefaultCallTarget) operand.getTarget()).getRootNode()).getSourceCode();
}
@Specialization
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment