Skip to content

Commit

Permalink
[Truffle] Reove BodyTranslator.translateCPath()
Browse files Browse the repository at this point in the history
* Since we have our own lexical scope tracking now.
  • Loading branch information
eregon committed Nov 10, 2014
1 parent 4bf104a commit e76db94
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public RubyNode visitClassNode(org.jruby.ast.ClassNode node) {

final String name = node.getCPath().getName();

RubyNode lexicalParent = translateCPath(sourceSection, node.getCPath());
RubyNode lexicalParent = new LexicalScopeNode(context, sourceSection, environment.getLexicalScope());

RubyNode superClass;
if (node.getSuperNode() != null) {
Expand Down Expand Up @@ -646,16 +646,6 @@ public RubyNode visitColon3Node(org.jruby.ast.Colon3Node node) {
return new ReadConstantNode(context, sourceSection, node.getName(), root, LexicalScope.NONE);
}

private RubyNode translateCPath(SourceSection sourceSection, org.jruby.ast.Colon3Node node) {
if (node instanceof Colon2ImplicitNode) { // use current lexical scope
return new LexicalScopeNode(context, sourceSection, environment.getLexicalScope());
} else if (node instanceof Colon2ConstNode) { // A::B
return node.childNodes().get(0).accept(this);
} else { // Colon3Node: on top-level (Object)
return new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getObjectClass());
}
}

@Override
public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
final SourceSection sourceSection = translate(node.getPosition());
Expand Down Expand Up @@ -1317,7 +1307,7 @@ public RubyNode visitModuleNode(org.jruby.ast.ModuleNode node) {

final String name = node.getCPath().getName();

RubyNode lexicalParent = translateCPath(sourceSection, node.getCPath());
RubyNode lexicalParent = new LexicalScopeNode(context, sourceSection, environment.getLexicalScope());

final DefineOrGetModuleNode defineModuleNode = new DefineOrGetModuleNode(context, sourceSection, name, lexicalParent);

Expand Down

0 comments on commit e76db94

Please sign in to comment.