149
149
import com .oracle .truffle .api .RootCallTarget ;
150
150
import com .oracle .truffle .api .dsl .Cached ;
151
151
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
152
- import com .oracle .truffle .api .dsl .CreateCast ;
153
152
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
154
153
import com .oracle .truffle .api .dsl .GenerateUncached ;
155
154
import com .oracle .truffle .api .dsl .ImportStatic ;
@@ -1251,29 +1250,40 @@ protected RubyMethod method(Frame callerFrame, Object self, Object[] rubyArgs, R
1251
1250
@ CoreMethod (names = "methods" , optional = 1 )
1252
1251
@ NodeChild (value = "object" , type = RubyNode .class )
1253
1252
@ NodeChild (value = "regular" , type = RubyBaseNodeWithExecute .class )
1254
- public abstract static class MethodsNode extends CoreMethodNode {
1253
+ public abstract static class KernelMethodsNode extends CoreMethodNode {
1254
+
1255
+ @ Specialization
1256
+ protected RubyArray doMethods (Object self , Object maybeRegular ,
1257
+ @ Cached BooleanCastWithDefaultNode booleanCastWithDefaultNode ,
1258
+ @ Cached MethodsNode methodsNode ) {
1259
+ final boolean regular = booleanCastWithDefaultNode .execute (maybeRegular , true );
1260
+ return methodsNode .execute (this , self , regular );
1255
1261
1256
- @ CreateCast ("regular" )
1257
- protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute regular ) {
1258
- return BooleanCastWithDefaultNode .create (true , regular );
1259
1262
}
1263
+ }
1264
+
1265
+ @ GenerateInline
1266
+ @ GenerateCached (false )
1267
+ public abstract static class MethodsNode extends RubyBaseNode {
1268
+
1269
+ public abstract RubyArray execute (Node node , Object self , boolean regular );
1260
1270
1261
1271
@ TruffleBoundary
1262
1272
@ Specialization (guards = "regular" )
1263
- protected RubyArray methodsRegular (Object self , boolean regular ,
1273
+ protected static RubyArray methodsRegular (Node node , Object self , boolean regular ,
1264
1274
@ Cached MetaClassNode metaClassNode ) {
1265
- final RubyModule metaClass = metaClassNode .execute (this , self );
1275
+ final RubyModule metaClass = metaClassNode .execute (node , self );
1266
1276
1267
1277
Object [] objects = metaClass .fields
1268
- .filterMethodsOnObject (getLanguage (), regular , MethodFilter .PUBLIC_PROTECTED )
1278
+ .filterMethodsOnObject (getLanguage (node ), regular , MethodFilter .PUBLIC_PROTECTED )
1269
1279
.toArray ();
1270
- return createArray (objects );
1280
+ return createArray (node , objects );
1271
1281
}
1272
1282
1273
1283
@ Specialization (guards = "!regular" )
1274
- protected RubyArray methodsSingleton (Object self , boolean regular ,
1284
+ protected static RubyArray methodsSingleton (Node node , Object self , boolean regular ,
1275
1285
@ Cached SingletonMethodsNode singletonMethodsNode ) {
1276
- return singletonMethodsNode .execute (this , self , false );
1286
+ return singletonMethodsNode .execute (node , self , false );
1277
1287
}
1278
1288
1279
1289
}
@@ -1312,15 +1322,12 @@ private void print(Object inspected) {
1312
1322
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1313
1323
public abstract static class PrivateMethodsNode extends CoreMethodNode {
1314
1324
1315
- @ CreateCast ("includeAncestors" )
1316
- protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1317
- return BooleanCastWithDefaultNode .create (true , includeAncestors );
1318
- }
1319
-
1320
1325
@ TruffleBoundary
1321
1326
@ Specialization
1322
- protected RubyArray privateMethods (Object self , boolean includeAncestors ,
1327
+ protected RubyArray privateMethods (Object self , Object maybeIncludeAncestors ,
1328
+ @ Cached BooleanCastWithDefaultNode booleanCastWithDefaultNode ,
1323
1329
@ Cached MetaClassNode metaClassNode ) {
1330
+ final boolean includeAncestors = booleanCastWithDefaultNode .execute (maybeIncludeAncestors , true );
1324
1331
RubyClass metaClass = metaClassNode .execute (this , self );
1325
1332
1326
1333
Object [] objects = metaClass .fields
@@ -1347,15 +1354,12 @@ protected RubyProc proc(VirtualFrame frame, Object maybeBlock,
1347
1354
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1348
1355
public abstract static class ProtectedMethodsNode extends CoreMethodNode {
1349
1356
1350
- @ CreateCast ("includeAncestors" )
1351
- protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1352
- return BooleanCastWithDefaultNode .create (true , includeAncestors );
1353
- }
1354
-
1355
1357
@ TruffleBoundary
1356
1358
@ Specialization
1357
- protected RubyArray protectedMethods (Object self , boolean includeAncestors ,
1359
+ protected RubyArray protectedMethods (Object self , Object maybeIncludeAncestors ,
1360
+ @ Cached BooleanCastWithDefaultNode booleanCastWithDefaultNode ,
1358
1361
@ Cached MetaClassNode metaClassNode ) {
1362
+ final boolean includeAncestors = booleanCastWithDefaultNode .execute (maybeIncludeAncestors , true );
1359
1363
final RubyClass metaClass = metaClassNode .execute (this , self );
1360
1364
1361
1365
Object [] objects = metaClass .fields
@@ -1386,16 +1390,13 @@ protected RubyMethod method(Frame callerFrame, Object self, Object[] rubyArgs, R
1386
1390
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1387
1391
public abstract static class PublicMethodsNode extends CoreMethodNode {
1388
1392
1389
- @ CreateCast ("includeAncestors" )
1390
- protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1391
- return BooleanCastWithDefaultNode .create (true , includeAncestors );
1392
- }
1393
-
1394
1393
@ TruffleBoundary
1395
1394
@ Specialization
1396
- protected RubyArray publicMethods (Object self , boolean includeAncestors ,
1395
+ protected RubyArray publicMethods (Object self , Object maybeIncludeAncestors ,
1396
+ @ Cached BooleanCastWithDefaultNode booleanCastWithDefaultNode ,
1397
1397
@ Cached MetaClassNode metaClassNode ) {
1398
1398
final RubyModule metaClass = metaClassNode .execute (this , self );
1399
+ final boolean includeAncestors = booleanCastWithDefaultNode .execute (maybeIncludeAncestors , true );
1399
1400
1400
1401
Object [] objects = metaClass .fields
1401
1402
.filterMethodsOnObject (getLanguage (), includeAncestors , MethodFilter .PUBLIC )
@@ -1557,14 +1558,11 @@ protected RubyMethod singletonMethod(Object self, Object nameObject,
1557
1558
@ NodeChild (value = "includeAncestors" , type = RubyBaseNodeWithExecute .class )
1558
1559
public abstract static class KernelSingletonMethodsNode extends CoreMethodNode {
1559
1560
1560
- @ CreateCast ("includeAncestors" )
1561
- protected RubyBaseNodeWithExecute coerceToBoolean (RubyBaseNodeWithExecute includeAncestors ) {
1562
- return BooleanCastWithDefaultNode .create (true , includeAncestors );
1563
- }
1564
-
1565
1561
@ Specialization
1566
- protected RubyArray singletonMethods (Object self , boolean includeAncestors ,
1562
+ protected RubyArray singletonMethods (Object self , Object maybeIncludeAncestors ,
1563
+ @ Cached BooleanCastWithDefaultNode booleanCastWithDefaultNode ,
1567
1564
@ Cached SingletonMethodsNode singletonMethodsNode ) {
1565
+ final boolean includeAncestors = booleanCastWithDefaultNode .execute (maybeIncludeAncestors , true );
1568
1566
return singletonMethodsNode .execute (this , self , includeAncestors );
1569
1567
}
1570
1568
}
0 commit comments