Skip to content

Commit 969e184

Browse files
committed
Rename Primitive.object_kind_of? to Primitive.is_a?
1 parent d24019b commit 969e184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+379
-379
lines changed

lib/truffle/digest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def size
138138
alias_method :length, :size
139139

140140
def ==(other)
141-
if Primitive.object_kind_of?(other, Digest::Instance)
141+
if Primitive.is_a?(other, Digest::Instance)
142142
self_str = self.digest
143143
other_str = other.digest
144144
else

lib/truffle/io/wait.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def wait_priority(timeout = nil)
5252
def wait(*args)
5353
ensure_open
5454

55-
if args.size != 2 || Primitive.object_kind_of?(args[0], Symbol) || Primitive.object_kind_of?(args[1], Symbol)
55+
if args.size != 2 || Primitive.is_a?(args[0], Symbol) || Primitive.is_a?(args[1], Symbol)
5656
# Slow/messy path:
5757
timeout = :undef
5858
events = 0
5959
args.each do |arg|
60-
if Primitive.object_kind_of?(arg, Symbol)
60+
if Primitive.is_a?(arg, Symbol)
6161
events |= case arg
6262
when :r, :read, :readable then IO::READABLE
6363
when :w, :write, :writable then IO::WRITABLE

lib/truffle/objspace.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def count_tdata_objects(hash = {})
7878

