@@ -459,7 +459,7 @@ protected RubyNode coerceToBoolean(RubyNode freeze) {
459
459
return BooleanCastWithDefaultNodeGen .create (true , freeze );
460
460
}
461
461
462
- @ Specialization
462
+ @ Specialization ( guards = { "!isNil(self)" , "!isRubyBignum(self)" , "!isRubySymbol(self)" })
463
463
protected DynamicObject clone (VirtualFrame frame , DynamicObject self , boolean freeze ,
464
464
@ Cached ("createBinaryProfile()" ) ConditionProfile isSingletonProfile ,
465
465
@ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ,
@@ -494,6 +494,73 @@ protected DynamicObject clone(VirtualFrame frame, DynamicObject self, boolean fr
494
494
return newObject ;
495
495
}
496
496
497
+ @ Specialization
498
+ protected Object cloneBoolean (boolean self , boolean freeze ,
499
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
500
+ if (freezeProfile .profile (!freeze )) {
501
+ raiseCantUnfreezeError (self );
502
+ }
503
+ return self ;
504
+ }
505
+
506
+ @ Specialization
507
+ protected Object cloneInteger (int self , boolean freeze ,
508
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
509
+ if (freezeProfile .profile (!freeze )) {
510
+ raiseCantUnfreezeError (self );
511
+ }
512
+ return self ;
513
+ }
514
+
515
+ @ Specialization
516
+ protected Object cloneLong (long self , boolean freeze ,
517
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
518
+ if (freezeProfile .profile (!freeze )) {
519
+ raiseCantUnfreezeError (self );
520
+ }
521
+ return self ;
522
+ }
523
+
524
+ @ Specialization
525
+ protected Object cloneFloat (double self , boolean freeze ,
526
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
527
+ if (freezeProfile .profile (!freeze )) {
528
+ raiseCantUnfreezeError (self );
529
+ }
530
+ return self ;
531
+ }
532
+
533
+ @ Specialization (guards = "isNil(nil)" )
534
+ protected Object cloneNil (Object nil , boolean freeze ,
535
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
536
+ if (freezeProfile .profile (!freeze )) {
537
+ raiseCantUnfreezeError (nil );
538
+ }
539
+ return nil ;
540
+ }
541
+
542
+ @ Specialization (guards = "isRubyBignum(object)" )
543
+ protected Object cloneBignum (DynamicObject object , boolean freeze ,
544
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
545
+ if (freezeProfile .profile (!freeze )) {
546
+ raiseCantUnfreezeError (object );
547
+ }
548
+ return object ;
549
+ }
550
+
551
+ @ Specialization (guards = "isRubySymbol(symbol)" )
552
+ protected Object cloneSymbol (DynamicObject symbol , boolean freeze ,
553
+ @ Cached ("createBinaryProfile()" ) ConditionProfile freezeProfile ) {
554
+ if (freezeProfile .profile (!freeze )) {
555
+ raiseCantUnfreezeError (symbol );
556
+ }
557
+ return symbol ;
558
+ }
559
+
560
+ private void raiseCantUnfreezeError (Object self ) {
561
+ throw new RaiseException (getContext (), coreExceptions ().argumentErrorCantUnfreeze (self , this ));
562
+ }
563
+
497
564
private DynamicObject executeSingletonClass (DynamicObject newObject ) {
498
565
if (singletonClassNode == null ) {
499
566
CompilerDirectives .transferToInterpreterAndInvalidate ();
0 commit comments