Skip to content
Browse files
[Truffle] Translate Rubinius to ::Rubinius in Rubinius kernel code.
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 658b5883cac46c9447ff04f4dcfb577c334308c8
Showing with 11 additions and 0 deletions.
  1. +11 −0 truffle/src/main/java/org/jruby/truffle/translator/
@@ -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);

0 comments on commit 658b588

Please sign in to comment.