summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-11-04 11:49:25 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-11-04 11:49:25 +0900
commitde2363a9f0c7d368ee9002f86931d124e644a243 (patch)
tree2112928a80786a109ecac4b3ce200f45ac75e2cb /mrblib
parent388d26d77027feaa3e107abf7209e2681868bbe6 (diff)
parent625f9f6fa314872968632c5adbee7fb3823268b8 (diff)
downloadmruby-de2363a9f0c7d368ee9002f86931d124e644a243.tar.gz
mruby-de2363a9f0c7d368ee9002f86931d124e644a243.zip
Merge branch 'mrb_without_float' of https://github.com/pandax381/mruby into pandax381-mrb_without_float
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/float.rb9
-rw-r--r--mrblib/mrblib.rake3
-rw-r--r--mrblib/numeric.rb12
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