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
1616 };
1717
1818 static Tbl *name2rune;
19−static sl_v readtablesym;
2019
2120 const char *ascii2name[0x20+1] = {
2221 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
@@ -248,7 +247,7 @@ again: · 225 unmodified lines
248247 RS->loc0 = IO->loc;
249248
250249 sl_v best = sl_nil;
251− sl_htable *rt = totable(sym_value(readtablesym));
250+ sl_htable *rt = totable(sl.readtable);
252251 Rune c2 = c;
253252 // FIXME(sigrid): any length should work
254253 for(int i = 0; i < 2; i++){
@@ -702,13 +701,14 @@ read_list(sl_v label, u32int closer) · 447 unmodified lines
702701 const usize pprevc = pval+3;
703702 ios_loc loc0 = IO->loc;
704703 loc0.colno--;
705− u32int t = peek(0);
706704 PUSH_SAFE(sl_nil);
707705 PUSH_SAFE(sl_nil);
708706 PUSH_SAFE(sl_noexpr);
709707 sl_v c = sl_nil, e, prevc;
710708 bool allocnew = true;
711709
710+ u32int t = peek(0);
711+
712712 while(t != closer){
713713 if(sl_unlikely((IO->flags & IOS_FL_EOF) != 0)){
714714 cthrow(
@@ -940,6 +940,7 @@ sl_read_sexpr(sl_v f, sl_v term, sl_expr_kind kind, bool ws) · 225 unmodified lines
940940 rs.prev = RS;
941941 rs.toktype = TOK_NONE;
942942 rs.tokval = sl_nil;
943+ rs.macro = sl_nil;
943944 rs.ws = ws;
944945 rs.bq = 0;
945946 rs.ags = sl.ags+1;
@@ -1005,12 +1006,10 @@ mk_rune2name_(Rune r, const char *str, int len) · 59 unmodified lines
10051006 void
10061007 sl_read_init(void)
10071008 {
1008− set(
1009− readtablesym = mk_csym("*read-table*"),
1010− cvalue_nofinalizer(sl_tabletype, sizeof(sl_htable))
1011− );
1012− sl_htable *h = cvalue_data(sym_value(readtablesym));
1009+ sl.readtable = cvalue_nofinalizer(sl_tabletype, sizeof(sl_htable));
1010+ sl_htable *h = cvalue_data(sl.readtable);
10131011 htable_new(h, HT_N_INLINE);
1012+ set(mk_csym("*read-table*"), sl.readtable);
10141013
10151014 for(Rune r = 0; r < nelem(ascii2name); r++)
10161015 mk_name2rune(r, ascii2name[r]);
src/sl.c+2−0
@@ -572,10 +572,12 @@ sl_gc(bool mustgrow) · 571 unmodified lines
572572 }
573573 rs->io = sl_relocate(rs->io);
574574 rs->tokval = sl_relocate(rs->tokval);
575+ rs->macro = sl_relocate(rs->macro);
575576 rs = rs->prev;
576577 }
577578 sl.lasterror = sl_relocate(sl.lasterror);
578579 sl.randstate = sl_relocate(sl.randstate);
580+ sl.readtable = sl_relocate(sl.readtable);
579581 sl_erroom = sl_relocate(sl_erroom);
580582 sl_emptyvec = sl_relocate(sl_emptyvec);
581583 sl_emptystr = sl_relocate(sl_emptystr);
src/slpriv.h+2−0
@@ -184,6 +184,8 @@ struct sl_proc { · 183 unmodified lines
184184 sl_v randstate;
185185 // extra data used by random logic
186186 void *randstatectx;
187+
188+ sl_v readtable;
187189 };
188190
189191 struct 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