Skip to content

Commit 732ec90

Browse files
committed
Move implicit block arg name to the translator environment.
1 parent 348f505 commit 732ec90

File tree

6 files changed

+6
-5
lines changed

6 files changed

+6
-5
lines changed

src/main/java/org/truffleruby/core/inlined/CoreMethods.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public RubyNode createCallNode(RubyCallNodeParameters callParameters, Translator
173173
break;
174174
case "block_given?":
175175
if (callParameters.isIgnoreVisibility()) {
176-
RubyNode readBlockNode = environment.findLocalVarOrNilNode(TranslatorEnvironment.TEMP_PREFIX + "__unnamed_block_arg__", null);
176+
RubyNode readBlockNode = environment.findLocalVarOrNilNode(TranslatorEnvironment.IMPLICIT_BLOCK_NAME, null);
177177
return InlinedBlockGivenNodeGen.create(context, callParameters,
178178
readBlockNode,
179179
self);

src/main/java/org/truffleruby/core/kernel/KernelNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public boolean blockGiven(VirtualFrame frame,
294294
@Cached("create(nil())") FindAndReadDeclarationVariableNode readNode,
295295
@Cached("createBinaryProfile()") ConditionProfile blockProfile) {
296296
MaterializedFrame callerFrame = callerFrameNode.execute(frame).materialize();
297-
return readNode.execute(callerFrame, TranslatorEnvironment.TEMP_PREFIX + "__unnamed_block_arg__") != nil();
297+
return readNode.execute(callerFrame, TranslatorEnvironment.IMPLICIT_BLOCK_NAME) != nil();
298298
}
299299
}
300300

src/main/java/org/truffleruby/core/proc/ProcNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public DynamicObject proc(VirtualFrame frame, DynamicObject procClass, Object[]
7777
final MaterializedFrame parentFrame = getContext().getCallStack().getCallerFrameIgnoringSend()
7878
.getFrame(FrameAccess.MATERIALIZE).materialize();
7979

80-
DynamicObject parentBlock = (DynamicObject) readNode.execute(parentFrame, TranslatorEnvironment.TEMP_PREFIX + "__unnamed_block_arg__");
80+
DynamicObject parentBlock = (DynamicObject) readNode.execute(parentFrame, TranslatorEnvironment.IMPLICIT_BLOCK_NAME);
8181

8282
if (parentBlock == nil()) {
8383
parentBlock = tryParentBlockForCExts();

src/main/java/org/truffleruby/parser/BodyTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3056,7 +3056,7 @@ public RubyNode visitYieldNode(YieldParseNode node) {
30563056
argumentsTranslated[i] = arguments[i].accept(this);
30573057
}
30583058

3059-
RubyNode readBlock = environment.findLocalVarOrNilNode(TranslatorEnvironment.TEMP_PREFIX + "__unnamed_block_arg__", node.getPosition());
3059+
RubyNode readBlock = environment.findLocalVarOrNilNode(TranslatorEnvironment.IMPLICIT_BLOCK_NAME, node.getPosition());
30603060
final RubyNode ret = new YieldExpressionNode(unsplat, argumentsTranslated, readBlock);
30613061
ret.unsafeSetSourceSection(node.getPosition());
30623062
return addNewlineIfNeeded(node, ret);

src/main/java/org/truffleruby/parser/LoadArgumentsTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public RubyNode visitRestArgNode(RestArgParseNode node) {
344344

345345
public RubyNode visitUnnamedBlockArg() {
346346
final RubyNode readNode = new ReadBlockNode(context.getCoreLibrary().getNil());
347-
final FrameSlot slot = methodBodyTranslator.getEnvironment().getFrameDescriptor().findOrAddFrameSlot(TranslatorEnvironment.TEMP_PREFIX + "__unnamed_block_arg__");
347+
final FrameSlot slot = methodBodyTranslator.getEnvironment().getFrameDescriptor().findOrAddFrameSlot(TranslatorEnvironment.IMPLICIT_BLOCK_NAME);
348348
return new WriteLocalVariableNode(slot, readNode);
349349
}
350350

src/main/java/org/truffleruby/parser/TranslatorEnvironment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
public class TranslatorEnvironment {
3131

3232
public static final char TEMP_PREFIX = '%';
33+
public static final String IMPLICIT_BLOCK_NAME = TEMP_PREFIX + "__unnamed_block_arg__";
3334

3435
private final ParseEnvironment parseEnvironment;
3536

0 commit comments

Comments
 (0)