diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-03-22 18:44:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-03-22 18:44:12 -0700 |
commit | 24bfded1413e45bb949f6c1ee2b3e8ef34f12329 (patch) | |
tree | 2c0ee03aa67f25cde703f6b98b6c33bedcaa0e39 /lib.h | |
parent | 6ff237b689590320f942a195193fed3f95934de1 (diff) | |
download | txr-24bfded1413e45bb949f6c1ee2b3e8ef34f12329.tar.gz txr-24bfded1413e45bb949f6c1ee2b3e8ef34f12329.tar.bz2 txr-24bfded1413e45bb949f6c1ee2b3e8ef34f12329.zip |
New type args with DARG type code.
An object of args type captures into the heap the "struct
args" argument list that normally appears only on the stack.
Such an object also has space for a car and cdr field,
which can come in handy.
* args.c (dyn_args): New function: hoist a struct args *
into an args heap object.
* args.h (dyn_args): Declared.
* gc.c (finalize, mark_obj): Handle DARGS type code.
* hash.c (equal_hash): Handle DARG via eq equivalence.
* lib.c (args_s): New symbol variable.
(code2type): Map DARG to args symbol.
(equal): Handle DARG type, using eq equivalence for now.
(obj_init): Initialize args_s with interned symbol.
* lib.h (enum type, type_t): New type code, DARG.
(struct dyn_args): New struct.
(union obj): New member, a of type struct dyn_args.
* txr.1: Documented args type under typeof.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -67,7 +67,7 @@ typedef double_uintptr_t dbl_ucnum; typedef enum type { NIL = TAG_PTR, NUM = TAG_NUM, CHR = TAG_CHR, LIT = TAG_LIT, CONS, STR, SYM, PKG, FUN, VEC, LCONS, LSTR, COBJ, CPTR, ENV, - BGNUM, FLNUM, RNG, BUF, TNOD, MAXTYPE = TNOD + BGNUM, FLNUM, RNG, BUF, TNOD, DARG, MAXTYPE = TNOD /* If extending, check TYPE_SHIFT and all ocurrences of MAX_TYPE */ } type_t; @@ -243,6 +243,13 @@ struct cobj { val cls; }; +struct dyn_args { + obj_common; + val car; + val cdr; + struct args *args; +}; + struct strm_ctx; struct cobj_ops { @@ -327,6 +334,7 @@ union obj { struct range rn; struct buf b; struct tnod tn; + struct dyn_args a; }; #if CONFIG_GEN_GC |