mirror of
https://github.com/false-schemers/skint.git
synced 2025-01-21 19:27:27 +01:00
immediate-hash, '#&box constants serialized
This commit is contained in:
parent
7cc993e16b
commit
e95b05135b
4 changed files with 1410 additions and 1352 deletions
21
i.c
21
i.c
|
@ -3426,6 +3426,15 @@ define_instruction(igco) {
|
|||
gonexti();
|
||||
}
|
||||
|
||||
define_instruction(hshim) {
|
||||
unsigned long long v = (unsigned long long)ac, base = 0; obj b = spop();
|
||||
if (v && isaptr(v)) failtype(v, "immediate value");
|
||||
if (b) { ckk(b); base = get_fixnum(b); }
|
||||
if (!base) base = 1 + (unsigned long long)FIXNUM_MAX;
|
||||
ac = fixnum_obj((fixnum_t)(v % base));
|
||||
gonexti();
|
||||
}
|
||||
|
||||
define_instruction(rdsx) {
|
||||
cks(ac);
|
||||
unload_ac(); /* ac->ra (string) */
|
||||
|
@ -3448,6 +3457,7 @@ define_instruction(rdsc) {
|
|||
gonexti();
|
||||
}
|
||||
|
||||
|
||||
define_instruction(litf) { ac = bool_obj(0); gonexti(); }
|
||||
define_instruction(litt) { ac = bool_obj(1); gonexti(); }
|
||||
define_instruction(litn) { ac = null_obj(); gonexti(); }
|
||||
|
@ -4097,7 +4107,16 @@ static obj *rds_sexp(obj *r, obj *sp, obj *hp)
|
|||
}
|
||||
ra = hpushu8v(sp-r, newbytevector((unsigned char *)cbdata(pcb), (int)cblen(pcb)));
|
||||
freecb(pcb);
|
||||
}
|
||||
} break;
|
||||
case 'z': {
|
||||
spush(port);
|
||||
ra = sref(0); hp = rds_elt(r, sp, hp);
|
||||
if (iseof(ra)) { sdrop(1); return hp; } else spush(ra);
|
||||
hreserve(boxbsz(), sp-r);
|
||||
*--hp = sref(0);
|
||||
ra = hend_box();
|
||||
sdrop(2);
|
||||
} break;
|
||||
}
|
||||
return hp;
|
||||
}
|
||||
|
|
3
i.h
3
i.h
|
@ -523,7 +523,7 @@ declare_instruction(panic, "Z7", 0, "%panic",
|
|||
declare_instruction(abort, "Z8\0t", 0, "%abort", 'u', AUTOGL)
|
||||
declare_instruction(exit, "Z9\0t", 0, "%exit", 'u', AUTOGL)
|
||||
|
||||
/* serialization and deserialization instructions */
|
||||
/* serialization, deserialization, compilation-related instructions */
|
||||
declare_instruction(igp, "U0", 0, "integrable?", '1', AUTOGL)
|
||||
declare_instruction(itrs, "U1", 0, "initial-transformers", '0', AUTOGL)
|
||||
declare_instruction(rdsx, "U3", 0, "deserialize-sexp", '1', AUTOGL)
|
||||
|
@ -532,6 +532,7 @@ declare_instruction(iglk, "U5", 0, "lookup-integrable",
|
|||
declare_instruction(igty, "U6", 0, "integrable-type", '1', AUTOGL)
|
||||
declare_instruction(iggl, "U7", 0, "integrable-global", '1', AUTOGL)
|
||||
declare_instruction(igco, "U8", 0, "integrable-code", '2', AUTOGL)
|
||||
declare_instruction(hshim, "H2\0f", 0, "immediate-hash", 'b', AUTOGL)
|
||||
|
||||
/* inlined integrables (no custom instructions) */
|
||||
declare_integrable(NULL, "N0", 0, "complex?", '1', AUTOGL)
|
||||
|
|
3
src/k.sf
3
src/k.sf
|
@ -793,6 +793,9 @@
|
|||
(write-serialized-size (string-length x) port)
|
||||
(do ([i 0 (fx+ i 1)]) [(fx=? i (string-length x))]
|
||||
(write-serialized-char (string-ref x i) port)))]
|
||||
[(box? x)
|
||||
(write-char #\z port)
|
||||
(write-serialized-element (unbox x) port)]
|
||||
[else (c-error "cannot encode literal" x)]))
|
||||
|
||||
(define (write-serialized-arg arg port)
|
||||
|
|
Loading…
Reference in a new issue