From acdc2d1f242f2547ca842be5d62a2b06356b39ea Mon Sep 17 00:00:00 2001 From: YAMAMOTO Masaya Date: Wed, 11 Oct 2017 17:53:17 +0900 Subject: Add MRB_WITHOUT_FLOAT --- mrbgems/mruby-compiler/core/codegen.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mrbgems/mruby-compiler/core/codegen.c') diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 8f15a9b18..ba8ed2c71 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -460,6 +460,7 @@ new_lit(codegen_scope *s, mrb_value val) return i; } break; +#ifndef MRB_WITHOUT_FLOAT case MRB_TT_FLOAT: for (i=0; iirep->plen; i++) { pv = &s->irep->pool[i]; @@ -467,6 +468,7 @@ new_lit(codegen_scope *s, mrb_value val) if (mrb_float(*pv) == mrb_float(val)) return i; } break; +#endif case MRB_TT_FIXNUM: for (i=0; iirep->plen; i++) { pv = &s->irep->pool[i]; @@ -492,10 +494,12 @@ new_lit(codegen_scope *s, mrb_value val) *pv = mrb_str_pool(s->mrb, val); break; +#ifndef MRB_WITHOUT_FLOAT case MRB_TT_FLOAT: #ifdef MRB_WORD_BOXING *pv = mrb_float_pool(s->mrb, mrb_float(val)); break; +#endif #endif case MRB_TT_FIXNUM: *pv = val; @@ -1163,6 +1167,7 @@ raise_error(codegen_scope *s, const char *msg) genop(s, MKOP_ABx(OP_ERR, 1, idx)); } +#ifndef MRB_WITHOUT_FLOAT static double readint_float(codegen_scope *s, const char *p, int base) { @@ -1188,6 +1193,7 @@ readint_float(codegen_scope *s, const char *p, int base) } return f; } +#endif static mrb_int readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_bool *overflow) @@ -2237,6 +2243,7 @@ codegen(codegen_scope *s, node *tree, int val) mrb_bool overflow; i = readint_mrb_int(s, p, base, FALSE, &overflow); +#ifndef MRB_WITHOUT_FLOAT if (overflow) { double f = readint_float(s, p, base); int off = new_lit(s, mrb_float_value(s->mrb, f)); @@ -2244,6 +2251,7 @@ codegen(codegen_scope *s, node *tree, int val) genop(s, MKOP_ABx(OP_LOADL, cursp(), off)); } else { +#endif if (i < MAXARG_sBx && i > -MAXARG_sBx) { co = MKOP_AsBx(OP_LOADI, cursp(), i); } @@ -2252,11 +2260,14 @@ codegen(codegen_scope *s, node *tree, int val) co = MKOP_ABx(OP_LOADL, cursp(), off); } genop(s, co); +#ifndef MRB_WITHOUT_FLOAT } +#endif push(); } break; +#ifndef MRB_WITHOUT_FLOAT case NODE_FLOAT: if (val) { char *p = (char*)tree; @@ -2267,12 +2278,14 @@ codegen(codegen_scope *s, node *tree, int val) push(); } break; +#endif case NODE_NEGATE: { nt = nint(tree->car); tree = tree->cdr; switch (nt) { +#ifndef MRB_WITHOUT_FLOAT case NODE_FLOAT: if (val) { char *p = (char*)tree; @@ -2283,6 +2296,7 @@ codegen(codegen_scope *s, node *tree, int val) push(); } break; +#endif case NODE_INT: if (val) { @@ -2293,6 +2307,7 @@ codegen(codegen_scope *s, node *tree, int val) mrb_bool overflow; i = readint_mrb_int(s, p, base, TRUE, &overflow); +#ifndef MRB_WITHOUT_FLOAT if (overflow) { double f = readint_float(s, p, base); int off = new_lit(s, mrb_float_value(s->mrb, -f)); @@ -2300,6 +2315,7 @@ codegen(codegen_scope *s, node *tree, int val) genop(s, MKOP_ABx(OP_LOADL, cursp(), off)); } else { +#endif if (i < MAXARG_sBx && i > -MAXARG_sBx) { co = MKOP_AsBx(OP_LOADI, cursp(), i); } @@ -2308,7 +2324,9 @@ codegen(codegen_scope *s, node *tree, int val) co = MKOP_ABx(OP_LOADL, cursp(), off); } genop(s, co); +#ifndef MRB_WITHOUT_FLOAT } +#endif push(); } break; -- cgit v1.2.3