diff options
author | Takashi Kokubun <[email protected]> | 2023-03-10 23:40:57 -0800 |
---|---|---|
committer | <[email protected]> | 2023-03-10 23:40:57 -0800 |
commit | 3a02c7818cb6cbcc70957dfc449ebf32f9dd9e0b () | |
tree | d730517014017cd1ae72ee31638ec287528e4076 | |
parent | ac47b8df8f0a58d70eb35e95656d83da0c155aa0 (diff) |
Change the syntax of Primitive.attr! to Symbol (#7501)
Notes: Merged-By: k0kubun <[email protected]>
-rw-r--r-- | kernel.rb | 4 | ||||
-rw-r--r-- | numeric.rb | 28 | ||||
-rw-r--r-- | tool/mk_builtin_loader.rb | 26 |
3 files changed, 38 insertions, 20 deletions
@@ -16,7 +16,7 @@ module Kernel #++ # def class - Primitive.attr! 'inline' Primitive.cexpr! 'rb_obj_class(self)' end @@ -65,7 +65,7 @@ module Kernel #++ # def frozen? - Primitive.attr! 'inline' Primitive.cexpr! 'rb_obj_frozen_p(self)' end @@ -86,7 +86,7 @@ class Integer # # Returns +int+, negated. def -@ - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_uminus(self)' end @@ -102,7 +102,7 @@ class Integer # # sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA" def ~ - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_comp(self)' end @@ -117,7 +117,7 @@ class Integer # 12345.abs #=> 12345 # def abs - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_abs(self)' end @@ -163,7 +163,7 @@ class Integer # raise "overflow" # end def bit_length - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_bit_length(self)' end @@ -172,7 +172,7 @@ class Integer # # Returns +true+ if +int+ is an even number. def even? - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_even_p(self)' end @@ -191,7 +191,7 @@ class Integer # # Returns +true+ if +int+ is an odd number. def odd? - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_odd_p(self)' end @@ -226,7 +226,7 @@ class Integer # (256**40 - 1).size #=> 40 # def size - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_size(self)' end @@ -251,7 +251,7 @@ class Integer # # Returns +true+ if +int+ has a zero value. def zero? - Primitive.attr! 'inline' Primitive.cexpr! 'rb_int_zero_p(self)' end @@ -316,12 +316,12 @@ class Float # 34.56.abs #=> 34.56 # def abs - Primitive.attr! 'inline' Primitive.cexpr! 'rb_float_abs(self)' end def magnitude - Primitive.attr! 'inline' Primitive.cexpr! 'rb_float_abs(self)' end @@ -332,7 +332,7 @@ class Float # Returns +float+, negated. # def -@ - Primitive.attr! 'inline' Primitive.cexpr! 'rb_float_uminus(self)' end @@ -343,7 +343,7 @@ class Float # Returns +true+ if +float+ is 0.0. # def zero? - Primitive.attr! 'inline' Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))' end @@ -354,7 +354,7 @@ class Float # Returns +true+ if +float+ is greater than 0. # def positive? - Primitive.attr! 'inline' Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)' end @@ -365,7 +365,7 @@ class Float # Returns +true+ if +float+ is less than 0. # def negative? - Primitive.attr! 'inline' Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)' end @@ -6,6 +6,7 @@ require_relative 'ruby_vm/helpers/c_escape' SUBLIBS = {} REQUIRED = {} def string_literal(lit, str = []) while lit @@ -25,6 +26,17 @@ def string_literal(lit, str = []) end end def inline_text argc, arg1 raise "argc (#{argc}) of inline! should be 1" unless argc == 1 arg1 = string_literal(arg1) @@ -32,6 +44,15 @@ def inline_text argc, arg1 arg1.join("").rstrip end def make_cfunc_name inlines, name, lineno case name when /\[\]/ @@ -138,10 +159,7 @@ def collect_builtin base, tree, name, bs, inlines, locals = nil if /(.+)[\!\?]\z/ =~ func_name case $1 when 'attr' - text = inline_text(argc, args.first) - if text != 'inline' - raise "Only 'inline' is allowed to be annotated (but got: '#{text}')" - end break when 'cstmt' text = inline_text argc, args.first |