Skip to content

Commit

Permalink
[Truffle] Translate Rubinius to ::Rubinius in Rubinius kernel code.
Browse files Browse the repository at this point in the history
Rubinius is used in classes such as BasicObject where we can't
understand how it's found. This fixes that but isn't exactly the same
behaviour as Rubinius, where Rubinius wouldn't be found, but
Rubinius::Type would be.
  • Loading branch information
chrisseaton committed Jan 26, 2015
1 parent 667e30f commit 658b588
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -880,6 +880,17 @@ public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {
// Unqualified constant access, as in CONST
final SourceSection sourceSection = translate(node.getPosition());

/*
* Constants of the form Rubinius::Foo in the Rubinius kernel code always seem to get resolved, even if
* Rubinius is not defined, such as in BasicObject. We get around this by translating Rubinius to be
* ::Rubinius. Note that this isn't quite what Rubinius does, as they say that Rubinius isn't defined, but
* we will because we'll translate that to ::Rubinius. But it is a simpler translation.
*/

if (node.getName().equals("Rubinius") && sourceSection.getSource().getPath().startsWith("core:/jruby/truffle/core/rubinius/kernel")) {
return new org.jruby.ast.Colon3Node(node.getPosition(), node.getName()).accept(this);
}

final LexicalScope lexicalScope = environment.getLexicalScope();
final RubyNode moduleNode = new LexicalScopeNode(context, sourceSection, lexicalScope);
return new ReadConstantNode(context, sourceSection, node.getName(), moduleNode, lexicalScope);
Expand Down

0 comments on commit 658b588

Please sign in to comment.