7979
# Helper method for ObjectSpace.dump
8080
def _dump(object, output)
81-
if Primitive.object_kind_of?(output, String)
81+
if Primitive.is_a?(output, String)
8282
require 'json'
8383
json = {
8484
address: '0x' + object.object_id.to_s(16),
@@ -120,7 +120,7 @@ def _dump(object, output)
120120

121121
# Helper method for ObjectSpace.dump_all
122122
def _dump_all(output, full, since)
123-
if Primitive.object_kind_of?(output, String)
123+
if Primitive.is_a?(output, String)
124124
objects = []
125125
ObjectSpace.each_object do |object|
126126
objects.push dump(object)

lib/truffle/strscan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def peep(len)
333333
private def scan_internal(pattern, advance_pos, getstr, headonly)
334334
scan_check_args(pattern, headonly)
335335

336-
if Primitive.object_kind_of?(pattern, String)
336+
if Primitive.is_a?(pattern, String)
337337
md = scan_internal_string_pattern(pattern)
338338
else
339339
start = @fixed_anchor ? 0 : @pos

lib/truffle/truffle/cext.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def rbimpl_rtypeddata_p(obj)
266266
end
267267

268268
def ensure_class(obj, klass, message = 'expected class %s, but object class is %s')
269-
raise TypeError, format(message, klass, Primitive.object_class(obj)) unless Primitive.object_kind_of?(obj, klass)
269+
raise TypeError, format(message, klass, Primitive.object_class(obj)) unless Primitive.is_a?(obj, klass)
270270
end
271271

272272
def rb_method_boundp(klass, id, ex)
@@ -282,7 +282,7 @@ def rb_obj_is_instance_of(object, ruby_class)
282282
end
283283

284284
def rb_obj_is_kind_of(object, ruby_class)
285-
Primitive.object_kind_of?(object, ruby_class)
285+
Primitive.is_a?(object, ruby_class)
286286
end
287287

288288
def SYMBOL_P(value)
@@ -310,7 +310,7 @@ def RB_FIXNUM_P(value)
310310
end
311311

312312
def RB_FLOAT_TYPE_P(value)
313-
Primitive.object_kind_of?(value, Float)
313+
Primitive.is_a?(value, Float)
314314
end
315315

316316
def rb_integer_type_p(value)
@@ -406,7 +406,7 @@ def rb_num_coerce_relop(x, y, func)
406406
if Primitive.nil?(ary) && !raise_error
407407
return nil
408408
end
409-
if !Primitive.object_kind_of?(ary, Array) || ary.size != 2
409+
if !Primitive.is_a?(ary, Array) || ary.size != 2
410410
raise TypeError, 'coerce must return [x, y]'
411411
end
412412
ary
@@ -785,7 +785,7 @@ def coderange_java_to_rb(cr)
785785
end
786786

787787
def RB_ENC_CODERANGE(obj)
788-
if Primitive.object_kind_of?(obj, String)
788+
if Primitive.is_a?(obj, String)
789789
rb_enc_str_coderange(obj)
790790
else
791791
raise "Unknown coderange for obj with class `#{obj.class}`"
@@ -847,7 +847,7 @@ def rb_enc_get_index(obj)
847847
0
848848
end
849849
end
850-
enc = rb_enc_to_index(enc) if Primitive.object_kind_of?(enc, Encoding)
850+
enc = rb_enc_to_index(enc) if Primitive.is_a?(enc, Encoding)
851851
enc
852852
end
853853

@@ -1007,7 +1007,7 @@ def rb_path_to_class(path)
10071007
rescue NameError
10081008
raise ArgumentError, "undefined class/module #{path}"
10091009
end
1010-
unless Primitive.object_kind_of?(const, ::Module)
1010+
unless Primitive.is_a?(const, ::Module)
10111011
raise TypeError, "#{path} does not refer to class/module"
10121012
end
10131013
const
@@ -1129,7 +1129,7 @@ def rb_exc_raise(exception)
11291129
end
11301130

11311131
def rb_set_errinfo(error)
1132-
if Primitive.nil?(error) || Primitive.object_kind_of?(error, Exception)
1132+
if Primitive.nil?(error) || Primitive.is_a?(error, Exception)
11331133
Primitive.thread_set_exception(error)
11341134
else
11351135
raise TypeError, 'assigning non-exception to ?!'
@@ -1544,7 +1544,7 @@ def rb_tr_error(message)
15441544
def test_kwargs(kwargs, raise_error)
15451545
return false if kwargs.nil?
15461546

1547-
if Primitive.object_kind_of?(kwargs, Hash) && kwargs.keys.all? { |k| Primitive.object_kind_of?(k, Symbol) }
1547+
if Primitive.is_a?(kwargs, Hash) && kwargs.keys.all? { |k| Primitive.is_a?(k, Symbol) }
15481548
true
15491549
elsif raise_error
15501550
raise ArgumentError, "the value is not a Hash with all keys being Symbols as kwargs requires: #{kwargs}"
@@ -1698,7 +1698,7 @@ def rb_time_num_new(timev, off)
16981698

16991699
def rb_time_interval_acceptable(time_val)
17001700
# TODO (pitr-ch 09-Mar-2017): more precise error messages
1701-
raise TypeError, 'cannot be Time' if Primitive.object_kind_of?(time_val, Time)
1701+
raise TypeError, 'cannot be Time' if Primitive.is_a?(time_val, Time)
17021702
raise ArgumentError, 'cannot be negative' if time_val < 0
17031703
end
17041704

@@ -1789,7 +1789,7 @@ def rb_obj_as_string(object)
17891789
end
17901790

17911791
def rb_class_inherited_p(ruby_module, object)
1792-
if Primitive.object_kind_of?(object, Module)
1792+
if Primitive.is_a?(object, Module)
17931793
ruby_module <= object
17941794
else
17951795
raise TypeError

src/main/java/org/truffleruby/core/support/TypeNodes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
@CoreModule("Truffle::Type")
6767
public abstract class TypeNodes {
6868

69-
@Primitive(name = "object_kind_of?")
70-
public abstract static class ObjectKindOfNode extends PrimitiveArrayArgumentsNode {
69+
@Primitive(name = "is_a?")
70+
public abstract static class IsAPrimitiveNode extends PrimitiveArrayArgumentsNode {
7171
@Specialization
72-
protected boolean objectKindOf(Object object, RubyModule module,
72+
protected boolean isA(Object object, RubyModule module,
7373
@Cached IsANode isANode) {
7474
return isANode.executeIsA(object, module);
7575
}

src/main/ruby/truffleruby/core/array.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def ==(other)
126126
end
127127

128128
return true if Primitive.object_equal(self, other)
129-
unless Primitive.object_kind_of?(other, Array)
129+
unless Primitive.is_a?(other, Array)
130130
return false unless other.respond_to? :to_ary
131131
return other == self
132132
end
@@ -204,7 +204,7 @@ def ==(other)
204204

205205
def assoc(obj)
206206
each do |x|
207-
if Primitive.object_kind_of?(x, Array) and x.first == obj
207+
if Primitive.is_a?(x, Array) and x.first == obj
208208
return x
209209
end
210210
end
@@ -382,7 +382,7 @@ def eql?(other)
382382
end
383383

384384
return true if Primitive.object_equal(self, other)
385-
return false unless Primitive.object_kind_of?(other, Array)
385+
return false unless Primitive.is_a?(other, Array)
386386
return false if size != other.size
387387

388388
Truffle::ThreadOperations.detect_pair_recursion self, other do
@@ -442,7 +442,7 @@ def fetch(idx, default = undefined)
442442
if Primitive.undefined?(index) || !index
443443
left = 0
444444
right = size
445-
elsif Primitive.object_kind_of?(index, Range)
445+
elsif Primitive.is_a?(index, Range)
446446
raise TypeError, 'length invalid with range' unless Primitive.undefined?(length)
447447

448448
left, length = Primitive.range_normalized_start_length(index, size)
@@ -862,7 +862,7 @@ def product(*args)
862862

863863
def rassoc(obj)
864864
each do |elem|
865-
if Primitive.object_kind_of?(elem, Array) and elem.at(1) == obj
865+
if Primitive.is_a?(elem, Array) and elem.at(1) == obj
866866
return elem
867867
end
868868
end
@@ -1334,7 +1334,7 @@ def values_at(*args)
13341334

13351335
args.each do |elem|
13361336
# Cannot use #[] because of subtly different errors
1337-
if Primitive.object_kind_of?(elem, Range)
1337+
if Primitive.is_a?(elem, Range)
13381338
start, length = Primitive.range_normalized_start_length(elem, size)
13391339
finish = start + length - 1
13401340
next if start < 0
@@ -1351,7 +1351,7 @@ def values_at(*args)
13511351

13521352
# Synchronize with Enumerator#zip and Enumerable#zip
13531353
def zip(*others)
1354-
if !block_given? and others.size == 1 and Primitive.object_kind_of?(others[0], Array)
1354+
if !block_given? and others.size == 1 and Primitive.is_a?(others[0], Array)
13551355
return Primitive.array_zip self, others[0]
13561356
end
13571357

@@ -1619,7 +1619,7 @@ def slice!(start, length = undefined)
16191619
Primitive.check_frozen self
16201620

16211621
if Primitive.undefined? length
1622-
if Primitive.object_kind_of?(start, Range)
1622+
if Primitive.is_a?(start, Range)
16231623
range = start
16241624
out = self[range]
16251625

src/main/ruby/truffleruby/core/comparable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def between?(min, max)
8282
def clamp(min, max = undefined)
8383
if Primitive.undefined?(max)
8484
range = min
85-
raise TypeError, "wrong argument type #{Primitive.object_class(range)} (expected Range)" unless Primitive.object_kind_of?(range, Range)
85+
raise TypeError, "wrong argument type #{Primitive.object_class(range)} (expected Range)" unless Primitive.is_a?(range, Range)
8686
raise ArgumentError, 'cannot clamp with an exclusive range' if range.exclude_end?
8787
min, max = range.begin, range.end
8888
end
@@ -96,7 +96,7 @@ def clamp(min, max = undefined)
9696

9797
# A version of MRI's rb_cmpint (sort of)
9898
def self.compare_int(int)
99-
return int if Primitive.object_kind_of?(int, Integer)
99+
return int if Primitive.is_a?(int, Integer)
100100

101101
return 1 if int > 0
102102
return -1 if int < 0

0 commit comments

Comments
 (0)