add extra parameter to obj_ptr and obj_value

This commit is contained in:
Yuichi Nishiwaki 2017-03-29 08:32:28 +09:00
parent 70a4432d20
commit c658b97dd2
21 changed files with 87 additions and 85 deletions

View File

@ -55,10 +55,10 @@ cont_mark(pic_state *pic, void *data, void (*mark)(pic_state *, pic_value))
/* checkpoint */
for (cp = cont->cp; cp != NULL; cp = cp->prev) {
if (cp->in) {
mark(pic, obj_value(cp->in));
mark(pic, obj_value(pic, cp->in));
}
if (cp->out) {
mark(pic, obj_value(cp->out));
mark(pic, obj_value(pic, cp->out));
}
}
@ -70,13 +70,13 @@ cont_mark(pic_state *pic, void *data, void (*mark)(pic_state *, pic_value))
/* callinfo */
for (ci = cont->ci_ptr + cont->ci_offset; ci != cont->ci_ptr; --ci) {
if (ci->cxt) {
mark(pic, obj_value(ci->cxt));
mark(pic, obj_value(pic, ci->cxt));
}
}
/* arena */
for (i = 0; i < cont->arena_idx; ++i) {
mark(pic, obj_value(cont->arena[i]));
mark(pic, obj_value(pic, cont->arena[i]));
}
}

View File

@ -16,7 +16,7 @@ pic_blob_value(pic_state *pic, const unsigned char *buf, int len)
if (buf) {
memcpy(bv->data, buf, len);
}
return obj_value(bv);
return obj_value(pic, bv);
}
unsigned char *

View File

@ -33,7 +33,7 @@ pic_eq_p(pic_state *PIC_UNUSED(pic), pic_value x, pic_value y)
case PIC_TYPE_TRUE: case PIC_TYPE_FALSE:
return pic_type(pic, x) == pic_type(pic, y);
default:
return obj_ptr(x) == obj_ptr(y);
return obj_ptr(pic, x) == obj_ptr(pic, y);
}
}
@ -53,7 +53,7 @@ pic_eqv_p(pic_state *PIC_UNUSED(pic), pic_value x, pic_value y)
case PIC_TYPE_INT:
return pic_int(pic, x) == pic_int(pic, y);
default:
return obj_ptr(x) == obj_ptr(y);
return obj_ptr(pic, x) == obj_ptr(pic, y);
}
}
@ -76,7 +76,7 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, int depth, khash_t(m)
}
if (pic_pair_p(pic, x) || pic_vec_p(pic, x)) {
int ret;
kh_put(m, h, obj_ptr(x), &ret);
kh_put(m, h, obj_ptr(pic, x), &ret);
if (ret != 0) {
return true; /* `x' was seen already. */
}
@ -100,8 +100,8 @@ internal_equal_p(pic_state *pic, pic_value x, pic_value y, int depth, khash_t(m)
id1 = pic_id_ptr(pic, x);
id2 = pic_id_ptr(pic, y);
s1 = pic_find_identifier(pic, obj_value(id1->u.id), obj_value(id1->env));
s2 = pic_find_identifier(pic, obj_value(id2->u.id), obj_value(id2->env));
s1 = pic_find_identifier(pic, obj_value(pic, id1->u.id), obj_value(pic, id1->env));
s2 = pic_find_identifier(pic, obj_value(pic, id2->u.id), obj_value(pic, id2->env));
return pic_eq_p(pic, s1, s2);
}

View File

@ -69,10 +69,10 @@ pic_wind(pic_state *pic, struct checkpoint *here, struct checkpoint *there)
if (here->depth < there->depth) {
pic_wind(pic, here, there->prev);
pic_call(pic, obj_value(there->in), 0);
pic_call(pic, obj_value(pic, there->in), 0);
}
else {
pic_call(pic, obj_value(here->out), 0);
pic_call(pic, obj_value(pic, here->out), 0);
pic_wind(pic, here->prev, there);
}
}

View File

@ -29,5 +29,5 @@ pic_data_value(pic_state *pic, void *userdata, const pic_data_type *type)
data->type = type;
data->data = userdata;
return obj_value(data);
return obj_value(pic, data);
}

View File

