diff options
| author | YAMAMOTO Masaya <[email protected]> | 2017-10-11 17:53:17 +0900 |
|---|---|---|
| committer | YAMAMOTO Masaya <[email protected]> | 2017-10-11 17:58:11 +0900 |
| commit | acdc2d1f242f2547ca842be5d62a2b06356b39ea (patch) | |
| tree | 3479c21be76ce7edde6a5fcacb6f60c1a5698a8a /mrblib | |
| parent | 679dfd75a8aeb26ee4ff0d7c148e1f6e88e39c3d (diff) | |
| download | mruby-acdc2d1f242f2547ca842be5d62a2b06356b39ea.tar.gz mruby-acdc2d1f242f2547ca842be5d62a2b06356b39ea.zip | |
Add MRB_WITHOUT_FLOAT
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/float.rb | 9 | ||||
| -rw-r--r-- | mrblib/mrblib.rake | 3 | ||||
| -rw-r--r-- | mrblib/numeric.rb | 12 |
3 files changed, 13 insertions, 11 deletions
diff --git a/mrblib/float.rb b/mrblib/float.rb new file mode 100644 index 000000000..6343b9b85 --- /dev/null +++ b/mrblib/float.rb @@ -0,0 +1,9 @@ +## +# Float +# +# ISO 15.2.9 +class Float + # mruby special - since mruby integers may be upgraded to floats, + # floats should be compatible to integers. + include Integral +end diff --git a/mrblib/mrblib.rake b/mrblib/mrblib.rake index 19fd00d66..fe4aae1f7 100644 --- a/mrblib/mrblib.rake +++ b/mrblib/mrblib.rake @@ -8,6 +8,9 @@ MRuby.each_target do file objfile("#{current_build_dir}/mrblib") => "#{current_build_dir}/mrblib.c" file "#{current_build_dir}/mrblib.c" => [mrbcfile, __FILE__] + Dir.glob("#{current_dir}/*.rb").sort do |t| _, _, *rbfiles = t.prerequisites + if self.cc.defines.flatten.include?("MRB_WITHOUT_FLOAT") + rbfiles.delete("#{current_dir}/float.rb") + end FileUtils.mkdir_p File.dirname(t.name) open(t.name, 'w') do |f| _pp "GEN", "*.rb", "#{t.name.relative_path}" diff --git a/mrblib/numeric.rb b/mrblib/numeric.rb index 89401a084..1b11e92ad 100644 --- a/mrblib/numeric.rb +++ b/mrblib/numeric.rb @@ -104,7 +104,7 @@ module Integral raise ArgumentError, "step can't be 0" if step == 0 return to_enum(:step, num, step) unless block - i = if num.kind_of? Float then self.to_f else self end + i = if class_defined?("Float") && num.kind_of?(Float) then self.to_f else self end if num == nil while true block.call(i) @@ -161,13 +161,3 @@ class Integer # ISO 15.2.8.3.26 alias truncate floor end - -## -# Float -# -# ISO 15.2.9 -class Float - # mruby special - since mruby integers may be upgraded to floats, - # floats should be compatible to integers. - include Integral -end |
