File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
src/main/java/org/truffleruby/language/arguments Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
package org .truffleruby .language .arguments ;
11
11
12
- import org .truffleruby .core .proc .RubyProc ;
13
12
import org .truffleruby .language .RubyContextSourceNode ;
14
13
15
14
import com .oracle .truffle .api .frame .VirtualFrame ;
@@ -27,7 +26,7 @@ public ReadBlockFromCurrentFrameArgumentsNode(Object valueIfAbsent) {
27
26
28
27
@ Override
29
28
public Object execute (VirtualFrame frame ) {
30
- final RubyProc block = RubyArguments .getBlock (frame );
29
+ final Object block = RubyArguments .getBlockAssertType (frame );
31
30
return nullProfile .profile (block == null ) ? valueIfAbsent : block ;
32
31
}
33
32
Original file line number Diff line number Diff line change @@ -150,6 +150,13 @@ public static RubyProc getBlock(Frame frame) {
150
150
return (RubyProc ) frame .getArguments ()[ArgumentIndicies .BLOCK .ordinal ()];
151
151
}
152
152
153
+ /** A variant of getBlock() when the return type does not need to be RubyProc and which avoids the extra cast. */
154
+ public static Object getBlockAssertType (Frame frame ) {
155
+ final Object block = frame .getArguments ()[ArgumentIndicies .BLOCK .ordinal ()];
156
+ assert block == null || block instanceof RubyProc : block ;
157
+ return block ;
158
+ }
159
+
153
160
public static int getArgumentsCount (Frame frame ) {
154
161
return frame .getArguments ().length - RUNTIME_ARGUMENT_COUNT ;
155
162
}
You can’t perform that action at this time.
0 commit comments