@ -46,15 +46,15 @@ pic_print_error(pic_state *pic, pic_value port, pic_value err)
pic_value elem, it;
e = pic_error_ptr(pic, err);
if (! pic_eq_p(pic, obj_value(e->type), pic_intern_lit(pic, ""))) {
pic_fprintf(pic, port, "~s-", obj_value(e->type));
if (! pic_eq_p(pic, obj_value(pic, e->type), pic_intern_lit(pic, ""))) {
pic_fprintf(pic, port, "~s-", obj_value(pic, e->type));
}
pic_fprintf(pic, port, "error: ~s", obj_value(e->msg));
pic_fprintf(pic, port, "error: ~s", obj_value(pic, e->msg));
pic_for_each (elem, e->irrs, it) { /* print error irritants */
pic_fprintf(pic, port, " ~s", elem);
}
pic_fprintf(pic, port, "\n%s", pic_str(pic, obj_value(e->stack), NULL));
pic_fprintf(pic, port, "\n%s", pic_str(pic, obj_value(pic, e->stack), NULL));
}
}

View File

@ -14,7 +14,7 @@ pic_make_dict(pic_state *pic)
dict = (struct dict *)pic_obj_alloc(pic, sizeof(struct dict), PIC_TYPE_DICT);
kh_init(dict, &dict->hash);
return obj_value(dict);
return obj_value(pic, dict);
}
pic_value
@ -76,7 +76,7 @@ pic_dict_next(pic_state *PIC_UNUSED(pic), pic_value dict, int *iter, pic_value *
for (it = *iter; it != kh_end(h); ++it) {
if (kh_exist(h, it)) {
if (key) *key = obj_value(kh_key(h, it));
if (key) *key = obj_value(pic, kh_key(h, it));
if (val) *val = kh_val(h, it);
*iter = ++it;
return true;

View File

@ -95,7 +95,7 @@ pic_start_try(pic_state *pic, PIC_JMPBUF *jmp)
pic->cp->in = pic_proc_ptr(pic, in);
pic->cp->out = pic_proc_ptr(pic, out);
return pic_cons(pic, obj_value(here), out);
return pic_cons(pic, obj_value(pic, here), out);
}
void
@ -131,7 +131,7 @@ pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs
e->irrs = irrs;
e->stack = pic_str_ptr(pic, stack);
return obj_value(e);
return obj_value(pic, e);
}
pic_value pic_raise_continuable(pic_state *, pic_value err);
@ -261,7 +261,7 @@ pic_error_error_object_message(pic_state *pic)
TYPE_CHECK(pic, e, error);
return obj_value(pic_error_ptr(pic, e)->msg);
return obj_value(pic, pic_error_ptr(pic, e)->msg);
}
static pic_value
@ -285,7 +285,7 @@ pic_error_error_object_type(pic_state *pic)
TYPE_CHECK(pic, e, error);
return obj_value(pic_error_ptr(pic, e)->type);
return obj_value(pic, pic_error_ptr(pic, e)->type);
}
void

View File

@ -984,7 +984,7 @@ codegen_quote(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
assert(obj_p(pic,obj));
check_pool_size(pic, cxt);
pidx = (int)cxt->plen++;
cxt->pool[pidx] = obj_ptr(obj);
cxt->pool[pidx] = obj_ptr(pic, obj);
emit_i(pic, cxt, OP_PUSHCONST, pidx);
break;
}

View File

