diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-02-18 21:34:44 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-02-18 21:34:44 -0800 |
commit | 3cf469537b318388a3dde41d47d5a2c2d9fe0e70 (patch) | |
tree | 8d34e1438a8b94833ba97a7967c631bfd47861e0 /lisplib.h | |
parent | f6b8a4a199c9ba358e3571ae9486dd6e3b93e5b2 (diff) | |
download | txr-3cf469537b318388a3dde41d47d5a2c2d9fe0e70.tar.gz txr-3cf469537b318388a3dde41d47d5a2c2d9fe0e70.tar.bz2 txr-3cf469537b318388a3dde41d47d5a2c2d9fe0e70.zip |
lisplib: split autoload entries into namespaces.
Autoloads are now keyed to spearate namespaces for
functions/macros, variables, structures, slots and a keyword
namespace for autoloading miscellaneous things tied to
keywords like parameter macros.
There is some renaming going on as part of this. The "dlt"
acronym is replaced by "autload". Some functions in lisplib.c
were in an inconsistent order, and were reordered.
Motivation: the one namespace autoload causes hidden problems
in the standard library, due to inappropriate loads. This
shows up particularly when then uncompiled library is used.
Tests no longer execute as they should.
Story time: when struct.tl is autloaded, it loads param.tl
for parameter parsing, param.tl defines a structure that has
an opt slot, and accesses it with an expression like me.opt.
When this expression is expanded, the qref macro checks
whether opt is a valid slot, and for that, autoload is
triggered. But, oops, opt is a function in getopts.tl,
Thus param.tl autoloads getopt.tl. Paul A. Patience recently
introduced changes into getopt.tl that make use of pattern
matching. So getopt.tl auto-loads match.tl. But match.tl uses
structures. But, oops, that material is defined in struct.tl,
which is in progress of being auto-loaded. Thus, a false
circular dependency exists, caused by a check of the opt slot
triggering the loading of the irrelevant getopts.tl module.
These irrelevant loads will also slow down the compiling of
the library also, as well as test cases when the library is
not compiled: especially tests run under the GC torture test.
* lisplib.c (dl_table): Global variable removed.
(autoload_hash): New static array.
(set_dlt_entries_impl): Renamed to autoload_set_impl.
(autoload_set_impl): Takes al_ns_t namespace enum argument.
Operates on the hash table indicated by that argument.
(set_dlt_entries): Renamed to autoload_set.
(set_dlt_entries_sys): Renamed to autoload_sys_set.
(autoload_key_set): New static function.
(place_set_entries, ver_set_entries, ifa_set_entries,
txr_case_set_entries, with_resources_set_entries,
path_test_set_entries, struct_set_entries,
with_stream_set_entries, hash_set_entries, except_set_entries,
type_set_entries, yield_set_entries, sock_set_entries,
termios_set_entries, awk_set_entries, build_set_entries,
trace_set_entries, getopts_set_entries, package_set_entries,
getput_set_entries, tagbody_set_entries, pmac_set_entries,
error_set_entries, keyparams_set_entries, ffi_set_entries,
doloop_set_entries, stream_wrap_set_entries, asm_set_entries,
compiler_set_entries, debugger_set_entries, op_set_entries,
save_exe_set_entries, defset_set_entries,
copy_file_set_entries, arith_each_set_entries,
each_prod_set_entries, quips_set_entries, match_set_entries,
doc_set_entries, pic_set_entries, constfun_set_entries):
Separate name arrays into multipel namespaces as appropriate
and register using approprate namespace enums.
(dlt_register): Renamed to autoload_reg.
(autoload_reg): dlt parameter removed.
(lisplib_try_load): Take namespace enum argument, and check
against the corresponding hash.
(lisplib_try_load_fun, lisplib_try_load_var,
lisplib_try_load_slot, lisblib_try_load_struct,
lisplib_try_load_keyword): Pass appropriate enum value to
lisplib_try_load to request the right namespace.
(lisplib_try_load_fun_var): Call lisplib_try_load_fun,
and if that does nothing, lisplib_try_load_var.
(lisplib_init_tables): New function.
(lisplib_init): References to dl_table removed. Call to
dlt_register replaced with autoload_reg.
* lisplib.h (dl_table): Declaration removed.
(enum autoload_ns, al_ns_t): New enum.
(set_dlt_entries, dlt_register): Declarations removed.
(autoload_set, autoload_reg): Declared.
* gencadr.txr (cadr_set_entries): Drop dlt parameter, call
autoload_set instead of set_dlt_entries.
(cadr_init): Call autoload_reg instead of dlt_register.
* cadr.c: regenerated.
Diffstat (limited to 'lisplib.h')
-rw-r--r-- | lisplib.h | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -26,7 +26,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -extern val dl_table; +typedef enum autoload_ns { + al_var, al_fun, al_slot, al_struct, al_key, al_max = al_key +} al_ns_t; + extern val trace_loaded; void lisplib_init(void); val lisplib_try_load_fun(val sym); @@ -35,7 +38,6 @@ val lisplib_try_load_fun_var(val sym); val lisplib_try_load_slot(val sym); val lisplib_try_load_struct(val sym); val lisplib_try_load_keyword(val sym); -void set_dlt_entries(val dlt, val *name, val fun); -val dlt_register(val dlt, - val (*instantiate)(val), - val (*set_entries)(val, val)); +void autoload_set(al_ns_t ns, val *name, val fun); +val autoload_reg(val (*instantiate)(val), + val (*set_entries)(val)); |