int to size_t conversion

This commit is contained in:
Yuichi Nishiwaki 2014-09-27 17:18:11 +09:00
parent f8a32d7d60
commit 7350f7e71e
5 changed files with 19 additions and 19 deletions

View File

@ -1075,20 +1075,20 @@ static int
index_local(codegen_state *state, pic_sym sym)
{
codegen_context *cxt = state->cxt;
int i, offset;
size_t i, offset;
pic_sym *var;
offset = 1;
for (i = 0; i < (int)xv_size(&cxt->args); ++i) {
for (i = 0; i < xv_size(&cxt->args); ++i) {
var = xv_get(&cxt->args, i);
if (*var == sym)
return i + offset;
return (int)(i + offset);
}
offset += i;
for (i = 0; i < (int)xv_size(&cxt->locals); ++i) {
for (i = 0; i < xv_size(&cxt->locals); ++i) {
var = xv_get(&cxt->locals, i);
if (*var == sym)
return i + offset;
return (int)(i + offset);
}
return -1;
}
@ -1126,7 +1126,7 @@ codegen(codegen_state *state, pic_value obj)
name = pic_sym(pic_list_ref(pic, obj, 1));
if ((i = index_capture(state, name, 0)) != -1) {
cxt->code[cxt->clen].insn = OP_LREF;
cxt->code[cxt->clen].u.i = i + xv_size(&cxt->args) + xv_size(&cxt->locals) + 1;
cxt->code[cxt->clen].u.i = i + (int)xv_size(&cxt->args) + (int)xv_size(&cxt->locals) + 1;
cxt->clen++;
return;
}
@ -1172,7 +1172,7 @@ codegen(codegen_state *state, pic_value obj)
name = pic_sym(pic_list_ref(pic, var, 1));
if ((i = index_capture(state, name, 0)) != -1) {
cxt->code[cxt->clen].insn = OP_LSET;
cxt->code[cxt->clen].u.i = i + xv_size(&cxt->args) + xv_size(&cxt->locals) + 1;
cxt->code[cxt->clen].u.i = i + (int)xv_size(&cxt->args) + (int)xv_size(&cxt->locals) + 1;
cxt->clen++;
cxt->code[cxt->clen].insn = OP_PUSHNONE;
cxt->clen++;
@ -1193,7 +1193,7 @@ codegen(codegen_state *state, pic_value obj)
cxt->icapa *= 2;
cxt->irep = pic_realloc(pic, cxt->irep, sizeof(struct pic_irep *) * cxt->icapa);
}
k = cxt->ilen++;
k = (int)cxt->ilen++;
cxt->code[cxt->clen].insn = OP_LAMBDA;
cxt->code[cxt->clen].u.i = k;
cxt->clen++;
@ -1207,18 +1207,18 @@ codegen(codegen_state *state, pic_value obj)
codegen(state, pic_list_ref(pic, obj, 1));
cxt->code[cxt->clen].insn = OP_JMPIF;
s = cxt->clen++;
s = (int)cxt->clen++;
/* if false branch */
codegen(state, pic_list_ref(pic, obj, 3));
cxt->code[cxt->clen].insn = OP_JMP;
t = cxt->clen++;
t = (int)cxt->clen++;
cxt->code[s].u.i = cxt->clen - s;
cxt->code[s].u.i = (int)cxt->clen - s;
/* if true branch */
codegen(state, pic_list_ref(pic, obj, 2));
cxt->code[t].u.i = cxt->clen - t;
cxt->code[t].u.i = (int)cxt->clen - t;
return;
}
else if (sym == pic->sBEGIN) {
@ -1266,7 +1266,7 @@ codegen(codegen_state *state, pic_value obj)
cxt->pcapa *= 2;
cxt->pool = pic_realloc(pic, cxt->pool, sizeof(pic_value) * cxt->pcapa);
}
pidx = cxt->plen++;
pidx = (int)cxt->plen++;
cxt->pool[pidx] = obj;
cxt->code[cxt->clen].insn = OP_PUSHCONST;
cxt->code[cxt->clen].u.i = pidx;

View File

@ -52,8 +52,8 @@ struct pic_code {
int i;
char c;
struct {
short depth;
short idx;
int depth;
int idx;
} r;
} u;
};

View File

@ -240,14 +240,14 @@ pic_str_string(pic_state *pic)
pic_get_args(pic, "*", &argc, &argv);
buf = pic_alloc(pic, argc);
buf = pic_alloc(pic, (size_t)argc);
for (i = 0; i < argc; ++i) {
pic_assert_type(pic, argv[i], char);
buf[i] = pic_char(argv[i]);
}
str = pic_make_str(pic, buf, argc);
str = pic_make_str(pic, buf, (size_t)argc);
pic_free(pic, buf);
return pic_obj_value(str);

View File

@ -80,7 +80,7 @@ pic_ungensym(pic_state *pic, pic_sym base)
if ((occr = strrchr(name, '@')) == NULL) {
pic_panic(pic, "logic flaw");
}
return pic_intern(pic, name, occr - name);
return pic_intern(pic, name, (size_t)(occr - name));
}
bool

View File

@ -110,7 +110,7 @@ pic_system_getenvs(pic_state *pic)
for (i = 0; (*envp)[i] != '='; ++i)
;
key = pic_make_str(pic, *envp, i);
key = pic_make_str(pic, *envp, (size_t)i);
val = pic_make_str_cstr(pic, getenv(pic_str_cstr(key)));
/* push */