History

move *read-table* to sl proc; relocate

Sigrid Solveig Haflínudóttir committed 3 months ago

Commit 12cd5b31 parent 33001243 files · +11 −8Browse files

Unified · Split

3 files
  1. src/read.c +7 −8
  2. src/sl.c +2 −0
  3. src/slpriv.h +2 −0
src/read.c+7−8
@@ -16,7 +16,6 @@ enum { · 15 unmodified lines
16};16};
17 17
18static Tbl *name2rune;18static Tbl *name2rune;
19static sl_v readtablesym;
20 19
21const char *ascii2name[0x20+1] = {20const char *ascii2name[0x20+1] = {
22 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",21 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
@@ -248,7 +247,7 @@ again: · 225 unmodified lines
248 RS->loc0 = IO->loc;247 RS->loc0 = IO->loc;
249 248
250 sl_v best = sl_nil;249 sl_v best = sl_nil;
251 sl_htable *rt = totable(sym_value(readtablesym));250 sl_htable *rt = totable(sl.readtable);
252 Rune c2 = c;251 Rune c2 = c;
253 // FIXME(sigrid): any length should work252 // FIXME(sigrid): any length should work
254 for(int i = 0; i < 2; i++){253 for(int i = 0; i < 2; i++){
@@ -702,13 +701,14 @@ read_list(sl_v label, u32int closer) · 447 unmodified lines
702 const usize pprevc = pval+3;701 const usize pprevc = pval+3;
703 ios_loc loc0 = IO->loc;702 ios_loc loc0 = IO->loc;
704 loc0.colno--;703 loc0.colno--;
705 u32int t = peek(0);
706 PUSH_SAFE(sl_nil);704 PUSH_SAFE(sl_nil);
707 PUSH_SAFE(sl_nil);705 PUSH_SAFE(sl_nil);
708 PUSH_SAFE(sl_noexpr);706 PUSH_SAFE(sl_noexpr);
709 sl_v c = sl_nil, e, prevc;707 sl_v c = sl_nil, e, prevc;
710 bool allocnew = true;708 bool allocnew = true;
711 709
710 u32int t = peek(0);
711
712 while(t != closer){712 while(t != closer){
713 if(sl_unlikely((IO->flags & IOS_FL_EOF) != 0)){713 if(sl_unlikely((IO->flags & IOS_FL_EOF) != 0)){
714 cthrow(714 cthrow(
@@ -940,6 +940,7 @@ sl_read_sexpr(sl_v f, sl_v term, sl_expr_kind kind, bool ws) · 225 unmodified lines
940 rs.prev = RS;940 rs.prev = RS;
941 rs.toktype = TOK_NONE;941 rs.toktype = TOK_NONE;
942 rs.tokval = sl_nil;942 rs.tokval = sl_nil;
943 rs.macro = sl_nil;
943 rs.ws = ws;944 rs.ws = ws;
944 rs.bq = 0;945 rs.bq = 0;
945 rs.ags = sl.ags+1;946 rs.ags = sl.ags+1;
@@ -1005,12 +1006,10 @@ mk_rune2name_(Rune r, const char *str, int len) · 59 unmodified lines
1005void1006void
1006sl_read_init(void)1007sl_read_init(void)
1007{1008{
1008 set(1009 sl.readtable = cvalue_nofinalizer(sl_tabletype, sizeof(sl_htable));
1009 readtablesym = mk_csym("*read-table*"),1010 sl_htable *h = cvalue_data(sl.readtable);
1010 cvalue_nofinalizer(sl_tabletype, sizeof(sl_htable))
1011 );
1012 sl_htable *h = cvalue_data(sym_value(readtablesym));
1013 htable_new(h, HT_N_INLINE);1011 htable_new(h, HT_N_INLINE);
1012 set(mk_csym("*read-table*"), sl.readtable);
1014 1013
1015 for(Rune r = 0; r < nelem(ascii2name); r++)1014 for(Rune r = 0; r < nelem(ascii2name); r++)
1016 mk_name2rune(r, ascii2name[r]);1015 mk_name2rune(r, ascii2name[r]);
src/sl.c+2−0
@@ -572,10 +572,12 @@ sl_gc(bool mustgrow) · 571 unmodified lines
572 }572 }
573 rs->io = sl_relocate(rs->io);573 rs->io = sl_relocate(rs->io);
574 rs->tokval = sl_relocate(rs->tokval);574 rs->tokval = sl_relocate(rs->tokval);
575 rs->macro = sl_relocate(rs->macro);
575 rs = rs->prev;576 rs = rs->prev;
576 }577 }
577 sl.lasterror = sl_relocate(sl.lasterror);578 sl.lasterror = sl_relocate(sl.lasterror);
578 sl.randstate = sl_relocate(sl.randstate);579 sl.randstate = sl_relocate(sl.randstate);
580 sl.readtable = sl_relocate(sl.readtable);
579 sl_erroom = sl_relocate(sl_erroom);581 sl_erroom = sl_relocate(sl_erroom);
580 sl_emptyvec = sl_relocate(sl_emptyvec);582 sl_emptyvec = sl_relocate(sl_emptyvec);
581 sl_emptystr = sl_relocate(sl_emptystr);583 sl_emptystr = sl_relocate(sl_emptystr);
src/slpriv.h+2−0
@@ -184,6 +184,8 @@ struct sl_proc { · 183 unmodified lines
184 sl_v randstate;184 sl_v randstate;
185 // extra data used by random logic185 // extra data used by random logic
186 void *randstatectx;186 void *randstatectx;
187
188 sl_v readtable;
187};189};
188 190
189struct sl_vm {191struct sl_vm {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t