@@ -593,6 +593,47 @@ public Object abs(RubyBignum value) {
593
593
594
594
}
595
595
596
+ @ CoreMethod (names = "coerce" , required = 1 )
597
+ public abstract static class CoerceNode extends CoreMethodNode {
598
+
599
+ public CoerceNode (RubyContext context , SourceSection sourceSection ) {
600
+ super (context , sourceSection );
601
+ }
602
+
603
+ public CoerceNode (CoerceNode prev ) {
604
+ super (prev );
605
+ }
606
+
607
+ @ Specialization
608
+ public RubyArray coerce (RubyBignum a , int b ) {
609
+ notDesignedForCompilation ();
610
+
611
+ // TODO (eregon, 16 Feb. 2015): This is NOT spec, but let's try to see if we can make it work.
612
+ // b is converted to a Bignum here in other implementations.
613
+ Object [] store = new Object [] { b , a };
614
+ return new RubyArray (getContext ().getCoreLibrary ().getArrayClass (), store , store .length );
615
+ }
616
+
617
+ @ Specialization
618
+ public RubyArray coerce (RubyBignum a , long b ) {
619
+ notDesignedForCompilation ();
620
+
621
+ // TODO (eregon, 16 Feb. 2015): This is NOT spec, but let's try to see if we can make it work.
622
+ // b is converted to a Bignum here in other implementations.
623
+ Object [] store = new Object [] { b , a };
624
+ return new RubyArray (getContext ().getCoreLibrary ().getArrayClass (), store , store .length );
625
+ }
626
+
627
+ @ Specialization
628
+ public RubyArray coerce (RubyBignum a , RubyBignum b ) {
629
+ notDesignedForCompilation ();
630
+
631
+ Object [] store = new Object [] { b , a };
632
+ return new RubyArray (getContext ().getCoreLibrary ().getArrayClass (), store , store .length );
633
+ }
634
+
635
+ }
636
+
596
637
@ CoreMethod (names = "divmod" , required = 1 )
597
638
public abstract static class DivModNode extends CoreMethodNode {
598
639
0 commit comments