The fasl-loader interns gensyms by default now.

This commit is contained in:
Abdulaziz Ghuloum 2006-12-25 10:35:18 +03:00
parent b9a369197a
commit 158980aeea
5 changed files with 11 additions and 15 deletions

Binary file not shown.

View File

@ -310,16 +310,11 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){
char x = fasl_read_byte(p); char x = fasl_read_byte(p);
return byte_to_scheme_char(x); return byte_to_scheme_char(x);
} }
else if(c == 'G'){ /* G is for gensym */ else if(c == 'G'){
/* G is for gensym */
ikp pretty = do_read(pcb, p); ikp pretty = do_read(pcb, p);
ikp unique = do_read(pcb, p); ikp unique = do_read(pcb, p);
ikp sym = ik_alloc(pcb, align(symbol_size)) + symbol_tag; ikp sym = ikrt_strings_to_gensym(pretty, unique, pcb);
ref(sym, off_symbol_string) = pretty;
ref(sym, off_symbol_ustring) = unique;
ref(sym, off_symbol_value) = unbound_object;
ref(sym, off_symbol_system_value) = unbound_object;
ref(sym, off_symbol_plist) = null_object;
ref(sym, off_symbol_system_plist) = null_object;
if(put_mark_index){ if(put_mark_index){
p->marks[put_mark_index] = sym; p->marks[put_mark_index] = sym;
} }

View File

@ -78,21 +78,21 @@ intern_string(ikp str, ikp st, ikpcb* pcb){
return sym; return sym;
} }
ikp static ikp
ikrt_intern_unique_string(ikp ustr, ikp st, ikpcb* pcb){ intern_unique_string(ikp str, ikp ustr, ikp st, ikpcb* pcb){
int h = compute_hash(ustr); int h = compute_hash(ustr);
int idx = h & (unfix(ref(st, off_vector_length)) - 1); int idx = h & (unfix(ref(st, off_vector_length)) - 1);
ikp bckt = ref(st, off_vector_data + idx*wordsize); ikp bckt = ref(st, off_vector_data + idx*wordsize);
ikp b = bckt; ikp b = bckt;
while(b){ while(b){
ikp sym = ref(b, off_car); ikp sym = ref(b, off_car);
ikp sym_str = ref(sym, off_symbol_ustring); ikp sym_ustr = ref(sym, off_symbol_ustring);
if(strings_eqp(sym_str, ustr)){ if(strings_eqp(sym_ustr, ustr)){
return sym; return sym;
} }
b = ref(b, off_cdr); b = ref(b, off_cdr);
} }
ikp sym = ik_make_symbol(false_object, ustr, pcb); ikp sym = ik_make_symbol(str, ustr, pcb);
b = ik_alloc(pcb, pair_size) + pair_tag; b = ik_alloc(pcb, pair_size) + pair_tag;
ref(b, off_car) = sym; ref(b, off_car) = sym;
ref(b, off_cdr) = bckt; ref(b, off_cdr) = bckt;
@ -148,13 +148,13 @@ ik_intern_string(ikp str, ikpcb* pcb){
} }
ikp ikp
ikrt_string_to_gensym(ikp str, ikpcb* pcb){ ikrt_strings_to_gensym(ikp str, ikp ustr, ikpcb* pcb){
ikp st = pcb->gensym_table; ikp st = pcb->gensym_table;
if(st == 0){ if(st == 0){
st = make_symbol_table(pcb); st = make_symbol_table(pcb);
pcb->gensym_table = st; pcb->gensym_table = st;
} }
return intern_string(str, st, pcb); return intern_unique_string(str, ustr, st, pcb);
} }

View File

@ -162,6 +162,7 @@ void ik_print(ikp x);
void ik_fprint(FILE*, ikp x); void ik_fprint(FILE*, ikp x);
ikp ikrt_string_to_symbol(ikp, ikpcb*); ikp ikrt_string_to_symbol(ikp, ikpcb*);
ikp ikrt_strings_to_gensym(ikp, ikp, ikpcb*);
ikp ik_cstring_to_symbol(char*, ikpcb*); ikp ik_cstring_to_symbol(char*, ikpcb*);

Binary file not shown.