@@ -569,7 +569,7 @@ protected RubyDynamicObject copyable(Object object, Object freeze,
569
569
final RubyDynamicObject newObject = copyNode .executeCopy (object );
570
570
571
571
// Copy the singleton class if any.
572
- final RubyClass selfMetaClass = metaClassNode .execute (object );
572
+ final RubyClass selfMetaClass = metaClassNode .execute (this , object );
573
573
if (isSingletonProfile .profile (this , selfMetaClass .isSingleton )) {
574
574
final RubyClass newObjectMetaClass = executeSingletonClass (newObject );
575
575
newObjectMetaClass .fields .initCopy (selfMetaClass );
@@ -1261,7 +1261,7 @@ protected RubyBaseNodeWithExecute coerceToBoolean(RubyBaseNodeWithExecute regula
1261
1261
@ Specialization (guards = "regular" )
1262
1262
protected RubyArray methodsRegular (Object self , boolean regular ,
1263
1263
@ Cached MetaClassNode metaClassNode ) {
1264
- final RubyModule metaClass = metaClassNode .execute (self );
1264
+ final RubyModule metaClass = metaClassNode .execute (this , self );
1265
1265
1266
1266
Object [] objects = metaClass .fields
1267
1267
.filterMethodsOnObject (getLanguage (), regular , MethodFilter .PUBLIC_PROTECTED )
@@ -1311,17 +1311,16 @@ private void print(Object inspected) {
1311
1311
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1312
1312
public abstract static class PrivateMethodsNode extends CoreMethodNode {
1313
1313
1314
- @ Child private MetaClassNode metaClassNode = MetaClassNode .create ();
1315
-
1316
1314
@ CreateCast ("includeAncestors" )
1317
1315
protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1318
1316
return BooleanCastWithDefaultNode .create (true , includeAncestors );
1319
1317
}
1320
1318
1321
1319
@ TruffleBoundary
1322
1320
@ Specialization
1323
- protected RubyArray privateMethods (Object self , boolean includeAncestors ) {
1324
- RubyClass metaClass = metaClassNode .execute (self );
1321
+ protected RubyArray privateMethods (Object self , boolean includeAncestors ,
1322
+ @ Cached MetaClassNode metaClassNode ) {
1323
+ RubyClass metaClass = metaClassNode .execute (this , self );
1325
1324
1326
1325
Object [] objects = metaClass .fields
1327
1326
.filterMethodsOnObject (getLanguage (), includeAncestors , MethodFilter .PRIVATE )
@@ -1347,17 +1346,16 @@ protected RubyProc proc(VirtualFrame frame, Object maybeBlock,
1347
1346
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1348
1347
public abstract static class ProtectedMethodsNode extends CoreMethodNode {
1349
1348
1350
- @ Child private MetaClassNode metaClassNode = MetaClassNode .create ();
1351
-
1352
1349
@ CreateCast ("includeAncestors" )
1353
1350
protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1354
1351
return BooleanCastWithDefaultNode .create (true , includeAncestors );
1355
1352
}
1356
1353
1357
1354
@ TruffleBoundary
1358
1355
@ Specialization
1359
- protected RubyArray protectedMethods (Object self , boolean includeAncestors ) {
1360
- final RubyClass metaClass = metaClassNode .execute (self );
1356
+ protected RubyArray protectedMethods (Object self , boolean includeAncestors ,
1357
+ @ Cached MetaClassNode metaClassNode ) {
1358
+ final RubyClass metaClass = metaClassNode .execute (this , self );
1361
1359
1362
1360
Object [] objects = metaClass .fields
1363
1361
.filterMethodsOnObject (getLanguage (), includeAncestors , MethodFilter .PROTECTED )
@@ -1387,17 +1385,16 @@ protected RubyMethod method(Frame callerFrame, Object self, Object[] rubyArgs, R
1387
1385
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1388
1386
public abstract static class PublicMethodsNode extends CoreMethodNode {
1389
1387
1390
- @ Child private MetaClassNode metaClassNode = MetaClassNode .create ();
1391
-
1392
1388
@ CreateCast ("includeAncestors" )
1393
1389
protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1394
1390
return BooleanCastWithDefaultNode .create (true , includeAncestors );
1395
1391
}
1396
1392
1397
1393
@ TruffleBoundary
1398
1394
@ Specialization
1399
- protected RubyArray publicMethods (Object self , boolean includeAncestors ) {
1400
- final RubyModule metaClass = metaClassNode .execute (self );
1395
+ protected RubyArray publicMethods (Object self , boolean includeAncestors ,
1396
+ @ Cached MetaClassNode metaClassNode ) {
1397
+ final RubyModule metaClass = metaClassNode .execute (this , self );
1401
1398
1402
1399
Object [] objects = metaClass .fields
1403
1400
.filterMethodsOnObject (getLanguage (), includeAncestors , MethodFilter .PUBLIC )
@@ -1524,7 +1521,6 @@ protected RubyClass singletonClass(Object self) {
1524
1521
@ NodeChild (value = "name" , type = RubyBaseNodeWithExecute .class )
1525
1522
public abstract static class SingletonMethodNode extends CoreMethodNode {
1526
1523
1527
- @ Child private MetaClassNode metaClassNode = MetaClassNode .create ();
1528
1524
1529
1525
@ CreateCast ("name" )
1530
1526
protected RubyBaseNodeWithExecute coerceToString (RubyBaseNodeWithExecute name ) {
@@ -1535,8 +1531,9 @@ protected RubyBaseNodeWithExecute coerceToString(RubyBaseNodeWithExecute name) {
1535
1531
protected RubyMethod singletonMethod (Object self , String name ,
1536
1532
@ Cached InlinedBranchProfile errorProfile ,
1537
1533
@ Cached InlinedConditionProfile singletonProfile ,
1538
- @ Cached InlinedConditionProfile methodProfile ) {
1539
- final RubyClass metaClass = metaClassNode .execute (self );
1534
+ @ Cached InlinedConditionProfile methodProfile ,
1535
+ @ Cached MetaClassNode metaClassNode ) {
1536
+ final RubyClass metaClass = metaClassNode .execute (this , self );
1540
1537
1541
1538
if (singletonProfile .profile (this , metaClass .isSingleton )) {
1542
1539
final InternalMethod method = metaClass .fields .getMethod (name );
@@ -1580,7 +1577,7 @@ protected RubyBaseNodeWithExecute coerceToBoolean(RubyBaseNodeWithExecute includ
1580
1577
@ Specialization
1581
1578
protected RubyArray singletonMethods (Object self , boolean includeAncestors ,
1582
1579
@ Cached MetaClassNode metaClassNode ) {
1583
- final RubyClass metaClass = metaClassNode .execute (self );
1580
+ final RubyClass metaClass = metaClassNode .execute (this , self );
1584
1581
1585
1582
if (!metaClass .isSingleton ) {
1586
1583
return createEmptyArray ();
@@ -1601,7 +1598,7 @@ public abstract static class HasSingletonMethodsNode extends PrimitiveArrayArgum
1601
1598
@ Specialization
1602
1599
protected boolean hasSingletonMethods (Object self ,
1603
1600
@ Cached MetaClassNode metaClassNode ) {
1604
- final RubyClass metaClass = metaClassNode .execute (self );
1601
+ final RubyClass metaClass = metaClassNode .execute (this , self );
1605
1602
1606
1603
if (!metaClass .isSingleton ) {
1607
1604
return false ;
0 commit comments