Skip to content

Commit

Permalink
[Truffle] Fix multiple assignment involving global assignments.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Mar 4, 2015
1 parent 8bdf5bc commit 0de1440
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -1322,6 +1322,10 @@ private void initGlobalVariableAliases() {

@Override
public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
return translateGlobalAsgnNode(node, node.getValueNode().accept(this));
}

public RubyNode translateGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node, RubyNode rhs) {
final SourceSection sourceSection = translate(node.getPosition());

String name = node.getName();
Expand All @@ -1330,8 +1334,6 @@ public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
name = globalVariableAliases.get(name);
}

RubyNode rhs = node.getValueNode().accept(this);

if (name.equals("$~")) {
rhs = new CheckMatchVariableTypeNode(context, sourceSection, rhs);
} else if (name.equals("$0")) {
Expand Down Expand Up @@ -2082,6 +2084,8 @@ private RubyNode translateDummyAssignment(org.jruby.ast.Node dummyAssignment, Ru
} else {
translated = ((ReadNode) ((WriteLocalVariableNode) dummyTranslated.getNonProxyNode()).makeReadNode()).makeWriteNode(rhs);
}
} else if (dummyAssignment instanceof org.jruby.ast.GlobalAsgnNode) {
return translateGlobalAsgnNode((org.jruby.ast.GlobalAsgnNode) dummyAssignment, rhs);
} else {
translated = ((ReadNode) environment.findLocalVarNode(environment.allocateLocalTemp("dummy"), sourceSection)).makeWriteNode(rhs);
}
Expand Down

0 comments on commit 0de1440

Please sign in to comment.