4848
4949import org .jruby .anno .JRubyClass ;
5050import org .jruby .runtime .Block ;
51+ import org .jruby .runtime .Builtins ;
5152import org .jruby .runtime .ClassIndex ;
5253import org .jruby .runtime .JavaSites .ObjectSites ;
5354import org .jruby .runtime .ObjectAllocator ;
@@ -419,7 +420,7 @@ private static boolean fastNumEqualInternal(final ThreadContext context, final I
419420 }
420421 } else if (a instanceof RubyFloat ) {
421422 if (b instanceof RubyFloat ) {
422- if (!context . sites . Float . op_equal . isBuiltin ( a )) {
423+ if (!Builtins . checkFloatEquals ( context )) {
423424 return context .sites .Float .op_equal .call (context , a , a , b ).isTrue ();
424425 }
425426 return ((RubyFloat ) a ).fastEqual ((RubyFloat ) b );
@@ -484,11 +485,12 @@ public static IRubyObject dig(ThreadContext context, IRubyObject obj, IRubyObjec
484485 for (; idx < args .length ; idx ++) {
485486 if ( obj .isNil () ) break ;
486487 IRubyObject arg = args [idx ];
487- if (isArrayDig (obj , sites )) {
488+ RubyClass metaClass = obj .getMetaClass ();
489+ if (isArrayDig (context , metaClass )) {
488490 obj = ((RubyArray ) obj ).dig (context , arg );
489- } else if (isHashDig (obj , sites )) {
491+ } else if (isHashDig (context , metaClass )) {
490492 obj = ((RubyHash ) obj ).dig (context , arg );
491- } else if (isStructDig (obj , sites )) {
493+ } else if (isStructDig (context , metaClass )) {
492494 obj = ((RubyStruct ) obj ).dig (context , arg );
493495 } else if (sites .respond_to_dig .respondsTo (context , obj , obj , true ) ) {
494496 final int len = args .length - idx ;
@@ -517,10 +519,11 @@ public static IRubyObject dig1(ThreadContext context, IRubyObject obj, IRubyObje
517519 if ( obj .isNil () ) return context .nil ;
518520
519521 ObjectSites sites = sites (context );
522+ RubyClass metaClass = obj .getMetaClass ();
520523
521- if (isArrayDig (obj , sites )) return ((RubyArray ) obj ).dig (context , arg1 );
522- if (isHashDig (obj , sites )) return ((RubyHash ) obj ).dig (context , arg1 );
523- if (isStructDig (obj , sites )) return ((RubyStruct ) obj ).dig (context , arg1 );
524+ if (isArrayDig (context , metaClass )) return ((RubyArray ) obj ).dig (context , arg1 );
525+ if (isHashDig (context , metaClass )) return ((RubyHash ) obj ).dig (context , arg1 );
526+ if (isStructDig (context , metaClass )) return ((RubyStruct ) obj ).dig (context , arg1 );
524527
525528 if (!sites .respond_to_dig .respondsTo (context , obj , obj , true )) throw typeError (context , "" , obj ," does not have #dig method" );
526529 return sites .dig_misc .call (context , obj , obj , arg1 );
@@ -529,26 +532,27 @@ public static IRubyObject dig1(ThreadContext context, IRubyObject obj, IRubyObje
529532 public static IRubyObject dig2 (ThreadContext context , IRubyObject obj , IRubyObject arg1 , IRubyObject arg2 ) {
530533 if ( obj .isNil () ) return context .nil ;
531534
535+ RubyClass metaClass = obj .getMetaClass ();
532536 ObjectSites sites = sites (context );
533537
534- if (isArrayDig (obj , sites )) return ((RubyArray ) obj ).dig (context , arg1 , arg2 );
535- if (isHashDig (obj , sites )) return ((RubyHash ) obj ).dig (context , arg1 , arg2 );
536- if (isStructDig (obj , sites )) return ((RubyStruct ) obj ).dig (context , arg1 , arg2 );
538+ if (isArrayDig (context , metaClass )) return ((RubyArray ) obj ).dig (context , arg1 , arg2 );
539+ if (isHashDig (context , metaClass )) return ((RubyHash ) obj ).dig (context , arg1 , arg2 );
540+ if (isStructDig (context , metaClass )) return ((RubyStruct ) obj ).dig (context , arg1 , arg2 );
537541
538542 if (!sites .respond_to_dig .respondsTo (context , obj , obj , true )) throw typeError (context , "" , obj ," does not have #dig method" );
539543 return sites .dig_misc .call (context , obj , obj , arg1 , arg2 );
540544 }
541545
542- private static boolean isStructDig (IRubyObject obj , ObjectSites sites ) {
543- return obj instanceof RubyStruct && sites . dig_struct . isBuiltin ( obj . getMetaClass () );
546+ private static boolean isStructDig (ThreadContext context , RubyClass metaClass ) {
547+ return metaClass == context . runtime . getStructClass () && Builtins . checkStructDig ( context );
544548 }
545549
546- private static boolean isHashDig (IRubyObject obj , ObjectSites sites ) {
547- return obj instanceof RubyHash && sites . dig_hash . isBuiltin ( obj . getMetaClass () );
550+ private static boolean isHashDig (ThreadContext context , RubyClass metaClass ) {
551+ return metaClass == context . runtime . getHash () && Builtins . checkHashDig ( context );
548552 }
549553
550- private static boolean isArrayDig (IRubyObject obj , ObjectSites sites ) {
551- return obj instanceof RubyArray && sites . dig_array . isBuiltin ( obj . getMetaClass () );
554+ private static boolean isArrayDig (ThreadContext context , RubyClass metaClass ) {
555+ return metaClass == context . runtime . getArray () && Builtins . checkArrayDig ( context );
552556 }
553557
554558 /**
0 commit comments