Reduce integer casting warnings.
MODIFY
include/mruby.h
include/mruby.h
@@ -1234,7 +1234,7 @@ MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
* @mrbgem mruby-fiber
*/
#define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
-MRB_API void mrb_stack_extend(mrb_state*, int);
+MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
/* memory pool implementation */
typedef struct mrb_pool mrb_pool;

MODIFY
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
@@ -400,7 +400,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, int pc, int val)
}
else {
gen_B(s, i);
- gen_B(s, a);
+ gen_B(s, (uint8_t)a);
pos = s->pc;
gen_S(s, pc);
}
@@ -494,10 +494,10 @@ gen_addsub(codegen_scope *s, uint8_t op, uint16_t dst, uint16_t idx)
if (data.b >= 128) goto normal;
s->pc = s->lastpc;
if (op == OP_ADD) {
- genop_3(s, OP_ADDI, dst, idx, data.b);
+ genop_3(s, OP_ADDI, dst, idx, (uint8_t)data.b);
}
else {
- genop_3(s, OP_SUBI, dst, idx, data.b);
+ genop_3(s, OP_SUBI, dst, idx, (uint8_t)data.b);
}
break;
default:
@@ -2441,7 +2441,7 @@ codegen(codegen_scope *s, node *tree, int val)
#endif
if (i == -1) genop_1(s, OP_LOADI__1, cursp());
else if (i >= -0xffff) {
- genop_2(s, OP_LOADINEG, cursp(), -i);
+ genop_2(s, OP_LOADINEG, cursp(), (uint16_t)-i);
}
else {
int off = new_lit(s, mrb_fixnum_value(i));

MODIFY
mrbgems/mruby-eval/src/eval.c
mrbgems/mruby-eval/src/eval.c
@@ -154,7 +154,7 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
if (arg != 0) {
/* must replace */
irep->iseq[i] = insn = OP_SETUPVAR;
- irep->iseq[i+1] = b;
+ irep->iseq[i+1] = (mrb_code)b;
irep->iseq[i+2] = arg >> 8;
irep->iseq[i+3] = arg & 0xff;
}
@@ -169,7 +169,7 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
int lev = c+1;
mrb_irep *tmp = search_irep(top, bnest, lev, irep);
if (potential_upvar_p(tmp->lv, b, irep_argc(tmp), tmp->nlocals)) {
- mrb_code arg = search_variable(mrb, tmp->lv[b-1].name, bnest);
+ uint16_t arg = search_variable(mrb, tmp->lv[b-1].name, bnest);
if (arg != 0) {
/* must replace */
irep->iseq[i] = OP_GETUPVAR;
@@ -188,7 +188,7 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top)
int lev = c+1;
mrb_irep *tmp = search_irep(top, bnest, lev, irep);
if (potential_upvar_p(tmp->lv, b, irep_argc(tmp), tmp->nlocals)) {
- mrb_code arg = search_variable(mrb, tmp->lv[b-1].name, bnest);
+ uint16_t arg = search_variable(mrb, tmp->lv[b-1].name, bnest);
if (arg != 0) {
/* must replace */
irep->iseq[i] = OP_SETUPVAR;

MODIFY
src/codedump.c
src/codedump.c
@@ -48,7 +48,7 @@ print_lv_ab(mrb_state *mrb, mrb_irep *irep, uint16_t a, uint16_t b)
#endif
static void
-print_header(mrb_irep *irep, int i)
+print_header(mrb_irep *irep, ptrdiff_t i)
{
int32_t line;
@@ -60,7 +60,7 @@ print_header(mrb_irep *irep, int i)
printf("%5d ", line);
}
- printf("%03d ", i);
+ printf("%03d ", (int)i);
}
#define CASE(insn,ops) case insn: FETCH_ ## ops (); L_ ## insn
@@ -91,7 +91,7 @@ codedump(mrb_state *mrb, mrb_irep *irep)
pc = irep->iseq;
pcend = pc + irep->ilen;
while (pc < pcend) {
- int i;
+ ptrdiff_t i;
uint32_t a;
uint16_t b;
uint8_t c;

MODIFY
src/load.c
src/load.c
@@ -68,7 +68,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
/* Binary Data Section */
/* ISEQ BLOCK */
- irep->ilen = (size_t)bin_to_uint32(src);
+ irep->ilen = (uint16_t)bin_to_uint32(src);
src += sizeof(uint32_t);
src += skip_padding(src);
@@ -157,7 +157,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
}
/* SYMS BLOCK */
- irep->slen = (size_t)bin_to_uint32(src); /* syms length */
+ irep->slen = (uint16_t)bin_to_uint32(src); /* syms length */
src += sizeof(uint32_t);
if (irep->slen > 0) {
if (SIZE_ERROR_MUL(irep->slen, sizeof(mrb_sym))) {

MODIFY
src/vm.c
src/vm.c
@@ -218,7 +218,7 @@ stack_extend_alloc(mrb_state *mrb, int room)
}
MRB_API void
-mrb_stack_extend(mrb_state *mrb, int room)
+mrb_stack_extend(mrb_state *mrb, mrb_int room)
{
if (mrb->c->stack + room >= mrb->c->stend) {
stack_extend_alloc(mrb, room);

Reduce integer casting warnings.