summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-03-22 18:44:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-03-22 18:44:12 -0700
commit24bfded1413e45bb949f6c1ee2b3e8ef34f12329 (patch)
tree2c0ee03aa67f25cde703f6b98b6c33bedcaa0e39 /lib.h
parent6ff237b689590320f942a195193fed3f95934de1 (diff)
downloadtxr-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.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib.h b/lib.h
index dfc73e98..6c5b17ef 100644
--- a/lib.h
+++ b/lib.h
@@ -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