Fix compiler errors from `MRB_NO_FLOAT`;
Also added `no-float.rb` target in `build_config`.
ADD
build_config/no-float.rb
+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

MODIFY
mrblib/numeric.rb
mrblib/numeric.rb
@@ -185,4 +185,4 @@ class Float
end
self
end
-end
+end if Object.const_defined?(:Float)

MODIFY
src/codedump.c
src/codedump.c
@@ -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);

MODIFY
src/dump.c
src/dump.c
@@ -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;
}
}

MODIFY
src/load.c
src/load.c
@@ -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);

Fix compiler errors from `MRB_NO_FLOAT`; #5185

Also added `no-float.rb` target in `build_config`.