Skip to content
Permalink
Browse files
Revert "[Truffle] :: looks up constants slightly differently."
This reverts commit d3df63c.

Conflicts:
	core/src/main/java/org/jruby/truffle/nodes/ReadConstantNode.java
  • Loading branch information
chrisseaton committed Oct 2, 2014
1 parent 6be98c4 commit 8b0e25db651f919e49ca4c3abf0954e4dbbb4b6e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
@@ -20,37 +20,28 @@
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.*;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyModule;

public class ReadConstantNode extends RubyNode {

private final boolean isLiteral;
private final String name;
@Child protected RubyNode receiver;
protected final String name;
@Child protected BoxingNode receiver;

@Child protected DispatchHeadNode dispatch;

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

@Override
public Object execute(VirtualFrame frame) {
final Object receiverObject = receiver.execute(frame);

if (isLiteral && !(receiverObject instanceof RubyModule)) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeErrorIsNotA(receiverObject.toString(), "class/module", this));
}

return dispatch.dispatch(
frame,
NilPlaceholder.INSTANCE,
RubyArguments.getSelf(frame.getArguments()),
receiverObject,
receiver.executeRubyBasicObject(frame),
name,
null,
new Object[]{},
@@ -633,7 +633,7 @@ public RubyNode visitClassVarNode(org.jruby.ast.ClassVarNode node) {
public RubyNode visitColon2Node(org.jruby.ast.Colon2Node node) {
final RubyNode lhs = node.getLeftNode().accept(this);

return new ReadConstantNode(context, translate(node.getPosition()), true, node.getName(), lhs);
return new ReadConstantNode(context, translate(node.getPosition()), node.getName(), lhs);
}

@Override
@@ -642,9 +642,9 @@ public RubyNode visitColon3Node(org.jruby.ast.Colon3Node node) {

final SourceSection sourceSection = translate(node.getPosition());

final ObjectLiteralNode root = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getObjectClass());
final ObjectLiteralNode root = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getMainObject());

return new ReadConstantNode(context, sourceSection, false, node.getName(), root);
return new ReadConstantNode(context, sourceSection, node.getName(), root);
}

@Override
@@ -660,7 +660,7 @@ public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {
final SourceSection sourceSection = translate(node.getPosition());

return new ReadConstantNode(context, sourceSection, false, node.getName(), new SelfNode(context, sourceSection));
return new ReadConstantNode(context, sourceSection, node.getName(), new SelfNode(context, sourceSection));
}

@Override
@@ -82,7 +82,7 @@ public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {

final SelfNode selfNode = new SelfNode(context, sourceSection);

return new ReadConstantNode(context, sourceSection, false, node.getName(), selfNode);
return new ReadConstantNode(context, sourceSection, node.getName(), selfNode);
}

@Override
@@ -1,3 +1,4 @@
fails:Literal (A::X) constant resolution raises a TypeError if a non-class or non-module qualifier is given
fails:Literal (A::X) constant resolution with statically assigned constants does not search the singleton class of the class or module
fails:Literal (A::X) constant resolution with dynamically assigned constants does not search the singleton class of the class or module
fails:Constant resolution within methods sends #const_missing to the original class or module scope
@@ -28,6 +29,6 @@ fails:Literal (A::X) constant resolution with statically assigned constants sear
fails:Literal (A::X) constant resolution with statically assigned constants searches the superclass chain
fails:Constant resolution within methods with statically assigned constants does not search the lexical scope of qualifying modules
fails:Constant resolution within methods with dynamically assigned constants does not search the lexical scope of qualifying modules
fails:Constant resolution within methods with statically assigned constants searches Object as a lexical scope only if Object is explicitly opened
fails:Module#public_constant marked constants in a module is defined? with A::B form
fails:Module#public_constant marked constants in a class is defined? with A::B form
fails:Literal (A::X) constant resolution with statically assigned constants searches Object if a toplevel qualifier (::X) is given

0 comments on commit 8b0e25d

Please sign in to comment.