add pic_state parameter (to be used by copy gc)
This commit is contained in:
@@ -38,12 +38,12 @@ typedef struct pic_state pic_state;
|
||||
|
||||
#include "picrin/type.h"
|
||||
|
||||
typedef void *(*pic_allocf)(void *, void *, size_t);
|
||||
typedef void *(*pic_allocf)(void *userdata, void *ptr, size_t n);
|
||||
|
||||
pic_state *pic_open(pic_allocf, void *);
|
||||
pic_state *pic_open(pic_allocf f, void *userdata);
|
||||
void pic_close(pic_state *);
|
||||
|
||||
int pic_get_args(pic_state *, const char *, ...);
|
||||
int pic_get_args(pic_state *, const char *fmt, ...);
|
||||
|
||||
void *pic_malloc(pic_state *, size_t);
|
||||
void *pic_realloc(pic_state *, void *, size_t);
|
||||
@@ -58,83 +58,84 @@ size_t pic_gc_arena_preserve(pic_state *);
|
||||
void pic_gc_arena_restore(pic_state *, size_t);
|
||||
void pic_gc(pic_state *);
|
||||
|
||||
void pic_add_feature(pic_state *, const char *);
|
||||
void pic_add_feature(pic_state *, const char *feature);
|
||||
|
||||
void pic_defun(pic_state *, const char *, pic_func_t);
|
||||
void pic_defvar(pic_state *, const char *, pic_value, struct pic_proc *);
|
||||
void pic_defun(pic_state *, const char *name, pic_func_t f);
|
||||
void pic_defvar(pic_state *, const char *name, pic_value v, struct pic_proc *conv);
|
||||
|
||||
void pic_define(pic_state *, const char *, const char *, pic_value);
|
||||
pic_value pic_ref(pic_state *, const char *, const char *);
|
||||
void pic_set(pic_state *, const char *, const char *, pic_value);
|
||||
pic_value pic_closure_ref(pic_state *, int);
|
||||
void pic_closure_set(pic_state *, int, pic_value);
|
||||
pic_value pic_funcall(pic_state *pic, const char *, const char *, int, ...);
|
||||
void pic_define(pic_state *, const char *lib, const char *name, pic_value v);
|
||||
pic_value pic_ref(pic_state *, const char *lib, const char *name);
|
||||
void pic_set(pic_state *, const char *lib, const char *name, pic_value v);
|
||||
pic_value pic_closure_ref(pic_state *, int i);
|
||||
void pic_closure_set(pic_state *, int i, pic_value v);
|
||||
pic_value pic_funcall(pic_state *, const char *lib, const char *name, int n, ...);
|
||||
|
||||
void pic_make_library(pic_state *, const char *);
|
||||
void pic_in_library(pic_state *, const char *);
|
||||
bool pic_find_library(pic_state *, const char *);
|
||||
void pic_make_library(pic_state *, const char *lib);
|
||||
void pic_in_library(pic_state *, const char *lib);
|
||||
bool pic_find_library(pic_state *, const char *lib);
|
||||
const char *pic_current_library(pic_state *);
|
||||
void pic_import(pic_state *, const char *);
|
||||
void pic_export(pic_state *, pic_sym *);
|
||||
void pic_import(pic_state *, const char *lib);
|
||||
void pic_export(pic_state *, pic_sym *sym);
|
||||
|
||||
PIC_NORETURN void pic_panic(pic_state *, const char *);
|
||||
PIC_NORETURN void pic_errorf(pic_state *, const char *, ...);
|
||||
PIC_NORETURN void pic_panic(pic_state *, const char *msg);
|
||||
PIC_NORETURN void pic_errorf(pic_state *, const char *fmt, ...);
|
||||
|
||||
struct pic_proc *pic_lambda(pic_state *, pic_func_t, int, ...);
|
||||
struct pic_proc *pic_vlambda(pic_state *, pic_func_t, int, va_list);
|
||||
pic_value pic_call(pic_state *, struct pic_proc *, int, ...);
|
||||
pic_value pic_vcall(pic_state *, struct pic_proc *, int, va_list);
|
||||
pic_value pic_apply(pic_state *, struct pic_proc *, int, pic_value *);
|
||||
pic_value pic_applyk(pic_state *, struct pic_proc *, int, pic_value *);
|
||||
struct pic_proc *pic_lambda(pic_state *, pic_func_t f, int n, ...);
|
||||
struct pic_proc *pic_vlambda(pic_state *, pic_func_t f, int n, va_list);
|
||||
pic_value pic_call(pic_state *, struct pic_proc *proc, int, ...);
|
||||
pic_value pic_vcall(pic_state *, struct pic_proc *proc, int, va_list);
|
||||
pic_value pic_apply(pic_state *, struct pic_proc *proc, int n, pic_value *argv);
|
||||
pic_value pic_applyk(pic_state *, struct pic_proc *proc, int n, pic_value *argv);
|
||||
|
||||
int pic_int(pic_value);
|
||||
double pic_float(pic_value);
|
||||
char pic_char(pic_value);
|
||||
bool pic_bool(pic_value);
|
||||
int pic_int(pic_state *, pic_value);
|
||||
double pic_float(pic_state *, pic_value);
|
||||
char pic_char(pic_state *, pic_value);
|
||||
bool pic_bool(pic_state *, pic_value);
|
||||
/* const char *pic_str(pic_state *, pic_value); */
|
||||
/* unsigned char *pic_blob(pic_state *, pic_value, int *len); */
|
||||
/* void *pic_data(pic_state *, pic_value); */
|
||||
|
||||
pic_value pic_undef_value();
|
||||
pic_value pic_int_value(int);
|
||||
pic_value pic_float_value(double);
|
||||
pic_value pic_char_value(char c);
|
||||
pic_value pic_true_value();
|
||||
pic_value pic_false_value();
|
||||
pic_value pic_bool_value(bool);
|
||||
pic_value pic_undef_value(pic_state *);
|
||||
pic_value pic_int_value(pic_state *, int);
|
||||
pic_value pic_float_value(pic_state *, double);
|
||||
pic_value pic_char_value(pic_state *, char);
|
||||
pic_value pic_true_value(pic_state *);
|
||||
pic_value pic_false_value(pic_state *);
|
||||
pic_value pic_bool_value(pic_state *, bool);
|
||||
|
||||
#define pic_undef_p(v) (pic_vtype(v) == PIC_VTYPE_UNDEF)
|
||||
#define pic_int_p(v) (pic_vtype(v) == PIC_VTYPE_INT)
|
||||
#define pic_float_p(v) (pic_vtype(v) == PIC_VTYPE_FLOAT)
|
||||
#define pic_char_p(v) (pic_vtype(v) == PIC_VTYPE_CHAR)
|
||||
#define pic_true_p(v) (pic_vtype(v) == PIC_VTYPE_TRUE)
|
||||
#define pic_false_p(v) (pic_vtype(v) == PIC_VTYPE_FALSE)
|
||||
#define pic_str_p(v) (pic_type(v) == PIC_TT_STRING)
|
||||
#define pic_blob_p(v) (pic_type(v) == PIC_TT_BLOB)
|
||||
#define pic_proc_p(o) (pic_type(o) == PIC_TT_PROC)
|
||||
#define pic_data_p(o) (pic_type(o) == PIC_TT_DATA)
|
||||
#define pic_nil_p(v) (pic_vtype(v) == PIC_VTYPE_NIL)
|
||||
#define pic_pair_p(v) (pic_type(v) == PIC_TT_PAIR)
|
||||
#define pic_vec_p(v) (pic_type(v) == PIC_TT_VECTOR)
|
||||
#define pic_dict_p(v) (pic_type(v) == PIC_TT_DICT)
|
||||
#define pic_weak_p(v) (pic_type(v) == PIC_TT_WEAK)
|
||||
#define pic_sym_p(v) (pic_type(v) == PIC_TT_SYMBOL)
|
||||
#define pic_undef_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_UNDEF)
|
||||
#define pic_int_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_INT)
|
||||
#define pic_float_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_FLOAT)
|
||||
#define pic_char_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_CHAR)
|
||||
#define pic_true_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_TRUE)
|
||||
#define pic_false_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_FALSE)
|
||||
#define pic_str_p(pic,v) (pic_type(pic,v) == PIC_TT_STRING)
|
||||
#define pic_blob_p(pic,v) (pic_type(pic,v) == PIC_TT_BLOB)
|
||||
#define pic_proc_p(pic,v) (pic_type(pic,v) == PIC_TT_PROC)
|
||||
#define pic_data_p(pic,v) (pic_type(pic,v) == PIC_TT_DATA)
|
||||
#define pic_nil_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_NIL)
|
||||
#define pic_pair_p(pic,v) (pic_type(pic,v) == PIC_TT_PAIR)
|
||||
#define pic_vec_p(pic,v) (pic_type(pic,v) == PIC_TT_VECTOR)
|
||||
#define pic_dict_p(pic,v) (pic_type(pic,v) == PIC_TT_DICT)
|
||||
#define pic_weak_p(pic,v) (pic_type(pic,v) == PIC_TT_WEAK)
|
||||
#define pic_port_p(pic, v) (pic_type(pic, v) == PIC_TT_PORT)
|
||||
#define pic_sym_p(pic,v) (pic_type(pic,v) == PIC_TT_SYMBOL)
|
||||
|
||||
enum pic_tt pic_type(pic_value);
|
||||
const char *pic_type_repr(enum pic_tt);
|
||||
enum pic_tt pic_type(pic_state *, pic_value);
|
||||
const char *pic_type_repr(pic_state *, enum pic_tt);
|
||||
|
||||
bool pic_eq_p(pic_value, pic_value);
|
||||
bool pic_eqv_p(pic_value, pic_value);
|
||||
bool pic_eq_p(pic_state *, pic_value, pic_value);
|
||||
bool pic_eqv_p(pic_state *, pic_value, pic_value);
|
||||
bool pic_equal_p(pic_state *, pic_value, pic_value);
|
||||
|
||||
/* list */
|
||||
pic_value pic_nil_value();
|
||||
pic_value pic_nil_value(pic_state *);
|
||||
pic_value pic_cons(pic_state *, pic_value, pic_value);
|
||||
PIC_INLINE pic_value pic_car(pic_state *, pic_value);
|
||||
PIC_INLINE pic_value pic_cdr(pic_state *, pic_value);
|
||||
void pic_set_car(pic_state *, pic_value, pic_value);
|
||||
void pic_set_cdr(pic_state *, pic_value, pic_value);
|
||||
bool pic_list_p(pic_value);
|
||||
bool pic_list_p(pic_state *, pic_value);
|
||||
pic_value pic_list(pic_state *, int n, ...);
|
||||
pic_value pic_vlist(pic_state *, int n, va_list);
|
||||
pic_value pic_list_ref(pic_state *, pic_value, int);
|
||||
@@ -171,7 +172,7 @@ pic_sym *pic_intern(pic_state *, struct pic_string *);
|
||||
const char *pic_symbol_name(pic_state *, pic_sym *);
|
||||
|
||||
/* string */
|
||||
int pic_str_len(struct pic_string *);
|
||||
int pic_str_len(pic_state *, struct pic_string *);
|
||||
char pic_str_ref(pic_state *, struct pic_string *, int);
|
||||
struct pic_string *pic_str_cat(pic_state *, struct pic_string *, struct pic_string *);
|
||||
struct pic_string *pic_str_sub(pic_state *, struct pic_string *, int, int);
|
||||
@@ -199,6 +200,11 @@ int pic_str_hash(pic_state *, struct pic_string *);
|
||||
|
||||
void *pic_default_allocf(void *, void *, size_t);
|
||||
|
||||
#define pic_assert_type(pic, v, type) \
|
||||
if (! pic_##type##_p(pic, v)) { \
|
||||
pic_errorf(pic, "expected " #type ", but got ~s", v); \
|
||||
}
|
||||
|
||||
struct pic_object *pic_obj_alloc(pic_state *, size_t, enum pic_tt);
|
||||
|
||||
#define pic_void(exec) \
|
||||
|
||||
@@ -23,8 +23,8 @@ struct pic_data {
|
||||
|
||||
#define pic_data_ptr(o) ((struct pic_data *)pic_ptr(o))
|
||||
|
||||
PIC_INLINE bool pic_data_type_p(const pic_value obj, const pic_data_type *type) {
|
||||
return pic_data_p(obj) && pic_data_ptr(obj)->type == type;
|
||||
PIC_INLINE bool pic_data_type_p(pic_state *pic, const pic_value obj, const pic_data_type *type) {
|
||||
return pic_data_p(pic, obj) && pic_data_ptr(obj)->type == type;
|
||||
}
|
||||
|
||||
struct pic_data *pic_data_alloc(pic_state *, const pic_data_type *, void *);
|
||||
|
||||
@@ -17,7 +17,7 @@ struct pic_error {
|
||||
struct pic_string *stack;
|
||||
};
|
||||
|
||||
#define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR)
|
||||
#define pic_error_p(pic, v) (pic_type(pic, v) == PIC_TT_ERROR)
|
||||
#define pic_error_ptr(v) ((struct pic_error *)pic_ptr(v))
|
||||
|
||||
struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_value);
|
||||
|
||||
@@ -18,7 +18,7 @@ struct pic_env {
|
||||
struct pic_string *lib;
|
||||
};
|
||||
|
||||
#define pic_env_p(v) (pic_type(v) == PIC_TT_ENV)
|
||||
#define pic_env_p(pic, v) (pic_type(pic, v) == PIC_TT_ENV)
|
||||
#define pic_env_ptr(v) ((struct pic_env *)pic_ptr(v))
|
||||
|
||||
struct pic_env *pic_make_topenv(pic_state *, struct pic_string *);
|
||||
|
||||
@@ -22,7 +22,7 @@ pic_car(pic_state *pic, pic_value obj)
|
||||
{
|
||||
struct pic_pair *pair;
|
||||
|
||||
if (! pic_pair_p(obj)) {
|
||||
if (! pic_pair_p(pic, obj)) {
|
||||
pic_errorf(pic, "car: pair required, but got ~s", obj);
|
||||
}
|
||||
pair = pic_pair_ptr(obj);
|
||||
@@ -35,7 +35,7 @@ pic_cdr(pic_state *pic, pic_value obj)
|
||||
{
|
||||
struct pic_pair *pair;
|
||||
|
||||
if (! pic_pair_p(obj)) {
|
||||
if (! pic_pair_p(pic, obj)) {
|
||||
pic_errorf(pic, "cdr: pair required, but got ~s", obj);
|
||||
}
|
||||
pair = pic_pair_ptr(obj);
|
||||
@@ -53,8 +53,8 @@ pic_value pic_list7(pic_state *, pic_value, pic_value, pic_value, pic_value, pic
|
||||
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)) \
|
||||
#define pic_for_each(var, list, it) \
|
||||
for (it = (list); ! pic_nil_p(pic, it); it = pic_cdr(pic, it)) \
|
||||
if ((var = pic_car(pic, it)), true)
|
||||
|
||||
#define pic_push(pic, item, place) (place = pic_cons(pic, item, place))
|
||||
|
||||
@@ -23,7 +23,6 @@ struct pic_port {
|
||||
int flags;
|
||||
};
|
||||
|
||||
#define pic_port_p(v) (pic_type(v) == PIC_TT_PORT)
|
||||
#define pic_port_ptr(v) ((struct pic_port *)pic_ptr(v))
|
||||
|
||||
pic_value pic_eof_object();
|
||||
|
||||
@@ -41,7 +41,7 @@ struct pic_proc {
|
||||
|
||||
#define pic_proc_ptr(o) ((struct pic_proc *)pic_ptr(o))
|
||||
|
||||
#define pic_context_p(o) (pic_type(o) == PIC_TT_CXT)
|
||||
#define pic_context_p(o) (pic_type(pic, o) == PIC_TT_CXT)
|
||||
#define pic_context_ptr(o) ((struct pic_context *)pic_ptr(o))
|
||||
|
||||
struct pic_proc *pic_make_proc(pic_state *, pic_func_t, int, pic_value *);
|
||||
|
||||
@@ -15,7 +15,7 @@ struct pic_record {
|
||||
pic_value datum;
|
||||
};
|
||||
|
||||
#define pic_rec_p(v) (pic_type(v) == PIC_TT_RECORD)
|
||||
#define pic_rec_p(pic, v) (pic_type(pic, v) == PIC_TT_RECORD)
|
||||
#define pic_rec_ptr(v) ((struct pic_record *)pic_ptr(v))
|
||||
|
||||
struct pic_record *pic_make_rec(pic_state *, pic_value, pic_value);
|
||||
|
||||
@@ -25,7 +25,7 @@ struct pic_id {
|
||||
|
||||
#define pic_sym_ptr(v) ((pic_sym *)pic_ptr(v))
|
||||
|
||||
#define pic_id_p(v) (pic_type(v) == PIC_TT_ID || pic_type(v) == PIC_TT_SYMBOL)
|
||||
#define pic_id_p(pic, v) (pic_type(pic, v) == PIC_TT_ID || pic_type(pic, v) == PIC_TT_SYMBOL)
|
||||
#define pic_id_ptr(v) ((pic_id *)pic_ptr(v))
|
||||
|
||||
pic_id *pic_make_identifier(pic_state *, pic_id *, struct pic_env *);
|
||||
|
||||
@@ -45,13 +45,13 @@ typedef uint64_t pic_value;
|
||||
#define pic_init_value(v,vtype) (v = (0xfff0000000000000ul | ((uint64_t)(vtype) << 48)))
|
||||
|
||||
static inline enum pic_vtype
|
||||
pic_vtype(pic_value v)
|
||||
pic_vtype(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
return 0xfff0 >= (v >> 48) ? PIC_VTYPE_FLOAT : ((v >> 48) & 0xf);
|
||||
}
|
||||
|
||||
static inline double
|
||||
pic_float(pic_value v)
|
||||
pic_float(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
union { double f; uint64_t i; } u;
|
||||
u.i = v;
|
||||
@@ -59,7 +59,7 @@ pic_float(pic_value v)
|
||||
}
|
||||
|
||||
static inline int
|
||||
pic_int(pic_value v)
|
||||
pic_int(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
union { int i; unsigned u; } u;
|
||||
u.u = v & 0xfffffffful;
|
||||
@@ -67,7 +67,7 @@ pic_int(pic_value v)
|
||||
}
|
||||
|
||||
static inline char
|
||||
pic_char(pic_value v)
|
||||
pic_char(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
return v & 0xfffffffful;
|
||||
}
|
||||
@@ -85,23 +85,23 @@ typedef struct {
|
||||
} pic_value;
|
||||
|
||||
#define pic_ptr(v) ((v).u.data)
|
||||
#define pic_vtype(v) ((v).type)
|
||||
#define pic_vtype(pic,v) ((v).type)
|
||||
#define pic_init_value(v,vtype) ((v).type = (vtype), (v).u.data = NULL)
|
||||
|
||||
PIC_INLINE double
|
||||
pic_float(pic_value v)
|
||||
pic_float(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
return v.u.f;
|
||||
}
|
||||
|
||||
PIC_INLINE int
|
||||
pic_int(pic_value v)
|
||||
pic_int(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
return v.u.i;
|
||||
}
|
||||
|
||||
PIC_INLINE char
|
||||
pic_char(pic_value v)
|
||||
pic_char(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
return v.u.c;
|
||||
}
|
||||
@@ -163,18 +163,13 @@ typedef struct pic_id pic_id;
|
||||
typedef struct pic_pair pic_pair;
|
||||
typedef struct pic_vector pic_vec;
|
||||
|
||||
#define pic_obj_p(v) (pic_vtype(v) == PIC_VTYPE_HEAP)
|
||||
#define pic_obj_p(pic,v) (pic_vtype(pic,v) == PIC_VTYPE_HEAP)
|
||||
#define pic_obj_ptr(v) ((struct pic_object *)pic_ptr(v))
|
||||
|
||||
#define pic_invalid_p(v) (pic_vtype(v) == PIC_VTYPE_INVALID)
|
||||
#define pic_eof_p(v) (pic_vtype(v) == PIC_VTYPE_EOF)
|
||||
#define pic_invalid_p(pic, v) (pic_vtype(pic, v) == PIC_VTYPE_INVALID)
|
||||
#define pic_eof_p(pic, v) (pic_vtype(pic, v) == PIC_VTYPE_EOF)
|
||||
|
||||
#define pic_test(v) (! pic_false_p(v))
|
||||
|
||||
#define pic_assert_type(pic, v, type) \
|
||||
if (! pic_##type##_p(v)) { \
|
||||
pic_errorf(pic, "expected " #type ", but got ~s", v); \
|
||||
}
|
||||
#define pic_test(pic, v) (! pic_false_p(pic, v))
|
||||
|
||||
PIC_INLINE bool
|
||||
pic_valid_int(double v)
|
||||
@@ -186,9 +181,9 @@ PIC_INLINE pic_value pic_invalid_value();
|
||||
PIC_INLINE pic_value pic_obj_value(void *);
|
||||
|
||||
PIC_INLINE enum pic_tt
|
||||
pic_type(pic_value v)
|
||||
pic_type(pic_state PIC_UNUSED(*pic), pic_value v)
|
||||
{
|
||||
switch (pic_vtype(v)) {
|
||||
switch (pic_vtype(pic, v)) {
|
||||
case PIC_VTYPE_NIL:
|
||||
return PIC_TT_NIL;
|
||||
case PIC_VTYPE_TRUE:
|
||||
@@ -215,7 +210,7 @@ pic_type(pic_value v)
|
||||
}
|
||||
|
||||
PIC_INLINE const char *
|
||||
pic_type_repr(enum pic_tt tt)
|
||||
pic_type_repr(pic_state PIC_UNUSED(*pic), enum pic_tt tt)
|
||||
{
|
||||
switch (tt) {
|
||||
case PIC_TT_NIL:
|
||||
@@ -271,7 +266,7 @@ pic_type_repr(enum pic_tt tt)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_nil_value()
|
||||
pic_nil_value(pic_state PIC_UNUSED(*pic))
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -280,7 +275,7 @@ pic_nil_value()
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_true_value()
|
||||
pic_true_value(pic_state PIC_UNUSED(*pic))
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -289,7 +284,7 @@ pic_true_value()
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_false_value()
|
||||
pic_false_value(pic_state PIC_UNUSED(*pic))
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -298,7 +293,7 @@ pic_false_value()
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_bool_value(bool b)
|
||||
pic_bool_value(pic_state PIC_UNUSED(*pic), bool b)
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -319,7 +314,7 @@ pic_obj_value(void *ptr)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_float_value(double f)
|
||||
pic_float_value(pic_state PIC_UNUSED(*pic), double f)
|
||||
{
|
||||
union { double f; uint64_t i; } u;
|
||||
|
||||
@@ -332,7 +327,7 @@ pic_float_value(double f)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_int_value(int i)
|
||||
pic_int_value(pic_state PIC_UNUSED(*pic), int i)
|
||||
{
|
||||
union { int i; unsigned u; } u;
|
||||
pic_value v;
|
||||
@@ -345,7 +340,7 @@ pic_int_value(int i)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_char_value(char c)
|
||||
pic_char_value(pic_state PIC_UNUSED(*pic), char c)
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -367,7 +362,7 @@ pic_obj_value(void *ptr)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_float_value(double f)
|
||||
pic_float_value(pic_state PIC_UNUSED(*pic), double f)
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -377,7 +372,7 @@ pic_float_value(double f)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_int_value(int i)
|
||||
pic_int_value(pic_state PIC_UNUSED(*pic), int i)
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -387,7 +382,7 @@ pic_int_value(int i)
|
||||
}
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_char_value(char c)
|
||||
pic_char_value(pic_state PIC_UNUSED(*pic), char c)
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -399,7 +394,7 @@ pic_char_value(char c)
|
||||
#endif
|
||||
|
||||
PIC_INLINE pic_value
|
||||
pic_undef_value()
|
||||
pic_undef_value(pic_state PIC_UNUSED(*pic))
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
@@ -419,13 +414,13 @@ pic_invalid_value()
|
||||
#if PIC_NAN_BOXING
|
||||
|
||||
PIC_INLINE bool
|
||||
pic_eq_p(pic_value x, pic_value y)
|
||||
pic_eq_p(pic_state PIC_UNUSED(*pic), pic_value x, pic_value y)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
PIC_INLINE bool
|
||||
pic_eqv_p(pic_value x, pic_value y)
|
||||
pic_eqv_p(pic_state PIC_UNUSED(*pic), pic_value x, pic_value y)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
@@ -433,36 +428,36 @@ pic_eqv_p(pic_value x, pic_value y)
|
||||
#else
|
||||
|
||||
PIC_INLINE bool
|
||||
pic_eq_p(pic_value x, pic_value y)
|
||||
pic_eq_p(pic_state PIC_UNUSED(*pic), pic_value x, pic_value y)
|
||||
{
|
||||
if (pic_type(x) != pic_type(y))
|
||||
if (pic_type(pic, x) != pic_type(pic, y))
|
||||
return false;
|
||||
|
||||
switch (pic_type(x)) {
|
||||
switch (pic_type(pic, x)) {
|
||||
case PIC_TT_NIL:
|
||||
return true;
|
||||
case PIC_TT_BOOL:
|
||||
return pic_vtype(x) == pic_vtype(y);
|
||||
return pic_vtype(pic, x) == pic_vtype(pic, y);
|
||||
default:
|
||||
return pic_ptr(x) == pic_ptr(y);
|
||||
}
|
||||
}
|
||||
|
||||
PIC_INLINE bool
|
||||
pic_eqv_p(pic_value x, pic_value y)
|
||||
pic_eqv_p(pic_state PIC_UNUSED(*pic), pic_value x, pic_value y)
|
||||
{
|
||||
if (pic_type(x) != pic_type(y))
|
||||
if (pic_type(pic, x) != pic_type(pic, y))
|
||||
return false;
|
||||
|
||||
switch (pic_type(x)) {
|
||||
switch (pic_type(pic, x)) {
|
||||
case PIC_TT_NIL:
|
||||
return true;
|
||||
case PIC_TT_BOOL:
|
||||
return pic_vtype(x) == pic_vtype(y);
|
||||
return pic_vtype(pic, x) == pic_vtype(pic, y);
|
||||
case PIC_TT_FLOAT:
|
||||
return pic_float(x) == pic_float(y);
|
||||
return pic_float(pic, x) == pic_float(pic, y);
|
||||
case PIC_TT_INT:
|
||||
return pic_int(x) == pic_int(y);
|
||||
return pic_int(pic, x) == pic_int(pic, y);
|
||||
default:
|
||||
return pic_ptr(x) == pic_ptr(y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user