remove pic->sGREF, sLREF, sCREF, sCALL

This commit is contained in:
Yuichi Nishiwaki 2015-08-25 19:37:20 +09:00
parent b96846dc6e
commit 06af0265f6
4 changed files with 20 additions and 20 deletions

View File

@ -448,6 +448,11 @@ define_var(pic_state *pic, analyze_scope *scope, pic_sym *sym)
static pic_value analyze(pic_state *, analyze_scope *, pic_value);
static pic_value analyze_lambda(pic_state *, analyze_scope *, pic_value);
#define GREF pic_intern(pic, "gref")
#define LREF pic_intern(pic, "lref")
#define CREF pic_intern(pic, "cref")
#define CALL pic_intern(pic, "call")
static pic_value
analyze_var(pic_state *pic, analyze_scope *scope, pic_sym *sym)
{
@ -456,11 +461,11 @@ analyze_var(pic_state *pic, analyze_scope *scope, pic_sym *sym)
depth = find_var(pic, scope, sym);
if (depth == scope->depth) {
return pic_list2(pic, pic_obj_value(pic->sGREF), pic_obj_value(sym));
return pic_list2(pic, pic_obj_value(GREF), pic_obj_value(sym));
} else if (depth == 0) {
return pic_list2(pic, pic_obj_value(pic->sLREF), pic_obj_value(sym));
return pic_list2(pic, pic_obj_value(LREF), pic_obj_value(sym));
} else {
return pic_list3(pic, pic_obj_value(pic->sCREF), pic_int_value(depth), pic_obj_value(sym));
return pic_list3(pic, pic_obj_value(CREF), pic_int_value(depth), pic_obj_value(sym));
}
}
@ -569,7 +574,7 @@ analyze_define(pic_state *pic, analyze_scope *scope, pic_value obj)
static pic_value
analyze_call(pic_state *pic, analyze_scope *scope, pic_value obj)
{
return pic_cons(pic, pic_obj_value(pic->sCALL), analyze_list(pic, scope, obj));
return pic_cons(pic, pic_obj_value(CALL), analyze_list(pic, scope, obj));
}
static pic_value
@ -821,14 +826,14 @@ codegen_ref(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
pic_sym *sym;
sym = pic_sym_ptr(pic_car(pic, obj));
if (sym == pic->sGREF) {
if (sym == GREF) {
pic_sym *name;
name = pic_sym_ptr(pic_list_ref(pic, obj, 1));
emit_i(pic, cxt, OP_GREF, index_global(pic, cxt, name));
emit_ret(pic, cxt, tailpos);
}
else if (sym == pic->sCREF) {
else if (sym == CREF) {
pic_sym *name;
int depth;
@ -837,7 +842,7 @@ codegen_ref(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
emit_r(pic, cxt, OP_CREF, depth, index_capture(cxt, name, depth));
emit_ret(pic, cxt, tailpos);
}
else if (sym == pic->sLREF) {
else if (sym == LREF) {
pic_sym *name;
int i;
@ -863,14 +868,14 @@ codegen_set(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
var = pic_list_ref(pic, obj, 1);
type = pic_sym_ptr(pic_list_ref(pic, var, 0));
if (type == pic->sGREF) {
if (type == GREF) {
pic_sym *name;
name = pic_sym_ptr(pic_list_ref(pic, var, 1));
emit_i(pic, cxt, OP_GSET, index_global(pic, cxt, name));
emit_ret(pic, cxt, tailpos);
}
else if (type == pic->sCREF) {
else if (type == CREF) {
pic_sym *name;
int depth;
@ -879,7 +884,7 @@ codegen_set(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
emit_r(pic, cxt, OP_CSET, depth, index_capture(cxt, name, depth));
emit_ret(pic, cxt, tailpos);
}
else if (type == pic->sLREF) {
else if (type == LREF) {
pic_sym *name;
int i;
@ -1008,7 +1013,7 @@ codegen_call(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
}
functor = pic_list_ref(pic, obj, 1);
if (pic_sym_ptr(pic_list_ref(pic, functor, 0)) == pic->sGREF) {
if (pic_sym_ptr(pic_list_ref(pic, functor, 0)) == GREF) {
pic_sym *sym;
sym = pic_sym_ptr(pic_list_ref(pic, functor, 1));
@ -1040,7 +1045,7 @@ codegen(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
pic_sym *sym;
sym = pic_sym_ptr(pic_car(pic, obj));
if (sym == pic->sGREF || sym == pic->sCREF || sym == pic->sLREF) {
if (sym == GREF || sym == CREF || sym == LREF) {
codegen_ref(pic, cxt, obj, tailpos);
}
else if (sym == pic->uSETBANG || sym == pic->uDEFINE) {
@ -1058,7 +1063,7 @@ codegen(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
else if (sym == pic->uQUOTE) {
codegen_quote(pic, cxt, obj, tailpos);
}
else if (sym == pic->sCALL) {
else if (sym == CALL) {
codegen_call(pic, cxt, obj, tailpos);
}
else {

View File

@ -477,7 +477,6 @@ gc_mark_phase(pic_state *pic)
M(sQUOTE); M(sQUASIQUOTE); M(sUNQUOTE); M(sUNQUOTE_SPLICING);
M(sSYNTAX_QUOTE); M(sSYNTAX_QUASIQUOTE); M(sSYNTAX_UNQUOTE); M(sSYNTAX_UNQUOTE_SPLICING);
M(sDEFINE_LIBRARY); M(sIMPORT); M(sEXPORT); M(sCOND_EXPAND);
M(sCALL); M(sGREF); M(sLREF); M(sCREF);
M(uDEFINE); M(uLAMBDA); M(uIF); M(uBEGIN); M(uQUOTE); M(uSETBANG); M(uDEFINE_MACRO);
M(uDEFINE_LIBRARY); M(uIMPORT); M(uEXPORT); M(uCOND_EXPAND);

View File

@ -96,9 +96,9 @@ struct pic_state {
struct pic_lib *lib, *prev_lib;
pic_sym *sQUOTE, *sQUASIQUOTE, *sUNQUOTE, *sUNQUOTE_SPLICING;
pic_sym *sSYNTAX_QUOTE, *sSYNTAX_QUASIQUOTE, *sSYNTAX_UNQUOTE, *sSYNTAX_UNQUOTE_SPLICING;
pic_sym *sSYNTAX_QUOTE, *sSYNTAX_QUASIQUOTE;
pic_sym *sSYNTAX_UNQUOTE, *sSYNTAX_UNQUOTE_SPLICING;
pic_sym *sDEFINE_LIBRARY, *sIMPORT, *sEXPORT, *sCOND_EXPAND;
pic_sym *sGREF, *sCREF, *sLREF, *sCALL;
pic_sym *uDEFINE, *uLAMBDA, *uIF, *uBEGIN, *uQUOTE, *uSETBANG, *uDEFINE_MACRO;
pic_sym *uDEFINE_LIBRARY, *uIMPORT, *uEXPORT, *uCOND_EXPAND;

View File

@ -349,10 +349,6 @@ pic_open(pic_allocf allocf, void *userdata)
S(sEXPORT, "export");
S(sDEFINE_LIBRARY, "define-library");
S(sCOND_EXPAND, "cond-expand");
S(sCALL, "call");
S(sGREF, "gref");
S(sLREF, "lref");
S(sCREF, "cref");
pic_gc_arena_restore(pic, ai);