pic_sym is not a pointer
This commit is contained in:
parent
2d1ddb9a5a
commit
6e6e1de7a5
|
@ -36,11 +36,11 @@ typedef struct analyze_scope {
|
||||||
typedef struct analyze_state {
|
typedef struct analyze_state {
|
||||||
pic_state *pic;
|
pic_state *pic;
|
||||||
analyze_scope *scope;
|
analyze_scope *scope;
|
||||||
pic_sym rCONS, rCAR, rCDR, rNILP;
|
pic_sym *rCONS, *rCAR, *rCDR, *rNILP;
|
||||||
pic_sym rSYMBOLP, rPAIRP;
|
pic_sym *rSYMBOLP, *rPAIRP;
|
||||||
pic_sym rADD, rSUB, rMUL, rDIV;
|
pic_sym *rADD, *rSUB, *rMUL, *rDIV;
|
||||||
pic_sym rEQ, rLT, rLE, rGT, rGE, rNOT;
|
pic_sym *rEQ, *rLT, *rLE, *rGT, *rGE, *rNOT;
|
||||||
pic_sym rVALUES, rCALL_WITH_VALUES;
|
pic_sym *rVALUES, *rCALL_WITH_VALUES;
|
||||||
} analyze_state;
|
} analyze_state;
|
||||||
|
|
||||||
static bool push_scope(analyze_state *, pic_value);
|
static bool push_scope(analyze_state *, pic_value);
|
||||||
|
@ -51,7 +51,7 @@ static void pop_scope(analyze_state *);
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define register_renamed_symbol(pic, state, slot, lib, id) do { \
|
#define register_renamed_symbol(pic, state, slot, lib, id) do { \
|
||||||
pic_sym sym, gsym; \
|
pic_sym *sym, *gsym; \
|
||||||
sym = pic_intern_cstr(pic, id); \
|
sym = pic_intern_cstr(pic, id); \
|
||||||
if (! pic_find_rename(pic, lib->env, sym, &gsym)) { \
|
if (! pic_find_rename(pic, lib->env, sym, &gsym)) { \
|
||||||
pic_errorf(pic, "internal error! native VM procedure not found: %s", id); \
|
pic_errorf(pic, "internal error! native VM procedure not found: %s", id); \
|
||||||
|
@ -63,7 +63,7 @@ static analyze_state *
|
||||||
new_analyze_state(pic_state *pic)
|
new_analyze_state(pic_state *pic)
|
||||||
{
|
{
|
||||||
analyze_state *state;
|
analyze_state *state;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
state = pic_alloc(pic, sizeof(analyze_state));
|
state = pic_alloc(pic, sizeof(analyze_state));
|
||||||
state->pic = pic;
|
state->pic = pic;
|
||||||
|
@ -110,7 +110,7 @@ static bool
|
||||||
analyze_args(pic_state *pic, pic_value formals, bool *varg, xvect *args, xvect *locals)
|
analyze_args(pic_state *pic, pic_value formals, bool *varg, xvect *args, xvect *locals)
|
||||||
{
|
{
|
||||||
pic_value v, t;
|
pic_value v, t;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
for (v = formals; pic_pair_p(v); v = pic_cdr(pic, v)) {
|
for (v = formals; pic_pair_p(v); v = pic_cdr(pic, v)) {
|
||||||
t = pic_car(pic, v);
|
t = pic_car(pic, v);
|
||||||
|
@ -143,9 +143,9 @@ push_scope(analyze_state *state, pic_value formals)
|
||||||
bool varg;
|
bool varg;
|
||||||
xvect args, locals, captures;
|
xvect args, locals, captures;
|
||||||
|
|
||||||
xv_init(&args, sizeof(pic_sym));
|
xv_init(&args, sizeof(pic_sym *));
|
||||||
xv_init(&locals, sizeof(pic_sym));
|
xv_init(&locals, sizeof(pic_sym *));
|
||||||
xv_init(&captures, sizeof(pic_sym));
|
xv_init(&captures, sizeof(pic_sym *));
|
||||||
|
|
||||||
if (analyze_args(pic, formals, &varg, &args, &locals)) {
|
if (analyze_args(pic, formals, &varg, &args, &locals)) {
|
||||||
scope = pic_alloc(pic, sizeof(analyze_scope));
|
scope = pic_alloc(pic, sizeof(analyze_scope));
|
||||||
|
@ -184,9 +184,9 @@ pop_scope(analyze_state *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
lookup_scope(analyze_scope *scope, pic_sym sym)
|
lookup_scope(analyze_scope *scope, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_sym *arg, *local;
|
pic_sym **arg, **local;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
/* args */
|
/* args */
|
||||||
|
@ -205,9 +205,9 @@ lookup_scope(analyze_scope *scope, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
capture_var(analyze_scope *scope, pic_sym sym)
|
capture_var(analyze_scope *scope, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_sym *var;
|
pic_sym **var;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < xv_size(&scope->captures); ++i) {
|
for (i = 0; i < xv_size(&scope->captures); ++i) {
|
||||||
|
@ -222,7 +222,7 @@ capture_var(analyze_scope *scope, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
find_var(analyze_state *state, pic_sym sym)
|
find_var(analyze_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
analyze_scope *scope = state->scope;
|
analyze_scope *scope = state->scope;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
@ -241,7 +241,7 @@ find_var(analyze_state *state, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
define_var(analyze_state *state, pic_sym sym)
|
define_var(analyze_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
analyze_scope *scope = state->scope;
|
analyze_scope *scope = state->scope;
|
||||||
|
@ -263,7 +263,7 @@ analyze(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
size_t ai = pic_gc_arena_preserve(pic);
|
size_t ai = pic_gc_arena_preserve(pic);
|
||||||
pic_value res;
|
pic_value res;
|
||||||
pic_sym tag;
|
pic_sym *tag;
|
||||||
|
|
||||||
res = analyze_node(state, obj, tailpos);
|
res = analyze_node(state, obj, tailpos);
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ analyze(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
analyze_global_var(analyze_state *state, pic_sym sym)
|
analyze_global_var(analyze_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ analyze_global_var(analyze_state *state, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
analyze_local_var(analyze_state *state, pic_sym sym)
|
analyze_local_var(analyze_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ analyze_local_var(analyze_state *state, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
analyze_free_var(analyze_state *state, pic_sym sym, int depth)
|
analyze_free_var(analyze_state *state, pic_sym *sym, int depth)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ analyze_free_var(analyze_state *state, pic_sym sym, int depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
analyze_var(analyze_state *state, pic_sym sym)
|
analyze_var(analyze_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
int depth;
|
int depth;
|
||||||
|
@ -330,7 +330,7 @@ static pic_value
|
||||||
analyze_defer(analyze_state *state, pic_value name, pic_value formal, pic_value body)
|
analyze_defer(analyze_state *state, pic_value name, pic_value formal, pic_value body)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
const pic_sym sNOWHERE = pic_intern_cstr(pic, "<<nowhere>>");
|
pic_sym *sNOWHERE = pic_intern_cstr(pic, "<<nowhere>>");
|
||||||
pic_value skel;
|
pic_value skel;
|
||||||
|
|
||||||
skel = pic_list2(pic, pic_obj_value(pic->sGREF), pic_obj_value(sNOWHERE));
|
skel = pic_list2(pic, pic_obj_value(pic->sGREF), pic_obj_value(sNOWHERE));
|
||||||
|
@ -372,7 +372,7 @@ analyze_procedure(analyze_state *state, pic_value name, pic_value formals, pic_v
|
||||||
|
|
||||||
if (push_scope(state, formals)) {
|
if (push_scope(state, formals)) {
|
||||||
analyze_scope *scope = state->scope;
|
analyze_scope *scope = state->scope;
|
||||||
pic_sym *var;
|
pic_sym **var;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
args = pic_nil_value();
|
args = pic_nil_value();
|
||||||
|
@ -428,7 +428,7 @@ analyze_lambda(analyze_state *state, pic_value obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
analyze_declare(analyze_state *state, pic_sym var)
|
analyze_declare(analyze_state *state, pic_sym *var)
|
||||||
{
|
{
|
||||||
define_var(state, var);
|
define_var(state, var);
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ analyze_define(analyze_state *state, pic_value obj)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
pic_value var, val;
|
pic_value var, val;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
if (pic_length(pic, obj) != 3) {
|
if (pic_length(pic, obj) != 3) {
|
||||||
pic_errorf(pic, "syntax error");
|
pic_errorf(pic, "syntax error");
|
||||||
|
@ -652,7 +652,7 @@ analyze_call(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
pic_value seq, elt;
|
pic_value seq, elt;
|
||||||
pic_sym call;
|
pic_sym *call;
|
||||||
|
|
||||||
if (! tailpos) {
|
if (! tailpos) {
|
||||||
call = pic->sCALL;
|
call = pic->sCALL;
|
||||||
|
@ -688,7 +688,7 @@ analyze_call_with_values(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
pic_value prod, cnsm;
|
pic_value prod, cnsm;
|
||||||
pic_sym call;
|
pic_sym *call;
|
||||||
|
|
||||||
if (pic_length(pic, obj) != 3) {
|
if (pic_length(pic, obj) != 3) {
|
||||||
pic_errorf(pic, "wrong number of arguments");
|
pic_errorf(pic, "wrong number of arguments");
|
||||||
|
@ -745,7 +745,7 @@ analyze_node(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
|
|
||||||
proc = pic_list_ref(pic, obj, 0);
|
proc = pic_list_ref(pic, obj, 0);
|
||||||
if (pic_sym_p(proc)) {
|
if (pic_sym_p(proc)) {
|
||||||
pic_sym sym = pic_sym_ptr(proc);
|
pic_sym *sym = pic_sym_ptr(proc);
|
||||||
|
|
||||||
if (sym == pic->rDEFINE) {
|
if (sym == pic->rDEFINE) {
|
||||||
return analyze_define(state, obj);
|
return analyze_define(state, obj);
|
||||||
|
@ -861,7 +861,7 @@ pic_analyze(pic_state *pic, pic_value obj)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct codegen_context {
|
typedef struct codegen_context {
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
/* rest args variable is counted as a local */
|
/* rest args variable is counted as a local */
|
||||||
bool varg;
|
bool varg;
|
||||||
xvect args, locals, captures;
|
xvect args, locals, captures;
|
||||||
|
@ -875,7 +875,7 @@ typedef struct codegen_context {
|
||||||
pic_value *pool;
|
pic_value *pool;
|
||||||
size_t plen, pcapa;
|
size_t plen, pcapa;
|
||||||
/* symbol pool */
|
/* symbol pool */
|
||||||
pic_sym *syms;
|
pic_sym **syms;
|
||||||
size_t slen, scapa;
|
size_t slen, scapa;
|
||||||
|
|
||||||
struct codegen_context *up;
|
struct codegen_context *up;
|
||||||
|
@ -924,7 +924,7 @@ create_activation(codegen_context *cxt)
|
||||||
{
|
{
|
||||||
size_t i, n;
|
size_t i, n;
|
||||||
xhash regs;
|
xhash regs;
|
||||||
pic_sym *var;
|
pic_sym **var;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
||||||
xh_init_ptr(®s, sizeof(size_t));
|
xh_init_ptr(®s, sizeof(size_t));
|
||||||
|
@ -965,7 +965,7 @@ push_codegen_context(codegen_state *state, pic_value name, pic_value args, pic_v
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
codegen_context *cxt;
|
codegen_context *cxt;
|
||||||
pic_value var;
|
pic_value var;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
assert(pic_sym_p(name) || pic_false_p(name));
|
assert(pic_sym_p(name) || pic_false_p(name));
|
||||||
|
|
||||||
|
@ -976,9 +976,9 @@ push_codegen_context(codegen_state *state, pic_value name, pic_value args, pic_v
|
||||||
: pic_sym_ptr(name);
|
: pic_sym_ptr(name);
|
||||||
cxt->varg = varg;
|
cxt->varg = varg;
|
||||||
|
|
||||||
xv_init(&cxt->args, sizeof(pic_sym));
|
xv_init(&cxt->args, sizeof(pic_sym *));
|
||||||
xv_init(&cxt->locals, sizeof(pic_sym));
|
xv_init(&cxt->locals, sizeof(pic_sym *));
|
||||||
xv_init(&cxt->captures, sizeof(pic_sym));
|
xv_init(&cxt->captures, sizeof(pic_sym *));
|
||||||
|
|
||||||
pic_for_each (var, args) {
|
pic_for_each (var, args) {
|
||||||
sym = pic_sym_ptr(var);
|
sym = pic_sym_ptr(var);
|
||||||
|
@ -1005,7 +1005,7 @@ push_codegen_context(codegen_state *state, pic_value name, pic_value args, pic_v
|
||||||
cxt->plen = 0;
|
cxt->plen = 0;
|
||||||
cxt->pcapa = PIC_POOL_SIZE;
|
cxt->pcapa = PIC_POOL_SIZE;
|
||||||
|
|
||||||
cxt->syms = pic_calloc(pic, PIC_POOL_SIZE, sizeof(pic_sym));
|
cxt->syms = pic_calloc(pic, PIC_POOL_SIZE, sizeof(pic_sym *));
|
||||||
cxt->slen = 0;
|
cxt->slen = 0;
|
||||||
cxt->scapa = PIC_POOL_SIZE;
|
cxt->scapa = PIC_POOL_SIZE;
|
||||||
|
|
||||||
|
@ -1034,7 +1034,7 @@ pop_codegen_context(codegen_state *state)
|
||||||
irep->ilen = state->cxt->ilen;
|
irep->ilen = state->cxt->ilen;
|
||||||
irep->pool = pic_realloc(pic, state->cxt->pool, sizeof(pic_value) * state->cxt->plen);
|
irep->pool = pic_realloc(pic, state->cxt->pool, sizeof(pic_value) * state->cxt->plen);
|
||||||
irep->plen = state->cxt->plen;
|
irep->plen = state->cxt->plen;
|
||||||
irep->syms = pic_realloc(pic, state->cxt->syms, sizeof(pic_sym) * state->cxt->slen);
|
irep->syms = pic_realloc(pic, state->cxt->syms, sizeof(pic_sym *) * state->cxt->slen);
|
||||||
irep->slen = state->cxt->slen;
|
irep->slen = state->cxt->slen;
|
||||||
|
|
||||||
/* finalize */
|
/* finalize */
|
||||||
|
@ -1051,11 +1051,11 @@ pop_codegen_context(codegen_state *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
index_capture(codegen_state *state, pic_sym sym, int depth)
|
index_capture(codegen_state *state, pic_sym *sym, int depth)
|
||||||
{
|
{
|
||||||
codegen_context *cxt = state->cxt;
|
codegen_context *cxt = state->cxt;
|
||||||
size_t i;
|
size_t i;
|
||||||
pic_sym *var;
|
pic_sym **var;
|
||||||
|
|
||||||
while (depth-- > 0) {
|
while (depth-- > 0) {
|
||||||
cxt = cxt->up;
|
cxt = cxt->up;
|
||||||
|
@ -1070,11 +1070,11 @@ index_capture(codegen_state *state, pic_sym sym, int depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
index_local(codegen_state *state, pic_sym sym)
|
index_local(codegen_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
codegen_context *cxt = state->cxt;
|
codegen_context *cxt = state->cxt;
|
||||||
size_t i, offset;
|
size_t i, offset;
|
||||||
pic_sym *var;
|
pic_sym **var;
|
||||||
|
|
||||||
offset = 1;
|
offset = 1;
|
||||||
for (i = 0; i < xv_size(&cxt->args); ++i) {
|
for (i = 0; i < xv_size(&cxt->args); ++i) {
|
||||||
|
@ -1092,7 +1092,7 @@ index_local(codegen_state *state, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
index_symbol(codegen_state *state, pic_sym sym)
|
index_symbol(codegen_state *state, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
codegen_context *cxt = state->cxt;
|
codegen_context *cxt = state->cxt;
|
||||||
|
@ -1105,7 +1105,7 @@ index_symbol(codegen_state *state, pic_sym sym)
|
||||||
}
|
}
|
||||||
if (cxt->slen >= cxt->scapa) {
|
if (cxt->slen >= cxt->scapa) {
|
||||||
cxt->scapa *= 2;
|
cxt->scapa *= 2;
|
||||||
cxt->syms = pic_realloc(pic, cxt->syms, sizeof(pic_sym) * cxt->scapa);
|
cxt->syms = pic_realloc(pic, cxt->syms, sizeof(pic_sym *) * cxt->scapa);
|
||||||
}
|
}
|
||||||
cxt->syms[cxt->slen++] = sym;
|
cxt->syms[cxt->slen++] = sym;
|
||||||
return i;
|
return i;
|
||||||
|
@ -1118,7 +1118,7 @@ codegen(codegen_state *state, pic_value obj)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
codegen_context *cxt = state->cxt;
|
codegen_context *cxt = state->cxt;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
sym = pic_sym_ptr(pic_car(pic, obj));
|
sym = pic_sym_ptr(pic_car(pic, obj));
|
||||||
if (sym == pic->sGREF) {
|
if (sym == pic->sGREF) {
|
||||||
|
@ -1127,7 +1127,7 @@ codegen(codegen_state *state, pic_value obj)
|
||||||
cxt->clen++;
|
cxt->clen++;
|
||||||
return;
|
return;
|
||||||
} else if (sym == pic->sCREF) {
|
} else if (sym == pic->sCREF) {
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
depth = pic_int(pic_list_ref(pic, obj, 1));
|
depth = pic_int(pic_list_ref(pic, obj, 1));
|
||||||
|
@ -1138,7 +1138,7 @@ codegen(codegen_state *state, pic_value obj)
|
||||||
cxt->clen++;
|
cxt->clen++;
|
||||||
return;
|
return;
|
||||||
} else if (sym == pic->sLREF) {
|
} else if (sym == pic->sLREF) {
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
name = pic_sym_ptr(pic_list_ref(pic, obj, 1));
|
name = pic_sym_ptr(pic_list_ref(pic, obj, 1));
|
||||||
|
@ -1154,7 +1154,7 @@ codegen(codegen_state *state, pic_value obj)
|
||||||
return;
|
return;
|
||||||
} else if (sym == pic->sSETBANG) {
|
} else if (sym == pic->sSETBANG) {
|
||||||
pic_value var, val;
|
pic_value var, val;
|
||||||
pic_sym type;
|
pic_sym *type;
|
||||||
|
|
||||||
val = pic_list_ref(pic, obj, 2);
|
val = pic_list_ref(pic, obj, 2);
|
||||||
codegen(state, val);
|
codegen(state, val);
|
||||||
|
@ -1170,7 +1170,7 @@ codegen(codegen_state *state, pic_value obj)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (type == pic->sCREF) {
|
else if (type == pic->sCREF) {
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
depth = pic_int(pic_list_ref(pic, var, 1));
|
depth = pic_int(pic_list_ref(pic, var, 1));
|
||||||
|
@ -1184,7 +1184,7 @@ codegen(codegen_state *state, pic_value obj)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (type == pic->sLREF) {
|
else if (type == pic->sLREF) {
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
name = pic_sym_ptr(pic_list_ref(pic, var, 1));
|
name = pic_sym_ptr(pic_list_ref(pic, var, 1));
|
||||||
|
|
|
@ -21,7 +21,7 @@ pic_make_dict(pic_state *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_sym *key)
|
||||||
{
|
{
|
||||||
xh_entry *e;
|
xh_entry *e;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_dict_set(pic_state *pic, struct pic_dict *dict, pic_sym key, pic_value val)
|
pic_dict_set(pic_state *pic, struct pic_dict *dict, pic_sym *key, pic_value val)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(pic);
|
PIC_UNUSED(pic);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ pic_dict_size(pic_state *pic, struct pic_dict *dict)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_sym *key)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(pic);
|
PIC_UNUSED(pic);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_dict_del(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
pic_dict_del(pic_state *pic, struct pic_dict *dict, pic_sym *key)
|
||||||
{
|
{
|
||||||
if (xh_get_ptr(&dict->hash, key) == NULL) {
|
if (xh_get_ptr(&dict->hash, key) == NULL) {
|
||||||
pic_errorf(pic, "no slot named ~s found in dictionary", pic_obj_value(key));
|
pic_errorf(pic, "no slot named ~s found in dictionary", pic_obj_value(key));
|
||||||
|
@ -111,7 +111,7 @@ static pic_value
|
||||||
pic_dict_dictionary_ref(pic_state *pic)
|
pic_dict_dictionary_ref(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_dict *dict;
|
struct pic_dict *dict;
|
||||||
pic_sym key;
|
pic_sym *key;
|
||||||
|
|
||||||
pic_get_args(pic, "dm", &dict, &key);
|
pic_get_args(pic, "dm", &dict, &key);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ static pic_value
|
||||||
pic_dict_dictionary_set(pic_state *pic)
|
pic_dict_dictionary_set(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_dict *dict;
|
struct pic_dict *dict;
|
||||||
pic_sym key;
|
pic_sym *key;
|
||||||
pic_value val;
|
pic_value val;
|
||||||
|
|
||||||
pic_get_args(pic, "dmo", &dict, &key, &val);
|
pic_get_args(pic, "dmo", &dict, &key, &val);
|
||||||
|
@ -140,7 +140,7 @@ static pic_value
|
||||||
pic_dict_dictionary_del(pic_state *pic)
|
pic_dict_dictionary_del(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_dict *dict;
|
struct pic_dict *dict;
|
||||||
pic_sym key;
|
pic_sym *key;
|
||||||
|
|
||||||
pic_get_args(pic, "dm", &dict, &key);
|
pic_get_args(pic, "dm", &dict, &key);
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ pic_dict_dictionary_map(pic_state *pic)
|
||||||
if (it[i] == NULL) {
|
if (it[i] == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pic_push(pic, pic_obj_value(xh_key(it[i], pic_sym)), arg);
|
pic_push(pic, pic_obj_value(xh_key(it[i], pic_sym *)), arg);
|
||||||
it[i] = xh_next(it[i]);
|
it[i] = xh_next(it[i]);
|
||||||
}
|
}
|
||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
|
@ -233,7 +233,7 @@ pic_dict_dictionary_for_each(pic_state *pic)
|
||||||
if (it[i] == NULL) {
|
if (it[i] == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pic_push(pic, pic_obj_value(xh_key(it[i], pic_sym)), arg);
|
pic_push(pic, pic_obj_value(xh_key(it[i], pic_sym *)), arg);
|
||||||
it[i] = xh_next(it[i]);
|
it[i] = xh_next(it[i]);
|
||||||
}
|
}
|
||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
|
@ -262,7 +262,7 @@ pic_dict_dictionary_to_alist(pic_state *pic)
|
||||||
pic_get_args(pic, "d", &dict);
|
pic_get_args(pic, "d", &dict);
|
||||||
|
|
||||||
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
||||||
item = pic_cons(pic, pic_obj_value(xh_key(it, pic_sym)), xh_val(it, pic_value));
|
item = pic_cons(pic, pic_obj_value(xh_key(it, pic_sym *)), xh_val(it, pic_value));
|
||||||
pic_push(pic, item, alist);
|
pic_push(pic, item, alist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ pic_dict_dictionary_to_plist(pic_state *pic)
|
||||||
pic_get_args(pic, "d", &dict);
|
pic_get_args(pic, "d", &dict);
|
||||||
|
|
||||||
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
||||||
pic_push(pic, pic_obj_value(xh_key(it, pic_sym)), plist);
|
pic_push(pic, pic_obj_value(xh_key(it, pic_sym *)), plist);
|
||||||
pic_push(pic, xh_val(it, pic_value), plist);
|
pic_push(pic, xh_val(it, pic_value), plist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ pic_pop_try(pic_state *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pic_error *
|
struct pic_error *
|
||||||
pic_make_error(pic_state *pic, pic_sym type, const char *msg, pic_value irrs)
|
pic_make_error(pic_state *pic, pic_sym *type, const char *msg, pic_value irrs)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
struct pic_error *e;
|
||||||
pic_str *stack;
|
pic_str *stack;
|
||||||
|
@ -175,7 +175,7 @@ pic_raise(pic_state *pic, pic_value err)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_throw(pic_state *pic, pic_sym type, const char *msg, pic_value irrs)
|
pic_throw(pic_state *pic, pic_sym *type, const char *msg, pic_value irrs)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
struct pic_error *e;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ static pic_value
|
||||||
pic_error_make_error_object(pic_state *pic)
|
pic_error_make_error_object(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
struct pic_error *e;
|
||||||
pic_sym type;
|
pic_sym *type;
|
||||||
pic_str *msg;
|
pic_str *msg;
|
||||||
size_t argc;
|
size_t argc;
|
||||||
pic_value *argv;
|
pic_value *argv;
|
||||||
|
|
|
@ -470,7 +470,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
||||||
xh_entry *it;
|
xh_entry *it;
|
||||||
|
|
||||||
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
||||||
gc_mark_object(pic, (struct pic_object *)xh_key(it, pic_sym));
|
gc_mark_object(pic, (struct pic_object *)xh_key(it, pic_sym *));
|
||||||
gc_mark(pic, xh_val(it, pic_value));
|
gc_mark(pic, xh_val(it, pic_value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -578,7 +578,7 @@ gc_mark_phase(pic_state *pic)
|
||||||
|
|
||||||
/* mark all interned symbols */
|
/* mark all interned symbols */
|
||||||
for (it = xh_begin(&pic->syms); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&pic->syms); it != NULL; it = xh_next(it)) {
|
||||||
gc_mark_object(pic, (struct pic_object *)xh_val(it, pic_sym));
|
gc_mark_object(pic, (struct pic_object *)xh_val(it, pic_sym *));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
|
|
|
@ -89,25 +89,25 @@ typedef struct {
|
||||||
|
|
||||||
struct pic_lib *lib;
|
struct pic_lib *lib;
|
||||||
|
|
||||||
pic_sym sDEFINE, sLAMBDA, sIF, sBEGIN, sQUOTE, sSETBANG;
|
pic_sym *sDEFINE, *sLAMBDA, *sIF, *sBEGIN, *sQUOTE, *sSETBANG;
|
||||||
pic_sym sQUASIQUOTE, sUNQUOTE, sUNQUOTE_SPLICING;
|
pic_sym *sQUASIQUOTE, *sUNQUOTE, *sUNQUOTE_SPLICING;
|
||||||
pic_sym sDEFINE_SYNTAX, sIMPORT, sEXPORT;
|
pic_sym *sDEFINE_SYNTAX, *sIMPORT, *sEXPORT;
|
||||||
pic_sym sDEFINE_LIBRARY, sIN_LIBRARY;
|
pic_sym *sDEFINE_LIBRARY, *sIN_LIBRARY;
|
||||||
pic_sym sCOND_EXPAND, sAND, sOR, sELSE, sLIBRARY;
|
pic_sym *sCOND_EXPAND, *sAND, *sOR, *sELSE, *sLIBRARY;
|
||||||
pic_sym sONLY, sRENAME, sPREFIX, sEXCEPT;
|
pic_sym *sONLY, *sRENAME, *sPREFIX, *sEXCEPT;
|
||||||
pic_sym sCONS, sCAR, sCDR, sNILP;
|
pic_sym *sCONS, *sCAR, *sCDR, *sNILP;
|
||||||
pic_sym sSYMBOLP, sPAIRP;
|
pic_sym *sSYMBOLP, *sPAIRP;
|
||||||
pic_sym sADD, sSUB, sMUL, sDIV, sMINUS;
|
pic_sym *sADD, *sSUB, *sMUL, *sDIV, *sMINUS;
|
||||||
pic_sym sEQ, sLT, sLE, sGT, sGE, sNOT;
|
pic_sym *sEQ, *sLT, *sLE, *sGT, *sGE, *sNOT;
|
||||||
pic_sym sREAD, sFILE;
|
pic_sym *sREAD, *sFILE;
|
||||||
pic_sym sGREF, sCREF, sLREF;
|
pic_sym *sGREF, *sCREF, *sLREF;
|
||||||
pic_sym sCALL, sTAILCALL, sRETURN;
|
pic_sym *sCALL, *sTAILCALL, *sRETURN;
|
||||||
pic_sym sCALL_WITH_VALUES, sTAILCALL_WITH_VALUES;
|
pic_sym *sCALL_WITH_VALUES, *sTAILCALL_WITH_VALUES;
|
||||||
|
|
||||||
pic_sym rDEFINE, rLAMBDA, rIF, rBEGIN, rQUOTE, rSETBANG;
|
pic_sym *rDEFINE, *rLAMBDA, *rIF, *rBEGIN, *rQUOTE, *rSETBANG;
|
||||||
pic_sym rDEFINE_SYNTAX, rIMPORT, rEXPORT;
|
pic_sym *rDEFINE_SYNTAX, *rIMPORT, *rEXPORT;
|
||||||
pic_sym rDEFINE_LIBRARY, rIN_LIBRARY;
|
pic_sym *rDEFINE_LIBRARY, *rIN_LIBRARY;
|
||||||
pic_sym rCOND_EXPAND;
|
pic_sym *rCOND_EXPAND;
|
||||||
|
|
||||||
struct pic_lib *PICRIN_BASE;
|
struct pic_lib *PICRIN_BASE;
|
||||||
struct pic_lib *PICRIN_USER;
|
struct pic_lib *PICRIN_USER;
|
||||||
|
@ -175,11 +175,11 @@ bool pic_eq_p(pic_value, pic_value);
|
||||||
bool pic_eqv_p(pic_value, pic_value);
|
bool pic_eqv_p(pic_value, pic_value);
|
||||||
bool pic_equal_p(pic_state *, pic_value, pic_value);
|
bool pic_equal_p(pic_state *, pic_value, pic_value);
|
||||||
|
|
||||||
pic_sym pic_intern(pic_state *, pic_str *);
|
pic_sym *pic_intern(pic_state *, pic_str *);
|
||||||
pic_sym pic_intern_cstr(pic_state *, const char *);
|
pic_sym *pic_intern_cstr(pic_state *, const char *);
|
||||||
const char *pic_symbol_name(pic_state *, pic_sym);
|
const char *pic_symbol_name(pic_state *, pic_sym *);
|
||||||
pic_sym pic_gensym(pic_state *, pic_sym);
|
pic_sym *pic_gensym(pic_state *, pic_sym *);
|
||||||
bool pic_interned_p(pic_state *, pic_sym);
|
bool pic_interned_p(pic_state *, pic_sym *);
|
||||||
|
|
||||||
pic_value pic_read(pic_state *, struct pic_port *);
|
pic_value pic_read(pic_state *, struct pic_port *);
|
||||||
pic_value pic_read_cstr(pic_state *, const char *);
|
pic_value pic_read_cstr(pic_state *, const char *);
|
||||||
|
@ -216,7 +216,7 @@ struct pic_lib *pic_find_library(pic_state *, pic_value);
|
||||||
|
|
||||||
void pic_import(pic_state *, pic_value);
|
void pic_import(pic_state *, pic_value);
|
||||||
void pic_import_library(pic_state *, struct pic_lib *);
|
void pic_import_library(pic_state *, struct pic_lib *);
|
||||||
void pic_export(pic_state *, pic_sym);
|
void pic_export(pic_state *, pic_sym *);
|
||||||
|
|
||||||
pic_noreturn void pic_panic(pic_state *, const char *);
|
pic_noreturn void pic_panic(pic_state *, const char *);
|
||||||
pic_noreturn void pic_errorf(pic_state *, const char *, ...);
|
pic_noreturn void pic_errorf(pic_state *, const char *, ...);
|
||||||
|
|
|
@ -23,14 +23,14 @@ struct pic_dict *pic_make_dict(pic_state *);
|
||||||
pic_dict_for_each_helper_((sym), PIC_GENSYM(tmp), (dict))
|
pic_dict_for_each_helper_((sym), PIC_GENSYM(tmp), (dict))
|
||||||
#define pic_dict_for_each_helper_(var, tmp, dict) \
|
#define pic_dict_for_each_helper_(var, tmp, dict) \
|
||||||
for (xh_entry *tmp = xh_begin(&dict->hash); \
|
for (xh_entry *tmp = xh_begin(&dict->hash); \
|
||||||
(tmp && ((var = xh_key(tmp, pic_sym)), 1)); \
|
(tmp && ((var = xh_key(tmp, pic_sym *)), 1)); \
|
||||||
tmp = xh_next(tmp))
|
tmp = xh_next(tmp))
|
||||||
|
|
||||||
pic_value pic_dict_ref(pic_state *, struct pic_dict *, pic_sym);
|
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_set(pic_state *, struct pic_dict *, pic_sym *, pic_value);
|
||||||
void pic_dict_del(pic_state *, struct pic_dict *, pic_sym);
|
void pic_dict_del(pic_state *, struct pic_dict *, pic_sym *);
|
||||||
size_t pic_dict_size(pic_state *, struct pic_dict *);
|
size_t pic_dict_size(pic_state *, struct pic_dict *);
|
||||||
bool pic_dict_has(pic_state *, struct pic_dict *, pic_sym);
|
bool pic_dict_has(pic_state *, struct pic_dict *, pic_sym *);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
||||||
|
|
||||||
struct pic_error {
|
struct pic_error {
|
||||||
PIC_OBJECT_HEADER
|
PIC_OBJECT_HEADER
|
||||||
pic_sym type;
|
pic_sym *type;
|
||||||
pic_str *msg;
|
pic_str *msg;
|
||||||
pic_value irrs;
|
pic_value irrs;
|
||||||
pic_str *stack;
|
pic_str *stack;
|
||||||
|
@ -22,7 +22,7 @@ struct pic_error {
|
||||||
#define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR)
|
#define pic_error_p(v) (pic_type(v) == PIC_TT_ERROR)
|
||||||
#define pic_error_ptr(v) ((struct pic_error *)pic_ptr(v))
|
#define pic_error_ptr(v) ((struct pic_error *)pic_ptr(v))
|
||||||
|
|
||||||
struct pic_error *pic_make_error(pic_state *, pic_sym, const char *, pic_list);
|
struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_list);
|
||||||
|
|
||||||
/* do not return from try block! */
|
/* do not return from try block! */
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void pic_pop_try(pic_state *);
|
||||||
|
|
||||||
pic_value pic_raise_continuable(pic_state *, pic_value);
|
pic_value pic_raise_continuable(pic_state *, pic_value);
|
||||||
pic_noreturn void pic_raise(pic_state *, pic_value);
|
pic_noreturn void pic_raise(pic_state *, pic_value);
|
||||||
pic_noreturn void pic_throw(pic_state *, pic_sym, const char *, pic_list);
|
pic_noreturn void pic_throw(pic_state *, pic_sym *, const char *, pic_list);
|
||||||
pic_noreturn void pic_error(pic_state *, const char *, pic_list);
|
pic_noreturn void pic_error(pic_state *, const char *, pic_list);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
|
@ -62,13 +62,13 @@ struct pic_code {
|
||||||
|
|
||||||
struct pic_irep {
|
struct pic_irep {
|
||||||
PIC_OBJECT_HEADER
|
PIC_OBJECT_HEADER
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
pic_code *code;
|
pic_code *code;
|
||||||
int argc, localc, capturec;
|
int argc, localc, capturec;
|
||||||
bool varg;
|
bool varg;
|
||||||
struct pic_irep **irep;
|
struct pic_irep **irep;
|
||||||
pic_value *pool;
|
pic_value *pool;
|
||||||
pic_sym *syms;
|
pic_sym **syms;
|
||||||
size_t clen, ilen, plen, slen;
|
size_t clen, ilen, plen, slen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,15 @@ struct pic_senv {
|
||||||
struct pic_senv *pic_null_syntactic_environment(pic_state *);
|
struct pic_senv *pic_null_syntactic_environment(pic_state *);
|
||||||
|
|
||||||
bool pic_identifier_p(pic_state *pic, pic_value obj);
|
bool pic_identifier_p(pic_state *pic, pic_value obj);
|
||||||
bool pic_identifier_eq_p(pic_state *, struct pic_senv *, pic_sym, struct pic_senv *, pic_sym);
|
bool pic_identifier_eq_p(pic_state *, struct pic_senv *, pic_sym *, struct pic_senv *, pic_sym *);
|
||||||
|
|
||||||
struct pic_senv *pic_make_senv(pic_state *, struct pic_senv *);
|
struct pic_senv *pic_make_senv(pic_state *, struct pic_senv *);
|
||||||
|
|
||||||
pic_sym pic_add_rename(pic_state *, struct pic_senv *, pic_sym);
|
pic_sym *pic_add_rename(pic_state *, struct pic_senv *, pic_sym *);
|
||||||
bool pic_find_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym * /* = NULL */);
|
bool pic_find_rename(pic_state *, struct pic_senv *, pic_sym *, pic_sym ** /* = NULL */);
|
||||||
void pic_put_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym);
|
void pic_put_rename(pic_state *, struct pic_senv *, pic_sym *, pic_sym *);
|
||||||
|
|
||||||
void pic_define_syntactic_keyword(pic_state *, struct pic_senv *, pic_sym, pic_sym);
|
void pic_define_syntactic_keyword(pic_state *, struct pic_senv *, pic_sym *, pic_sym *);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
||||||
/* native C function */
|
/* native C function */
|
||||||
struct pic_func {
|
struct pic_func {
|
||||||
pic_func_t f;
|
pic_func_t f;
|
||||||
pic_sym name;
|
pic_sym *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pic_env {
|
struct pic_env {
|
||||||
|
@ -48,7 +48,7 @@ struct pic_proc {
|
||||||
struct pic_proc *pic_make_proc(pic_state *, pic_func_t, const char *);
|
struct pic_proc *pic_make_proc(pic_state *, pic_func_t, const char *);
|
||||||
struct pic_proc *pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_env *);
|
struct pic_proc *pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_env *);
|
||||||
|
|
||||||
pic_sym pic_proc_name(struct pic_proc *);
|
pic_sym *pic_proc_name(struct pic_proc *);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ struct pic_record {
|
||||||
struct pic_record *pic_make_record(pic_state *, pic_value);
|
struct pic_record *pic_make_record(pic_state *, pic_value);
|
||||||
|
|
||||||
pic_value pic_record_type(pic_state *, struct pic_record *);
|
pic_value pic_record_type(pic_state *, struct pic_record *);
|
||||||
pic_value pic_record_ref(pic_state *, struct pic_record *, pic_sym);
|
pic_value pic_record_ref(pic_state *, struct pic_record *, pic_sym *);
|
||||||
void pic_record_set(pic_state *, struct pic_record *, pic_sym, pic_value);
|
void pic_record_set(pic_state *, struct pic_record *, pic_sym *, pic_value);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ struct pic_error;
|
||||||
|
|
||||||
/* set aliases to basic types */
|
/* set aliases to basic types */
|
||||||
typedef pic_value pic_list;
|
typedef pic_value pic_list;
|
||||||
typedef struct pic_symbol *pic_sym;
|
typedef struct pic_symbol pic_sym;
|
||||||
typedef struct pic_pair pic_pair;
|
typedef struct pic_pair pic_pair;
|
||||||
typedef struct pic_string pic_str;
|
typedef struct pic_string pic_str;
|
||||||
typedef struct pic_vector pic_vec;
|
typedef struct pic_vector pic_vec;
|
||||||
|
|
|
@ -74,7 +74,7 @@ import_table(pic_state *pic, pic_value spec, struct pic_dict *imports)
|
||||||
struct pic_lib *lib;
|
struct pic_lib *lib;
|
||||||
struct pic_dict *table;
|
struct pic_dict *table;
|
||||||
pic_value val, tmp, prefix;
|
pic_value val, tmp, prefix;
|
||||||
pic_sym sym, id, tag;
|
pic_sym *sym, *id, *tag;
|
||||||
|
|
||||||
table = pic_make_dict(pic);
|
table = pic_make_dict(pic);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ static void
|
||||||
import(pic_state *pic, pic_value spec)
|
import(pic_state *pic, pic_value spec)
|
||||||
{
|
{
|
||||||
struct pic_dict *imports;
|
struct pic_dict *imports;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
imports = pic_make_dict(pic);
|
imports = pic_make_dict(pic);
|
||||||
|
|
||||||
|
@ -145,9 +145,9 @@ import(pic_state *pic, pic_value spec)
|
||||||
static void
|
static void
|
||||||
export(pic_state *pic, pic_value spec)
|
export(pic_state *pic, pic_value spec)
|
||||||
{
|
{
|
||||||
const pic_sym sRENAME = pic_intern_cstr(pic, "rename");
|
pic_sym *sRENAME = pic_intern_cstr(pic, "rename");
|
||||||
pic_value a, b;
|
pic_value a, b;
|
||||||
pic_sym rename;
|
pic_sym *rename;
|
||||||
|
|
||||||
if (pic_sym_p(spec)) { /* (export a) */
|
if (pic_sym_p(spec)) { /* (export a) */
|
||||||
a = b = spec;
|
a = b = spec;
|
||||||
|
@ -193,7 +193,7 @@ pic_import_library(pic_state *pic, struct pic_lib *lib)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_export(pic_state *pic, pic_sym sym)
|
pic_export(pic_state *pic, pic_sym *sym)
|
||||||
{
|
{
|
||||||
export(pic, pic_obj_value(sym));
|
export(pic, pic_obj_value(sym));
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ pic_export(pic_state *pic, pic_sym sym)
|
||||||
static bool
|
static bool
|
||||||
condexpand(pic_state *pic, pic_value clause)
|
condexpand(pic_state *pic, pic_value clause)
|
||||||
{
|
{
|
||||||
pic_sym tag;
|
pic_sym *tag;
|
||||||
pic_value c, feature;
|
pic_value c, feature;
|
||||||
|
|
||||||
if (pic_eq_p(clause, pic_obj_value(pic->sELSE))) {
|
if (pic_eq_p(clause, pic_obj_value(pic->sELSE))) {
|
||||||
|
@ -335,7 +335,7 @@ pic_lib_in_library(pic_state *pic)
|
||||||
void
|
void
|
||||||
pic_init_lib(pic_state *pic)
|
pic_init_lib(pic_state *pic)
|
||||||
{
|
{
|
||||||
void pic_defmacro(pic_state *, pic_sym, pic_sym, pic_func_t);
|
void pic_defmacro(pic_state *, pic_sym *, pic_sym *, pic_func_t);
|
||||||
|
|
||||||
pic_defmacro(pic, pic->sCOND_EXPAND, pic->rCOND_EXPAND, pic_lib_condexpand);
|
pic_defmacro(pic, pic->sCOND_EXPAND, pic->rCOND_EXPAND, pic_lib_condexpand);
|
||||||
pic_defmacro(pic, pic->sIMPORT, pic->rIMPORT, pic_lib_import);
|
pic_defmacro(pic, pic->sIMPORT, pic->rIMPORT, pic_lib_import);
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
#include "picrin/cont.h"
|
#include "picrin/cont.h"
|
||||||
#include "picrin/symbol.h"
|
#include "picrin/symbol.h"
|
||||||
|
|
||||||
pic_sym
|
pic_sym *
|
||||||
pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym)
|
pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym *sym)
|
||||||
{
|
{
|
||||||
pic_sym rename;
|
pic_sym *rename;
|
||||||
|
|
||||||
rename = pic_gensym(pic, sym);
|
rename = pic_gensym(pic, sym);
|
||||||
pic_put_rename(pic, senv, sym, rename);
|
pic_put_rename(pic, senv, sym, rename);
|
||||||
|
@ -24,13 +24,13 @@ pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_put_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym rename)
|
pic_put_rename(pic_state *pic, struct pic_senv *senv, pic_sym *sym, pic_sym *rename)
|
||||||
{
|
{
|
||||||
pic_dict_set(pic, senv->map, sym, pic_obj_value(rename));
|
pic_dict_set(pic, senv->map, sym, pic_obj_value(rename));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pic_find_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym *rename)
|
pic_find_rename(pic_state *pic, struct pic_senv *senv, pic_sym *sym, pic_sym **rename)
|
||||||
{
|
{
|
||||||
if (! pic_dict_has(pic, senv->map, sym)) {
|
if (! pic_dict_has(pic, senv->map, sym)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -42,13 +42,13 @@ pic_find_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym *ren
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
define_macro(pic_state *pic, pic_sym rename, struct pic_proc *mac)
|
define_macro(pic_state *pic, pic_sym *rename, struct pic_proc *mac)
|
||||||
{
|
{
|
||||||
pic_dict_set(pic, pic->macros, rename, pic_obj_value(mac));
|
pic_dict_set(pic, pic->macros, rename, pic_obj_value(mac));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pic_proc *
|
static struct pic_proc *
|
||||||
find_macro(pic_state *pic, pic_sym rename)
|
find_macro(pic_state *pic, pic_sym *rename)
|
||||||
{
|
{
|
||||||
if (! pic_dict_has(pic, pic->macros, rename)) {
|
if (! pic_dict_has(pic, pic->macros, rename)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -56,10 +56,10 @@ find_macro(pic_state *pic, pic_sym rename)
|
||||||
return pic_proc_ptr(pic_dict_ref(pic, pic->macros, rename));
|
return pic_proc_ptr(pic_dict_ref(pic, pic->macros, rename));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_sym
|
static pic_sym *
|
||||||
make_identifier(pic_state *pic, pic_sym sym, struct pic_senv *senv)
|
make_identifier(pic_state *pic, pic_sym *sym, struct pic_senv *senv)
|
||||||
{
|
{
|
||||||
pic_sym rename;
|
pic_sym *rename;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (pic_find_rename(pic, senv, sym, &rename)) {
|
if (pic_find_rename(pic, senv, sym, &rename)) {
|
||||||
|
@ -81,7 +81,7 @@ static pic_value macroexpand(pic_state *, pic_value, struct pic_senv *);
|
||||||
static pic_value macroexpand_lambda(pic_state *, pic_value, struct pic_senv *);
|
static pic_value macroexpand_lambda(pic_state *, pic_value, struct pic_senv *);
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
macroexpand_symbol(pic_state *pic, pic_sym sym, struct pic_senv *senv)
|
macroexpand_symbol(pic_state *pic, pic_sym *sym, struct pic_senv *senv)
|
||||||
{
|
{
|
||||||
return pic_obj_value(make_identifier(pic, sym, senv));
|
return pic_obj_value(make_identifier(pic, sym, senv));
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ macroexpand_lambda(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
static pic_value
|
static pic_value
|
||||||
macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
{
|
{
|
||||||
pic_sym sym, rename;
|
pic_sym *sym, *rename;
|
||||||
pic_value var, val;
|
pic_value var, val;
|
||||||
|
|
||||||
while (pic_length(pic, expr) >= 2 && pic_pair_p(pic_cadr(pic, expr))) {
|
while (pic_length(pic, expr) >= 2 && pic_pair_p(pic_cadr(pic, expr))) {
|
||||||
|
@ -210,7 +210,7 @@ static pic_value
|
||||||
macroexpand_defsyntax(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
macroexpand_defsyntax(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
{
|
{
|
||||||
pic_value var, val;
|
pic_value var, val;
|
||||||
pic_sym sym, rename;
|
pic_sym *sym, *rename;
|
||||||
|
|
||||||
if (pic_length(pic, expr) != 3) {
|
if (pic_length(pic, expr) != 3) {
|
||||||
pic_errorf(pic, "syntax error");
|
pic_errorf(pic, "syntax error");
|
||||||
|
@ -295,7 +295,7 @@ macroexpand_node(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
|
|
||||||
car = macroexpand(pic, pic_car(pic, expr), senv);
|
car = macroexpand(pic, pic_car(pic, expr), senv);
|
||||||
if (pic_sym_p(car)) {
|
if (pic_sym_p(car)) {
|
||||||
pic_sym tag = pic_sym_ptr(car);
|
pic_sym *tag = pic_sym_ptr(car);
|
||||||
|
|
||||||
if (tag == pic->rDEFINE_SYNTAX) {
|
if (tag == pic->rDEFINE_SYNTAX) {
|
||||||
return macroexpand_defsyntax(pic, expr, senv);
|
return macroexpand_defsyntax(pic, expr, senv);
|
||||||
|
@ -407,7 +407,7 @@ pic_null_syntactic_environment(pic_state *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_define_syntactic_keyword(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym rsym)
|
pic_define_syntactic_keyword(pic_state *pic, struct pic_senv *senv, pic_sym *sym, pic_sym *rsym)
|
||||||
{
|
{
|
||||||
pic_put_rename(pic, senv, sym, rsym);
|
pic_put_rename(pic, senv, sym, rsym);
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ defmacro_call(pic_state *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_defmacro(pic_state *pic, pic_sym name, pic_sym id, pic_func_t func)
|
pic_defmacro(pic_state *pic, pic_sym *name, pic_sym *id, pic_func_t func)
|
||||||
{
|
{
|
||||||
struct pic_proc *proc, *trans;
|
struct pic_proc *proc, *trans;
|
||||||
|
|
||||||
|
@ -455,9 +455,9 @@ pic_identifier_p(pic_state *pic, pic_value obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pic_identifier_eq_p(pic_state *pic, struct pic_senv *env1, pic_sym sym1, struct pic_senv *env2, pic_sym sym2)
|
pic_identifier_eq_p(pic_state *pic, struct pic_senv *env1, pic_sym *sym1, struct pic_senv *env2, pic_sym *sym2)
|
||||||
{
|
{
|
||||||
pic_sym a, b;
|
pic_sym *a, *b;
|
||||||
|
|
||||||
a = make_identifier(pic, sym1, env1);
|
a = make_identifier(pic, sym1, env1);
|
||||||
if (a != make_identifier(pic, sym1, env1)) {
|
if (a != make_identifier(pic, sym1, env1)) {
|
||||||
|
@ -486,7 +486,7 @@ static pic_value
|
||||||
pic_macro_make_identifier(pic_state *pic)
|
pic_macro_make_identifier(pic_state *pic)
|
||||||
{
|
{
|
||||||
pic_value obj;
|
pic_value obj;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
pic_get_args(pic, "mo", &sym, &obj);
|
pic_get_args(pic, "mo", &sym, &obj);
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ pic_macro_make_identifier(pic_state *pic)
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_macro_identifier_eq_p(pic_state *pic)
|
pic_macro_identifier_eq_p(pic_state *pic)
|
||||||
{
|
{
|
||||||
pic_sym sym1, sym2;
|
pic_sym *sym1, *sym2;
|
||||||
pic_value env1, env2;
|
pic_value env1, env2;
|
||||||
|
|
||||||
pic_get_args(pic, "omom", &env1, &sym1, &env2, &sym2);
|
pic_get_args(pic, "omom", &env1, &sym1, &env2, &sym2);
|
||||||
|
|
|
@ -34,7 +34,7 @@ pic_make_proc_irep(pic_state *pic, struct pic_irep *irep, struct pic_env *env)
|
||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_sym
|
pic_sym *
|
||||||
pic_proc_name(struct pic_proc *proc)
|
pic_proc_name(struct pic_proc *proc)
|
||||||
{
|
{
|
||||||
switch (proc->kind) {
|
switch (proc->kind) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ read_symbol(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
{
|
{
|
||||||
size_t len, i;
|
size_t len, i;
|
||||||
char *buf;
|
char *buf;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
@ -452,7 +452,7 @@ read_pipe(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t size, cnt;
|
size_t size, cnt;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
/* Currently supports only ascii chars */
|
/* Currently supports only ascii chars */
|
||||||
char HEX_BUF[3];
|
char HEX_BUF[3];
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
|
@ -29,7 +29,7 @@ pic_record_type(pic_state *pic, struct pic_record *rec)
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_record_ref(pic_state *pic, struct pic_record *rec, pic_sym slot)
|
pic_record_ref(pic_state *pic, struct pic_record *rec, pic_sym *slot)
|
||||||
{
|
{
|
||||||
if (! pic_dict_has(pic, rec->data, slot)) {
|
if (! pic_dict_has(pic, rec->data, slot)) {
|
||||||
pic_errorf(pic, "slot named ~s is not found for record: ~s", pic_obj_value(slot), rec);
|
pic_errorf(pic, "slot named ~s is not found for record: ~s", pic_obj_value(slot), rec);
|
||||||
|
@ -38,7 +38,7 @@ pic_record_ref(pic_state *pic, struct pic_record *rec, pic_sym slot)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_record_set(pic_state *pic, struct pic_record *rec, pic_sym slot, pic_value val)
|
pic_record_set(pic_state *pic, struct pic_record *rec, pic_sym *slot, pic_value val)
|
||||||
{
|
{
|
||||||
pic_dict_set(pic, rec->data, slot, val);
|
pic_dict_set(pic, rec->data, slot, val);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ static pic_value
|
||||||
pic_record_record_ref(pic_state *pic)
|
pic_record_record_ref(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_record *rec;
|
struct pic_record *rec;
|
||||||
pic_sym slot;
|
pic_sym *slot;
|
||||||
|
|
||||||
pic_get_args(pic, "rm", &rec, &slot);
|
pic_get_args(pic, "rm", &rec, &slot);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ static pic_value
|
||||||
pic_record_record_set(pic_state *pic)
|
pic_record_record_set(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_record *rec;
|
struct pic_record *rec;
|
||||||
pic_sym slot;
|
pic_sym *slot;
|
||||||
pic_value val;
|
pic_value val;
|
||||||
|
|
||||||
pic_get_args(pic, "rmo", &rec, &slot, &val);
|
pic_get_args(pic, "rmo", &rec, &slot, &val);
|
||||||
|
|
|
@ -52,7 +52,7 @@ pic_open(int argc, char *argv[], char **envp)
|
||||||
pic->heap = pic_heap_open();
|
pic->heap = pic_heap_open();
|
||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
xh_init_str(&pic->syms, sizeof(pic_sym));
|
xh_init_str(&pic->syms, sizeof(pic_sym *));
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
pic->globals = NULL;
|
pic->globals = NULL;
|
||||||
|
|
|
@ -6,26 +6,26 @@
|
||||||
#include "picrin/symbol.h"
|
#include "picrin/symbol.h"
|
||||||
#include "picrin/string.h"
|
#include "picrin/string.h"
|
||||||
|
|
||||||
pic_sym
|
pic_sym *
|
||||||
pic_make_symbol(pic_state *pic, pic_str *str)
|
pic_make_symbol(pic_state *pic, pic_str *str)
|
||||||
{
|
{
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
sym = (pic_sym)pic_obj_alloc(pic, sizeof(struct pic_symbol), PIC_TT_SYMBOL);
|
sym = (pic_sym *)pic_obj_alloc(pic, sizeof(struct pic_symbol), PIC_TT_SYMBOL);
|
||||||
sym->str = str;
|
sym->str = str;
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_sym
|
pic_sym *
|
||||||
pic_intern(pic_state *pic, pic_str *str)
|
pic_intern(pic_state *pic, pic_str *str)
|
||||||
{
|
{
|
||||||
xh_entry *e;
|
xh_entry *e;
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
char *cstr;
|
char *cstr;
|
||||||
|
|
||||||
e = xh_get_str(&pic->syms, pic_str_cstr(str));
|
e = xh_get_str(&pic->syms, pic_str_cstr(str));
|
||||||
if (e) {
|
if (e) {
|
||||||
sym = xh_val(e, pic_sym);
|
sym = xh_val(e, pic_sym *);
|
||||||
pic_gc_protect(pic, pic_obj_value(sym));
|
pic_gc_protect(pic, pic_obj_value(sym));
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
@ -38,33 +38,33 @@ pic_intern(pic_state *pic, pic_str *str)
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_sym
|
pic_sym *
|
||||||
pic_intern_cstr(pic_state *pic, const char *str)
|
pic_intern_cstr(pic_state *pic, const char *str)
|
||||||
{
|
{
|
||||||
return pic_intern(pic, pic_make_str(pic, str, strlen(str)));
|
return pic_intern(pic, pic_make_str(pic, str, strlen(str)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_sym
|
pic_sym *
|
||||||
pic_gensym(pic_state *pic, pic_sym base)
|
pic_gensym(pic_state *pic, pic_sym *base)
|
||||||
{
|
{
|
||||||
return pic_make_symbol(pic, base->str);
|
return pic_make_symbol(pic, base->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pic_interned_p(pic_state *pic, pic_sym sym)
|
pic_interned_p(pic_state *pic, pic_sym *sym)
|
||||||
{
|
{
|
||||||
xh_entry *e;
|
xh_entry *e;
|
||||||
|
|
||||||
e = xh_get_str(&pic->syms, pic_str_cstr(sym->str));
|
e = xh_get_str(&pic->syms, pic_str_cstr(sym->str));
|
||||||
if (e) {
|
if (e) {
|
||||||
return sym == xh_val(e, pic_sym);
|
return sym == xh_val(e, pic_sym *);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
pic_symbol_name(pic_state *pic, pic_sym sym)
|
pic_symbol_name(pic_state *pic, pic_sym *sym)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(pic);
|
PIC_UNUSED(pic);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ pic_symbol_symbol_eq_p(pic_state *pic)
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_symbol_symbol_to_string(pic_state *pic)
|
pic_symbol_symbol_to_string(pic_state *pic)
|
||||||
{
|
{
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
pic_get_args(pic, "m", &sym);
|
pic_get_args(pic, "m", &sym);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ pic_get_proc(pic_state *pic)
|
||||||
* F double *, bool * float with exactness
|
* F double *, bool * float with exactness
|
||||||
* s pic_str ** string object
|
* s pic_str ** string object
|
||||||
* z char ** c string
|
* z char ** c string
|
||||||
* m pic_sym * symbol
|
* m pic_sym ** symbol
|
||||||
* v pic_vec ** vector object
|
* v pic_vec ** vector object
|
||||||
* b pic_blob ** bytevector object
|
* b pic_blob ** bytevector object
|
||||||
* c char * char
|
* c char * char
|
||||||
|
@ -255,10 +255,10 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'm': {
|
case 'm': {
|
||||||
pic_sym *m;
|
pic_sym **m;
|
||||||
pic_value v;
|
pic_value v;
|
||||||
|
|
||||||
m = va_arg(ap, pic_sym *);
|
m = va_arg(ap, pic_sym **);
|
||||||
if (i < argc) {
|
if (i < argc) {
|
||||||
v = GET_OPERAND(pic,i);
|
v = GET_OPERAND(pic,i);
|
||||||
if (pic_sym_p(v)) {
|
if (pic_sym_p(v)) {
|
||||||
|
@ -433,7 +433,7 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
||||||
void
|
void
|
||||||
pic_define_noexport(pic_state *pic, const char *name, pic_value val)
|
pic_define_noexport(pic_state *pic, const char *name, pic_value val)
|
||||||
{
|
{
|
||||||
pic_sym sym, rename;
|
pic_sym *sym, *rename;
|
||||||
|
|
||||||
sym = pic_intern_cstr(pic, name);
|
sym = pic_intern_cstr(pic, name);
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ pic_define(pic_state *pic, const char *name, pic_value val)
|
||||||
pic_value
|
pic_value
|
||||||
pic_ref(pic_state *pic, struct pic_lib *lib, const char *name)
|
pic_ref(pic_state *pic, struct pic_lib *lib, const char *name)
|
||||||
{
|
{
|
||||||
pic_sym sym, rename;
|
pic_sym *sym, *rename;
|
||||||
|
|
||||||
sym = pic_intern_cstr(pic, name);
|
sym = pic_intern_cstr(pic, name);
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ pic_ref(pic_state *pic, struct pic_lib *lib, const char *name)
|
||||||
void
|
void
|
||||||
pic_set(pic_state *pic, struct pic_lib *lib, const char *name, pic_value val)
|
pic_set(pic_state *pic, struct pic_lib *lib, const char *name, pic_value val)
|
||||||
{
|
{
|
||||||
pic_sym sym, rename;
|
pic_sym *sym, *rename;
|
||||||
|
|
||||||
sym = pic_intern_cstr(pic, name);
|
sym = pic_intern_cstr(pic, name);
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args)
|
||||||
}
|
}
|
||||||
CASE(OP_GREF) {
|
CASE(OP_GREF) {
|
||||||
struct pic_irep *irep = vm_get_irep(pic);
|
struct pic_irep *irep = vm_get_irep(pic);
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
|
|
||||||
sym = irep->syms[c.u.i];
|
sym = irep->syms[c.u.i];
|
||||||
if (! pic_dict_has(pic, pic->globals, sym)) {
|
if (! pic_dict_has(pic, pic->globals, sym)) {
|
||||||
|
@ -787,7 +787,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args)
|
||||||
}
|
}
|
||||||
CASE(OP_GSET) {
|
CASE(OP_GSET) {
|
||||||
struct pic_irep *irep = vm_get_irep(pic);
|
struct pic_irep *irep = vm_get_irep(pic);
|
||||||
pic_sym sym;
|
pic_sym *sym;
|
||||||
pic_value val;
|
pic_value val;
|
||||||
|
|
||||||
sym = irep->syms[c.u.i];
|
sym = irep->syms[c.u.i];
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "picrin/symbol.h"
|
#include "picrin/symbol.h"
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_tagged(pic_state *pic, pic_sym tag, pic_value pair)
|
is_tagged(pic_state *pic, pic_sym *tag, pic_value pair)
|
||||||
{
|
{
|
||||||
return pic_pair_p(pic_cdr(pic, pair))
|
return pic_pair_p(pic_cdr(pic, pair))
|
||||||
&& pic_nil_p(pic_cddr(pic, pair))
|
&& pic_nil_p(pic_cddr(pic, pair))
|
||||||
|
@ -176,7 +176,7 @@ write_str(pic_state *pic, struct pic_string *str, xFILE *file)
|
||||||
static void
|
static void
|
||||||
write_record(pic_state *pic, struct pic_record *rec, xFILE *file)
|
write_record(pic_state *pic, struct pic_record *rec, xFILE *file)
|
||||||
{
|
{
|
||||||
const pic_sym sWRITER = pic_intern_cstr(pic, "writer");
|
pic_sym *sWRITER = pic_intern_cstr(pic, "writer");
|
||||||
pic_value type, writer, str;
|
pic_value type, writer, str;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -333,7 +333,7 @@ write_core(struct writer_control *p, pic_value obj)
|
||||||
case PIC_TT_DICT:
|
case PIC_TT_DICT:
|
||||||
xfprintf(file, "#.(dictionary");
|
xfprintf(file, "#.(dictionary");
|
||||||
for (it = xh_begin(&pic_dict_ptr(obj)->hash); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&pic_dict_ptr(obj)->hash); it != NULL; it = xh_next(it)) {
|
||||||
xfprintf(file, " '%s ", pic_symbol_name(pic, xh_key(it, pic_sym)));
|
xfprintf(file, " '%s ", pic_symbol_name(pic, xh_key(it, pic_sym *)));
|
||||||
write_core(p, xh_val(it, pic_value));
|
write_core(p, xh_val(it, pic_value));
|
||||||
}
|
}
|
||||||
xfprintf(file, ")");
|
xfprintf(file, ")");
|
||||||
|
|
Loading…
Reference in New Issue