never use size_t
This commit is contained in:
parent
cc952404c5
commit
6f3083c3ca
|
@ -219,7 +219,7 @@ PIC_NORETURN static pic_value
|
|||
cont_call(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value *argv;
|
||||
struct pic_fullcont *cont;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "picrin.h"
|
||||
|
||||
void
|
||||
pic_str_set(pic_state *pic, pic_str *str, size_t i, char c)
|
||||
pic_str_set(pic_state *pic, pic_str *str, int i, char c)
|
||||
{
|
||||
pic_str *x, *y, *z, *tmp;
|
||||
char buf[1];
|
||||
|
|
|
@ -102,7 +102,7 @@ pic_system_getenvs(pic_state *pic)
|
|||
|
||||
for (envp = pic->envp; *envp; ++envp) {
|
||||
pic_str *key, *val;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
for (i = 0; (*envp)[i] != '='; ++i)
|
||||
;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "picrin.h"
|
||||
|
||||
struct pic_blob *
|
||||
pic_make_blob(pic_state *pic, size_t len)
|
||||
pic_make_blob(pic_state *pic, int len)
|
||||
{
|
||||
struct pic_blob *bv;
|
||||
|
||||
|
@ -29,7 +29,7 @@ static pic_value
|
|||
pic_blob_bytevector(pic_state *pic)
|
||||
{
|
||||
pic_value *argv;
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_blob *blob;
|
||||
unsigned char *data;
|
||||
|
||||
|
@ -56,10 +56,9 @@ static pic_value
|
|||
pic_blob_make_bytevector(pic_state *pic)
|
||||
{
|
||||
pic_blob *blob;
|
||||
size_t k, i;
|
||||
int b = 0;
|
||||
int k, i, b = 0;
|
||||
|
||||
pic_get_args(pic, "k|i", &k, &b);
|
||||
pic_get_args(pic, "i|i", &k, &b);
|
||||
|
||||
if (b < 0 || b > 255)
|
||||
pic_errorf(pic, "byte out of range");
|
||||
|
@ -79,7 +78,7 @@ pic_blob_bytevector_length(pic_state *pic)
|
|||
|
||||
pic_get_args(pic, "b", &bv);
|
||||
|
||||
return pic_size_value(bv->len);
|
||||
return pic_int_value(bv->len);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
|
@ -112,10 +111,9 @@ static pic_value
|
|||
pic_blob_bytevector_copy_i(pic_state *pic)
|
||||
{
|
||||
pic_blob *to, *from;
|
||||
int n;
|
||||
size_t at, start, end;
|
||||
int n, at, start, end;
|
||||
|
||||
n = pic_get_args(pic, "bkb|kk", &to, &at, &from, &start, &end);
|
||||
n = pic_get_args(pic, "bib|ii", &to, &at, &from, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 3:
|
||||
|
@ -144,10 +142,9 @@ static pic_value
|
|||
pic_blob_bytevector_copy(pic_state *pic)
|
||||
{
|
||||
pic_blob *from, *to;
|
||||
int n;
|
||||
size_t start, end, i = 0;
|
||||
int n, start, end, i = 0;
|
||||
|
||||
n = pic_get_args(pic, "b|kk", &from, &start, &end);
|
||||
n = pic_get_args(pic, "b|ii", &from, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
@ -171,7 +168,7 @@ pic_blob_bytevector_copy(pic_state *pic)
|
|||
static pic_value
|
||||
pic_blob_bytevector_append(pic_state *pic)
|
||||
{
|
||||
size_t argc, i, j, len;
|
||||
int argc, i, j, len;
|
||||
pic_value *argv;
|
||||
pic_blob *blob;
|
||||
|
||||
|
@ -225,10 +222,9 @@ pic_blob_bytevector_to_list(pic_state *pic)
|
|||
{
|
||||
pic_blob *blob;
|
||||
pic_value list;
|
||||
int n;
|
||||
size_t start, end, i;
|
||||
int n, start, end, i;
|
||||
|
||||
n = pic_get_args(pic, "b|kk", &blob, &start, &end);
|
||||
n = pic_get_args(pic, "b|ii", &blob, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
|
|
@ -8,10 +8,10 @@ KHASH_DECLARE(m, void *, int)
|
|||
KHASH_DEFINE2(m, void *, int, 0, kh_ptr_hash_func, kh_ptr_hash_equal)
|
||||
|
||||
static bool
|
||||
internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, khash_t(m) *h)
|
||||
internal_equal_p(pic_state *pic, pic_value x, pic_value y, int depth, khash_t(m) *h)
|
||||
{
|
||||
pic_value local = pic_nil_value();
|
||||
size_t c = 0;
|
||||
int c = 0;
|
||||
|
||||
if (depth > 10) {
|
||||
if (depth > 200) {
|
||||
|
@ -49,7 +49,7 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, khash_t
|
|||
}
|
||||
case PIC_TT_BLOB: {
|
||||
pic_blob *blob1, *blob2;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
blob1 = pic_blob_ptr(x);
|
||||
blob2 = pic_blob_ptr(y);
|
||||
|
@ -84,7 +84,7 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, khash_t
|
|||
goto LOOP; /* tail-call optimization */
|
||||
}
|
||||
case PIC_TT_VECTOR: {
|
||||
size_t i;
|
||||
int i;
|
||||
struct pic_vector *u, *v;
|
||||
|
||||
u = pic_vec_ptr(x);
|
||||
|
@ -167,7 +167,7 @@ pic_bool_boolean_p(pic_state *pic)
|
|||
static pic_value
|
||||
pic_bool_boolean_eq_p(pic_state *pic)
|
||||
{
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *argv;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
|
|
@ -34,7 +34,7 @@ pic_char_integer_to_char(pic_state *pic)
|
|||
if (i < 0 || i > 127) {
|
||||
pic_errorf(pic, "integer->char: integer out of char range: %d", i);
|
||||
}
|
||||
|
||||
|
||||
return pic_char_value((char)i);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ pic_char_integer_to_char(pic_state *pic)
|
|||
static pic_value \
|
||||
pic_char_##name##_p(pic_state *pic) \
|
||||
{ \
|
||||
size_t argc, i; \
|
||||
int argc, i; \
|
||||
pic_value *argv; \
|
||||
char c, d; \
|
||||
\
|
||||
|
|
|
@ -505,7 +505,7 @@ analyze_lambda(pic_state *pic, analyze_scope *up, pic_value form)
|
|||
pic_value formals, body;
|
||||
pic_value rest = pic_undef_value();
|
||||
pic_vec *args, *locals, *captures;
|
||||
size_t i, j;
|
||||
int i, j;
|
||||
khiter_t it;
|
||||
|
||||
formals = pic_list_ref(pic, form, 1);
|
||||
|
@ -752,7 +752,7 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
|
|||
static int
|
||||
index_capture(codegen_context *cxt, pic_sym *sym, int depth)
|
||||
{
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
while (depth-- > 0) {
|
||||
cxt = cxt->up;
|
||||
|
@ -760,7 +760,7 @@ index_capture(codegen_context *cxt, pic_sym *sym, int depth)
|
|||
|
||||
for (i = 0; i < cxt->captures->len; ++i) {
|
||||
if (pic_sym_ptr(cxt->captures->data[i]) == sym)
|
||||
return (int)i;
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -768,17 +768,17 @@ index_capture(codegen_context *cxt, pic_sym *sym, int depth)
|
|||
static int
|
||||
index_local(codegen_context *cxt, pic_sym *sym)
|
||||
{
|
||||
size_t i, offset;
|
||||
int i, offset;
|
||||
|
||||
offset = 1;
|
||||
for (i = 0; i < cxt->args->len; ++i) {
|
||||
if (pic_sym_ptr(cxt->args->data[i]) == sym)
|
||||
return (int)(i + offset);
|
||||
return i + offset;
|
||||
}
|
||||
offset += i;
|
||||
for (i = 0; i < cxt->locals->len; ++i) {
|
||||
if (pic_sym_ptr(cxt->locals->data[i]) == sym)
|
||||
return (int)(i + offset);
|
||||
return i + offset;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -802,13 +802,12 @@ index_global(pic_state *pic, codegen_context *cxt, pic_sym *name)
|
|||
static void
|
||||
create_activation(pic_state *pic, codegen_context *cxt)
|
||||
{
|
||||
size_t i;
|
||||
int n;
|
||||
int i, n;
|
||||
|
||||
for (i = 0; i < cxt->captures->len; ++i) {
|
||||
n = index_local(cxt, pic_sym_ptr(cxt->captures->data[i]));
|
||||
assert(n != -1);
|
||||
if (n <= (int)cxt->args->len || cxt->rest == pic_sym_ptr(cxt->captures->data[i])) {
|
||||
if (n <= cxt->args->len || cxt->rest == pic_sym_ptr(cxt->captures->data[i])) {
|
||||
/* copy arguments to capture variable area */
|
||||
emit_i(pic, cxt, OP_LREF, n);
|
||||
} else {
|
||||
|
|
|
@ -86,7 +86,7 @@ static pic_value
|
|||
cont_call(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *self = pic_get_proc(pic);
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value *argv;
|
||||
int id;
|
||||
struct pic_cont *cc, *cont;
|
||||
|
@ -155,11 +155,11 @@ pic_callcc(pic_state *pic, struct pic_proc *proc)
|
|||
}
|
||||
|
||||
static pic_value
|
||||
pic_va_values(pic_state *pic, size_t n, ...)
|
||||
pic_va_values(pic_state *pic, int n, ...)
|
||||
{
|
||||
pic_vec *args = pic_make_vec(pic, n);
|
||||
va_list ap;
|
||||
size_t i = 0;
|
||||
int i = 0;
|
||||
|
||||
va_start(ap, n);
|
||||
|
||||
|
@ -209,9 +209,9 @@ pic_values5(pic_state *pic, pic_value arg1, pic_value arg2, pic_value arg3, pic_
|
|||
}
|
||||
|
||||
pic_value
|
||||
pic_values(pic_state *pic, size_t argc, pic_value *argv)
|
||||
pic_values(pic_state *pic, int argc, pic_value *argv)
|
||||
{
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < argc; ++i) {
|
||||
pic->sp[i] = argv[i];
|
||||
|
@ -236,15 +236,15 @@ pic_values_by_list(pic_state *pic, pic_value list)
|
|||
return pic_nil_p(list) ? pic_undef_value() : pic->sp[0];
|
||||
}
|
||||
|
||||
size_t
|
||||
pic_receive(pic_state *pic, size_t n, pic_value *argv)
|
||||
int
|
||||
pic_receive(pic_state *pic, int n, pic_value *argv)
|
||||
{
|
||||
pic_callinfo *ci;
|
||||
size_t i, retc;
|
||||
int i, retc;
|
||||
|
||||
/* take info from discarded frame */
|
||||
ci = pic->ci + 1;
|
||||
retc = (size_t)ci->retc;
|
||||
retc = ci->retc;
|
||||
|
||||
for (i = 0; i < retc && i < n; ++i) {
|
||||
argv[i] = ci->fp[i];
|
||||
|
@ -276,7 +276,7 @@ pic_cont_dynamic_wind(pic_state *pic)
|
|||
static pic_value
|
||||
pic_cont_values(pic_state *pic)
|
||||
{
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value *argv;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
@ -288,7 +288,7 @@ static pic_value
|
|||
pic_cont_call_with_values(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *producer, *consumer;
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_vec *args;
|
||||
|
||||
pic_get_args(pic, "ll", &producer, &consumer);
|
||||
|
|
|
@ -41,7 +41,7 @@ pic_dict_set(pic_state PIC_UNUSED(*pic), struct pic_dict *dict, pic_sym *key, pi
|
|||
kh_val(h, it) = val;
|
||||
}
|
||||
|
||||
size_t
|
||||
int
|
||||
pic_dict_size(pic_state PIC_UNUSED(*pic), struct pic_dict *dict)
|
||||
{
|
||||
return kh_size(&dict->hash);
|
||||
|
@ -83,7 +83,7 @@ pic_dict_dictionary(pic_state *pic)
|
|||
{
|
||||
struct pic_dict *dict;
|
||||
pic_value *argv;
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ static pic_value
|
|||
pic_error_error(pic_state *pic)
|
||||
{
|
||||
const char *str;
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value *argv;
|
||||
|
||||
pic_get_args(pic, "z*", &str, &argc, &argv);
|
||||
|
|
|
@ -325,7 +325,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
|||
break;
|
||||
}
|
||||
case PIC_TT_VECTOR: {
|
||||
size_t i;
|
||||
int i;
|
||||
for (i = 0; i < obj->u.vec.len; ++i) {
|
||||
gc_mark(pic, obj->u.vec.data[i]);
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ pic_value pic_apply2(pic_state *, struct pic_proc *, pic_value, pic_value);
|
|||
pic_value pic_apply3(pic_state *, struct pic_proc *, pic_value, pic_value, pic_value);
|
||||
pic_value pic_apply4(pic_state *, struct pic_proc *, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_apply5(pic_state *, struct pic_proc *, pic_value, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_apply_trampoline(pic_state *, struct pic_proc *, size_t, pic_value *);
|
||||
pic_value pic_apply_trampoline(pic_state *, struct pic_proc *, int, pic_value *);
|
||||
pic_value pic_apply_trampoline_list(pic_state *, struct pic_proc *, pic_value);
|
||||
pic_value pic_eval(pic_state *, pic_value, struct pic_env *);
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ extern "C" {
|
|||
struct pic_blob {
|
||||
PIC_OBJECT_HEADER
|
||||
unsigned char *data;
|
||||
size_t len;
|
||||
int 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_make_blob(pic_state *, size_t);
|
||||
struct pic_blob *pic_make_blob(pic_state *, int);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ pic_value pic_values2(pic_state *, pic_value, pic_value);
|
|||
pic_value pic_values3(pic_state *, pic_value, pic_value, pic_value);
|
||||
pic_value pic_values4(pic_state *, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_values5(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_values(pic_state *, size_t, pic_value *);
|
||||
pic_value pic_values(pic_state *, int, pic_value *);
|
||||
pic_value pic_values_by_list(pic_state *, pic_value);
|
||||
size_t pic_receive(pic_state *, size_t, pic_value *);
|
||||
int pic_receive(pic_state *, int, pic_value *);
|
||||
|
||||
pic_value pic_callcc(pic_state *, struct pic_proc *);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ struct pic_dict *pic_make_dict(pic_state *);
|
|||
pic_value pic_dict_ref(pic_state *, struct pic_dict *, pic_sym *);
|
||||
void pic_dict_set(pic_state *, struct pic_dict *, pic_sym *, pic_value);
|
||||
void pic_dict_del(pic_state *, struct pic_dict *, pic_sym *);
|
||||
size_t pic_dict_size(pic_state *, struct pic_dict *);
|
||||
int pic_dict_size(pic_state *, struct pic_dict *);
|
||||
bool pic_dict_has(pic_state *, struct pic_dict *, pic_sym *);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -56,8 +56,8 @@ pic_value pic_list4(pic_state *, pic_value, pic_value, pic_value, pic_value);
|
|||
pic_value pic_list5(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_list6(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_list7(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value);
|
||||
pic_value pic_list_by_array(pic_state *, size_t, pic_value *);
|
||||
pic_value pic_make_list(pic_state *, size_t, pic_value);
|
||||
pic_value pic_list_by_array(pic_state *, int, pic_value *);
|
||||
pic_value pic_make_list(pic_state *, int, pic_value);
|
||||
|
||||
#define pic_for_each(var, list, it) \
|
||||
for (it = (list); ! pic_nil_p(it); it = pic_cdr(pic, it)) \
|
||||
|
@ -85,9 +85,9 @@ pic_value pic_cadr(pic_state *, pic_value);
|
|||
pic_value pic_cdar(pic_state *, pic_value);
|
||||
pic_value pic_cddr(pic_state *, pic_value);
|
||||
|
||||
pic_value pic_list_tail(pic_state *, pic_value, size_t);
|
||||
pic_value pic_list_ref(pic_state *, pic_value, size_t);
|
||||
void pic_list_set(pic_state *, pic_value, size_t, pic_value);
|
||||
pic_value pic_list_tail(pic_state *, pic_value, int);
|
||||
pic_value pic_list_ref(pic_state *, pic_value, int);
|
||||
void pic_list_set(pic_state *, pic_value, int, pic_value);
|
||||
pic_value pic_list_copy(pic_state *, pic_value);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -20,13 +20,13 @@ void pic_rope_decref(pic_state *, struct pic_rope *);
|
|||
#define pic_str_p(v) (pic_type(v) == PIC_TT_STRING)
|
||||
#define pic_str_ptr(o) ((struct pic_string *)pic_ptr(o))
|
||||
|
||||
pic_str *pic_make_str(pic_state *, const char * /* nullable */, size_t);
|
||||
pic_str *pic_make_str(pic_state *, const char * /* nullable */, int);
|
||||
pic_str *pic_make_str_cstr(pic_state *, const char *);
|
||||
|
||||
char pic_str_ref(pic_state *, pic_str *, size_t);
|
||||
size_t pic_str_len(pic_str *);
|
||||
char pic_str_ref(pic_state *, pic_str *, int);
|
||||
int pic_str_len(pic_str *);
|
||||
pic_str *pic_str_cat(pic_state *, pic_str *, pic_str *);
|
||||
pic_str *pic_str_sub(pic_state *, pic_str *, size_t, size_t);
|
||||
pic_str *pic_str_sub(pic_state *, pic_str *, int, int);
|
||||
int pic_str_cmp(pic_state *, pic_str *, pic_str *);
|
||||
const char *pic_str_cstr(pic_state *, pic_str *);
|
||||
|
||||
|
|
|
@ -227,7 +227,6 @@ PIC_INLINE pic_value pic_invalid_value();
|
|||
PIC_INLINE pic_value pic_obj_value(void *);
|
||||
PIC_INLINE pic_value pic_float_value(double);
|
||||
PIC_INLINE pic_value pic_int_value(int);
|
||||
PIC_INLINE pic_value pic_size_value(size_t);
|
||||
PIC_INLINE pic_value pic_char_value(char c);
|
||||
|
||||
PIC_INLINE bool pic_eq_p(pic_value, pic_value);
|
||||
|
@ -360,17 +359,6 @@ pic_bool_value(bool b)
|
|||
return v;
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_size_value(size_t s)
|
||||
{
|
||||
if (sizeof(unsigned) < sizeof(size_t)) {
|
||||
if (s > (size_t)INT_MAX) {
|
||||
return pic_float_value(s);
|
||||
}
|
||||
}
|
||||
return pic_int_value((int)s);
|
||||
}
|
||||
|
||||
#if PIC_NAN_BOXING
|
||||
|
||||
PIC_INLINE pic_value
|
||||
|
|
|
@ -12,13 +12,13 @@ extern "C" {
|
|||
struct pic_vector {
|
||||
PIC_OBJECT_HEADER
|
||||
pic_value *data;
|
||||
size_t len;
|
||||
int len;
|
||||
};
|
||||
|
||||
#define pic_vec_p(v) (pic_type(v) == PIC_TT_VECTOR)
|
||||
#define pic_vec_ptr(o) ((struct pic_vector *)pic_ptr(o))
|
||||
|
||||
pic_vec *pic_make_vec(pic_state *, size_t);
|
||||
pic_vec *pic_make_vec(pic_state *, int);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ static pic_value
|
|||
pic_lib_current_library(pic_state *pic)
|
||||
{
|
||||
pic_value lib;
|
||||
size_t n;
|
||||
int n;
|
||||
|
||||
n = pic_get_args(pic, "|o", &lib);
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ pic_macro_variable_p(pic_state *pic)
|
|||
static pic_value
|
||||
pic_macro_variable_eq_p(pic_state *pic)
|
||||
{
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *argv;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
|
|
@ -58,7 +58,7 @@ pic_number_exact(pic_state *pic)
|
|||
static pic_value \
|
||||
pic_number_##op(pic_state *pic) \
|
||||
{ \
|
||||
size_t argc, i; \
|
||||
int argc, i; \
|
||||
pic_value *argv; \
|
||||
\
|
||||
pic_get_args(pic, "*", &argc, &argv); \
|
||||
|
@ -85,7 +85,7 @@ DEFINE_CMP(ge)
|
|||
static pic_value \
|
||||
pic_number_##op(pic_state *pic) \
|
||||
{ \
|
||||
size_t argc, i; \
|
||||
int argc, i; \
|
||||
pic_value *argv, tmp; \
|
||||
\
|
||||
pic_get_args(pic, "*", &argc, &argv); \
|
||||
|
@ -176,7 +176,7 @@ pic_number_number_to_string(pic_state *pic)
|
|||
if (e) {
|
||||
int ival = (int) f;
|
||||
int ilen = number_string_length(ival, radix);
|
||||
size_t s = ilen + 1;
|
||||
int s = ilen + 1;
|
||||
char *buf = pic_malloc(pic, s);
|
||||
|
||||
number_string(ival, radix, ilen, buf);
|
||||
|
|
|
@ -157,7 +157,7 @@ pic_list7(pic_state *pic, pic_value obj1, pic_value obj2, pic_value obj3, pic_va
|
|||
}
|
||||
|
||||
pic_value
|
||||
pic_list_by_array(pic_state *pic, size_t c, pic_value *vs)
|
||||
pic_list_by_array(pic_state *pic, int c, pic_value *vs)
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
|
@ -169,10 +169,10 @@ pic_list_by_array(pic_state *pic, size_t c, pic_value *vs)
|
|||
}
|
||||
|
||||
pic_value
|
||||
pic_make_list(pic_state *pic, size_t k, pic_value fill)
|
||||
pic_make_list(pic_state *pic, int k, pic_value fill)
|
||||
{
|
||||
pic_value list;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
list = pic_nil_value();
|
||||
for (i = 0; i < k; ++i) {
|
||||
|
@ -372,7 +372,7 @@ pic_cddr(pic_state *pic, pic_value v)
|
|||
}
|
||||
|
||||
pic_value
|
||||
pic_list_tail(pic_state *pic, pic_value list, size_t i)
|
||||
pic_list_tail(pic_state *pic, pic_value list, int i)
|
||||
{
|
||||
while (i-- > 0) {
|
||||
list = pic_cdr(pic, list);
|
||||
|
@ -381,13 +381,13 @@ pic_list_tail(pic_state *pic, pic_value list, size_t i)
|
|||
}
|
||||
|
||||
pic_value
|
||||
pic_list_ref(pic_state *pic, pic_value list, size_t i)
|
||||
pic_list_ref(pic_state *pic, pic_value list, int i)
|
||||
{
|
||||
return pic_car(pic, pic_list_tail(pic, list, i));
|
||||
}
|
||||
|
||||
void
|
||||
pic_list_set(pic_state *pic, pic_value list, size_t i, pic_value obj)
|
||||
pic_list_set(pic_state *pic, pic_value list, int i, pic_value obj)
|
||||
{
|
||||
pic_pair_ptr(pic_list_tail(pic, list, i))->car = obj;
|
||||
}
|
||||
|
@ -530,10 +530,10 @@ pic_pair_list_p(pic_state *pic)
|
|||
static pic_value
|
||||
pic_pair_make_list(pic_state *pic)
|
||||
{
|
||||
size_t i;
|
||||
int i;
|
||||
pic_value fill = pic_undef_value();
|
||||
|
||||
pic_get_args(pic, "k|o", &i, &fill);
|
||||
pic_get_args(pic, "i|o", &i, &fill);
|
||||
|
||||
return pic_make_list(pic, i, fill);
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ pic_pair_make_list(pic_state *pic)
|
|||
static pic_value
|
||||
pic_pair_list(pic_state *pic)
|
||||
{
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value *argv;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
@ -556,13 +556,13 @@ pic_pair_length(pic_state *pic)
|
|||
|
||||
pic_get_args(pic, "o", &list);
|
||||
|
||||
return pic_size_value(pic_length(pic, list));
|
||||
return pic_int_value(pic_length(pic, list));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_pair_append(pic_state *pic)
|
||||
{
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value *args, list;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &args);
|
||||
|
@ -593,9 +593,9 @@ static pic_value
|
|||
pic_pair_list_tail(pic_state *pic)
|
||||
{
|
||||
pic_value list;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
pic_get_args(pic, "ok", &list, &i);
|
||||
pic_get_args(pic, "oi", &list, &i);
|
||||
|
||||
return pic_list_tail(pic, list, i);
|
||||
}
|
||||
|
@ -604,9 +604,9 @@ static pic_value
|
|||
pic_pair_list_ref(pic_state *pic)
|
||||
{
|
||||
pic_value list;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
pic_get_args(pic, "ok", &list, &i);
|
||||
pic_get_args(pic, "oi", &list, &i);
|
||||
|
||||
return pic_list_ref(pic, list, i);
|
||||
}
|
||||
|
@ -615,9 +615,9 @@ static pic_value
|
|||
pic_pair_list_set(pic_state *pic)
|
||||
{
|
||||
pic_value list, obj;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
pic_get_args(pic, "oko", &list, &i, &obj);
|
||||
pic_get_args(pic, "oio", &list, &i, &obj);
|
||||
|
||||
pic_list_set(pic, list, i, obj);
|
||||
|
||||
|
@ -638,7 +638,7 @@ static pic_value
|
|||
pic_pair_map(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *args;
|
||||
pic_value arg, ret;
|
||||
|
||||
|
@ -671,7 +671,7 @@ static pic_value
|
|||
pic_pair_for_each(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *args;
|
||||
pic_value arg;
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ string_write(pic_state *pic, void *cookie, const char *ptr, int size)
|
|||
|
||||
if (m->pos + size >= m->capa) {
|
||||
m->capa = (m->pos + size) * 2;
|
||||
m->buf = pic_realloc(pic, m->buf, (size_t)m->capa);
|
||||
m->buf = pic_realloc(pic, m->buf, m->capa);
|
||||
}
|
||||
memcpy(m->buf + m->pos, ptr, size);
|
||||
m->pos += size;
|
||||
|
@ -726,9 +726,9 @@ pic_port_read_blob(pic_state *pic)
|
|||
{
|
||||
struct pic_port *port = pic_stdin(pic);
|
||||
pic_blob *blob;
|
||||
size_t k, i;
|
||||
int k, i;
|
||||
|
||||
pic_get_args(pic, "k|p", &k, &port);
|
||||
pic_get_args(pic, "i|p", &k, &port);
|
||||
|
||||
assert_port_profile(port, PIC_PORT_IN | PIC_PORT_BINARY, "read-bytevector");
|
||||
|
||||
|
@ -750,11 +750,10 @@ pic_port_read_blob_ip(pic_state *pic)
|
|||
{
|
||||
struct pic_port *port;
|
||||
struct pic_blob *bv;
|
||||
int n;
|
||||
char *buf;
|
||||
size_t start, end, i, len;
|
||||
int n, start, end, i, len;
|
||||
|
||||
n = pic_get_args(pic, "b|pkk", &bv, &port, &start, &end);
|
||||
n = pic_get_args(pic, "b|pii", &bv, &port, &start, &end);
|
||||
switch (n) {
|
||||
case 1:
|
||||
port = pic_stdin(pic);
|
||||
|
@ -781,7 +780,7 @@ pic_port_read_blob_ip(pic_state *pic)
|
|||
return pic_eof_object();
|
||||
}
|
||||
else {
|
||||
return pic_size_value(i);
|
||||
return pic_int_value(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -856,10 +855,9 @@ pic_port_write_blob(pic_state *pic)
|
|||
{
|
||||
struct pic_blob *blob;
|
||||
struct pic_port *port;
|
||||
int n;
|
||||
size_t start, end, i;
|
||||
int n, start, end, i;
|
||||
|
||||
n = pic_get_args(pic, "b|pkk", &blob, &port, &start, &end);
|
||||
n = pic_get_args(pic, "b|pii", &blob, &port, &start, &end);
|
||||
switch (n) {
|
||||
case 1:
|
||||
port = pic_stdout(pic);
|
||||
|
|
|
@ -72,7 +72,7 @@ pic_proc_apply(pic_state *pic)
|
|||
{
|
||||
struct pic_proc *proc;
|
||||
pic_value *args;
|
||||
size_t argc;
|
||||
int argc;
|
||||
pic_value arg_list;
|
||||
|
||||
pic_get_args(pic, "l*", &proc, &argc, &args);
|
||||
|
|
|
@ -197,7 +197,7 @@ read_syntax_unquote(pic_state *pic, struct pic_port *port, int PIC_UNUSED(c))
|
|||
static pic_value
|
||||
read_symbol(pic_state *pic, struct pic_port *port, int c)
|
||||
{
|
||||
size_t len;
|
||||
int len;
|
||||
char *buf;
|
||||
pic_sym *sym;
|
||||
|
||||
|
@ -460,7 +460,7 @@ static pic_value
|
|||
read_string(pic_state *pic, struct pic_port *port, int c)
|
||||
{
|
||||
char *buf;
|
||||
size_t size, cnt;
|
||||
int size, cnt;
|
||||
pic_str *str;
|
||||
|
||||
size = 256;
|
||||
|
@ -495,7 +495,7 @@ static pic_value
|
|||
read_pipe(pic_state *pic, struct pic_port *port, int c)
|
||||
{
|
||||
char *buf;
|
||||
size_t size, cnt;
|
||||
int size, cnt;
|
||||
pic_sym *sym;
|
||||
/* Currently supports only ascii chars */
|
||||
char HEX_BUF[3];
|
||||
|
@ -539,7 +539,7 @@ static pic_value
|
|||
read_blob(pic_state *pic, struct pic_port *port, int c)
|
||||
{
|
||||
int nbits, n;
|
||||
size_t len, i;
|
||||
int len, i;
|
||||
unsigned char *dat;
|
||||
pic_blob *blob;
|
||||
|
||||
|
@ -637,7 +637,7 @@ read_vector(pic_state *pic, struct pic_port *port, int c)
|
|||
{
|
||||
pic_value list, it, elem;
|
||||
pic_vec *vec;
|
||||
size_t i = 0;
|
||||
int i = 0;
|
||||
|
||||
list = read(pic, port, c);
|
||||
|
||||
|
@ -690,7 +690,7 @@ read_label_set(pic_state *pic, struct pic_port *port, int i)
|
|||
|
||||
tmp = pic_vec_ptr(read(pic, port, c));
|
||||
PIC_SWAP(pic_value *, tmp->data, pic_vec_ptr(val)->data);
|
||||
PIC_SWAP(size_t, tmp->len, pic_vec_ptr(val)->len);
|
||||
PIC_SWAP(int, tmp->len, pic_vec_ptr(val)->len);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ rope_cstr(pic_state *pic, struct pic_rope *x)
|
|||
}
|
||||
|
||||
pic_str *
|
||||
pic_make_str(pic_state *pic, const char *str, size_t len)
|
||||
pic_make_str(pic_state *pic, const char *str, int len)
|
||||
{
|
||||
if (str == NULL && len > 0) {
|
||||
pic_errorf(pic, "zero length specified against NULL ptr");
|
||||
|
@ -240,14 +240,14 @@ pic_make_str_cstr(pic_state *pic, const char *cstr)
|
|||
return pic_make_str(pic, cstr, strlen(cstr));
|
||||
}
|
||||
|
||||
size_t
|
||||
int
|
||||
pic_str_len(pic_str *str)
|
||||
{
|
||||
return rope_len(str->rope);
|
||||
}
|
||||
|
||||
char
|
||||
pic_str_ref(pic_state *pic, pic_str *str, size_t i)
|
||||
pic_str_ref(pic_state *pic, pic_str *str, int i)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -265,7 +265,7 @@ pic_str_cat(pic_state *pic, pic_str *a, pic_str *b)
|
|||
}
|
||||
|
||||
pic_str *
|
||||
pic_str_sub(pic_state *pic, pic_str *str, size_t s, size_t e)
|
||||
pic_str_sub(pic_state *pic, pic_str *str, int s, int e)
|
||||
{
|
||||
return pic_make_string(pic, rope_sub(pic, str->rope, s, e));
|
||||
}
|
||||
|
@ -425,21 +425,21 @@ pic_str_string_p(pic_state *pic)
|
|||
static pic_value
|
||||
pic_str_string(pic_state *pic)
|
||||
{
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *argv;
|
||||
pic_str *str;
|
||||
char *buf;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
||||
buf = pic_malloc(pic, (size_t)argc);
|
||||
buf = pic_malloc(pic, 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, (size_t)argc);
|
||||
str = pic_make_str(pic, buf, argc);
|
||||
pic_free(pic, buf);
|
||||
|
||||
return pic_obj_value(str);
|
||||
|
@ -448,12 +448,12 @@ pic_str_string(pic_state *pic)
|
|||
static pic_value
|
||||
pic_str_make_string(pic_state *pic)
|
||||
{
|
||||
size_t len;
|
||||
int len;
|
||||
char c = ' ';
|
||||
char *buf;
|
||||
pic_value ret;
|
||||
|
||||
pic_get_args(pic, "k|c", &len, &c);
|
||||
pic_get_args(pic, "i|c", &len, &c);
|
||||
|
||||
buf = pic_malloc(pic, len);
|
||||
memset(buf, c, len);
|
||||
|
@ -471,16 +471,16 @@ pic_str_string_length(pic_state *pic)
|
|||
|
||||
pic_get_args(pic, "s", &str);
|
||||
|
||||
return pic_size_value(pic_str_len(str));
|
||||
return pic_int_value(pic_str_len(str));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_str_string_ref(pic_state *pic)
|
||||
{
|
||||
pic_str *str;
|
||||
size_t k;
|
||||
int k;
|
||||
|
||||
pic_get_args(pic, "sk", &str, &k);
|
||||
pic_get_args(pic, "si", &str, &k);
|
||||
|
||||
return pic_char_value(pic_str_ref(pic, str, k));
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ pic_str_string_ref(pic_state *pic)
|
|||
static pic_value \
|
||||
pic_str_string_##name(pic_state *pic) \
|
||||
{ \
|
||||
size_t argc, i; \
|
||||
int argc, i; \
|
||||
pic_value *argv; \
|
||||
\
|
||||
pic_get_args(pic, "*", &argc, &argv); \
|
||||
|
@ -519,10 +519,9 @@ static pic_value
|
|||
pic_str_string_copy(pic_state *pic)
|
||||
{
|
||||
pic_str *str;
|
||||
int n;
|
||||
size_t start, end;
|
||||
int n, start, end;
|
||||
|
||||
n = pic_get_args(pic, "s|kk", &str, &start, &end);
|
||||
n = pic_get_args(pic, "s|ii", &str, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
@ -537,7 +536,7 @@ pic_str_string_copy(pic_state *pic)
|
|||
static pic_value
|
||||
pic_str_string_append(pic_state *pic)
|
||||
{
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *argv;
|
||||
pic_str *str;
|
||||
|
||||
|
@ -558,7 +557,7 @@ pic_str_string_map(pic_state *pic)
|
|||
{
|
||||
struct pic_proc *proc;
|
||||
pic_value *argv, vals, val;
|
||||
size_t argc, i, len, j;
|
||||
int argc, i, len, j;
|
||||
pic_str *str;
|
||||
char *buf;
|
||||
|
||||
|
@ -606,7 +605,7 @@ static pic_value
|
|||
pic_str_string_for_each(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
size_t argc, len, i, j;
|
||||
int argc, len, i, j;
|
||||
pic_value *argv, vals;
|
||||
|
||||
pic_get_args(pic, "l*", &proc, &argc, &argv);
|
||||
|
@ -641,7 +640,7 @@ pic_str_list_to_string(pic_state *pic)
|
|||
{
|
||||
pic_str *str;
|
||||
pic_value list, e, it;
|
||||
size_t i;
|
||||
int i;
|
||||
char *buf;
|
||||
|
||||
pic_get_args(pic, "o", &list);
|
||||
|
@ -676,10 +675,9 @@ pic_str_string_to_list(pic_state *pic)
|
|||
{
|
||||
pic_str *str;
|
||||
pic_value list;
|
||||
int n;
|
||||
size_t start, end, i;
|
||||
int n, start, end, i;
|
||||
|
||||
n = pic_get_args(pic, "s|kk", &str, &start, &end);
|
||||
n = pic_get_args(pic, "s|ii", &str, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
|
|
@ -60,7 +60,7 @@ pic_symbol_symbol_p(pic_state *pic)
|
|||
static pic_value
|
||||
pic_symbol_symbol_eq_p(pic_state *pic)
|
||||
{
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *argv;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#include "picrin.h"
|
||||
|
||||
struct pic_vector *
|
||||
pic_make_vec(pic_state *pic, size_t len)
|
||||
pic_make_vec(pic_state *pic, int len)
|
||||
{
|
||||
struct pic_vector *vec;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
vec = (struct pic_vector *)pic_obj_alloc(pic, sizeof(struct pic_vector), PIC_TT_VECTOR);
|
||||
vec->len = len;
|
||||
|
@ -32,13 +32,13 @@ pic_vec_vector_p(pic_state *pic)
|
|||
static pic_value
|
||||
pic_vec_vector(pic_state *pic)
|
||||
{
|
||||
size_t argc, i;
|
||||
int argc, i;
|
||||
pic_value *argv;
|
||||
pic_vec *vec;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
||||
vec = pic_make_vec(pic, (size_t)argc);
|
||||
vec = pic_make_vec(pic, argc);
|
||||
|
||||
for (i = 0; i < argc; ++i) {
|
||||
vec->data[i] = argv[i];
|
||||
|
@ -51,11 +51,10 @@ static pic_value
|
|||
pic_vec_make_vector(pic_state *pic)
|
||||
{
|
||||
pic_value v;
|
||||
int n;
|
||||
size_t k, i;
|
||||
int n, k, i;
|
||||
struct pic_vector *vec;
|
||||
|
||||
n = pic_get_args(pic, "k|o", &k, &v);
|
||||
n = pic_get_args(pic, "i|o", &k, &v);
|
||||
|
||||
vec = pic_make_vec(pic, k);
|
||||
if (n == 2) {
|
||||
|
@ -73,16 +72,16 @@ pic_vec_vector_length(pic_state *pic)
|
|||
|
||||
pic_get_args(pic, "v", &v);
|
||||
|
||||
return pic_size_value(v->len);
|
||||
return pic_int_value(v->len);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_vec_vector_ref(pic_state *pic)
|
||||
{
|
||||
struct pic_vector *v;
|
||||
size_t k;
|
||||
int k;
|
||||
|
||||
pic_get_args(pic, "vk", &v, &k);
|
||||
pic_get_args(pic, "vi", &v, &k);
|
||||
|
||||
if (v->len <= k) {
|
||||
pic_errorf(pic, "vector-ref: index out of range");
|
||||
|
@ -94,10 +93,10 @@ static pic_value
|
|||
pic_vec_vector_set(pic_state *pic)
|
||||
{
|
||||
struct pic_vector *v;
|
||||
size_t k;
|
||||
int k;
|
||||
pic_value o;
|
||||
|
||||
pic_get_args(pic, "vko", &v, &k, &o);
|
||||
pic_get_args(pic, "vio", &v, &k, &o);
|
||||
|
||||
if (v->len <= k) {
|
||||
pic_errorf(pic, "vector-set!: index out of range");
|
||||
|
@ -110,10 +109,9 @@ static pic_value
|
|||
pic_vec_vector_copy_i(pic_state *pic)
|
||||
{
|
||||
pic_vec *to, *from;
|
||||
int n;
|
||||
size_t at, start, end;
|
||||
int n, at, start, end;
|
||||
|
||||
n = pic_get_args(pic, "vkv|kk", &to, &at, &from, &start, &end);
|
||||
n = pic_get_args(pic, "viv|ii", &to, &at, &from, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 3:
|
||||
|
@ -142,10 +140,9 @@ static pic_value
|
|||
pic_vec_vector_copy(pic_state *pic)
|
||||
{
|
||||
pic_vec *vec, *to;
|
||||
int n;
|
||||
size_t start, end, i = 0;
|
||||
int n, start, end, i = 0;
|
||||
|
||||
n = pic_get_args(pic, "v|kk", &vec, &start, &end);
|
||||
n = pic_get_args(pic, "v|ii", &vec, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
@ -170,7 +167,7 @@ static pic_value
|
|||
pic_vec_vector_append(pic_state *pic)
|
||||
{
|
||||
pic_value *argv;
|
||||
size_t argc, i, j, len;
|
||||
int argc, i, j, len;
|
||||
pic_vec *vec;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
@ -199,10 +196,9 @@ pic_vec_vector_fill_i(pic_state *pic)
|
|||
{
|
||||
pic_vec *vec;
|
||||
pic_value obj;
|
||||
int n;
|
||||
size_t start, end;
|
||||
int n, start, end;
|
||||
|
||||
n = pic_get_args(pic, "vo|kk", &vec, &obj, &start, &end);
|
||||
n = pic_get_args(pic, "vo|ii", &vec, &obj, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 2:
|
||||
|
@ -222,7 +218,7 @@ static pic_value
|
|||
pic_vec_vector_map(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
size_t argc, i, len, j;
|
||||
int argc, i, len, j;
|
||||
pic_value *argv, vals;
|
||||
pic_vec *vec;
|
||||
|
||||
|
@ -254,7 +250,7 @@ static pic_value
|
|||
pic_vec_vector_for_each(pic_state *pic)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
size_t argc, i, len, j;
|
||||
int argc, i, len, j;
|
||||
pic_value *argv, vals;
|
||||
|
||||
pic_get_args(pic, "l*", &proc, &argc, &argv);
|
||||
|
@ -302,10 +298,9 @@ pic_vec_vector_to_list(pic_state *pic)
|
|||
{
|
||||
struct pic_vector *vec;
|
||||
pic_value list;
|
||||
int n;
|
||||
size_t start, end, i;
|
||||
int n, start, end, i;
|
||||
|
||||
n = pic_get_args(pic, "v|kk", &vec, &start, &end);
|
||||
n = pic_get_args(pic, "v|ii", &vec, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
@ -327,11 +322,10 @@ pic_vec_vector_to_string(pic_state *pic)
|
|||
{
|
||||
pic_vec *vec;
|
||||
char *buf;
|
||||
int n;
|
||||
size_t start, end, i;
|
||||
int n, start, end, i;
|
||||
pic_str *str;
|
||||
|
||||
n = pic_get_args(pic, "v|kk", &vec, &start, &end);
|
||||
n = pic_get_args(pic, "v|ii", &vec, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
@ -362,12 +356,10 @@ static pic_value
|
|||
pic_vec_string_to_vector(pic_state *pic)
|
||||
{
|
||||
pic_str *str;
|
||||
int n;
|
||||
size_t start, end;
|
||||
size_t i;
|
||||
int n, start, end, i;
|
||||
pic_vec *vec;
|
||||
|
||||
n = pic_get_args(pic, "s|kk", &str, &start, &end);
|
||||
n = pic_get_args(pic, "s|ii", &str, &start, &end);
|
||||
|
||||
switch (n) {
|
||||
case 1:
|
||||
|
|
|
@ -24,7 +24,6 @@ pic_get_proc(pic_state *pic)
|
|||
* o pic_value * object
|
||||
* i int * int
|
||||
* I int *, bool * int with exactness
|
||||
* k size_t * size_t implicitly converted from int
|
||||
* f double * float
|
||||
* F double *, bool * float with exactness
|
||||
* s pic_str ** string object
|
||||
|
@ -39,15 +38,15 @@ pic_get_proc(pic_state *pic)
|
|||
* e struct pic_error ** error object
|
||||
*
|
||||
* | optional operator
|
||||
* * size_t *, pic_value ** variable length operator
|
||||
* * int *, pic_value ** variable length operator
|
||||
*/
|
||||
|
||||
int
|
||||
pic_get_args(pic_state *pic, const char *format, ...)
|
||||
{
|
||||
char c;
|
||||
size_t paramc, optc, min;
|
||||
size_t i , argc = pic->ci->argc - 1;
|
||||
int paramc, optc, min;
|
||||
int i, argc = pic->ci->argc - 1;
|
||||
va_list ap;
|
||||
bool rest = false, opt = false;
|
||||
|
||||
|
@ -187,34 +186,6 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'k': {
|
||||
size_t *k;
|
||||
pic_value v;
|
||||
int x;
|
||||
size_t s;
|
||||
|
||||
k = va_arg(ap, size_t *);
|
||||
|
||||
v = GET_OPERAND(pic, i);
|
||||
switch (pic_type(v)) {
|
||||
case PIC_TT_INT:
|
||||
x = pic_int(v);
|
||||
if (x < 0) {
|
||||
pic_errorf(pic, "pic_get_args: expected non-negative int, but got ~s", v);
|
||||
}
|
||||
s = (size_t)x;
|
||||
if (sizeof(unsigned) > sizeof(size_t)) {
|
||||
if (x != (int)s) {
|
||||
pic_errorf(pic, "pic_get_args: int unrepresentable with size_t ~s", v);
|
||||
}
|
||||
}
|
||||
*k = (size_t)x;
|
||||
break;
|
||||
default:
|
||||
pic_errorf(pic, "pic_get_args: expected int, but got ~s", v);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 's': {
|
||||
pic_str **str;
|
||||
pic_value v;
|
||||
|
@ -374,12 +345,12 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
|||
}
|
||||
}
|
||||
if (rest) {
|
||||
size_t *n;
|
||||
int *n;
|
||||
pic_value **argv;
|
||||
|
||||
n = va_arg(ap, size_t *);
|
||||
n = va_arg(ap, int *);
|
||||
argv = va_arg(ap, pic_value **);
|
||||
*n = (size_t)(argc - (i - 1));
|
||||
*n = argc - (i - 1);
|
||||
*argv = &GET_OPERAND(pic, i);
|
||||
}
|
||||
va_end(ap);
|
||||
|
@ -422,7 +393,7 @@ vm_push_cxt(pic_state *pic)
|
|||
{
|
||||
pic_callinfo *ci = pic->ci;
|
||||
|
||||
ci->cxt = (struct pic_context *)pic_obj_alloc(pic, sizeof(struct pic_context) + sizeof(pic_value) * (size_t)(ci->regc), PIC_TT_CXT);
|
||||
ci->cxt = (struct pic_context *)pic_obj_alloc(pic, sizeof(struct pic_context) + sizeof(pic_value) * ci->regc, PIC_TT_CXT);
|
||||
ci->cxt->up = ci->up;
|
||||
ci->cxt->regc = ci->regc;
|
||||
ci->cxt->regs = ci->regs;
|
||||
|
@ -1007,11 +978,11 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args)
|
|||
}
|
||||
|
||||
pic_value
|
||||
pic_apply_trampoline(pic_state *pic, struct pic_proc *proc, size_t argc, pic_value *args)
|
||||
pic_apply_trampoline(pic_state *pic, struct pic_proc *proc, int argc, pic_value *args)
|
||||
{
|
||||
pic_value *sp;
|
||||
pic_callinfo *ci;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
PIC_INIT_CODE_I(pic->iseq[0], OP_NOP, 0);
|
||||
PIC_INIT_CODE_I(pic->iseq[1], OP_TAILCALL, -1);
|
||||
|
@ -1038,7 +1009,7 @@ pic_apply_trampoline(pic_state *pic, struct pic_proc *proc, size_t argc, pic_val
|
|||
pic_value
|
||||
pic_apply_trampoline_list(pic_state *pic, struct pic_proc *proc, pic_value args)
|
||||
{
|
||||
size_t i, argc = pic_length(pic, args);
|
||||
int i, argc = pic_length(pic, args);
|
||||
pic_value val, it;
|
||||
pic_vec *argv = pic_make_vec(pic, argc);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ writer_control_destroy(struct writer_control *p)
|
|||
static void
|
||||
write_blob(pic_state *pic, pic_blob *blob, xFILE *file)
|
||||
{
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
xfprintf(pic, file, "#u8(");
|
||||
for (i = 0; i < blob->len; ++i) {
|
||||
|
@ -84,7 +84,7 @@ write_char(pic_state *pic, char c, xFILE *file, int mode)
|
|||
static void
|
||||
write_str(pic_state *pic, pic_str *str, xFILE *file, int mode)
|
||||
{
|
||||
size_t i;
|
||||
int i;
|
||||
const char *cstr = pic_str_cstr(pic, str);
|
||||
|
||||
if (mode == DISPLAY_MODE) {
|
||||
|
@ -224,7 +224,7 @@ write_vec(struct writer_control *p, pic_vec *vec)
|
|||
{
|
||||
pic_state *pic = p->pic;
|
||||
xFILE *file = p->file;
|
||||
size_t i;
|
||||
int i;
|
||||
|
||||
xfprintf(pic, file, "#(");
|
||||
for (i = 0; i < vec->len; ++i) {
|
||||
|
@ -356,7 +356,7 @@ traverse(struct writer_control *p, pic_value obj)
|
|||
traverse(p, pic_cdr(pic, obj));
|
||||
} else if (pic_vec_p(obj)) {
|
||||
/* vector */
|
||||
size_t i;
|
||||
int i;
|
||||
for (i = 0; i < pic_vec_ptr(obj)->len; ++i) {
|
||||
traverse(p, pic_vec_ptr(obj)->data[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue