mirror of
https://github.com/false-schemers/skint.git
synced 2024-11-16 07:47:54 +01:00
globals kept in a hash table, (global-store)
This commit is contained in:
parent
7cbd996675
commit
01cdbba2f8
4 changed files with 662 additions and 648 deletions
19
i.c
19
i.c
|
@ -3415,6 +3415,11 @@ define_instruction(itrs) {
|
|||
gonexti();
|
||||
}
|
||||
|
||||
define_instruction(glos){
|
||||
ac = cx__2Aglobals_2A;
|
||||
gonexti();
|
||||
}
|
||||
|
||||
define_instruction(igp) {
|
||||
ac = bool_obj(isintegrable(ac));
|
||||
gonexti();
|
||||
|
@ -4305,18 +4310,21 @@ static obj *rds_arg(obj *r, obj *sp, obj *hp)
|
|||
/* protects registers from r to sp, in: ra=sym, out: ra=loc/eof */
|
||||
static obj *rds_global_loc(obj *r, obj *sp, obj *hp)
|
||||
{
|
||||
if (issymbol(ra)) {
|
||||
obj p = isassv(ra, cx__2Aglobals_2A);
|
||||
unsigned long long base;
|
||||
if (issymbol(ra) && isvector(cx__2Aglobals_2A) && (base = vectorlen(cx__2Aglobals_2A)) > 0) {
|
||||
unsigned long long v = (unsigned long long)ra; int i = (int)(v % base);
|
||||
obj p = isassv(ra, vectorref(cx__2Aglobals_2A, i));
|
||||
if (ispair(p)) ra = cdr(p);
|
||||
else { /* prepend (sym . #&sym) to *globals* */
|
||||
obj box;
|
||||
obj box, *pl;
|
||||
hreserve(boxbsz()*1+pairbsz()*2, sp-r);
|
||||
*--hp = ra;
|
||||
box = hend_box();
|
||||
*--hp = box; *--hp = ra;
|
||||
ra = hend_pair();
|
||||
*--hp = cx__2Aglobals_2A; *--hp = ra;
|
||||
cx__2Aglobals_2A = hend_pair();
|
||||
pl = &vectorref(cx__2Aglobals_2A, i);
|
||||
*--hp = *pl; *--hp = ra;
|
||||
*pl = hend_pair();
|
||||
ra = box;
|
||||
}
|
||||
} else {
|
||||
|
@ -4325,7 +4333,6 @@ static obj *rds_global_loc(obj *r, obj *sp, obj *hp)
|
|||
return hp;
|
||||
}
|
||||
|
||||
|
||||
/* see below */
|
||||
static obj *rds_seq(obj *r, obj *sp, obj *hp);
|
||||
|
||||
|
|
1
i.h
1
i.h
|
@ -528,6 +528,7 @@ declare_instruction(exit, "Z9\0t", 0, "%exit",
|
|||
/* serialization, deserialization, compilation-related instructions */
|
||||
declare_instruction(igp, "U0", 0, "integrable?", '1', AUTOGL)
|
||||
declare_instruction(itrs, "U1", 0, "initial-transformers", '0', AUTOGL)
|
||||
declare_instruction(glos, "U2", 0, "global-store", '0', AUTOGL)
|
||||
declare_instruction(rdsx, "U3", 0, "deserialize-sexp", '1', AUTOGL)
|
||||
declare_instruction(rdsc, "U4", 0, "deserialize-code", '1', AUTOGL)
|
||||
declare_instruction(iglk, "U5", 0, "lookup-integrable", '1', AUTOGL)
|
||||
|
|
2
src/k.sf
2
src/k.sf
|
@ -719,7 +719,7 @@
|
|||
|
||||
(%localdef "#include \"i.h\"")
|
||||
|
||||
(define *globals* '())
|
||||
(define *globals* (make-vector 991 '())) ; nice prime number
|
||||
|
||||
(define *dynamic-state* (list #f)) ; for dynamic-wind
|
||||
|
||||
|
|
Loading…
Reference in a new issue