@ -20,7 +20,7 @@ pic_make_env(pic_state *pic, pic_value up)
env->lib = NULL;
kh_init(env, &env->map);
return obj_value(env);
return obj_value(pic, env);
}
static bool
@ -32,7 +32,7 @@ search_scope(pic_state *pic, pic_value id, pic_value env, pic_value *uid)
if (it == kh_end(&pic_env_ptr(pic, env)->map)) {
return false;
}
*uid = obj_value(kh_val(&pic_env_ptr(pic, env)->map, it));
*uid = obj_value(pic, kh_val(&pic_env_ptr(pic, env)->map, it));
return true;
}
@ -47,7 +47,7 @@ search(pic_state *pic, pic_value id, pic_value env, pic_value *uid)
e = pic_env_ptr(pic, env)->up;
if (e == NULL)
break;
env = obj_value(e);
env = obj_value(pic, e);
}
return false;
}
@ -64,12 +64,12 @@ pic_find_identifier(pic_state *pic, pic_value id, pic_value env)
e = pic_env_ptr(pic, env);
if (e->up == NULL)
break;
env = obj_value(e->up);
env = obj_value(pic, e->up);
}
return pic_add_identifier(pic, id, env);
}
env = obj_value(pic_id_ptr(pic, id)->env); /* do not overwrite id first */
id = obj_value(pic_id_ptr(pic, id)->u.id);
env = obj_value(pic, pic_id_ptr(pic, id)->env); /* do not overwrite id first */
id = obj_value(pic, pic_id_ptr(pic, id)->u.id);
}
return uid;
}
@ -87,7 +87,7 @@ pic_add_identifier(pic_state *pic, pic_value id, pic_value env)
name = pic_str(pic, pic_id_name(pic, id), NULL);
if (pic_env_ptr(pic, env)->up == NULL && pic_sym_p(pic, id)) { /* toplevel & public */
lib = pic_str(pic, obj_value(pic_env_ptr(pic, env)->lib), NULL);
lib = pic_str(pic, obj_value(pic, pic_env_ptr(pic, env)->lib), NULL);
str = pic_strf_value(pic, "%s/%s", lib, name);
} else {
str = pic_strf_value(pic, ".%s.%d", name, pic->ucnt++);
@ -143,7 +143,7 @@ make_library_env(pic_state *pic, pic_value name)
env->lib = pic_str_ptr(pic, name);
kh_init(env, &env->map);
e = obj_value(env);
e = obj_value(pic, env);
#define REGISTER(name) pic_put_identifier(pic, pic_intern_lit(pic, name), pic_intern_lit(pic, name), e)
@ -200,7 +200,7 @@ pic_current_library(pic_state *pic)
pic_value
pic_library_environment(pic_state *pic, const char *lib)
{
return obj_value(get_library(pic, lib)->env);
return obj_value(pic, get_library(pic, lib)->env);
}
void
@ -213,19 +213,19 @@ pic_import(pic_state *pic, const char *lib)
our = get_library(pic, pic->lib);
their = get_library(pic, lib);
while (pic_dict_next(pic, obj_value(their->exports), &it, &name, &realname)) {
uid = pic_find_identifier(pic, realname, obj_value(their->env));
while (pic_dict_next(pic, obj_value(pic, their->exports), &it, &name, &realname)) {
uid = pic_find_identifier(pic, realname, obj_value(pic, their->env));
if (! pic_weak_has(pic, pic->globals, uid) && ! pic_weak_has(pic, pic->macros, uid)) {
pic_error(pic, "attempted to export undefined variable", 1, realname);
}
pic_put_identifier(pic, name, uid, obj_value(our->env));
pic_put_identifier(pic, name, uid, obj_value(pic, our->env));
}
}
void
pic_export(pic_state *pic, pic_value name)
{
pic_dict_set(pic, obj_value(get_library(pic, pic->lib)->exports), name, name);
pic_dict_set(pic, obj_value(pic, get_library(pic, pic->lib)->exports), name, name);
}
static pic_value
@ -284,18 +284,18 @@ pic_lib_library_import(pic_state *pic)
libp = get_library(pic, lib);
if (! pic_dict_has(pic, obj_value(libp->exports), name)) {
if (! pic_dict_has(pic, obj_value(pic, libp->exports), name)) {
pic_error(pic, "library-import: variable is not exported", 1, name);
} else {
realname = pic_dict_ref(pic, obj_value(libp->exports), name);
realname = pic_dict_ref(pic, obj_value(pic, libp->exports), name);
}
uid = pic_find_identifier(pic, realname, obj_value(libp->env));
uid = pic_find_identifier(pic, realname, obj_value(pic, libp->env));
if (! pic_weak_has(pic, pic->globals, uid) && ! pic_weak_has(pic, pic->macros, uid)) {
pic_error(pic, "attempted to export undefined variable", 1, realname);
}
pic_put_identifier(pic, alias, uid, obj_value(get_library(pic, pic->lib)->env));
pic_put_identifier(pic, alias, uid, obj_value(pic, get_library(pic, pic->lib)->env));
return pic_undef_value(pic);
}
@ -312,7 +312,7 @@ pic_lib_library_export(pic_state *pic)
alias = name;
}
pic_dict_set(pic, obj_value(get_library(pic, pic->lib)->exports), alias, name);
pic_dict_set(pic, obj_value(pic, get_library(pic, pic->lib)->exports), alias, name);
return pic_undef_value(pic);
}
@ -329,7 +329,7 @@ pic_lib_library_exports(pic_state *pic)
libp = get_library(pic, lib);
while (pic_dict_next(pic, obj_value(libp->exports), &it, &sym, NULL)) {
while (pic_dict_next(pic, obj_value(pic, libp->exports), &it, &sym, NULL)) {
pic_push(pic, sym, exports);
}
@ -343,7 +343,7 @@ pic_lib_library_environment(pic_state *pic)
pic_get_args(pic, "z", &lib);
return obj_value(get_library(pic, lib)->env);
return obj_value(pic, get_library(pic, lib)->env);
}
void

