Skip to content

Commit

Permalink
[Truffle] Use the StaticScope to find the block-local variables.
Browse files Browse the repository at this point in the history
* See #4181.
  • Loading branch information
eregon committed Sep 26, 2016
1 parent 477bcf3 commit 55d74cb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/language/block_tags.txt

This file was deleted.

Expand Up @@ -1990,7 +1990,7 @@ private RubyNode translateBlockLikeNode(IterParseNode node, boolean isLambda) {
final RubyNode definitionNode;

try {
definitionNode = methodCompiler.compileBlockNode(sourceSection, sharedMethodInfo.getName(), node.getBodyNode(), sharedMethodInfo, type);
definitionNode = methodCompiler.compileBlockNode(sourceSection, sharedMethodInfo.getName(), node.getBodyNode(), sharedMethodInfo, type, node.getScope().getVariables());
} finally {
if (isLambda) {
frameOnStackMarkerSlotStack.pop();
Expand Down
Expand Up @@ -74,7 +74,7 @@ public MethodTranslator(Node currentNode, RubyContext context, BodyTranslator pa
this.argsNode = argsNode;
}

public BlockDefinitionNode compileBlockNode(RubySourceSection sourceSection, String methodName, ParseNode bodyNode, SharedMethodInfo sharedMethodInfo, ProcType type) {
public BlockDefinitionNode compileBlockNode(RubySourceSection sourceSection, String methodName, ParseNode bodyNode, SharedMethodInfo sharedMethodInfo, ProcType type, String[] variables) {
final SourceSection fullSourceSection = sourceSection.toSourceSection(source);

declareArguments();
Expand Down Expand Up @@ -135,9 +135,10 @@ public BlockDefinitionNode compileBlockNode(RubySourceSection sourceSection, Str

parentSourceSection.push(sourceSection);
try {
if (argsNode.getBlockLocalVariables() != null && !argsNode.getBlockLocalVariables().isEmpty()) {
for (ParseNode var : argsNode.getBlockLocalVariables().children()) {
environment.declareVar(((INameNode) var).getName());
if (!translatingForStatement) {
// Make sure to declare block-local variables
for (String var : variables) {
environment.declareVar(var);
}
}

Expand Down

0 comments on commit 55d74cb

Please sign in to comment.