diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-13 23:16:53 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-13 23:16:53 +0900 |
| commit | 6919ca61edb2da9ea81217fdc355eef1208a6398 (patch) | |
| tree | 45db6c83b9331d5bff31308039151539c496f093 /src/codegen.c | |
| parent | 8004168725dc7e3c6975400c40fc9419a0ffed65 (diff) | |
| download | mruby-6919ca61edb2da9ea81217fdc355eef1208a6398.tar.gz mruby-6919ca61edb2da9ea81217fdc355eef1208a6398.zip | |
stop using strtol (via readint) except in load.c; use custom readint_float
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/codegen.c b/src/codegen.c index 5f8d17314..63531eac1 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1575,16 +1575,18 @@ codegen(codegen_scope *s, node *tree, int val) if (val) { char *p = (char*)tree->car; int base = (intptr_t)tree->cdr->car; - long i = readint(p, base); + mrb_float f; + mrb_int i; mrb_code co; - if ((i == LONG_MAX && errno == ERANGE) || !FIXABLE(i)) { - mrb_float f = readint_float(s, p, base); + f = readint_float(s, p, base); + if (!FIXABLE(f)) { int off = new_lit(s, mrb_float_value(f)); genop(s, MKOP_ABx(OP_LOADL, cursp(), off)); } else { + i = (mrb_int)f; if (i < MAXARG_sBx && i > -MAXARG_sBx) { co = MKOP_AsBx(OP_LOADI, cursp(), i); } @@ -1629,17 +1631,18 @@ codegen(codegen_scope *s, node *tree, int val) { char *p = (char*)tree->car; int base = (intptr_t)tree->cdr->car; - long i = readint(p, base); + mrb_float f; + mrb_int i; mrb_code co; - if ((i == LONG_MAX && errno == ERANGE) || !FIXABLE(i)) { - mrb_float f = readint_float(s, p, base); + f = readint_float(s, p, base); + if (!FIXABLE(f)) { int off = new_lit(s, mrb_float_value(-f)); - + genop(s, MKOP_ABx(OP_LOADL, cursp(), off)); } else { - i = -i; + i = (mrb_int)-f; if (i < MAXARG_sBx && i > -MAXARG_sBx) { co = MKOP_AsBx(OP_LOADI, cursp(), i); } |