View File

@ -532,7 +532,7 @@ write_core(pic_state *pic, pic_value obj, pic_value port, struct writer_control
write_dict(pic, obj, port, p);
break;
default:
pic_fprintf(pic, port, "#<%s %p>", typename(pic, obj), obj_ptr(obj));
pic_fprintf(pic, port, "#<%s %p>", typename(pic, obj), obj_ptr(pic, obj));
break;
}

View File

@ -171,7 +171,7 @@ pic_protect(pic_state *pic, pic_value v)
if (! obj_p(pic, v))
return v;
gc_protect(pic, obj_ptr(v));
gc_protect(pic, obj_ptr(pic, v));
return v;
}
@ -308,7 +308,7 @@ gc_mark(pic_state *pic, pic_value v)
if (! obj_p(pic, v))
return;
gc_mark_object(pic, obj_ptr(v));
gc_mark_object(pic, obj_ptr(pic, v));
}
static void
@ -327,7 +327,7 @@ gc_mark_object(pic_state *pic, struct object *obj)
case PIC_TYPE_PAIR: {
gc_mark(pic, obj->u.pair.car);
if (obj_p(pic, obj->u.pair.cdr)) {
LOOP(obj_ptr(obj->u.pair.cdr));
LOOP(obj_ptr(pic, obj->u.pair.cdr));
}
break;
}
@ -408,7 +408,7 @@ gc_mark_object(pic_state *pic, struct object *obj)
pic_value key, val;
int it = 0;
while (pic_dict_next(pic, obj_value(&obj->u.dict), &it, &key, &val)) {
while (pic_dict_next(pic, obj_value(pic, &obj->u.dict), &it, &key, &val)) {
gc_mark(pic, key);
gc_mark(pic, val);
}
@ -417,7 +417,7 @@ gc_mark_object(pic_state *pic, struct object *obj)
case PIC_TYPE_RECORD: {
gc_mark(pic, obj->u.rec.type);
if (obj_p(pic, obj->u.rec.datum)) {
LOOP(obj_ptr(obj->u.rec.datum));
LOOP(obj_ptr(pic, obj->u.rec.datum));
}
break;
}
@ -531,7 +531,7 @@ gc_mark_phase(pic_state *pic)
key = kh_key(h, it);
val = kh_val(h, it);
if (is_marked(pic, key)) {
if (obj_p(pic, val) && ! is_marked(pic, obj_ptr(val))) {
if (obj_p(pic, val) && ! is_marked(pic, obj_ptr(pic, val))) {
gc_mark(pic, val);
++j;
}
@ -587,7 +587,7 @@ gc_finalize_object(pic_state *pic, struct object *obj)
break;
}
case PIC_TYPE_PORT: {
pic_fclose(pic, obj_value(obj)); /* FIXME */
pic_fclose(pic, obj_value(pic, obj)); /* FIXME */
break;
}

View File

@ -188,14 +188,16 @@ struct checkpoint {
if (tolen - at < e - s) pic_error(pic, "invalid range", 0); \
} while (0)
PIC_STATIC_INLINE int obj_tt(void *ptr) {
PIC_STATIC_INLINE int
obj_tt(pic_state *PIC_UNUSED(pic), void *ptr)
{
return ((struct basic *)ptr)->tt;
}
#if !PIC_NAN_BOXING
PIC_STATIC_INLINE struct object *
obj_ptr(pic_value v)
obj_ptr(pic_state *PIC_UNUSED(pic), pic_value v)
{
return (struct object *)(v.u.data);
}
@ -207,9 +209,9 @@ obj_p(pic_state *PIC_UNUSED(pic), pic_value v)
}
PIC_STATIC_INLINE pic_value
obj_value(void *ptr)
obj_value(pic_state *PIC_UNUSED(pic), void *ptr)
{
pic_value v = pic_make_value(obj_tt(ptr));
pic_value v = pic_make_value(obj_tt(pic, ptr));
v.u.data = ptr;
return v;
}
@ -217,7 +219,7 @@ obj_value(void *ptr)
#else /* NAN_BOXING */
PIC_STATIC_INLINE struct object *
obj_ptr(pic_value v)
obj_ptr(pic_state *PIC_UNUSED(pic), pic_value v)
{
return (struct object *)((0x3ffffffffffful & v.v) << 2);
}
@ -229,9 +231,9 @@ obj_p(pic_state *PIC_UNUSED(pic), pic_value v)
}
PIC_STATIC_INLINE pic_value
obj_value(void *ptr)
obj_value(pic_state *PIC_UNUSED(pic), void *ptr)
{
pic_value v = pic_make_value(obj_tt(ptr));
pic_value v = pic_make_value(obj_tt(pic, ptr));
v.v |= 0x3ffffffffffful & ((uint64_t)ptr >> 2);
return v;
}
@ -240,7 +242,7 @@ obj_value(void *ptr)
#define DEFPTR(name,type) \
PIC_STATIC_INLINE type *name(pic_state *PIC_UNUSED(pic), pic_value o) { \
return (type *) obj_ptr(o); \
return (type *) obj_ptr(pic, o); \
}
DEFPTR(pic_id_ptr, struct identifier)

View File

@ -14,7 +14,7 @@ pic_cons(pic_state *pic, pic_value car, pic_value cdr)
pair->car = car;
pair->cdr = cdr;
return obj_value(pair);
return obj_value(pic, pair);
}
pic_value

