Skip to content
Snippets Groups Projects
Commit 95153104 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

simplification in Slot.java

parent e102de11
No related branches found
No related tags found
No related merge requests found
...@@ -22,16 +22,13 @@ import com.oracle.truffle.api.dsl.Specialization; ...@@ -22,16 +22,13 @@ import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.r.nodes.access.AccessSlotNode; import com.oracle.truffle.r.nodes.access.AccessSlotNode;
import com.oracle.truffle.r.nodes.access.AccessSlotNodeGen; import com.oracle.truffle.r.nodes.access.AccessSlotNodeGen;
import com.oracle.truffle.r.nodes.access.ConstantNode;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.nodes.function.WrapArgumentNode;
import com.oracle.truffle.r.nodes.function.opt.UpdateShareableChildValueNode; import com.oracle.truffle.r.nodes.function.opt.UpdateShareableChildValueNode;
import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError;
import com.oracle.truffle.r.runtime.Utils; import com.oracle.truffle.r.runtime.Utils;
import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.data.RPromise; import com.oracle.truffle.r.runtime.data.RPromise;
import com.oracle.truffle.r.runtime.data.RSymbol; import com.oracle.truffle.r.runtime.data.RPromise.Closure;
import com.oracle.truffle.r.runtime.nodes.RSyntaxLookup;
@RBuiltin(name = "@", kind = PRIMITIVE, parameterNames = {"", ""}, nonEvalArgs = 1, behavior = COMPLEX) @RBuiltin(name = "@", kind = PRIMITIVE, parameterNames = {"", ""}, nonEvalArgs = 1, behavior = COMPLEX)
public abstract class Slot extends RBuiltinNode.Arg2 { public abstract class Slot extends RBuiltinNode.Arg2 {
...@@ -46,20 +43,12 @@ public abstract class Slot extends RBuiltinNode.Arg2 { ...@@ -46,20 +43,12 @@ public abstract class Slot extends RBuiltinNode.Arg2 {
private String getName(Object nameObj) { private String getName(Object nameObj) {
if (nameObj instanceof RPromise) { if (nameObj instanceof RPromise) {
Object rep = ((RPromise) nameObj).getRep(); RPromise promise = (RPromise) nameObj;
if (rep instanceof WrapArgumentNode) { Closure closure = promise.getClosure();
rep = ((WrapArgumentNode) rep).getOperand(); if (closure.asStringConstant() != null) {
} return closure.asStringConstant();
if (rep instanceof ConstantNode) { } else if (closure.asSymbol() != null) {
Object val = ((ConstantNode) rep).getValue(); return closure.asSymbol();
if (val instanceof String) {
return (String) val;
}
if (val instanceof RSymbol) {
return ((RSymbol) val).getName();
}
} else if (rep instanceof RSyntaxLookup) {
return ((RSyntaxLookup) rep).getIdentifier();
} }
} }
CompilerDirectives.transferToInterpreter(); CompilerDirectives.transferToInterpreter();
......
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