mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix compiler errors from MRB_NO_FLOAT; #5185
Also added `no-float.rb` target in `build_config`.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
MRuby::Build.new("host") do |conf|
|
||||
# load specific toolchain settings
|
||||
toolchain :gcc
|
||||
conf.gem :core => "mruby-bin-mrbc"
|
||||
end
|
||||
|
||||
# Define cross build settings
|
||||
MRuby::CrossBuild.new('no-float') do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
# include the GEM box
|
||||
conf.compilers.each do |c|
|
||||
c.defines << "MRB_NO_FLOAT"
|
||||
end
|
||||
|
||||
conf.gem :core => "mruby-bin-mruby"
|
||||
conf.gem :core => "mruby-test"
|
||||
|
||||
conf.test_runner.command = 'env'
|
||||
|
||||
conf.enable_debug
|
||||
# conf.enable_bintest
|
||||
conf.enable_test
|
||||
end
|
||||
+1
-1
@@ -185,4 +185,4 @@ class Float
|
||||
end
|
||||
self
|
||||
end
|
||||
end
|
||||
end if Object.const_defined?(:Float)
|
||||
|
||||
@@ -141,7 +141,9 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
|
||||
op_loadl:
|
||||
switch (irep->pool[b].tt) {
|
||||
case IREP_TT_FLOAT:
|
||||
#ifndef MRB_NO_FLOAT
|
||||
printf("OP_LOADL\tR%d\tL(%d)\t; %f", a, b, (double)irep->pool[b].u.f);
|
||||
#endif
|
||||
break;
|
||||
case IREP_TT_INT32:
|
||||
printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId32, a, b, irep->pool[b].u.i32);
|
||||
|
||||
@@ -964,12 +964,14 @@ dump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
|
||||
fprintf(fp, "{IREP_TT_INT32, {.i32=%" PRId32 "}},\n", p->u.i32);
|
||||
break;
|
||||
case IREP_TT_FLOAT:
|
||||
#ifndef MRB_NO_FLOAT
|
||||
if (p->u.f == 0) {
|
||||
fprintf(fp, "{IREP_TT_FLOAT, {.f=%#.1f}},\n", p->u.f);
|
||||
}
|
||||
else {
|
||||
fprintf(fp, "{IREP_TT_FLOAT, {.f=" MRB_FLOAT_FMT "}},\n", p->u.f);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -649,10 +649,12 @@ load_irep(mrb_state *mrb, mrb_irep *irep, mrbc_context *c)
|
||||
MRB_API mrb_value
|
||||
mrb_load_irep_cxt(mrb_state *mrb, const uint8_t *bin, mrbc_context *c)
|
||||
{
|
||||
struct RData *irep_obj = mrb_data_object_alloc(mrb, mrb->object_class, NULL, &tempirep_type);
|
||||
struct RData *irep_obj;
|
||||
mrb_irep *irep = mrb_read_irep(mrb, bin);
|
||||
mrb_value ret;
|
||||
|
||||
if (!irep) return mrb_undef_value();
|
||||
irep_obj = mrb_data_object_alloc(mrb, mrb->object_class, NULL, &tempirep_type);
|
||||
irep_obj->data = irep;
|
||||
mrb_irep_incref(mrb, irep);
|
||||
ret = load_irep(mrb, irep, c);
|
||||
|
||||
+1
-1
@@ -1697,7 +1697,7 @@ mrb_init_numeric(mrb_state *mrb)
|
||||
mrb_define_method(mrb, fl, "eql?", flo_eql, MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */
|
||||
|
||||
mrb_define_method(mrb, fl, "to_s", flo_to_s, MRB_ARGS_NONE()); /* 15.2.9.3.16(x) */
|
||||
mrb_define_method(mrb, fl, "inspect", flo_to_s , MRB_ARGS_NONE());
|
||||
mrb_define_method(mrb, fl, "inspect", flo_to_s, MRB_ARGS_NONE());
|
||||
mrb_define_method(mrb, fl, "nan?", flo_nan_p, MRB_ARGS_NONE());
|
||||
|
||||
#ifdef INFINITY
|
||||
|
||||
Reference in New Issue
Block a user