View File

@ -31,7 +31,7 @@ pic_funopen(pic_state *pic, void *cookie, const pic_port_type *type)
port->file.cookie = cookie;
port->file.vtable = type;
return obj_value(port);
return obj_value(pic, port);
}
int

View File

@ -437,15 +437,15 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
NEXT;
}
CASE(OP_PUSHCONST) {
PUSH(obj_value(pic->ci->irep->pool[c.a]));
PUSH(obj_value(pic, pic->ci->irep->pool[c.a]));
NEXT;
}
CASE(OP_GREF) {
PUSH(pic_global_ref(pic, obj_value(pic->ci->irep->pool[c.a])));
PUSH(pic_global_ref(pic, obj_value(pic, pic->ci->irep->pool[c.a])));
NEXT;
}
CASE(OP_GSET) {
pic_global_set(pic, obj_value(pic->ci->irep->pool[c.a]), POP());
pic_global_set(pic, obj_value(pic, pic->ci->irep->pool[c.a]), POP());
PUSH(pic_undef_value(pic));
NEXT;
}
@ -864,7 +864,7 @@ pic_make_proc(pic_state *pic, pic_func_t func, int n, pic_value *env)
for (i = 0; i < n; ++i) {
proc->locals[i] = env[i];
}
return obj_value(proc);
return obj_value(pic, proc);
}
pic_value
@ -876,7 +876,7 @@ pic_make_proc_irep(pic_state *pic, struct irep *irep, struct context *cxt)
proc->u.i.irep = irep;
proc->u.i.cxt = cxt;
pic_irep_incref(pic, irep);
return obj_value(proc);
return obj_value(pic, proc);
}
static pic_value

View File

@ -14,7 +14,7 @@ pic_make_record(pic_state *pic, pic_value type, pic_value datum)
rec->type = type;
rec->datum = datum;
return obj_value(rec);
return obj_value(pic, rec);
}
static pic_value

View File

@ -120,7 +120,7 @@ make_str(pic_state *pic, struct rope *rope)
str = (struct string *)pic_obj_alloc(pic, sizeof(struct string), PIC_TYPE_STRING);
str->rope = rope; /* delegate ownership */
return obj_value(str);
return obj_value(pic, str);
}
static struct rope *

View File

