9
9
*/
10
10
package org .truffleruby .core .range ;
11
11
12
+ import com .oracle .truffle .api .dsl .Bind ;
12
13
import com .oracle .truffle .api .profiles .LoopConditionProfile ;
13
14
import org .truffleruby .builtins .CoreMethod ;
14
15
import org .truffleruby .builtins .CoreMethodArrayArgumentsNode ;
@@ -223,7 +224,8 @@ protected RubyObjectRange dup(RubyObjectRange range) {
223
224
getLanguage ().objectRangeShape ,
224
225
range .excludedEnd ,
225
226
range .begin ,
226
- range .end );
227
+ range .end ,
228
+ range .frozen );
227
229
AllocationTracing .trace (copy , this );
228
230
return copy ;
229
231
}
@@ -546,16 +548,17 @@ protected RubyLongRange longRange(RubyClass rubyClass, long begin, long end, boo
546
548
return range ;
547
549
}
548
550
549
- @ Specialization (guards = { "rubyClass != getRangeClass() || (!isImplicitLong(begin) || !isImplicitLong(end))" })
551
+ @ Specialization (guards = { "nonStandardClass || (!isImplicitLong(begin) || !isImplicitLong(end))" })
550
552
protected RubyObjectRange objectRange (RubyClass rubyClass , Object begin , Object end , boolean excludeEnd ,
551
- @ Cached DispatchNode compare ) {
553
+ @ Cached DispatchNode compare , @ Bind ( "rubyClass != getRangeClass()" ) boolean nonStandardClass ) {
552
554
553
555
if (compare .call (begin , "<=>" , end ) == nil && end != nil && begin != nil ) {
554
556
throw new RaiseException (getContext (), coreExceptions ().argumentError ("bad value for range" , this ));
555
557
}
556
558
557
559
final Shape shape = getLanguage ().objectRangeShape ;
558
- final RubyObjectRange range = new RubyObjectRange (rubyClass , shape , excludeEnd , begin , end );
560
+ final RubyObjectRange range = new RubyObjectRange (rubyClass , shape , excludeEnd , begin , end ,
561
+ !nonStandardClass );
559
562
AllocationTracing .trace (range , this );
560
563
return range ;
561
564
}
@@ -571,7 +574,7 @@ public abstract static class AllocateNode extends UnaryCoreMethodNode {
571
574
@ Specialization
572
575
protected RubyObjectRange allocate (RubyClass rubyClass ) {
573
576
final Shape shape = getLanguage ().objectRangeShape ;
574
- final RubyObjectRange range = new RubyObjectRange (rubyClass , shape , false , nil , nil );
577
+ final RubyObjectRange range = new RubyObjectRange (rubyClass , shape , false , nil , nil , false );
575
578
AllocationTracing .trace (range , this );
576
579
return range ;
577
580
}
0 commit comments