Skip to content

Commit

Permalink
[Truffle] Make constant lookup another path in method dispatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Sep 29, 2014
1 parent 5ee0832 commit 60d8a86
Show file tree
Hide file tree
Showing 23 changed files with 592 additions and 504 deletions.
Expand Up @@ -7,47 +7,44 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.constants;
package org.jruby.truffle.nodes;

import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import org.jruby.truffle.nodes.*;
import org.jruby.truffle.nodes.cast.BoxingNode;
import org.jruby.truffle.nodes.dispatch.Dispatch;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNode;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.*;
import org.jruby.truffle.runtime.core.RubyBasicObject;

public class ReadConstantHeadNode extends RubyNode {
public class ReadConstantNode extends RubyNode {

protected final String name;
@Child protected BoxingNode receiver;
@Child protected ReadConstantNode first;

public ReadConstantHeadNode(RubyContext context, SourceSection sourceSection, String name, RubyNode receiver) {
@Child protected DispatchHeadNode dispatch;

public ReadConstantNode(RubyContext context, SourceSection sourceSection, String name, RubyNode receiver) {
super(context, sourceSection);
this.name = name;
this.receiver = new BoxingNode(context, sourceSection, receiver);
first = new UninitializedReadConstantNode(name);
dispatch = new DispatchHeadNode(context, Dispatch.MissingBehavior.CALL_CONST_MISSING);
}

@Override
public Object execute(VirtualFrame frame) {
return first.execute(receiver.executeRubyBasicObject(frame));
}

@Override
public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException {
return first.executeBoolean(receiver.executeRubyBasicObject(frame));
}

@Override
public int executeIntegerFixnum(VirtualFrame frame) throws UnexpectedResultException {
return first.executeIntegerFixnum(receiver.executeRubyBasicObject(frame));
}

@Override
public double executeFloat(VirtualFrame frame) throws UnexpectedResultException {
return first.executeFloat(receiver.executeRubyBasicObject(frame));
return dispatch.dispatch(
frame,
NilPlaceholder.INSTANCE,
RubyArguments.getSelf(frame.getArguments()),
receiver.executeRubyBasicObject(frame),
name,
null,
new Object[]{},
Dispatch.DispatchAction.READ_CONSTANT);
}

@Override
Expand Down
Expand Up @@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.constants;
package org.jruby.truffle.nodes;

import com.oracle.truffle.api.*;
import com.oracle.truffle.api.source.*;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -176,7 +176,6 @@ private Object methodMissing(RubyBasicObject self, RubySymbol name, Object[] arg
throw new RaiseException(getContext().getCoreLibrary().nameErrorNoMethod(name.toString(), self.toString(), this));
}


}

@CoreMethod(names = {"send", "__send__"}, needsBlock = true, minArgs = 1, isSplatted = true)
Expand Down

0 comments on commit 60d8a86

Please sign in to comment.