@ -6,8 +6,8 @@
#include "object.h"
#include "state.h"
#define kh_pic_str_hash(a) (pic_str_hash(pic, obj_value(a)))
#define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, obj_value(a), obj_value(b)) == 0)
#define kh_pic_str_hash(a) (pic_str_hash(pic, obj_value(pic, a)))
#define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, obj_value(pic, a), obj_value(pic, b)) == 0)
KHASH_DEFINE(oblist, struct string *, symbol *, kh_pic_str_hash, kh_pic_str_cmp)
@ -22,8 +22,8 @@ pic_intern(pic_state *pic, pic_value str)
it = kh_put(oblist, h, pic_str_ptr(pic, str), &ret);
if (ret == 0) { /* if exists */
sym = kh_val(h, it);
pic_protect(pic, obj_value(sym));
return obj_value(sym);
pic_protect(pic, obj_value(pic, sym));
return obj_value(pic, sym);
}
kh_val(h, it) = NULL; /* dummy */
@ -32,7 +32,7 @@ pic_intern(pic_state *pic, pic_value str)
sym->u.str = pic_str_ptr(pic, str);
kh_val(h, it) = sym;
return obj_value(sym);
return obj_value(pic, sym);
}
pic_value
@ -44,20 +44,20 @@ pic_make_identifier(pic_state *pic, pic_value base, pic_value env)
id->u.id = pic_id_ptr(pic, base);
id->env = pic_env_ptr(pic, env);
return obj_value(id);
return obj_value(pic, id);
}
pic_value
pic_sym_name(pic_state *PIC_UNUSED(pic), pic_value sym)
{
return obj_value(pic_sym_ptr(pic, sym)->u.str);
return obj_value(pic, pic_sym_ptr(pic, sym)->u.str);
}
pic_value
pic_id_name(pic_state *pic, pic_value id)
{
while (! pic_sym_p(pic, id)) {
id = obj_value(pic_id_ptr(pic, id)->u.id);
id = obj_value(pic, pic_id_ptr(pic, id)->u.id);
}
return pic_sym_name(pic, id);
@ -148,7 +148,7 @@ pic_symbol_identifier_base(pic_state *pic)
pic_error(pic, "non-symbol identifier required", 1, id);
}
return obj_value(pic_id_ptr(pic, id)->u.id);
return obj_value(pic, pic_id_ptr(pic, id)->u.id);
}
static pic_value
@ -164,7 +164,7 @@ pic_symbol_identifier_environment(pic_state *pic)
pic_error(pic, "non-symbol identifier required", 1, id);
}
return obj_value(pic_id_ptr(pic, id)->env);
return obj_value(pic, pic_id_ptr(pic, id)->env);
}
static pic_value

View File

@ -21,7 +21,7 @@ pic_make_vec(pic_state *pic, int len, pic_value *argv)
} else {
memcpy(vec->data, argv, sizeof(pic_value) * len);
}
return obj_value(vec);
return obj_value(pic, vec);
}
pic_value

View File

@ -16,7 +16,7 @@ pic_make_weak(pic_state *pic)
weak->prev = NULL;
kh_init(weak, &weak->hash);
return obj_value(weak);
return obj_value(pic, weak);
}
pic_value
@ -25,7 +25,7 @@ pic_weak_ref(pic_state *pic, pic_value weak, pic_value key)
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
int it;
it = kh_get(weak, h, obj_ptr(key));
it = kh_get(weak, h, obj_ptr(pic, key));
if (it == kh_end(h)) {
pic_error(pic, "element not found for given key", 1, key);
}
@ -39,7 +39,7 @@ pic_weak_set(pic_state *pic, pic_value weak, pic_value key, pic_value val)
int ret;
int it;
it = kh_put(weak, h, obj_ptr(key), &ret);
it = kh_put(weak, h, obj_ptr(pic, key), &ret);
kh_val(h, it) = val;
}
@ -48,7 +48,7 @@ pic_weak_has(pic_state *pic, pic_value weak, pic_value key)
{
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
return kh_get(weak, h, obj_ptr(key)) != kh_end(h);
return kh_get(weak, h, obj_ptr(pic, key)) != kh_end(h);
}
void
@ -57,7 +57,7 @@ pic_weak_del(pic_state *pic, pic_value weak, pic_value key)
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
int it;
it = kh_get(weak, h, obj_ptr(key));
it = kh_get(weak, h, obj_ptr(pic, key));
if (it == kh_end(h)) {
pic_error(pic, "element not found for given key", 1, key);
}