Skip to content

Commit 7ed38ec

Browse files
committed
Make the naming of block arguments consistent.
1 parent 7312fe2 commit 7ed38ec

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public abstract class InlinedBlockGivenNode extends UnaryInlinedOperationNode {
2626

2727
public InlinedBlockGivenNode(RubyCallNodeParameters callNodeParameters, TranslatorEnvironment environment) {
2828
super(callNodeParameters);
29-
this.readNode = environment.findLocalVarOrNilNode(TranslatorEnvironment.IMPLICIT_BLOCK_NAME, null);
29+
this.readNode = environment.findLocalVarOrNilNode(TranslatorEnvironment.METHOD_BLOCK_NAME, null);
3030
}
3131

3232
@Specialization(guards = {

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 blockProfile.profile(readNode.execute(callerFrame, TranslatorEnvironment.IMPLICIT_BLOCK_NAME) != nil());
297+
return blockProfile.profile(readNode.execute(callerFrame, TranslatorEnvironment.METHOD_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.IMPLICIT_BLOCK_NAME);
80+
DynamicObject parentBlock = (DynamicObject) readNode.execute(parentFrame, TranslatorEnvironment.METHOD_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.IMPLICIT_BLOCK_NAME, node.getPosition());
3059+
RubyNode readBlock = environment.findLocalVarOrNilNode(TranslatorEnvironment.METHOD_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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public int getPreviousIndex() {
8686
}
8787

8888
private final boolean isProc;
89-
private final boolean hasImplicitBlock;
89+
private final boolean hasMethodBlock;
9090
private final BodyTranslator methodBodyTranslator;
9191
private final Deque<ArraySlot> arraySlotStack = new ArrayDeque<>();
9292

@@ -105,10 +105,10 @@ private enum State {
105105
private State state;
106106
private boolean firstOpt = false;
107107

108-
public LoadArgumentsTranslator(Node currentNode, ArgsParseNode argsNode, RubyContext context, Source source, ParserContext parserContext, boolean isProc, boolean hasImplicitBlock, BodyTranslator methodBodyTranslator) {
108+
public LoadArgumentsTranslator(Node currentNode, ArgsParseNode argsNode, RubyContext context, Source source, ParserContext parserContext, boolean isProc, boolean hasMethodBlock, BodyTranslator methodBodyTranslator) {
109109
super(currentNode, context, source, parserContext);
110110
this.isProc = isProc;
111-
this.hasImplicitBlock = hasImplicitBlock;
111+
this.hasMethodBlock = hasMethodBlock;
112112
this.methodBodyTranslator = methodBodyTranslator;
113113
this.argsNode = argsNode;
114114
this.required = argsNode.getRequiredCount();
@@ -159,8 +159,8 @@ public RubyNode translate() {
159159

160160
// Do this before handling optional arguments as one might get
161161
// its default value via a `yield`.
162-
if (hasImplicitBlock) {
163-
sequence.add(visitUnnamedBlockArg());
162+
if (hasMethodBlock) {
163+
sequence.add(visitMethodBlockArg());
164164
}
165165

166166
final int optArgCount = argsNode.getOptionalArgsCount();
@@ -342,9 +342,9 @@ public RubyNode visitRestArgNode(RestArgParseNode node) {
342342
return new WriteLocalVariableNode(slot, readNode);
343343
}
344344

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +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__";
33+
public static final String METHOD_BLOCK_NAME = TEMP_PREFIX + "__method_block_arg__";
3434

3535
private final ParseEnvironment parseEnvironment;
3636

0 commit comments

Comments
 (0)