96
96
import org .truffleruby .language .RubyRootNode ;
97
97
import org .truffleruby .language .RubySourceNode ;
98
98
import org .truffleruby .language .Visibility ;
99
- import org .truffleruby .language .WarnNode ;
100
99
import org .truffleruby .language .WarningNode ;
101
100
import org .truffleruby .language .arguments .ReadCallerFrameNode ;
102
101
import org .truffleruby .language .arguments .RubyArguments ;
148
147
import com .oracle .truffle .api .dsl .ReportPolymorphism ;
149
148
import com .oracle .truffle .api .dsl .Specialization ;
150
149
import com .oracle .truffle .api .frame .FrameDescriptor ;
151
- import com .oracle .truffle .api .frame .FrameInstance .FrameAccess ;
152
150
import com .oracle .truffle .api .frame .FrameSlot ;
153
151
import com .oracle .truffle .api .frame .MaterializedFrame ;
154
152
import com .oracle .truffle .api .frame .VirtualFrame ;
@@ -1191,33 +1189,9 @@ protected boolean isATypeError(Object self, Object module) {
1191
1189
@ CoreMethod (names = "lambda" , isModuleFunction = true , needsBlock = true )
1192
1190
public abstract static class LambdaNode extends CoreMethodArrayArgumentsNode {
1193
1191
1194
- @ Child private WarnNode warnNode ;
1195
-
1196
- @ TruffleBoundary
1197
1192
@ Specialization
1198
- protected RubyProc lambda (NotProvided block ,
1199
- @ Cached FindAndReadDeclarationVariableNode readNode ) {
1200
- final MaterializedFrame parentFrame = getContext ()
1201
- .getCallStack ()
1202
- .getCallerFrameIgnoringSend (FrameAccess .MATERIALIZE )
1203
- .materialize ();
1204
- Object parentBlock = readNode
1205
- .execute (parentFrame , TranslatorEnvironment .METHOD_BLOCK_NAME , nil );
1206
-
1207
- if (parentBlock == nil ) {
1208
- throw new RaiseException (
1209
- getContext (),
1210
- coreExceptions ().argumentError ("tried to create Proc object without a block" , this ));
1211
- } else {
1212
- warnProcWithoutBlock ();
1213
- }
1214
-
1215
- Node callNode = getContext ().getCallStack ().getCallerNode (2 , true );
1216
- if (isLiteralBlock (callNode )) {
1217
- return lambdaFromBlock ((RubyProc ) parentBlock );
1218
- } else {
1219
- return (RubyProc ) parentBlock ;
1220
- }
1193
+ protected RubyProc lambda (NotProvided block ) {
1194
+ throw new RaiseException (getContext (), coreExceptions ().argumentErrorProcWithoutBlock (this ));
1221
1195
}
1222
1196
1223
1197
@ Specialization (guards = "isLiteralBlock(block)" )
@@ -1240,19 +1214,6 @@ private boolean isLiteralBlock(Node callNode) {
1240
1214
RubyCallNode rubyCallNode = NodeUtil .findParent (callNode , RubyCallNode .class );
1241
1215
return rubyCallNode != null && rubyCallNode .hasLiteralBlock ();
1242
1216
}
1243
-
1244
- private void warnProcWithoutBlock () {
1245
- if (warnNode == null ) {
1246
- CompilerDirectives .transferToInterpreterAndInvalidate ();
1247
- warnNode = insert (new WarnNode ());
1248
- }
1249
-
1250
- if (warnNode .shouldWarn ()) {
1251
- final SourceSection sourceSection = getContext ().getCallStack ().getTopMostUserSourceSection ();
1252
- warnNode .warningMessage (sourceSection , "tried to create Proc object without a block" );
1253
- }
1254
- }
1255
-
1256
1217
}
1257
1218
1258
1219
@ CoreMethod (names = "__method__" , isModuleFunction = true )
0 commit comments