41
41
import org .truffleruby .language .arguments .RubyArguments ;
42
42
import org .truffleruby .language .control .RaiseException ;
43
43
import org .truffleruby .language .locals .FindDeclarationVariableNodes ;
44
- import org .truffleruby .language .locals .FindDeclarationVariableNodes .FindAndReadDeclarationVariableNode ;
45
44
import org .truffleruby .language .locals .FindDeclarationVariableNodes .FrameSlotAndDepth ;
46
45
import org .truffleruby .language .locals .FrameDescriptorNamesIterator ;
47
46
import org .truffleruby .language .locals .WriteFrameSlotNode ;
@@ -278,24 +277,12 @@ public RubyNode cloneUninitialized() {
278
277
279
278
}
280
279
281
- @ GenerateUncached
282
280
@ GenerateNodeFactory
283
281
@ CoreMethod (names = "local_variable_get" , required = 1 )
284
282
@ NodeChild (value = "bindingNode" , type = RubyNode .class )
285
283
@ NodeChild (value = "nameNode" , type = RubyBaseNodeWithExecute .class )
286
284
@ ImportStatic (BindingNodes .class )
287
- public abstract static class LocalVariableGetNode extends RubySourceNode {
288
-
289
- @ NeverDefault
290
- public static LocalVariableGetNode create () {
291
- return BindingNodesFactory .LocalVariableGetNodeFactory .create (null , null );
292
- }
293
-
294
- public static LocalVariableGetNode create (RubyNode bindingNode , RubyBaseNodeWithExecute nameNode ) {
295
- return BindingNodesFactory .LocalVariableGetNodeFactory .create (bindingNode , nameNode );
296
- }
297
-
298
- public abstract Object execute (RubyBinding binding , String name );
285
+ public abstract static class BindingLocalVariableGetNode extends RubySourceNode {
299
286
300
287
abstract RubyNode getBindingNode ();
301
288
@@ -306,29 +293,10 @@ protected RubyBaseNodeWithExecute coerceToString(RubyBaseNodeWithExecute name) {
306
293
return NameToJavaStringNode .create (name );
307
294
}
308
295
309
- @ Specialization ( guards = "!isHiddenVariable(name)" )
296
+ @ Specialization
310
297
protected Object localVariableGet (RubyBinding binding , String name ,
311
- @ Cached FindAndReadDeclarationVariableNode readNode ) {
312
- MaterializedFrame frame = binding .getFrame ();
313
- Object result = readNode .execute (frame , name , null );
314
- if (result == null ) {
315
- throw new RaiseException (
316
- getContext (),
317
- coreExceptions ().nameErrorLocalVariableNotDefined (name , binding , this ));
318
- }
319
- return result ;
320
- }
321
-
322
- @ TruffleBoundary
323
- @ Specialization (guards = "isHiddenVariable(name)" )
324
- protected Object localVariableGetLastLine (RubyBinding binding , String name ) {
325
- throw new RaiseException (
326
- getContext (),
327
- coreExceptions ().nameError ("Bad local variable name" , binding , name , this ));
328
- }
329
-
330
- protected int getCacheLimit () {
331
- return getLanguage ().options .BINDING_LOCAL_VARIABLE_CACHE ;
298
+ @ Cached LocalVariableGetNode localVariableGetNode ) {
299
+ return localVariableGetNode .execute (binding , name );
332
300
}
333
301
334
302
private RubyBaseNodeWithExecute getNameNodeBeforeCasting () {
@@ -337,11 +305,10 @@ private RubyBaseNodeWithExecute getNameNodeBeforeCasting() {
337
305
338
306
@ Override
339
307
public RubyNode cloneUninitialized () {
340
- return create (
308
+ return BindingNodesFactory . BindingLocalVariableGetNodeFactory . create (
341
309
getBindingNode ().cloneUninitialized (),
342
310
getNameNodeBeforeCasting ().cloneUninitialized ()).copyFlags (this );
343
311
}
344
-
345
312
}
346
313
347
314
@ ReportPolymorphism
0 commit comments