Skip to content

Commit

Permalink
Showing 31 changed files with 261 additions and 264 deletions.
9 changes: 3 additions & 6 deletions core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
Original file line number Diff line number Diff line change
@@ -19,10 +19,7 @@
import org.jruby.truffle.nodes.cast.BooleanCastNodeFactory;
import org.jruby.truffle.nodes.cast.ProcOrNullNode;
import org.jruby.truffle.nodes.cast.ProcOrNullNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.ModuleOperations;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
@@ -42,7 +39,7 @@ public class RubyCallNode extends RubyNode {
private final boolean isSplatted;
private final boolean isVCall;

@Child private DispatchHeadNode dispatchHead;
@Child private CallDispatchHeadNode dispatchHead;

private final BranchProfile splatNotArrayProfile = BranchProfile.create();

@@ -51,7 +48,7 @@ public class RubyCallNode extends RubyNode {
@CompilerDirectives.CompilationFinal private boolean seenLongFixnumInUnsplat = false;
@CompilerDirectives.CompilationFinal private boolean seenObjectInUnsplat = false;

@Child private DispatchHeadNode respondToMissing;
@Child private CallDispatchHeadNode respondToMissing;
@Child private BooleanCastNode respondToMissingCast;

private final boolean ignoreVisibility;
Original file line number Diff line number Diff line change
@@ -16,10 +16,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
@@ -35,7 +32,7 @@ public abstract class ArrayCastNode extends RubyNode {

private final SplatCastNode.NilBehavior nilBehavior;

@Child private DispatchHeadNode toArrayNode;
@Child private CallDispatchHeadNode toArrayNode;

public ArrayCastNode(RubyContext context, SourceSection sourceSection) {
this(context, sourceSection, SplatCastNode.NilBehavior.NIL);
Original file line number Diff line number Diff line change
@@ -15,10 +15,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
@@ -31,7 +28,7 @@
@NodeChild("child")
public abstract class HashCastNode extends RubyNode {

@Child private DispatchHeadNode toHashNode;
@Child private CallDispatchHeadNode toHashNode;

public HashCastNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -27,7 +28,7 @@
@NodeChild("child")
public abstract class ProcCastNode extends RubyNode {

@Child private DispatchHeadNode toProc;
@Child private CallDispatchHeadNode toProc;

public ProcCastNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -17,10 +17,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.ArrayDupNode;
import org.jruby.truffle.nodes.core.ArrayDupNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
@@ -42,9 +39,9 @@ public static enum NilBehavior {
private final boolean useToAry;

@Child private ArrayDupNode dup;
@Child private DispatchHeadNode respondToToA;
@Child private CallDispatchHeadNode respondToToA;
@Child private BooleanCastNode respondToCast;
@Child private DispatchHeadNode toA;
@Child private CallDispatchHeadNode toA;

public SplatCastNode(RubyContext context, SourceSection sourceSection, NilBehavior nilBehavior, boolean useToAry) {
super(context, sourceSection);
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/truffle/nodes/cast/ToSNode.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.nodes.RubyTypesGen;
import org.jruby.truffle.nodes.core.KernelNodes;
import org.jruby.truffle.nodes.core.KernelNodesFactory;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -27,7 +28,7 @@
@NodeChild(type = RubyNode.class)
public abstract class ToSNode extends RubyNode {

@Child private DispatchHeadNode callToSNode;
@Child private CallDispatchHeadNode callToSNode;
@Child private KernelNodes.ToSNode kernelToSNode;

public ToSNode(RubyContext context, SourceSection sourceSection) {
21 changes: 9 additions & 12 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -26,10 +26,7 @@
import org.jruby.truffle.nodes.CoreSourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.PredicateDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.methods.arguments.MissingArgumentBehaviour;
import org.jruby.truffle.nodes.methods.arguments.ReadPreArgumentNode;
import org.jruby.truffle.nodes.methods.locals.ReadLevelVariableNodeFactory;
@@ -2057,7 +2054,7 @@ public RubyArray initializeCopyObject(RubyArray self, RubyArray from) {
@ImportGuards(ArrayGuards.class)
public abstract static class InjectNode extends YieldingCoreMethodNode {

@Child private DispatchHeadNode dispatch;
@Child private CallDispatchHeadNode dispatch;

public InjectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -2183,7 +2180,7 @@ public Object insert(RubyArray array, int index, int value) {
@CoreMethod(names = {"inspect", "to_s"})
public abstract static class InspectNode extends CoreMethodNode {

@Child private DispatchHeadNode inspect;
@Child private CallDispatchHeadNode inspect;

public InspectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -2490,7 +2487,7 @@ public RubyArray mapInPlaceObject(VirtualFrame frame, RubyArray array, RubyProc
@CoreMethod(names = "max")
public abstract static class MaxNode extends ArrayCoreMethodNode {

@Child private DispatchHeadNode eachNode;
@Child private CallDispatchHeadNode eachNode;
private final MaxBlock maxBlock;

public MaxNode(RubyContext context, SourceSection sourceSection) {
@@ -2531,7 +2528,7 @@ public Object max(VirtualFrame frame, RubyArray array) {

public abstract static class MaxBlockNode extends CoreMethodNode {

@Child private DispatchHeadNode compareNode;
@Child private CallDispatchHeadNode compareNode;

public MaxBlockNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -2609,7 +2606,7 @@ public CallTarget getCallTarget() {
@CoreMethod(names = "min")
public abstract static class MinNode extends ArrayCoreMethodNode {

@Child private DispatchHeadNode eachNode;
@Child private CallDispatchHeadNode eachNode;
private final MinBlock minBlock;

public MinNode(RubyContext context, SourceSection sourceSection) {
@@ -2650,7 +2647,7 @@ public Object min(VirtualFrame frame, RubyArray array) {

public abstract static class MinBlockNode extends CoreMethodNode {

@Child private DispatchHeadNode compareNode;
@Child private CallDispatchHeadNode compareNode;

public MinBlockNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -3473,7 +3470,7 @@ public RubyArray sliceLongFixnum(RubyArray array, int start, int length) {
@CoreMethod(names = "sort", needsBlock = true)
public abstract static class SortNode extends ArrayCoreMethodNode {

@Child private DispatchHeadNode compareDispatchNode;
@Child private CallDispatchHeadNode compareDispatchNode;
@Child private YieldDispatchHeadNode yieldNode;

public SortNode(RubyContext context, SourceSection sourceSection) {
@@ -3655,7 +3652,7 @@ protected static boolean isSmall(RubyArray array) {
@CoreMethod(names = "sort!")
public abstract static class SortBangNode extends ArrayCoreMethodNode {

@Child private DispatchHeadNode compareDispatchNode;
@Child private CallDispatchHeadNode compareDispatchNode;

public SortBangNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -20,10 +20,7 @@
import org.jruby.truffle.nodes.RubyCallNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.cast.BooleanCastNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.PredicateDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.ObjectIDOperations;
import org.jruby.truffle.runtime.RubyContext;
@@ -310,7 +307,7 @@ private boolean lastCallWasVCall() {
@CoreMethod(names = "__send__", needsBlock = true, required = 1, argumentsAsArray = true)
public abstract static class SendNode extends CoreMethodNode {

@Child private DispatchHeadNode dispatchNode;
@Child private CallDispatchHeadNode dispatchNode;

public SendNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -56,7 +57,7 @@ public RubyBasicObject allocate(RubyClass rubyClass) {
public abstract static class NewNode extends CoreMethodNode {

@Child private AllocateNode allocateNode;
@Child private DispatchHeadNode initialize;
@Child private CallDispatchHeadNode initialize;
@CompilerDirectives.CompilationFinal private boolean isCached = true;
@CompilerDirectives.CompilationFinal private RubyClass cachedClass;

Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -22,7 +23,7 @@ public abstract class ComparableNodes {

public abstract static class ComparableCoreMethodNode extends CoreMethodNode {

@Child private DispatchHeadNode compareNode;
@Child private CallDispatchHeadNode compareNode;

public ComparableCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.methods.UnsupportedOperationBehavior;
@@ -69,7 +70,7 @@ public RubyBignum negWithOverflow(long value) {
@CoreMethod(names = "+", required = 1)
public abstract static class AddNode extends BignumNodes.BignumCoreMethodNode {

@Child private DispatchHeadNode rationalAdd;
@Child private CallDispatchHeadNode rationalAdd;

public AddNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -784,7 +785,7 @@ public boolean lessEqual(long a, RubyBignum b) {
@CoreMethod(names = {"==", "==="}, required = 1)
public abstract static class EqualNode extends CoreMethodNode {

@Child private DispatchHeadNode reverseCallNode;
@Child private CallDispatchHeadNode reverseCallNode;

public EqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -1250,7 +1251,7 @@ static boolean isStrictlyNegative(int value) {
@CoreMethod(names = ">>", required = 1, lowerFixnumParameters = 0)
public abstract static class RightShiftNode extends CoreMethodNode {

@Child private DispatchHeadNode toInt;
@Child private CallDispatchHeadNode toInt;

public RightShiftNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.PredicateDispatchHeadNode;
@@ -692,7 +693,7 @@ public RubyHash dupBuckets(RubyHash self, RubyHash from) {
@CoreMethod(names = {"inspect", "to_s"})
public abstract static class InspectNode extends HashCoreMethodNode {

@Child private DispatchHeadNode inspect;
@Child private CallDispatchHeadNode inspect;

public InspectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -25,7 +26,7 @@ public class InteroplatedRegexpNode extends RubyNode {

@Children private final RubyNode[] children;
private final RegexpOptions options;
@Child private DispatchHeadNode toS;
@Child private CallDispatchHeadNode toS;

public InteroplatedRegexpNode(RubyContext context, SourceSection sourceSection, RubyNode[] children, RegexpOptions options) {
super(context, sourceSection);
32 changes: 16 additions & 16 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ public boolean notMatch(VirtualFrame frame, Object self, Object other) {
@CoreMethod(names = {"<=>"}, required = 1)
public abstract static class CompareNode extends CoreMethodNode {

@Child private DispatchHeadNode equalNode;
@Child private CallDispatchHeadNode equalNode;
@Child private BooleanCastNode booleanCast;

public CompareNode(RubyContext context, SourceSection sourceSection) {
@@ -466,7 +466,7 @@ public RubyClass getClass(RubyBasicObject self) {
@CoreMethod(names = "clone")
public abstract static class CloneNode extends CoreMethodNode {

@Child private DispatchHeadNode initializeCloneNode;
@Child private CallDispatchHeadNode initializeCloneNode;

public CloneNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -501,7 +501,7 @@ public Object clone(VirtualFrame frame, RubyBasicObject self) {
@CoreMethod(names = "dup")
public abstract static class DupNode extends CoreMethodNode {

@Child private DispatchHeadNode initializeDupNode;
@Child private CallDispatchHeadNode initializeDupNode;

public DupNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -541,7 +541,7 @@ public EqlNode(EqlNode prev) {
@CoreMethod(names = "eval", isModuleFunction = true, required = 1, optional = 3)
public abstract static class EvalNode extends CoreMethodNode {

@Child private DispatchHeadNode toStr;
@Child private CallDispatchHeadNode toStr;
@Child private BindingNode bindingNode;

public EvalNode(RubyContext context, SourceSection sourceSection) {
@@ -974,7 +974,7 @@ public Object initializeCopy(RubyBasicObject self, RubyBasicObject from) {
@CoreMethod(names = {"initialize_dup", "initialize_clone"}, visibility = Visibility.PRIVATE, required = 1)
public abstract static class InitializeDupCloneNode extends CoreMethodNode {

@Child private DispatchHeadNode initializeCopyNode;
@Child private CallDispatchHeadNode initializeCopyNode;

public InitializeDupCloneNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -1133,13 +1133,13 @@ public RubyArray instanceVariables(RubyBasicObject self) {
@CoreMethod(names = "Integer", isModuleFunction = true, required = 1)
public abstract static class IntegerNode extends CoreMethodNode {

@Child private DispatchHeadNode toIntRespondTo;
@Child private DispatchHeadNode toInt;
@Child private DoesRespondDispatchHeadNode toIntRespondTo;
@Child private CallDispatchHeadNode toInt;

public IntegerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
toIntRespondTo = new DispatchHeadNode(context, false, false, MissingBehavior.CALL_METHOD_MISSING, null, DispatchAction.RESPOND_TO_METHOD);
toInt = new DispatchHeadNode(context, false, false, MissingBehavior.CALL_METHOD_MISSING, null, DispatchAction.CALL_METHOD);
toIntRespondTo = new DoesRespondDispatchHeadNode(context, false, false, MissingBehavior.CALL_METHOD_MISSING, null);
toInt = new CallDispatchHeadNode(context, false, false, MissingBehavior.CALL_METHOD_MISSING, null);
}

public IntegerNode(IntegerNode prev) {
@@ -1390,7 +1390,7 @@ public ObjectIDNode(ObjectIDNode prev) {
@CoreMethod(names = "print", isModuleFunction = true, argumentsAsArray = true)
public abstract static class PrintNode extends CoreMethodNode {

@Child private DispatchHeadNode toS;
@Child private CallDispatchHeadNode toS;

public PrintNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -1534,7 +1534,7 @@ public RubyArray methods(RubyBasicObject self, UndefinedPlaceholder includeInher
@CoreMethod(names = "raise", isModuleFunction = true, optional = 3)
public abstract static class RaiseNode extends CoreMethodNode {

@Child private DispatchHeadNode initialize;
@Child private CallDispatchHeadNode initialize;

public RaiseNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -1681,14 +1681,14 @@ public boolean require(RubyString feature) {
@CoreMethod(names = "respond_to?", required = 1, optional = 1)
public abstract static class RespondToNode extends CoreMethodNode {

@Child private DispatchHeadNode dispatch;
@Child private DispatchHeadNode dispatchIgnoreVisibility;
@Child private DoesRespondDispatchHeadNode dispatch;
@Child private DoesRespondDispatchHeadNode dispatchIgnoreVisibility;

public RespondToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);

dispatch = new DispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null, DispatchAction.RESPOND_TO_METHOD);
dispatchIgnoreVisibility = new DispatchHeadNode(context, true, false, MissingBehavior.RETURN_MISSING, null, DispatchAction.RESPOND_TO_METHOD);
dispatch = new DoesRespondDispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null);
dispatchIgnoreVisibility = new DoesRespondDispatchHeadNode(context, true, false, MissingBehavior.RETURN_MISSING, null);

if (Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_UNCACHED.load()) {
dispatch.forceUncached();
@@ -1871,7 +1871,7 @@ public RubyArray singletonMethods(RubyBasicObject self, UndefinedPlaceholder inc
@CoreMethod(names = "String", isModuleFunction = true, required = 1)
public abstract static class StringNode extends CoreMethodNode {

@Child private DispatchHeadNode toS;
@Child private CallDispatchHeadNode toS;

public StringNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
19 changes: 8 additions & 11 deletions core/src/main/java/org/jruby/truffle/nodes/core/MathNodes.java
Original file line number Diff line number Diff line change
@@ -16,10 +16,7 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.RubyMath;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.UseMethodMissingException;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.control.RaiseException;
@@ -366,7 +363,7 @@ protected double doFunction(double a) {
public abstract static class FrExpNode extends CoreMethodNode {

@Child private KernelNodes.IsANode isANode;
@Child private DispatchHeadNode floatNode;
@Child private CallDispatchHeadNode floatNode;

public FrExpNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -522,8 +519,8 @@ protected double doFunction(double a, double b) {
public abstract static class LdexpNode extends CoreMethodNode {

@Child private KernelNodes.IsANode isANode;
@Child private DispatchHeadNode floatANode;
@Child private DispatchHeadNode integerBNode;
@Child private CallDispatchHeadNode floatANode;
@Child private CallDispatchHeadNode integerBNode;

protected LdexpNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -635,7 +632,7 @@ public double function(VirtualFrame frame, Object a, Object b) {
public abstract static class LGammaNode extends CoreMethodNode {

@Child private KernelNodes.IsANode isANode;
@Child private DispatchHeadNode floatNode;
@Child private CallDispatchHeadNode floatNode;

public LGammaNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -916,7 +913,7 @@ protected double doFunction(double a) {
protected abstract static class SimpleMonadicMathNode extends CoreMethodNode {

@Child private KernelNodes.IsANode isANode;
@Child private DispatchHeadNode floatNode;
@Child private CallDispatchHeadNode floatNode;

protected SimpleMonadicMathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -982,8 +979,8 @@ public double function(VirtualFrame frame, Object a) {
protected abstract static class SimpleDyadicMathNode extends CoreMethodNode {

@Child protected KernelNodes.IsANode isANode;
@Child protected DispatchHeadNode floatANode;
@Child protected DispatchHeadNode floatBNode;
@Child protected CallDispatchHeadNode floatANode;
@Child protected CallDispatchHeadNode floatBNode;

protected SimpleDyadicMathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -24,10 +24,7 @@
import org.jruby.truffle.nodes.cast.BooleanCastNode;
import org.jruby.truffle.nodes.cast.BooleanCastNodeFactory;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.dispatch.DispatchAction;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.methods.SetMethodDeclarationContext;
import org.jruby.truffle.nodes.methods.arguments.CheckArityNode;
import org.jruby.truffle.nodes.methods.arguments.MissingArgumentBehaviour;
@@ -833,7 +830,7 @@ public Object initializeCopy(RubyModule self, RubyModule other) {
@CoreMethod(names = "include", argumentsAsArray = true, required = 1)
public abstract static class IncludeNode extends CoreMethodNode {

@Child private DispatchHeadNode appendFeaturesNode;
@Child private CallDispatchHeadNode appendFeaturesNode;

public IncludeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.PredicateDispatchHeadNode;
@@ -387,7 +388,7 @@ public RubyArray toA(RubyRange.IntegerFixnumRange range) {
@CoreMethod(names = "to_s")
public abstract static class ToSNode extends CoreMethodNode {

@Child private DispatchHeadNode toS;
@Child private CallDispatchHeadNode toS;

public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
import org.joni.Region;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -361,7 +362,7 @@ public RubyString chompBang(RubyString string) {
@CoreMethod(names = "count", argumentsAsArray = true)
public abstract static class CountNode extends CoreMethodNode {

@Child private DispatchHeadNode toStr;
@Child private CallDispatchHeadNode toStr;

public CountNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -625,7 +626,7 @@ public RubyString forceEncoding(RubyString string, RubyEncoding encoding) {
@CoreMethod(names = "gsub", required = 1, optional = 1, needsBlock = true)
public abstract static class GsubNode extends RegexpNodes.EscapingYieldingNode {

@Child private DispatchHeadNode toS;
@Child private CallDispatchHeadNode toS;

public GsubNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.RubyThread.Status;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
@@ -200,7 +201,7 @@ public RubyNilClass pass() {
@CoreMethod(names = "raise", required = 1, optional = 1)
public abstract static class RaiseNode extends CoreMethodNode {

@Child private DispatchHeadNode initialize;
@Child private CallDispatchHeadNode initialize;

public RaiseNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.dispatch;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyProc;

public class CallDispatchHeadNode extends DispatchHeadNode {

public CallDispatchHeadNode(RubyContext context, boolean ignoreVisibility, boolean indirect, MissingBehavior missingBehavior, LexicalScope lexicalScope) {
super(context, ignoreVisibility, indirect, missingBehavior, lexicalScope, DispatchAction.CALL_METHOD);
}

public Object call(
VirtualFrame frame,
Object receiverObject,
Object methodName,
RubyProc blockObject,
Object... argumentsObjects) {
return dispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

public double callFloat(
VirtualFrame frame,
Object receiverObject,
Object methodName,
RubyProc blockObject,
Object... argumentsObjects) throws UseMethodMissingException {
final Object value = call(frame, receiverObject, methodName, blockObject, argumentsObjects);

if (missingBehavior == MissingBehavior.RETURN_MISSING && value == DispatchNode.MISSING) {
throw new UseMethodMissingException();
}

if (value instanceof Double) {
return (double) value;
}

CompilerDirectives.transferToInterpreter();

final String message = String.format("%s (%s#%s gives %s)",
context.getCoreLibrary().getFloatClass().getName(),
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
methodName,
context.getCoreLibrary().getLogicalClass(value).getName());

throw new RaiseException(context.getCoreLibrary().typeErrorCantConvertTo(
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
message,
this));
}

public long callLongFixnum(
VirtualFrame frame,
Object receiverObject,
Object methodName,
RubyProc blockObject,
Object... argumentsObjects) throws UseMethodMissingException {
final Object value = call(frame, receiverObject, methodName, blockObject, argumentsObjects);

if (missingBehavior == MissingBehavior.RETURN_MISSING && value == DispatchNode.MISSING) {
throw new UseMethodMissingException();
}

if (value instanceof Integer) {
return (int) value;
}

if (value instanceof Long) {
return (long) value;
}

CompilerDirectives.transferToInterpreter();

final String message = String.format("%s (%s#%s gives %s)",
context.getCoreLibrary().getFloatClass().getName(),
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
methodName,
context.getCoreLibrary().getLogicalClass(value).getName());

throw new RaiseException(context.getCoreLibrary().typeErrorCantConvertTo(
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
message,
this));
}

}
Original file line number Diff line number Diff line change
@@ -19,12 +19,12 @@

public class DispatchHeadNode extends Node {

private final RubyContext context;
private final boolean ignoreVisibility;
private final boolean indirect;
private final MissingBehavior missingBehavior;
private final LexicalScope lexicalScope;
private final DispatchAction dispatchAction;
protected final RubyContext context;
protected final boolean ignoreVisibility;
protected final boolean indirect;
protected final MissingBehavior missingBehavior;
protected final LexicalScope lexicalScope;
protected final DispatchAction dispatchAction;

@Child private DispatchNode first;

@@ -44,107 +44,6 @@ public DispatchHeadNode(
first = new UnresolvedDispatchNode(context, ignoreVisibility, indirect, missingBehavior, dispatchAction);
}

public Object call(
VirtualFrame frame,
Object receiverObject,
Object methodName,
RubyProc blockObject,
Object... argumentsObjects) {
assert dispatchAction == DispatchAction.CALL_METHOD;

return dispatch(
frame,
receiverObject,
methodName,
blockObject,
argumentsObjects);
}

public double callFloat(
VirtualFrame frame,
Object receiverObject,
Object methodName,
RubyProc blockObject,
Object... argumentsObjects) throws UseMethodMissingException {
final Object value = call(frame, receiverObject, methodName, blockObject, argumentsObjects);

if (missingBehavior == MissingBehavior.RETURN_MISSING && value == DispatchNode.MISSING) {
throw new UseMethodMissingException();
}

if (value instanceof Double) {
return (double) value;
}

CompilerDirectives.transferToInterpreter();

final String message = String.format("%s (%s#%s gives %s)",
context.getCoreLibrary().getFloatClass().getName(),
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
methodName,
context.getCoreLibrary().getLogicalClass(value).getName());

throw new RaiseException(context.getCoreLibrary().typeErrorCantConvertTo(
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
message,
this));
}

public long callLongFixnum(
VirtualFrame frame,
Object receiverObject,
Object methodName,
RubyProc blockObject,
Object... argumentsObjects) throws UseMethodMissingException {
final Object value = call(frame, receiverObject, methodName, blockObject, argumentsObjects);

if (missingBehavior == MissingBehavior.RETURN_MISSING && value == DispatchNode.MISSING) {
throw new UseMethodMissingException();
}

if (value instanceof Integer) {
return (int) value;
}

if (value instanceof Long) {
return (long) value;
}

CompilerDirectives.transferToInterpreter();

final String message = String.format("%s (%s#%s gives %s)",
context.getCoreLibrary().getFloatClass().getName(),
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
methodName,
context.getCoreLibrary().getLogicalClass(value).getName());

throw new RaiseException(context.getCoreLibrary().typeErrorCantConvertTo(
context.getCoreLibrary().getLogicalClass(receiverObject).getName(),
message,
this));
}

/**
* Check if a specific method is defined on the receiver object.
* This check is "static" and should only be used in a few VM operations.
* In many cases, a dynamic call to Ruby's respond_to? should be used instead.
* Similar to MRI rb_check_funcall().
*/
public boolean doesRespondTo(
VirtualFrame frame,
Object methodName,
Object receiverObject) {
assert dispatchAction == DispatchAction.RESPOND_TO_METHOD;

// It's ok to cast here as we control what RESPOND_TO_METHOD returns
return (boolean) dispatch(
frame,
receiverObject,
methodName,
null,
null);
}

public Object dispatch(
VirtualFrame frame,
Object receiverObject,
@@ -168,16 +67,17 @@ public DispatchNode getFirstDispatchNode() {
return first;
}

public void forceUncached() {
adoptChildren();
first.replace(UncachedDispatchNodeFactory.create(context, ignoreVisibility, null, null, null, null, null));
}

public LexicalScope getLexicalScope() {
return lexicalScope;
}

public DispatchAction getDispatchAction() {
return dispatchAction;
}

public void forceUncached() {
adoptChildren();
first.replace(UncachedDispatchNodeFactory.create(context, ignoreVisibility, null, null, null, null, null));
}

}
Original file line number Diff line number Diff line change
@@ -13,64 +13,58 @@

public class DispatchHeadNodeFactory {

public static DispatchHeadNode createMethodCall(RubyContext context) {
return new DispatchHeadNode(
public static CallDispatchHeadNode createMethodCall(RubyContext context) {
return new CallDispatchHeadNode(
context,
false,
false,
MissingBehavior.CALL_METHOD_MISSING,
null,
DispatchAction.CALL_METHOD);
null);
}

public static DispatchHeadNode createMethodCall(RubyContext context, boolean ignoreVisibility) {
return new DispatchHeadNode(
public static CallDispatchHeadNode createMethodCall(RubyContext context, boolean ignoreVisibility) {
return new CallDispatchHeadNode(
context,
ignoreVisibility,
false,
MissingBehavior.CALL_METHOD_MISSING,
null,
DispatchAction.CALL_METHOD);
null);
}

public static DispatchHeadNode createMethodCall(RubyContext context, MissingBehavior missingBehavior) {
return new DispatchHeadNode(
public static CallDispatchHeadNode createMethodCall(RubyContext context, MissingBehavior missingBehavior) {
return new CallDispatchHeadNode(
context,
false,
false,
missingBehavior,
null,
DispatchAction.CALL_METHOD);
null);
}

public static DispatchHeadNode createMethodCall(RubyContext context, boolean ignoreVisibility, MissingBehavior missingBehavior) {
return new DispatchHeadNode(
public static CallDispatchHeadNode createMethodCall(RubyContext context, boolean ignoreVisibility, MissingBehavior missingBehavior) {
return new CallDispatchHeadNode(
context,
ignoreVisibility,
false,
missingBehavior,
null,
DispatchAction.CALL_METHOD);
null);
}

public static DispatchHeadNode createMethodCall(RubyContext context, boolean ignoreVisibility, boolean indirect, MissingBehavior missingBehavior) {
return new DispatchHeadNode(
public static CallDispatchHeadNode createMethodCall(RubyContext context, boolean ignoreVisibility, boolean indirect, MissingBehavior missingBehavior) {
return new CallDispatchHeadNode(
context,
ignoreVisibility,
indirect,
missingBehavior,
null,
DispatchAction.CALL_METHOD);
null);
}

public static DispatchHeadNode createMethodCallOnSelf(RubyContext context) {
return new DispatchHeadNode(
public static CallDispatchHeadNode createMethodCallOnSelf(RubyContext context) {
return new CallDispatchHeadNode(
context,
true,
false,
MissingBehavior.CALL_METHOD_MISSING,
null,
DispatchAction.CALL_METHOD);
null);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.dispatch;

import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;

public class DoesRespondDispatchHeadNode extends DispatchHeadNode {

public DoesRespondDispatchHeadNode(RubyContext context, boolean ignoreVisibility, boolean indirect, MissingBehavior missingBehavior, LexicalScope lexicalScope) {
super(context, ignoreVisibility, indirect, missingBehavior, lexicalScope, DispatchAction.RESPOND_TO_METHOD);
}

/**
* Check if a specific method is defined on the receiver object.
* This check is "static" and should only be used in a few VM operations.
* In many cases, a dynamic call to Ruby's respond_to? should be used instead.
* Similar to MRI rb_check_funcall().
*/
public boolean doesRespondTo(
VirtualFrame frame,
Object methodName,
Object receiverObject) {
// It's ok to cast here as we control what RESPOND_TO_METHOD returns
return (boolean) dispatch(
frame,
receiverObject,
methodName,
null,
null);
}

}
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@

public class PredicateDispatchHeadNode extends Node {

@Child private DispatchHeadNode dispatchNode;
@Child private CallDispatchHeadNode dispatchNode;
@Child private BooleanCastNode booleanCastNode;

public PredicateDispatchHeadNode(RubyContext context) {
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.PredicateDispatchHeadNode;
@@ -23,7 +24,7 @@

public class FindEntryNode extends RubyNode {

@Child DispatchHeadNode hashNode;
@Child CallDispatchHeadNode hashNode;
@Child PredicateDispatchHeadNode eqlNode;

public FindEntryNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.PredicateDispatchHeadNode;
@@ -28,8 +29,8 @@
public abstract class HashLiteralNode extends RubyNode {

@Children protected final RubyNode[] keyValues;
@Child protected DispatchHeadNode dupNode;
@Child protected DispatchHeadNode freezeNode;
@Child protected CallDispatchHeadNode dupNode;
@Child protected CallDispatchHeadNode freezeNode;

protected HashLiteralNode(RubyContext context, SourceSection sourceSection, RubyNode[] keyValues) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyArguments;
@@ -23,7 +24,7 @@ public class SymbolProcNode extends RubyNode {

private final String symbol;

@Child private DispatchHeadNode dispatch;
@Child private CallDispatchHeadNode dispatch;

public SymbolProcNode(RubyContext context, SourceSection sourceSection, String symbol) {
super(context, sourceSection);
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyConstant;
@@ -27,7 +28,7 @@
public class DefineOrGetClassNode extends DefineOrGetModuleNode {

@Child private RubyNode superClass;
@Child private DispatchHeadNode inheritedNode;
@Child private CallDispatchHeadNode inheritedNode;

public DefineOrGetClassNode(RubyContext context, SourceSection sourceSection, String name, RubyNode lexicalParent, RubyNode superClass) {
super(context, sourceSection, name, lexicalParent);
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.DispatchAction;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DoesRespondDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.runtime.RubyContext;

@@ -22,13 +23,13 @@ public class RespondToNode extends RubyNode {
private final String methodName;

@Child private RubyNode child;
@Child private DispatchHeadNode dispatch;
@Child private DoesRespondDispatchHeadNode dispatch;

public RespondToNode(RubyContext context, SourceSection sourceSection, RubyNode child, String methodName) {
super(context, sourceSection);
this.methodName = methodName;
this.child = child;
dispatch = new DispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null, DispatchAction.RESPOND_TO_METHOD);
dispatch = new DoesRespondDispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null);
}

public boolean executeBoolean(VirtualFrame frame) {
Original file line number Diff line number Diff line change
@@ -12,10 +12,7 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.dispatch.DispatchAction;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
@@ -29,12 +26,12 @@ public abstract class FixnumPrimitiveNodes {
@RubiniusPrimitive(name = "fixnum_coerce")
public static abstract class FixnumCoercePrimitiveNode extends RubiniusPrimitiveNode {

@Child private DispatchHeadNode toFRespond;
@Child private DispatchHeadNode toF;
@Child private DoesRespondDispatchHeadNode toFRespond;
@Child private CallDispatchHeadNode toF;

public FixnumCoercePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
toFRespond = new DispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null, DispatchAction.RESPOND_TO_METHOD);
toFRespond = new DoesRespondDispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null);
toF = DispatchHeadNodeFactory.createMethodCall(context);
}

This file was deleted.

3 comments on commit fb4b3b8

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eregon @nirvdrum there's now a couple of subclasses of DispatchHeadNode, CallDispatchHeadNode and DoesRespondDispatchHeadNode - create these using DispatchHeadNodeFactory. CallDispatchHeadNode has methods on it that return a particular type and will raise TypeError if it doesn't get it. I wrote those for Math which passes all the specs so they hopefully do the right thing in most cases. This will help us to get rid of all the random casts we often have after calls to dispatch.

@eregon
Copy link
Member

@eregon eregon commented on fb4b3b8 Jan 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, is it on purpose that not all nodes use the factory yet?

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - I'll make the constructor of DispatchHeadNode package protected and then we will be able to update them.

Please sign in to comment.