diff --git a/extlib/benz/codegen.c b/extlib/benz/codegen.c index 0e89c4b1..fa3125a7 100644 --- a/extlib/benz/codegen.c +++ b/extlib/benz/codegen.c @@ -36,11 +36,11 @@ typedef struct analyze_scope { typedef struct analyze_state { pic_state *pic; analyze_scope *scope; - pic_sym rCONS, rCAR, rCDR, rNILP; - pic_sym rSYMBOLP, rPAIRP; - pic_sym rADD, rSUB, rMUL, rDIV; - pic_sym rEQ, rLT, rLE, rGT, rGE, rNOT; - pic_sym rVALUES, rCALL_WITH_VALUES; + pic_sym *rCONS, *rCAR, *rCDR, *rNILP; + pic_sym *rSYMBOLP, *rPAIRP; + pic_sym *rADD, *rSUB, *rMUL, *rDIV; + pic_sym *rEQ, *rLT, *rLE, *rGT, *rGE, *rNOT; + pic_sym *rVALUES, *rCALL_WITH_VALUES; } analyze_state; static bool push_scope(analyze_state *, pic_value); @@ -51,7 +51,7 @@ static void pop_scope(analyze_state *); } while (0) #define register_renamed_symbol(pic, state, slot, lib, id) do { \ - pic_sym sym, gsym; \ + pic_sym *sym, *gsym; \ sym = pic_intern_cstr(pic, id); \ if (! pic_find_rename(pic, lib->env, sym, &gsym)) { \ 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) { analyze_state *state; - pic_sym sym; + pic_sym *sym; state = pic_alloc(pic, sizeof(analyze_state)); state->pic = pic; @@ -110,7 +110,7 @@ static bool analyze_args(pic_state *pic, pic_value formals, bool *varg, xvect *args, xvect *locals) { pic_value v, t; - pic_sym sym; + pic_sym *sym; for (v = formals; pic_pair_p(v); v = pic_cdr(pic, v)) { t = pic_car(pic, v); @@ -143,9 +143,9 @@ push_scope(analyze_state *state, pic_value formals) bool varg; xvect args, locals, captures; - xv_init(&args, sizeof(pic_sym)); - xv_init(&locals, sizeof(pic_sym)); - xv_init(&captures, sizeof(pic_sym)); + xv_init(&args, sizeof(pic_sym *)); + xv_init(&locals, sizeof(pic_sym *)); + xv_init(&captures, sizeof(pic_sym *)); if (analyze_args(pic, formals, &varg, &args, &locals)) { scope = pic_alloc(pic, sizeof(analyze_scope)); @@ -184,9 +184,9 @@ pop_scope(analyze_state *state) } 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; /* args */ @@ -205,9 +205,9 @@ lookup_scope(analyze_scope *scope, pic_sym sym) } 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; for (i = 0; i < xv_size(&scope->captures); ++i) { @@ -222,7 +222,7 @@ capture_var(analyze_scope *scope, pic_sym sym) } static int -find_var(analyze_state *state, pic_sym sym) +find_var(analyze_state *state, pic_sym *sym) { analyze_scope *scope = state->scope; int depth = 0; @@ -241,7 +241,7 @@ find_var(analyze_state *state, pic_sym sym) } static void -define_var(analyze_state *state, pic_sym sym) +define_var(analyze_state *state, pic_sym *sym) { pic_state *pic = state->pic; analyze_scope *scope = state->scope; @@ -263,7 +263,7 @@ analyze(analyze_state *state, pic_value obj, bool tailpos) pic_state *pic = state->pic; size_t ai = pic_gc_arena_preserve(pic); pic_value res; - pic_sym tag; + pic_sym *tag; res = analyze_node(state, obj, tailpos); @@ -284,7 +284,7 @@ analyze(analyze_state *state, pic_value obj, bool tailpos) } 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; @@ -292,7 +292,7 @@ analyze_global_var(analyze_state *state, pic_sym sym) } 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; @@ -300,7 +300,7 @@ analyze_local_var(analyze_state *state, pic_sym sym) } 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; @@ -308,7 +308,7 @@ analyze_free_var(analyze_state *state, pic_sym sym, int depth) } static pic_value -analyze_var(analyze_state *state, pic_sym sym) +analyze_var(analyze_state *state, pic_sym *sym) { pic_state *pic = state->pic; int depth; @@ -330,7 +330,7 @@ static pic_value analyze_defer(analyze_state *state, pic_value name, pic_value formal, pic_value body) { pic_state *pic = state->pic; - const pic_sym sNOWHERE = pic_intern_cstr(pic, "<>"); + pic_sym *sNOWHERE = pic_intern_cstr(pic, "<>"); pic_value skel; 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)) { analyze_scope *scope = state->scope; - pic_sym *var; + pic_sym **var; size_t i; args = pic_nil_value(); @@ -428,7 +428,7 @@ analyze_lambda(analyze_state *state, pic_value obj) } static pic_value -analyze_declare(analyze_state *state, pic_sym var) +analyze_declare(analyze_state *state, pic_sym *var) { define_var(state, var); @@ -440,7 +440,7 @@ analyze_define(analyze_state *state, pic_value obj) { pic_state *pic = state->pic; pic_value var, val; - pic_sym sym; + pic_sym *sym; if (pic_length(pic, obj) != 3) { 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_value seq, elt; - pic_sym call; + pic_sym *call; if (! tailpos) { 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_value prod, cnsm; - pic_sym call; + pic_sym *call; if (pic_length(pic, obj) != 3) { 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); if (pic_sym_p(proc)) { - pic_sym sym = pic_sym_ptr(proc); + pic_sym *sym = pic_sym_ptr(proc); if (sym == pic->rDEFINE) { return analyze_define(state, obj); @@ -861,7 +861,7 @@ pic_analyze(pic_state *pic, pic_value obj) */ typedef struct codegen_context { - pic_sym name; + pic_sym *name; /* rest args variable is counted as a local */ bool varg; xvect args, locals, captures; @@ -875,7 +875,7 @@ typedef struct codegen_context { pic_value *pool; size_t plen, pcapa; /* symbol pool */ - pic_sym *syms; + pic_sym **syms; size_t slen, scapa; struct codegen_context *up; @@ -924,7 +924,7 @@ create_activation(codegen_context *cxt) { size_t i, n; xhash regs; - pic_sym *var; + pic_sym **var; size_t offset; 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; codegen_context *cxt; pic_value var; - pic_sym sym; + pic_sym *sym; 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); cxt->varg = varg; - xv_init(&cxt->args, sizeof(pic_sym)); - xv_init(&cxt->locals, sizeof(pic_sym)); - xv_init(&cxt->captures, sizeof(pic_sym)); + xv_init(&cxt->args, sizeof(pic_sym *)); + xv_init(&cxt->locals, sizeof(pic_sym *)); + xv_init(&cxt->captures, sizeof(pic_sym *)); pic_for_each (var, args) { 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->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->scapa = PIC_POOL_SIZE; @@ -1034,7 +1034,7 @@ pop_codegen_context(codegen_state *state) irep->ilen = state->cxt->ilen; irep->pool = pic_realloc(pic, state->cxt->pool, sizeof(pic_value) * 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; /* finalize */ @@ -1051,11 +1051,11 @@ pop_codegen_context(codegen_state *state) } 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; size_t i; - pic_sym *var; + pic_sym **var; while (depth-- > 0) { cxt = cxt->up; @@ -1070,11 +1070,11 @@ index_capture(codegen_state *state, pic_sym sym, int depth) } static int -index_local(codegen_state *state, pic_sym sym) +index_local(codegen_state *state, pic_sym *sym) { codegen_context *cxt = state->cxt; size_t i, offset; - pic_sym *var; + pic_sym **var; offset = 1; for (i = 0; i < xv_size(&cxt->args); ++i) { @@ -1092,7 +1092,7 @@ index_local(codegen_state *state, pic_sym sym) } static int -index_symbol(codegen_state *state, pic_sym sym) +index_symbol(codegen_state *state, pic_sym *sym) { pic_state *pic = state->pic; codegen_context *cxt = state->cxt; @@ -1105,7 +1105,7 @@ index_symbol(codegen_state *state, pic_sym sym) } if (cxt->slen >= cxt->scapa) { 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; return i; @@ -1118,7 +1118,7 @@ codegen(codegen_state *state, pic_value obj) { pic_state *pic = state->pic; codegen_context *cxt = state->cxt; - pic_sym sym; + pic_sym *sym; sym = pic_sym_ptr(pic_car(pic, obj)); if (sym == pic->sGREF) { @@ -1127,7 +1127,7 @@ codegen(codegen_state *state, pic_value obj) cxt->clen++; return; } else if (sym == pic->sCREF) { - pic_sym name; + pic_sym *name; int depth; depth = pic_int(pic_list_ref(pic, obj, 1)); @@ -1138,7 +1138,7 @@ codegen(codegen_state *state, pic_value obj) cxt->clen++; return; } else if (sym == pic->sLREF) { - pic_sym name; + pic_sym *name; int i; name = pic_sym_ptr(pic_list_ref(pic, obj, 1)); @@ -1154,7 +1154,7 @@ codegen(codegen_state *state, pic_value obj) return; } else if (sym == pic->sSETBANG) { pic_value var, val; - pic_sym type; + pic_sym *type; val = pic_list_ref(pic, obj, 2); codegen(state, val); @@ -1170,7 +1170,7 @@ codegen(codegen_state *state, pic_value obj) return; } else if (type == pic->sCREF) { - pic_sym name; + pic_sym *name; int depth; depth = pic_int(pic_list_ref(pic, var, 1)); @@ -1184,7 +1184,7 @@ codegen(codegen_state *state, pic_value obj) return; } else if (type == pic->sLREF) { - pic_sym name; + pic_sym *name; int i; name = pic_sym_ptr(pic_list_ref(pic, var, 1)); diff --git a/extlib/benz/dict.c b/extlib/benz/dict.c index 1e1331e6..d677e935 100644 --- a/extlib/benz/dict.c +++ b/extlib/benz/dict.c @@ -21,7 +21,7 @@ pic_make_dict(pic_state *pic) } 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; @@ -33,7 +33,7 @@ pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_sym key) } 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); @@ -49,7 +49,7 @@ pic_dict_size(pic_state *pic, struct pic_dict *dict) } 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); @@ -57,7 +57,7 @@ pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_sym key) } 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) { 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) { struct pic_dict *dict; - pic_sym key; + pic_sym *key; pic_get_args(pic, "dm", &dict, &key); @@ -126,7 +126,7 @@ static pic_value pic_dict_dictionary_set(pic_state *pic) { struct pic_dict *dict; - pic_sym key; + pic_sym *key; pic_value val; pic_get_args(pic, "dmo", &dict, &key, &val); @@ -140,7 +140,7 @@ static pic_value pic_dict_dictionary_del(pic_state *pic) { struct pic_dict *dict; - pic_sym key; + pic_sym *key; pic_get_args(pic, "dm", &dict, &key); @@ -187,7 +187,7 @@ pic_dict_dictionary_map(pic_state *pic) if (it[i] == NULL) { 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]); } if (i != argc) { @@ -233,7 +233,7 @@ pic_dict_dictionary_for_each(pic_state *pic) if (it[i] == NULL) { 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]); } if (i != argc) { @@ -262,7 +262,7 @@ pic_dict_dictionary_to_alist(pic_state *pic) pic_get_args(pic, "d", &dict); 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); } @@ -297,7 +297,7 @@ pic_dict_dictionary_to_plist(pic_state *pic) pic_get_args(pic, "d", &dict); 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); } diff --git a/extlib/benz/error.c b/extlib/benz/error.c index 9a1ccac7..5df91233 100644 --- a/extlib/benz/error.c +++ b/extlib/benz/error.c @@ -125,7 +125,7 @@ pic_pop_try(pic_state *pic) } 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; pic_str *stack; @@ -175,7 +175,7 @@ pic_raise(pic_state *pic, pic_value err) } 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; @@ -253,7 +253,7 @@ static pic_value pic_error_make_error_object(pic_state *pic) { struct pic_error *e; - pic_sym type; + pic_sym *type; pic_str *msg; size_t argc; pic_value *argv; diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index a59c5b4c..5c5ef412 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -470,7 +470,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) xh_entry *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)); } break; @@ -578,7 +578,7 @@ gc_mark_phase(pic_state *pic) /* mark all interned symbols */ 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 */ diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index 9c2ef399..0c950425 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -89,25 +89,25 @@ typedef struct { struct pic_lib *lib; - pic_sym sDEFINE, sLAMBDA, sIF, sBEGIN, sQUOTE, sSETBANG; - pic_sym sQUASIQUOTE, sUNQUOTE, sUNQUOTE_SPLICING; - pic_sym sDEFINE_SYNTAX, sIMPORT, sEXPORT; - pic_sym sDEFINE_LIBRARY, sIN_LIBRARY; - pic_sym sCOND_EXPAND, sAND, sOR, sELSE, sLIBRARY; - pic_sym sONLY, sRENAME, sPREFIX, sEXCEPT; - pic_sym sCONS, sCAR, sCDR, sNILP; - pic_sym sSYMBOLP, sPAIRP; - pic_sym sADD, sSUB, sMUL, sDIV, sMINUS; - pic_sym sEQ, sLT, sLE, sGT, sGE, sNOT; - pic_sym sREAD, sFILE; - pic_sym sGREF, sCREF, sLREF; - pic_sym sCALL, sTAILCALL, sRETURN; - pic_sym sCALL_WITH_VALUES, sTAILCALL_WITH_VALUES; + pic_sym *sDEFINE, *sLAMBDA, *sIF, *sBEGIN, *sQUOTE, *sSETBANG; + pic_sym *sQUASIQUOTE, *sUNQUOTE, *sUNQUOTE_SPLICING; + pic_sym *sDEFINE_SYNTAX, *sIMPORT, *sEXPORT; + pic_sym *sDEFINE_LIBRARY, *sIN_LIBRARY; + pic_sym *sCOND_EXPAND, *sAND, *sOR, *sELSE, *sLIBRARY; + pic_sym *sONLY, *sRENAME, *sPREFIX, *sEXCEPT; + pic_sym *sCONS, *sCAR, *sCDR, *sNILP; + pic_sym *sSYMBOLP, *sPAIRP; + pic_sym *sADD, *sSUB, *sMUL, *sDIV, *sMINUS; + pic_sym *sEQ, *sLT, *sLE, *sGT, *sGE, *sNOT; + pic_sym *sREAD, *sFILE; + pic_sym *sGREF, *sCREF, *sLREF; + pic_sym *sCALL, *sTAILCALL, *sRETURN; + pic_sym *sCALL_WITH_VALUES, *sTAILCALL_WITH_VALUES; - pic_sym rDEFINE, rLAMBDA, rIF, rBEGIN, rQUOTE, rSETBANG; - pic_sym rDEFINE_SYNTAX, rIMPORT, rEXPORT; - pic_sym rDEFINE_LIBRARY, rIN_LIBRARY; - pic_sym rCOND_EXPAND; + pic_sym *rDEFINE, *rLAMBDA, *rIF, *rBEGIN, *rQUOTE, *rSETBANG; + pic_sym *rDEFINE_SYNTAX, *rIMPORT, *rEXPORT; + pic_sym *rDEFINE_LIBRARY, *rIN_LIBRARY; + pic_sym *rCOND_EXPAND; struct pic_lib *PICRIN_BASE; 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_equal_p(pic_state *, pic_value, pic_value); -pic_sym pic_intern(pic_state *, pic_str *); -pic_sym pic_intern_cstr(pic_state *, const char *); -const char *pic_symbol_name(pic_state *, pic_sym); -pic_sym pic_gensym(pic_state *, pic_sym); -bool pic_interned_p(pic_state *, pic_sym); +pic_sym *pic_intern(pic_state *, pic_str *); +pic_sym *pic_intern_cstr(pic_state *, const char *); +const char *pic_symbol_name(pic_state *, pic_sym *); +pic_sym *pic_gensym(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_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_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_errorf(pic_state *, const char *, ...); diff --git a/extlib/benz/include/picrin/dict.h b/extlib/benz/include/picrin/dict.h index cfbd4855..13379bf5 100644 --- a/extlib/benz/include/picrin/dict.h +++ b/extlib/benz/include/picrin/dict.h @@ -23,14 +23,14 @@ struct pic_dict *pic_make_dict(pic_state *); pic_dict_for_each_helper_((sym), PIC_GENSYM(tmp), (dict)) #define pic_dict_for_each_helper_(var, tmp, dict) \ 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)) -pic_value pic_dict_ref(pic_state *, struct pic_dict *, pic_sym); -void pic_dict_set(pic_state *, struct pic_dict *, pic_sym, pic_value); -void pic_dict_del(pic_state *, struct pic_dict *, pic_sym); +pic_value pic_dict_ref(pic_state *, struct pic_dict *, pic_sym *); +void pic_dict_set(pic_state *, struct pic_dict *, pic_sym *, pic_value); +void pic_dict_del(pic_state *, struct pic_dict *, pic_sym *); size_t pic_dict_size(pic_state *, struct pic_dict *); -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) } diff --git a/extlib/benz/include/picrin/error.h b/extlib/benz/include/picrin/error.h index e4cc630a..3a575cfe 100644 --- a/extlib/benz/include/picrin/error.h +++ b/extlib/benz/include/picrin/error.h @@ -13,7 +13,7 @@ extern "C" { struct pic_error { PIC_OBJECT_HEADER - pic_sym type; + pic_sym *type; pic_str *msg; pic_value irrs; pic_str *stack; @@ -22,7 +22,7 @@ struct pic_error { #define pic_error_p(v) (pic_type(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_list); +struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_list); /* 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_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); #if defined(__cplusplus) diff --git a/extlib/benz/include/picrin/irep.h b/extlib/benz/include/picrin/irep.h index 80159547..9c7932da 100644 --- a/extlib/benz/include/picrin/irep.h +++ b/extlib/benz/include/picrin/irep.h @@ -62,13 +62,13 @@ struct pic_code { struct pic_irep { PIC_OBJECT_HEADER - pic_sym name; + pic_sym *name; pic_code *code; int argc, localc, capturec; bool varg; struct pic_irep **irep; pic_value *pool; - pic_sym *syms; + pic_sym **syms; size_t clen, ilen, plen, slen; }; diff --git a/extlib/benz/include/picrin/macro.h b/extlib/benz/include/picrin/macro.h index e79c4251..07ca86d1 100644 --- a/extlib/benz/include/picrin/macro.h +++ b/extlib/benz/include/picrin/macro.h @@ -22,15 +22,15 @@ struct pic_senv { struct pic_senv *pic_null_syntactic_environment(pic_state *); 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 *); -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 */); -void pic_put_rename(pic_state *, struct pic_senv *, pic_sym, 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 */); +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) } diff --git a/extlib/benz/include/picrin/proc.h b/extlib/benz/include/picrin/proc.h index e64cd6fc..ebe13a82 100644 --- a/extlib/benz/include/picrin/proc.h +++ b/extlib/benz/include/picrin/proc.h @@ -12,7 +12,7 @@ extern "C" { /* native C function */ struct pic_func { pic_func_t f; - pic_sym name; + pic_sym *name; }; 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_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) } diff --git a/extlib/benz/include/picrin/record.h b/extlib/benz/include/picrin/record.h index 97476ce4..e3edcd01 100644 --- a/extlib/benz/include/picrin/record.h +++ b/extlib/benz/include/picrin/record.h @@ -20,8 +20,8 @@ struct pic_record { struct pic_record *pic_make_record(pic_state *, pic_value); pic_value pic_record_type(pic_state *, struct pic_record *); -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); +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); #if defined(__cplusplus) } diff --git a/extlib/benz/include/picrin/value.h b/extlib/benz/include/picrin/value.h index 8eb407e4..a6db5b98 100644 --- a/extlib/benz/include/picrin/value.h +++ b/extlib/benz/include/picrin/value.h @@ -133,7 +133,7 @@ struct pic_error; /* set aliases to basic types */ 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_string pic_str; typedef struct pic_vector pic_vec; diff --git a/extlib/benz/lib.c b/extlib/benz/lib.c index ca738790..4a82a981 100644 --- a/extlib/benz/lib.c +++ b/extlib/benz/lib.c @@ -74,7 +74,7 @@ import_table(pic_state *pic, pic_value spec, struct pic_dict *imports) struct pic_lib *lib; struct pic_dict *table; pic_value val, tmp, prefix; - pic_sym sym, id, tag; + pic_sym *sym, *id, *tag; table = pic_make_dict(pic); @@ -131,7 +131,7 @@ static void import(pic_state *pic, pic_value spec) { struct pic_dict *imports; - pic_sym sym; + pic_sym *sym; imports = pic_make_dict(pic); @@ -145,9 +145,9 @@ import(pic_state *pic, pic_value spec) static void 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_sym rename; + pic_sym *rename; if (pic_sym_p(spec)) { /* (export a) */ a = b = spec; @@ -193,7 +193,7 @@ pic_import_library(pic_state *pic, struct pic_lib *lib) } void -pic_export(pic_state *pic, pic_sym sym) +pic_export(pic_state *pic, pic_sym *sym) { export(pic, pic_obj_value(sym)); } @@ -201,7 +201,7 @@ pic_export(pic_state *pic, pic_sym sym) static bool condexpand(pic_state *pic, pic_value clause) { - pic_sym tag; + pic_sym *tag; pic_value c, feature; if (pic_eq_p(clause, pic_obj_value(pic->sELSE))) { @@ -335,7 +335,7 @@ pic_lib_in_library(pic_state *pic) void 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->sIMPORT, pic->rIMPORT, pic_lib_import); diff --git a/extlib/benz/macro.c b/extlib/benz/macro.c index f20b775f..622a28d3 100644 --- a/extlib/benz/macro.c +++ b/extlib/benz/macro.c @@ -13,10 +13,10 @@ #include "picrin/cont.h" #include "picrin/symbol.h" -pic_sym -pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym) +pic_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); 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 -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)); } 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)) { return false; @@ -42,13 +42,13 @@ pic_find_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym *ren } 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)); } 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)) { 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)); } -static pic_sym -make_identifier(pic_state *pic, pic_sym sym, struct pic_senv *senv) +static pic_sym * +make_identifier(pic_state *pic, pic_sym *sym, struct pic_senv *senv) { - pic_sym rename; + pic_sym *rename; while (true) { 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_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)); } @@ -179,7 +179,7 @@ macroexpand_lambda(pic_state *pic, pic_value expr, struct pic_senv *senv) static pic_value macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv) { - pic_sym sym, rename; + pic_sym *sym, *rename; pic_value var, val; 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) { pic_value var, val; - pic_sym sym, rename; + pic_sym *sym, *rename; if (pic_length(pic, expr) != 3) { 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); if (pic_sym_p(car)) { - pic_sym tag = pic_sym_ptr(car); + pic_sym *tag = pic_sym_ptr(car); if (tag == pic->rDEFINE_SYNTAX) { return macroexpand_defsyntax(pic, expr, senv); @@ -407,7 +407,7 @@ pic_null_syntactic_environment(pic_state *pic) } 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); @@ -430,7 +430,7 @@ defmacro_call(pic_state *pic) } 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; @@ -455,9 +455,9 @@ pic_identifier_p(pic_state *pic, pic_value obj) } 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); if (a != make_identifier(pic, sym1, env1)) { @@ -486,7 +486,7 @@ static pic_value pic_macro_make_identifier(pic_state *pic) { pic_value obj; - pic_sym sym; + pic_sym *sym; pic_get_args(pic, "mo", &sym, &obj); @@ -498,7 +498,7 @@ pic_macro_make_identifier(pic_state *pic) static pic_value pic_macro_identifier_eq_p(pic_state *pic) { - pic_sym sym1, sym2; + pic_sym *sym1, *sym2; pic_value env1, env2; pic_get_args(pic, "omom", &env1, &sym1, &env2, &sym2); diff --git a/extlib/benz/proc.c b/extlib/benz/proc.c index 2b94201b..321a362e 100644 --- a/extlib/benz/proc.c +++ b/extlib/benz/proc.c @@ -34,7 +34,7 @@ pic_make_proc_irep(pic_state *pic, struct pic_irep *irep, struct pic_env *env) return proc; } -pic_sym +pic_sym * pic_proc_name(struct pic_proc *proc) { switch (proc->kind) { diff --git a/extlib/benz/read.c b/extlib/benz/read.c index f54427a0..979113c5 100644 --- a/extlib/benz/read.c +++ b/extlib/benz/read.c @@ -199,7 +199,7 @@ read_symbol(pic_state *pic, struct pic_port *port, const char *str) { size_t len, i; char *buf; - pic_sym sym; + pic_sym *sym; int c; len = strlen(str); @@ -452,7 +452,7 @@ read_pipe(pic_state *pic, struct pic_port *port, const char *str) { char *buf; size_t size, cnt; - pic_sym sym; + pic_sym *sym; /* Currently supports only ascii chars */ char HEX_BUF[3]; size_t i = 0; diff --git a/extlib/benz/record.c b/extlib/benz/record.c index 331b43d4..2a6e85cc 100644 --- a/extlib/benz/record.c +++ b/extlib/benz/record.c @@ -29,7 +29,7 @@ pic_record_type(pic_state *pic, struct pic_record *rec) } 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)) { 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 -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); } @@ -80,7 +80,7 @@ static pic_value pic_record_record_ref(pic_state *pic) { struct pic_record *rec; - pic_sym slot; + pic_sym *slot; pic_get_args(pic, "rm", &rec, &slot); @@ -91,7 +91,7 @@ static pic_value pic_record_record_set(pic_state *pic) { struct pic_record *rec; - pic_sym slot; + pic_sym *slot; pic_value val; pic_get_args(pic, "rmo", &rec, &slot, &val); diff --git a/extlib/benz/state.c b/extlib/benz/state.c index a680c3ba..195f07ab 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -52,7 +52,7 @@ pic_open(int argc, char *argv[], char **envp) pic->heap = pic_heap_open(); /* symbol table */ - xh_init_str(&pic->syms, sizeof(pic_sym)); + xh_init_str(&pic->syms, sizeof(pic_sym *)); /* global variables */ pic->globals = NULL; diff --git a/extlib/benz/symbol.c b/extlib/benz/symbol.c index 7acbbece..f8f091bd 100644 --- a/extlib/benz/symbol.c +++ b/extlib/benz/symbol.c @@ -6,26 +6,26 @@ #include "picrin/symbol.h" #include "picrin/string.h" -pic_sym +pic_sym * 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; return sym; } -pic_sym +pic_sym * pic_intern(pic_state *pic, pic_str *str) { xh_entry *e; - pic_sym sym; + pic_sym *sym; char *cstr; e = xh_get_str(&pic->syms, pic_str_cstr(str)); if (e) { - sym = xh_val(e, pic_sym); + sym = xh_val(e, pic_sym *); pic_gc_protect(pic, pic_obj_value(sym)); return sym; } @@ -38,33 +38,33 @@ pic_intern(pic_state *pic, pic_str *str) return sym; } -pic_sym +pic_sym * pic_intern_cstr(pic_state *pic, const char *str) { return pic_intern(pic, pic_make_str(pic, str, strlen(str))); } -pic_sym -pic_gensym(pic_state *pic, pic_sym base) +pic_sym * +pic_gensym(pic_state *pic, pic_sym *base) { return pic_make_symbol(pic, base->str); } bool -pic_interned_p(pic_state *pic, pic_sym sym) +pic_interned_p(pic_state *pic, pic_sym *sym) { xh_entry *e; e = xh_get_str(&pic->syms, pic_str_cstr(sym->str)); if (e) { - return sym == xh_val(e, pic_sym); + return sym == xh_val(e, pic_sym *); } else { return false; } } const char * -pic_symbol_name(pic_state *pic, pic_sym sym) +pic_symbol_name(pic_state *pic, pic_sym *sym) { PIC_UNUSED(pic); @@ -103,7 +103,7 @@ pic_symbol_symbol_eq_p(pic_state *pic) static pic_value pic_symbol_symbol_to_string(pic_state *pic) { - pic_sym sym; + pic_sym *sym; pic_get_args(pic, "m", &sym); diff --git a/extlib/benz/vm.c b/extlib/benz/vm.c index ea46c9d2..0c82bdff 100644 --- a/extlib/benz/vm.c +++ b/extlib/benz/vm.c @@ -41,7 +41,7 @@ pic_get_proc(pic_state *pic) * F double *, bool * float with exactness * s pic_str ** string object * z char ** c string - * m pic_sym * symbol + * m pic_sym ** symbol * v pic_vec ** vector object * b pic_blob ** bytevector object * c char * char @@ -255,10 +255,10 @@ pic_get_args(pic_state *pic, const char *format, ...) break; } case 'm': { - pic_sym *m; + pic_sym **m; pic_value v; - m = va_arg(ap, pic_sym *); + m = va_arg(ap, pic_sym **); if (i < argc) { v = GET_OPERAND(pic,i); if (pic_sym_p(v)) { @@ -433,7 +433,7 @@ pic_get_args(pic_state *pic, const char *format, ...) void 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); @@ -457,7 +457,7 @@ pic_define(pic_state *pic, const char *name, pic_value val) pic_value 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); @@ -471,7 +471,7 @@ pic_ref(pic_state *pic, struct pic_lib *lib, const char *name) void 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); @@ -776,7 +776,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args) } CASE(OP_GREF) { struct pic_irep *irep = vm_get_irep(pic); - pic_sym sym; + pic_sym *sym; sym = irep->syms[c.u.i]; 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) { struct pic_irep *irep = vm_get_irep(pic); - pic_sym sym; + pic_sym *sym; pic_value val; sym = irep->syms[c.u.i]; diff --git a/extlib/benz/write.c b/extlib/benz/write.c index 3fecb4bc..5fe657e2 100644 --- a/extlib/benz/write.c +++ b/extlib/benz/write.c @@ -14,7 +14,7 @@ #include "picrin/symbol.h" 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)) && pic_nil_p(pic_cddr(pic, pair)) @@ -176,7 +176,7 @@ write_str(pic_state *pic, struct pic_string *str, xFILE *file) static void 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; #if DEBUG @@ -333,7 +333,7 @@ write_core(struct writer_control *p, pic_value obj) case PIC_TT_DICT: xfprintf(file, "#.(dictionary"); 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)); } xfprintf(file, ")");