s/pic_sym/pic_sym_ptr/g

This commit is contained in:
Yuichi Nishiwaki 2015-01-20 15:31:17 +09:00
parent c5f711ddd6
commit 2d1ddb9a5a
8 changed files with 48 additions and 48 deletions

View File

@ -117,7 +117,7 @@ analyze_args(pic_state *pic, pic_value formals, bool *varg, xvect *args, xvect *
if (! pic_sym_p(t)) {
return false;
}
sym = pic_sym(t);
sym = pic_sym_ptr(t);
xv_push(args, &sym);
}
if (pic_nil_p(v)) {
@ -125,7 +125,7 @@ analyze_args(pic_state *pic, pic_value formals, bool *varg, xvect *args, xvect *
}
else if (pic_sym_p(v)) {
*varg = true;
sym = pic_sym(v);
sym = pic_sym_ptr(v);
xv_push(locals, &sym);
}
else {
@ -267,7 +267,7 @@ analyze(analyze_state *state, pic_value obj, bool tailpos)
res = analyze_node(state, obj, tailpos);
tag = pic_sym(pic_car(pic, res));
tag = pic_sym_ptr(pic_car(pic, res));
if (tailpos) {
if (tag == pic->sIF || tag == pic->sBEGIN || tag == pic->sTAILCALL || tag == pic->sTAILCALL_WITH_VALUES || tag == pic->sRETURN) {
/* pass through */
@ -450,13 +450,13 @@ analyze_define(analyze_state *state, pic_value obj)
if (! pic_sym_p(var)) {
pic_errorf(pic, "syntax error");
} else {
sym = pic_sym(var);
sym = pic_sym_ptr(var);
}
var = analyze_declare(state, sym);
if (pic_pair_p(pic_list_ref(pic, obj, 2))
&& pic_sym_p(pic_list_ref(pic, pic_list_ref(pic, obj, 2), 0))
&& pic_sym(pic_list_ref(pic, pic_list_ref(pic, obj, 2), 0)) == pic->rLAMBDA) {
&& pic_sym_ptr(pic_list_ref(pic, pic_list_ref(pic, obj, 2), 0)) == pic->rLAMBDA) {
pic_value formals, body_exprs;
formals = pic_list_ref(pic, pic_list_ref(pic, obj, 2), 1);
@ -734,7 +734,7 @@ analyze_node(analyze_state *state, pic_value obj, bool tailpos)
switch (pic_type(obj)) {
case PIC_TT_SYMBOL: {
return analyze_var(state, pic_sym(obj));
return analyze_var(state, pic_sym_ptr(obj));
}
case PIC_TT_PAIR: {
pic_value proc;
@ -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(proc);
pic_sym sym = pic_sym_ptr(proc);
if (sym == pic->rDEFINE) {
return analyze_define(state, obj);
@ -973,7 +973,7 @@ push_codegen_context(codegen_state *state, pic_value name, pic_value args, pic_v
cxt->up = state->cxt;
cxt->name = pic_false_p(name)
? pic_intern_cstr(pic, "(anonymous lambda)")
: pic_sym(name);
: pic_sym_ptr(name);
cxt->varg = varg;
xv_init(&cxt->args, sizeof(pic_sym));
@ -981,15 +981,15 @@ push_codegen_context(codegen_state *state, pic_value name, pic_value args, pic_v
xv_init(&cxt->captures, sizeof(pic_sym));
pic_for_each (var, args) {
sym = pic_sym(var);
sym = pic_sym_ptr(var);
xv_push(&cxt->args, &sym);
}
pic_for_each (var, locals) {
sym = pic_sym(var);
sym = pic_sym_ptr(var);
xv_push(&cxt->locals, &sym);
}
pic_for_each (var, captures) {
sym = pic_sym(var);
sym = pic_sym_ptr(var);
xv_push(&cxt->captures, &sym);
}
@ -1120,10 +1120,10 @@ codegen(codegen_state *state, pic_value obj)
codegen_context *cxt = state->cxt;
pic_sym sym;
sym = pic_sym(pic_car(pic, obj));
sym = pic_sym_ptr(pic_car(pic, obj));
if (sym == pic->sGREF) {
cxt->code[cxt->clen].insn = OP_GREF;
cxt->code[cxt->clen].u.i = index_symbol(state, pic_sym(pic_list_ref(pic, obj, 1)));
cxt->code[cxt->clen].u.i = index_symbol(state, pic_sym_ptr(pic_list_ref(pic, obj, 1)));
cxt->clen++;
return;
} else if (sym == pic->sCREF) {
@ -1131,7 +1131,7 @@ codegen(codegen_state *state, pic_value obj)
int depth;
depth = pic_int(pic_list_ref(pic, obj, 1));
name = pic_sym(pic_list_ref(pic, obj, 2));
name = pic_sym_ptr(pic_list_ref(pic, obj, 2));
cxt->code[cxt->clen].insn = OP_CREF;
cxt->code[cxt->clen].u.r.depth = depth;
cxt->code[cxt->clen].u.r.idx = index_capture(state, name, depth);
@ -1141,7 +1141,7 @@ codegen(codegen_state *state, pic_value obj)
pic_sym name;
int i;
name = pic_sym(pic_list_ref(pic, obj, 1));
name = pic_sym_ptr(pic_list_ref(pic, obj, 1));
if ((i = index_capture(state, name, 0)) != -1) {
cxt->code[cxt->clen].insn = OP_LREF;
cxt->code[cxt->clen].u.i = i + (int)xv_size(&cxt->args) + (int)xv_size(&cxt->locals) + 1;
@ -1160,10 +1160,10 @@ codegen(codegen_state *state, pic_value obj)
codegen(state, val);
var = pic_list_ref(pic, obj, 1);
type = pic_sym(pic_list_ref(pic, var, 0));
type = pic_sym_ptr(pic_list_ref(pic, var, 0));
if (type == pic->sGREF) {
cxt->code[cxt->clen].insn = OP_GSET;
cxt->code[cxt->clen].u.i = index_symbol(state, pic_sym(pic_list_ref(pic, var, 1)));
cxt->code[cxt->clen].u.i = index_symbol(state, pic_sym_ptr(pic_list_ref(pic, var, 1)));
cxt->clen++;
cxt->code[cxt->clen].insn = OP_PUSHNONE;
cxt->clen++;
@ -1174,7 +1174,7 @@ codegen(codegen_state *state, pic_value obj)
int depth;
depth = pic_int(pic_list_ref(pic, var, 1));
name = pic_sym(pic_list_ref(pic, var, 2));
name = pic_sym_ptr(pic_list_ref(pic, var, 2));
cxt->code[cxt->clen].insn = OP_CSET;
cxt->code[cxt->clen].u.r.depth = depth;
cxt->code[cxt->clen].u.r.idx = index_capture(state, name, depth);
@ -1187,7 +1187,7 @@ codegen(codegen_state *state, pic_value obj)
pic_sym name;
int i;
name = pic_sym(pic_list_ref(pic, var, 1));
name = pic_sym_ptr(pic_list_ref(pic, var, 1));
if ((i = index_capture(state, name, 0)) != -1) {
cxt->code[cxt->clen].insn = OP_LSET;
cxt->code[cxt->clen].u.i = i + (int)xv_size(&cxt->args) + (int)xv_size(&cxt->locals) + 1;

View File

@ -91,7 +91,7 @@ pic_dict_dictionary(pic_state *pic)
for (i = 0; i < argc; i += 2) {
pic_assert_type(pic, argv[i], sym);
pic_dict_set(pic, dict, pic_sym(argv[i]), argv[i+1]);
pic_dict_set(pic, dict, pic_sym_ptr(argv[i]), argv[i+1]);
}
return pic_obj_value(dict);
@ -281,7 +281,7 @@ pic_dict_alist_to_dictionary(pic_state *pic)
pic_for_each (e, pic_reverse(pic, alist)) {
pic_assert_type(pic, pic_car(pic, e), sym);
pic_dict_set(pic, dict, pic_sym(pic_car(pic, e)), pic_cdr(pic, e));
pic_dict_set(pic, dict, pic_sym_ptr(pic_car(pic, e)), pic_cdr(pic, e));
}
return pic_obj_value(dict);
@ -316,7 +316,7 @@ pic_dict_plist_to_dictionary(pic_state *pic)
for (e = pic_reverse(pic, plist); ! pic_nil_p(e); e = pic_cddr(pic, e)) {
pic_assert_type(pic, pic_cadr(pic, e), sym);
pic_dict_set(pic, dict, pic_sym(pic_cadr(pic, e)), pic_car(pic, e));
pic_dict_set(pic, dict, pic_sym_ptr(pic_cadr(pic, e)), pic_car(pic, e));
}
return pic_obj_value(dict);

View File

@ -14,8 +14,8 @@ struct pic_symbol {
pic_str *str;
};
#define pic_sym(v) pic_ptr(v)
#define pic_sym_p(v) (pic_type(v) == PIC_TT_SYMBOL)
#define pic_sym_ptr(v) ((struct pic_symbol *)pic_ptr(v))
#if defined(__cplusplus)
}

View File

@ -80,13 +80,13 @@ import_table(pic_state *pic, pic_value spec, struct pic_dict *imports)
if (pic_pair_p(spec) && pic_sym_p(pic_car(pic, spec))) {
tag = pic_sym(pic_car(pic, spec));
tag = pic_sym_ptr(pic_car(pic, spec));
if (tag == pic->sONLY) {
import_table(pic, pic_cadr(pic, spec), table);
pic_for_each (val, pic_cddr(pic, spec)) {
pic_dict_set(pic, imports, pic_sym(val), pic_dict_ref(pic, table, pic_sym(val)));
pic_dict_set(pic, imports, pic_sym_ptr(val), pic_dict_ref(pic, table, pic_sym_ptr(val)));
}
return;
}
@ -94,9 +94,9 @@ import_table(pic_state *pic, pic_value spec, struct pic_dict *imports)
import_table(pic, pic_cadr(pic, spec), imports);
pic_for_each (val, pic_cddr(pic, spec)) {
tmp = pic_dict_ref(pic, imports, pic_sym(pic_car(pic, val)));
pic_dict_del(pic, imports, pic_sym(pic_car(pic, val)));
pic_dict_set(pic, imports, pic_sym(pic_cadr(pic, val)), tmp);
tmp = pic_dict_ref(pic, imports, pic_sym_ptr(pic_car(pic, val)));
pic_dict_del(pic, imports, pic_sym_ptr(pic_car(pic, val)));
pic_dict_set(pic, imports, pic_sym_ptr(pic_cadr(pic, val)), tmp);
}
return;
}
@ -113,7 +113,7 @@ import_table(pic_state *pic, pic_value spec, struct pic_dict *imports)
if (tag == pic->sEXCEPT) {
import_table(pic, pic_cadr(pic, spec), imports);
pic_for_each (val, pic_cddr(pic, spec)) {
pic_dict_del(pic, imports, pic_sym(val));
pic_dict_del(pic, imports, pic_sym_ptr(val));
}
return;
}
@ -138,7 +138,7 @@ import(pic_state *pic, pic_value spec)
import_table(pic, spec, imports);
pic_dict_for_each (sym, imports) {
pic_put_rename(pic, pic->lib->env, sym, pic_sym(pic_dict_ref(pic, imports, sym)));
pic_put_rename(pic, pic->lib->env, sym, pic_sym_ptr(pic_dict_ref(pic, imports, sym)));
}
}
@ -164,15 +164,15 @@ export(pic_state *pic, pic_value spec)
goto fail;
}
if (! pic_find_rename(pic, pic->lib->env, pic_sym(a), &rename)) {
pic_errorf(pic, "export: symbol not defined %s", pic_symbol_name(pic, pic_sym(a)));
if (! pic_find_rename(pic, pic->lib->env, pic_sym_ptr(a), &rename)) {
pic_errorf(pic, "export: symbol not defined %s", pic_symbol_name(pic, pic_sym_ptr(a)));
}
#if DEBUG
printf("* exporting %s as %s\n", pic_symbol_name(pic, pic_sym(b)), pic_symbol_name(pic, rename));
#endif
pic_dict_set(pic, pic->lib->exports, pic_sym(b), pic_obj_value(rename));
pic_dict_set(pic, pic->lib->exports, pic_sym_ptr(b), pic_obj_value(rename));
return;
@ -218,7 +218,7 @@ condexpand(pic_state *pic, pic_value clause)
if (! (pic_pair_p(clause) && pic_sym_p(pic_car(pic, clause)))) {
pic_errorf(pic, "invalid 'cond-expand' clause ~s", clause);
} else {
tag = pic_sym(pic_car(pic, clause));
tag = pic_sym_ptr(pic_car(pic, clause));
}
if (tag == pic->sLIBRARY) {

View File

@ -36,7 +36,7 @@ pic_find_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym *ren
return false;
}
if (rename != NULL) {
*rename = pic_sym(pic_dict_ref(pic, senv->map, sym));
*rename = pic_sym_ptr(pic_dict_ref(pic, senv->map, sym));
}
return true;
}
@ -159,10 +159,10 @@ macroexpand_lambda(pic_state *pic, pic_value expr, struct pic_senv *senv)
if (! pic_sym_p(v)) {
pic_errorf(pic, "syntax error");
}
pic_add_rename(pic, in, pic_sym(v));
pic_add_rename(pic, in, pic_sym_ptr(v));
}
if (pic_sym_p(a)) {
pic_add_rename(pic, in, pic_sym(a));
pic_add_rename(pic, in, pic_sym_ptr(a));
}
else if (! pic_nil_p(a)) {
pic_errorf(pic, "syntax error");
@ -197,7 +197,7 @@ macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv)
if (! pic_sym_p(var)) {
pic_errorf(pic, "binding to non-symbol object");
}
sym = pic_sym(var);
sym = pic_sym_ptr(var);
if (! pic_find_rename(pic, senv, sym, &rename)) {
rename = pic_add_rename(pic, senv, sym);
}
@ -220,7 +220,7 @@ macroexpand_defsyntax(pic_state *pic, pic_value expr, struct pic_senv *senv)
if (! pic_sym_p(var)) {
pic_errorf(pic, "binding to non-symbol object");
}
sym = pic_sym(var);
sym = pic_sym_ptr(var);
if (! pic_find_rename(pic, senv, sym, &rename)) {
rename = pic_add_rename(pic, senv, sym);
} else {
@ -283,7 +283,7 @@ macroexpand_node(pic_state *pic, pic_value expr, struct pic_senv *senv)
{
switch (pic_type(expr)) {
case PIC_TT_SYMBOL: {
return macroexpand_symbol(pic, pic_sym(expr), senv);
return macroexpand_symbol(pic, pic_sym_ptr(expr), senv);
}
case PIC_TT_PAIR: {
pic_value car;
@ -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(car);
pic_sym tag = pic_sym_ptr(car);
if (tag == pic->rDEFINE_SYNTAX) {
return macroexpand_defsyntax(pic, expr, senv);
@ -451,7 +451,7 @@ pic_defmacro(pic_state *pic, pic_sym name, pic_sym id, pic_func_t func)
bool
pic_identifier_p(pic_state *pic, pic_value obj)
{
return pic_sym_p(obj) && ! pic_interned_p(pic, pic_sym(obj));
return pic_sym_p(obj) && ! pic_interned_p(pic, pic_sym_ptr(obj));
}
bool

View File

@ -320,10 +320,10 @@ read_minus(pic_state *pic, struct pic_port *port, const char *str)
}
else {
sym = read_symbol(pic, port, str);
if (strcaseeq(pic_symbol_name(pic, pic_sym(sym)), "-inf.0")) {
if (strcaseeq(pic_symbol_name(pic, pic_sym_ptr(sym)), "-inf.0")) {
return pic_float_value(-INFINITY);
}
if (strcaseeq(pic_symbol_name(pic, pic_sym(sym)), "-nan.0")) {
if (strcaseeq(pic_symbol_name(pic, pic_sym_ptr(sym)), "-nan.0")) {
return pic_float_value(-NAN);
}
return sym;
@ -340,10 +340,10 @@ read_plus(pic_state *pic, struct pic_port *port, const char *str)
}
else {
sym = read_symbol(pic, port, str);
if (strcaseeq(pic_symbol_name(pic, pic_sym(sym)), "+inf.0")) {
if (strcaseeq(pic_symbol_name(pic, pic_sym_ptr(sym)), "+inf.0")) {
return pic_float_value(INFINITY);
}
if (strcaseeq(pic_symbol_name(pic, pic_sym(sym)), "+nan.0")) {
if (strcaseeq(pic_symbol_name(pic, pic_sym_ptr(sym)), "+nan.0")) {
return pic_float_value(NAN);
}
return sym;

View File

@ -262,7 +262,7 @@ pic_get_args(pic_state *pic, const char *format, ...)
if (i < argc) {
v = GET_OPERAND(pic,i);
if (pic_sym_p(v)) {
*m = pic_sym(v);
*m = pic_sym_ptr(v);
}
else {
pic_errorf(pic, "pic_get_args: expected symbol, but got ~s", v);

View File

@ -266,7 +266,7 @@ write_core(struct writer_control *p, pic_value obj)
xfprintf(file, ")");
break;
case PIC_TT_SYMBOL:
xfprintf(file, "%s", pic_symbol_name(pic, pic_sym(obj)));
xfprintf(file, "%s", pic_symbol_name(pic, pic_sym_ptr(obj)));
break;
case PIC_TT_CHAR:
if (p->mode == DISPLAY_MODE) {