diff --git a/include/picrin.h b/include/picrin.h index 7258fb7a..dbe58f12 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -151,7 +151,7 @@ struct pic_string *pic_str_new_cstr(pic_state *, const char *); struct pic_vector *pic_vec_new(pic_state *, size_t); struct pic_vector *pic_vec_new_from_list(pic_state *, pic_value); -void pic_vec_extend_ip(pic_state *, struct pic_vector *, int); +void pic_vec_extend_ip(pic_state *, struct pic_vector *, size_t); int pic_parse_file(pic_state *, FILE *file, pic_value *); int pic_parse_cstr(pic_state *, const char *, pic_value *); diff --git a/include/picrin/blob.h b/include/picrin/blob.h index 7b99885d..6b52d9e3 100644 --- a/include/picrin/blob.h +++ b/include/picrin/blob.h @@ -12,13 +12,13 @@ extern "C" { struct pic_blob { PIC_OBJECT_HEADER char *data; - int len; + size_t len; }; #define pic_blob_p(v) (pic_type(v) == PIC_TT_BLOB) #define pic_blob_ptr(v) ((struct pic_blob *)pic_ptr(v)) -struct pic_blob *pic_blob_new(pic_state *, char *, int len); +struct pic_blob *pic_blob_new(pic_state *, char *, size_t len); #if defined(__cplusplus) } diff --git a/include/picrin/parse.h b/include/picrin/parse.h index a1784f87..44405639 100644 --- a/include/picrin/parse.h +++ b/include/picrin/parse.h @@ -16,7 +16,7 @@ struct parser_control { bool incomp; int yynerrs; struct pic_vector *yy_arena; - int yy_arena_idx; + size_t yy_arena_idx; }; #if defined(__cplusplus) diff --git a/src/blob.c b/src/blob.c index 50304a19..afa50747 100644 --- a/src/blob.c +++ b/src/blob.c @@ -8,7 +8,7 @@ #include "picrin/blob.h" struct pic_blob * -pic_blob_new(pic_state *pic, char *dat, int len) +pic_blob_new(pic_state *pic, char *dat, size_t len) { struct pic_blob *bv; diff --git a/src/codegen.c b/src/codegen.c index d580c9e2..356fba0d 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -36,10 +36,10 @@ new_irep(pic_state *pic) } static pic_sym * -analyze_args(pic_state *pic, pic_value args, bool *varg, size_t *argc, size_t *localc) +analyze_args(pic_state *pic, pic_value args, bool *varg, int *argc, int *localc) { pic_sym *syms = (pic_sym *)pic_alloc(pic, sizeof(pic_sym)); - size_t i = 1, l = 0; + int i = 1, l = 0; pic_value v; *varg = false; @@ -78,7 +78,7 @@ static bool valid_formal(pic_state *pic, pic_value formal) { bool varg; - size_t argc, localc; + int argc, localc; pic_sym *syms; syms = analyze_args(pic, formal, &varg, &argc, &localc); @@ -94,7 +94,7 @@ valid_formal(pic_state *pic, pic_value formal) typedef struct analyze_scope { /* rest args variable is counted by localc */ bool varg; - size_t argc, localc; + int argc, localc; /* if variable v is captured, then xh_get(var_tbl, v) == 1 */ struct xhash *var_tbl; pic_sym *vars; @@ -665,7 +665,7 @@ pic_analyze(pic_state *pic, pic_value obj) typedef struct resolver_scope { int depth; bool varg; - size_t argc, localc; + int argc, localc; struct xhash *cvs, *lvs; unsigned cv_num; @@ -769,7 +769,7 @@ resolve_gref(resolver_state *state, pic_sym sym) pic_state *pic = state->pic; const char *name = pic_symbol_name(pic, sym); struct xh_entry *e; - int i; + size_t i; if ((e = xh_get(pic->global_tbl, name))) { i = e->val; @@ -911,7 +911,7 @@ pic_resolve(pic_state *pic, pic_value obj) typedef struct codegen_context { bool varg; /* rest args variable is counted by localc */ - size_t argc, localc; + int argc, localc; /* closed variable table */ unsigned *cv_tbl, cv_num; /* actual bit code sequence */ diff --git a/src/gc.c b/src/gc.c index 35b4e45f..a71af550 100644 --- a/src/gc.c +++ b/src/gc.c @@ -342,7 +342,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) break; } case PIC_TT_VECTOR: { - int i; + size_t i; for (i = 0; i < ((struct pic_vector *)obj)->len; ++i) { gc_mark(pic, ((struct pic_vector *)obj)->data[i]); } @@ -355,7 +355,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) struct pic_cont *cont = (struct pic_cont *)obj; pic_value *stack; pic_callinfo *ci; - int i; + size_t i; + int j; /* block */ gc_mark_block(pic, cont->blk); @@ -378,8 +379,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) } /* arena */ - for (i = 0; i < cont->arena_idx; ++i) { - gc_mark_object(pic, cont->arena[i]); + for (j = 0; j < cont->arena_idx; ++j) { + gc_mark_object(pic, cont->arena[j]); } gc_mark(pic, cont->result); @@ -403,7 +404,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) gc_mark_object(pic, (struct pic_object *)senv->up); } if (senv->stx) { - int i; + size_t i; for (i = 0; i < senv->xlen; ++i) { gc_mark_object(pic, (struct pic_object *)senv->stx[i]); @@ -433,7 +434,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) } case PIC_TT_IREP: { struct pic_irep *irep = (struct pic_irep *)obj; - int i; + size_t i; for (i = 0; i < irep->ilen; ++i) { gc_mark_object(pic, (struct pic_object *)irep->irep[i]); @@ -472,7 +473,8 @@ gc_mark_phase(pic_state *pic) { pic_value *stack; pic_callinfo *ci; - int i; + size_t i; + int j; /* block */ gc_mark_block(pic, pic->blk); @@ -495,8 +497,8 @@ gc_mark_phase(pic_state *pic) } /* arena */ - for (i = 0; i < pic->arena_idx; ++i) { - gc_mark_object(pic, pic->arena[i]); + for (j = 0; j < pic->arena_idx; ++j) { + gc_mark_object(pic, pic->arena[j]); } /* global variables */ diff --git a/src/macro.c b/src/macro.c index 3ad0a139..af011343 100644 --- a/src/macro.c +++ b/src/macro.c @@ -200,7 +200,7 @@ pic_import(pic_state *pic, pic_value spec) xh_put(pic->lib->senv->tbl, it.e->key, it.e->val); } else { /* syntax object */ - int idx; + size_t idx; struct pic_senv *senv = pic->lib->senv; idx = senv->xlen; @@ -233,7 +233,7 @@ pic_defsyntax(pic_state *pic, const char *name, struct pic_proc *macro, struct p { struct pic_syntax *stx; struct pic_senv *global_senv = pic->lib->senv; - int idx; + size_t idx; stx = pic_syntax_new_macro(pic, pic_intern_cstr(pic, name), macro, mac_env); diff --git a/src/number.c b/src/number.c index 321bab31..e5cdde1c 100644 --- a/src/number.c +++ b/src/number.c @@ -123,7 +123,7 @@ pic_number_nan_p(pic_state *pic) { \ size_t argc; \ pic_value *argv; \ - int i; \ + size_t i; \ double f,g; \ \ pic_get_args(pic, "ff*", &f, &g, &argc, &argv); \ @@ -207,7 +207,7 @@ pic_number_max(pic_state *pic) { size_t argc; pic_value *argv; - int i; + size_t i; double f; bool e = true; @@ -235,7 +235,7 @@ pic_number_min(pic_state *pic) { size_t argc; pic_value *argv; - int i; + size_t i; double f; bool e = true; @@ -264,7 +264,7 @@ pic_number_min(pic_state *pic) { \ size_t argc; \ pic_value *argv; \ - int i; \ + size_t i; \ double f; \ bool e = true; \ \ @@ -296,7 +296,7 @@ DEFINE_ARITH_OP(*, mul, 1) { \ size_t argc; \ pic_value *argv; \ - int i; \ + size_t i; \ double f; \ bool e; \ \ diff --git a/src/pair.c b/src/pair.c index 30291d46..4495b641 100644 --- a/src/pair.c +++ b/src/pair.c @@ -81,7 +81,7 @@ pic_value pic_list_from_array(pic_state *pic, size_t c, pic_value *vs) { pic_value v; - int i; + size_t i; v = pic_nil_value(); for (i = 0; i < c; ++i) { diff --git a/src/state.c b/src/state.c index bbe6c253..8236d2e9 100644 --- a/src/state.c +++ b/src/state.c @@ -126,7 +126,7 @@ pic_open(int argc, char *argv[], char **envp) void pic_close(pic_state *pic) { - int i; + size_t i; /* free global stacks */ free(pic->stbase); diff --git a/src/string.c b/src/string.c index 1b0c84ac..a9cddcb1 100644 --- a/src/string.c +++ b/src/string.c @@ -95,7 +95,7 @@ pic_str_string_set(pic_state *pic) { \ size_t argc; \ pic_value *argv; \ - int i; \ + size_t i; \ \ pic_get_args(pic, "*", &argc, &argv); \ \ diff --git a/src/vector.c b/src/vector.c index d8b34f3c..dcfe1bed 100644 --- a/src/vector.c +++ b/src/vector.c @@ -9,7 +9,7 @@ struct pic_vector * pic_vec_new(pic_state *pic, size_t len) { struct pic_vector *vec; - int i; + size_t i; vec = (struct pic_vector *)pic_obj_alloc(pic, sizeof(struct pic_vector), PIC_TT_VECTOR); vec->len = len; @@ -24,7 +24,7 @@ struct pic_vector * pic_vec_new_from_list(pic_state *pic, pic_value data) { struct pic_vector *vec; - int i, len; + size_t i, len; len = pic_length(pic, data); @@ -37,9 +37,9 @@ pic_vec_new_from_list(pic_state *pic, pic_value data) } void -pic_vec_extend_ip(pic_state *pic, struct pic_vector *vec, int size) +pic_vec_extend_ip(pic_state *pic, struct pic_vector *vec, size_t size) { - int len, i; + size_t len, i; len = vec->len; vec->len = size; @@ -63,14 +63,15 @@ static pic_value pic_vec_make_vector(pic_state *pic) { pic_value v; - int k, n, i; + int n, k; + size_t i; struct pic_vector *vec; n = pic_get_args(pic, "i|o", &k, &v); vec = pic_vec_new(pic, k); if (n == 3) { - for (i = 0; i < k; ++i) { + for (i = 0; i < (size_t)k; ++i) { vec->data[i] = v; } } @@ -95,7 +96,7 @@ pic_vec_vector_ref(pic_state *pic) pic_get_args(pic, "vi", &v, &k); - if (k < 0 || v->len <= k) { + if (k < 0 || v->len <= (size_t)k) { pic_error(pic, "vector-ref: index out of range"); } return v->data[k]; @@ -110,7 +111,7 @@ pic_vec_vector_set(pic_state *pic) pic_get_args(pic, "vio", &v, &k, &o); - if (k < 0 || v->len <= k) { + if (k < 0 || v->len <= (size_t)k) { pic_error(pic, "vector-set!: index out of range"); } v->data[k] = o; diff --git a/src/vm.c b/src/vm.c index 64fa4aaf..b1160196 100644 --- a/src/vm.c +++ b/src/vm.c @@ -630,7 +630,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) } } CASE(OP_TAILCALL) { - int argc; + int i, argc; pic_value *argv; argc = c.u.i; diff --git a/src/write.c b/src/write.c index 026cb391..614fcb9e 100644 --- a/src/write.c +++ b/src/write.c @@ -30,7 +30,7 @@ write_pair(pic_state *pic, struct pic_pair *pair) static void write_str(pic_state *pic, struct pic_string *str) { - int i; + size_t i; const char *cstr = str->str; for (i = 0; i < str->len; ++i) { @@ -44,7 +44,7 @@ write_str(pic_state *pic, struct pic_string *str) static void write(pic_state *pic, pic_value obj) { - int i; + size_t i; switch (pic_type(obj)) { case PIC_TT_NIL: