int and size_t

This commit is contained in:
Yuichi Nishiwaki 2014-09-26 17:36:00 +09:00
parent 7b0ec3adde
commit cb54f0e065
2 changed files with 13 additions and 12 deletions

View File

@ -490,7 +490,6 @@ analyze_if(analyze_state *state, pic_value obj, bool tailpos)
switch (pic_length(pic, obj)) { switch (pic_length(pic, obj)) {
default: default:
pic_errorf(pic, "syntax error"); pic_errorf(pic, "syntax error");
break;
case 4: case 4:
if_false = pic_list_ref(pic, obj, 3); if_false = pic_list_ref(pic, obj, 3);
FALLTHROUGH; FALLTHROUGH;
@ -956,7 +955,7 @@ create_activation(codegen_context *cxt)
if ((n = xh_val(xh_get_int(&regs, *var), size_t)) <= xv_size(&cxt->args) || (cxt->varg && n == xv_size(&cxt->args) + 1)) { if ((n = xh_val(xh_get_int(&regs, *var), size_t)) <= xv_size(&cxt->args) || (cxt->varg && n == xv_size(&cxt->args) + 1)) {
/* copy arguments to capture variable area */ /* copy arguments to capture variable area */
cxt->code[cxt->clen].insn = OP_LREF; cxt->code[cxt->clen].insn = OP_LREF;
cxt->code[cxt->clen].u.i = n; cxt->code[cxt->clen].u.i = (int)n;
cxt->clen++; cxt->clen++;
} else { } else {
/* otherwise, just extend the stack */ /* otherwise, just extend the stack */
@ -1030,9 +1029,9 @@ pop_codegen_context(codegen_state *state)
irep = (struct pic_irep *)pic_obj_alloc(pic, sizeof(struct pic_irep), PIC_TT_IREP); irep = (struct pic_irep *)pic_obj_alloc(pic, sizeof(struct pic_irep), PIC_TT_IREP);
irep->name = state->cxt->name; irep->name = state->cxt->name;
irep->varg = state->cxt->varg; irep->varg = state->cxt->varg;
irep->argc = xv_size(&state->cxt->args) + 1; irep->argc = (int)xv_size(&state->cxt->args) + 1;
irep->localc = xv_size(&state->cxt->locals); irep->localc = (int)xv_size(&state->cxt->locals);
irep->capturec = xv_size(&state->cxt->captures); irep->capturec = (int)xv_size(&state->cxt->captures);
irep->code = pic_realloc(pic, state->cxt->code, sizeof(pic_code) * state->cxt->clen); irep->code = pic_realloc(pic, state->cxt->code, sizeof(pic_code) * state->cxt->clen);
irep->clen = state->cxt->clen; irep->clen = state->cxt->clen;
irep->irep = pic_realloc(pic, state->cxt->irep, sizeof(struct pic_irep *) * state->cxt->ilen); irep->irep = pic_realloc(pic, state->cxt->irep, sizeof(struct pic_irep *) * state->cxt->ilen);
@ -1067,7 +1066,7 @@ index_capture(codegen_state *state, pic_sym sym, int depth)
for (i = 0; i < xv_size(&cxt->captures); ++i) { for (i = 0; i < xv_size(&cxt->captures); ++i) {
var = xv_get(&cxt->captures, i); var = xv_get(&cxt->captures, i);
if (*var == sym) if (*var == sym)
return i; return (int)i;
} }
return -1; return -1;
} }

View File

@ -243,14 +243,15 @@ static pic_value
pic_vec_vector_map(pic_state *pic) pic_vec_vector_map(pic_state *pic)
{ {
struct pic_proc *proc; struct pic_proc *proc;
int argc, i, len, j; int argc;
size_t i, len, j;
pic_value *argv, vals; pic_value *argv, vals;
pic_vec *vec; pic_vec *vec;
pic_get_args(pic, "l*", &proc, &argc, &argv); pic_get_args(pic, "l*", &proc, &argc, &argv);
len = INT_MAX; len = INT_MAX;
for (i = 0; i < argc; ++i) { for (i = 0; i < (size_t)argc; ++i) {
pic_assert_type(pic, argv[i], vec); pic_assert_type(pic, argv[i], vec);
len = len < pic_vec_ptr(argv[i])->len len = len < pic_vec_ptr(argv[i])->len
@ -262,7 +263,7 @@ pic_vec_vector_map(pic_state *pic)
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
vals = pic_nil_value(); vals = pic_nil_value();
for (j = 0; j < argc; ++j) { for (j = 0; j < (size_t)argc; ++j) {
pic_push(pic, pic_vec_ptr(argv[j])->data[i], vals); pic_push(pic, pic_vec_ptr(argv[j])->data[i], vals);
} }
vec->data[i] = pic_apply(pic, proc, vals); vec->data[i] = pic_apply(pic, proc, vals);
@ -275,13 +276,14 @@ static pic_value
pic_vec_vector_for_each(pic_state *pic) pic_vec_vector_for_each(pic_state *pic)
{ {
struct pic_proc *proc; struct pic_proc *proc;
int argc, i, len, j; int argc;
size_t i, len, j;
pic_value *argv, vals; pic_value *argv, vals;
pic_get_args(pic, "l*", &proc, &argc, &argv); pic_get_args(pic, "l*", &proc, &argc, &argv);
len = INT_MAX; len = INT_MAX;
for (i = 0; i < argc; ++i) { for (i = 0; i < (size_t)argc; ++i) {
pic_assert_type(pic, argv[i], vec); pic_assert_type(pic, argv[i], vec);
len = len < pic_vec_ptr(argv[i])->len len = len < pic_vec_ptr(argv[i])->len
@ -291,7 +293,7 @@ pic_vec_vector_for_each(pic_state *pic)
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
vals = pic_nil_value(); vals = pic_nil_value();
for (j = 0; j < argc; ++j) { for (j = 0; j < (size_t)argc; ++j) {
pic_push(pic, pic_vec_ptr(argv[j])->data[i], vals); pic_push(pic, pic_vec_ptr(argv[j])->data[i], vals);
} }
pic_apply(pic, proc, vals); pic_apply(pic, proc, vals);