diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-02-18 20:07:28 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-02-18 20:07:28 -0800 |
commit | f6b8a4a199c9ba358e3571ae9486dd6e3b93e5b2 (patch) | |
tree | b00cd2f6655e2f2d7d6a02bdbbee308ade673b61 | |
parent | 44a98cac667e57d5d9d05cb0a2c189dea03ebabe (diff) | |
download | txr-f6b8a4a199c9ba358e3571ae9486dd6e3b93e5b2.tar.gz txr-f6b8a4a199c9ba358e3571ae9486dd6e3b93e5b2.tar.bz2 txr-f6b8a4a199c9ba358e3571ae9486dd6e3b93e5b2.zip |
lisplib: split lisplib_try_load into namespaces.
* lisplib.c (lisplib_init): Change sys:try-load (only used by
place.tl) to sys:try-load-fun, and register it to
(lisplib_try_load): External function becomes static.
(lisplib_try_load_fun, lisplib_try_load_var,
lisplib_try_load_fun_var, lisplib_try_load_slot,
lisplib_try_load_struct, lisplib_try_load_keyword): New
functions.
* lisplib.h (lisplib_try_load): Declaration removed.
(lisplib_try_load): External function becomes static.
(lisplib_try_load_fun, lisplib_try_load_var,
lisplib_try_load_fun_var, lisplib_try_load_slot,
lisplib_try_load_struct, lisplib_try_load_keyword): Declared.
* eval.c (lookup_global_var, lookup_var, lookup_symac,
lookup_symac_lisp1, rt_defvarl, rt_defv, op_defsymacro,
rt_defsymacro, makunbound): Use lisplip_try_load_var.
(lookup_fun, lookup_mac, rt_defun, rt_defmacro, fmakunbound,
mmakunbound): Use lisplib_try_load_fun.
(expand_param_macro): Use lisplib_try_load_keyword, which is
a catch-all namespace for anything tied to keywords.
* struct.c (make_struct_type, find_struct_type): Use
lisplib_try_load_struct.
(lookup_sloat_load, lookup_static_slot_load,
lookup_static_slot_desc_load, slot_types, static_slot_types):
Use lisplib_try_load_slot.
* stdlib/place.tl (get-place-macro): Use try-load-fun,
rather than try-load.
-rw-r--r-- | eval.c | 36 | ||||
-rw-r--r-- | lisplib.c | 34 | ||||
-rw-r--r-- | lisplib.h | 7 | ||||
-rw-r--r-- | stdlib/place.tl | 2 | ||||
-rw-r--r-- | struct.c | 14 |
5 files changed, 64 insertions, 29 deletions
@@ -529,7 +529,7 @@ val lookup_global_var(val sym) { uses_or2; return or2(gethash(top_vb, sym), - if2(lisplib_try_load(sym), gethash(top_vb, sym))); + if2(lisplib_try_load_var(sym), gethash(top_vb, sym))); } val lookup_var(val env, val sym) @@ -582,7 +582,7 @@ val lookup_sym_lisp1(val env, val sym) } return or3(gethash(top_vb, sym), - if2(lisplib_try_load(sym), + if2(lisplib_try_load_fun_var(sym), gethash(top_vb, sym)), gethash(top_fb, sym)); } @@ -604,7 +604,7 @@ val lookup_fun(val env, val sym) val strct = cadr(sym); val slot = caddr(sym); val type = or2(find_struct_type(strct), - if2(lisplib_try_load(strct), + if2(lisplib_try_load_struct(strct), find_struct_type(strct))); if (slot == init_k) { return cons(sym, struct_get_initfun(type)); @@ -634,7 +634,7 @@ val lookup_fun(val env, val sym) } return or2(gethash(top_fb, sym), - if2(lisplib_try_load(sym), gethash(top_fb, sym))); + if2(lisplib_try_load_fun(sym), gethash(top_fb, sym))); } val func_get_name(val fun, val env) @@ -684,7 +684,7 @@ static val lookup_mac(val menv, val sym) if (nilp(menv)) { return or2(gethash(top_mb, sym), - if2(lisplib_try_load(sym), gethash(top_mb, sym))); + if2(lisplib_try_load_fun(sym), gethash(top_mb, sym))); } else { type_check(lit("macro lookup"), menv, ENV); @@ -703,7 +703,7 @@ static val lookup_symac(val menv, val sym) if (nilp(menv)) { return or2(gethash(top_smb, sym), - if2(lisplib_try_load(sym), gethash(top_smb, sym))); + if2(lisplib_try_load_var(sym), gethash(top_smb, sym))); } else { type_check(lit("symacro lookup"), menv, ENV); @@ -722,7 +722,7 @@ static val lookup_symac_lisp1(val menv, val sym) if (nilp(menv)) { return or2(gethash(top_smb, sym), - if2(lisplib_try_load(sym), gethash(top_smb, sym))); + if2(lisplib_try_load_var(sym), gethash(top_smb, sym))); } else { type_check(lit("symacro lookup"), menv, ENV); @@ -755,7 +755,7 @@ static val special_var_p(val sym) { uses_or2; return or2(gethash(special, sym), - if2(lisplib_try_load(sym), gethash(special, sym))); + if2(lisplib_try_load_var(sym), gethash(special, sym))); } static val lexical_var_p(val menv, val sym) @@ -1209,7 +1209,7 @@ static val expand_param_macro(val params, val body, val menv, val form) return cons(params, body); if (!pmac) { - lisplib_try_load(sym); + lisplib_try_load_keyword(sym); pmac = gethash(pm_table, sym); if (!pmac) expand_error(form, lit("~s: keyword ~s has no param macro binding"), @@ -2031,7 +2031,7 @@ static val rt_defvarl(val sym) { val self = lit("sys:defvarl"); val new_p; - val cell = (lisplib_try_load(sym), + val cell = (lisplib_try_load_var(sym), gethash_c(self, top_vb, sym, mkcloc(new_p))); if (new_p || !cdr(cell)) { @@ -2048,7 +2048,7 @@ static val rt_defv(val sym) { val self = lit("sys:defv"); val new_p; - val cell = (lisplib_try_load(sym), + val cell = (lisplib_try_load_var(sym), gethash_c(self, top_vb, sym, mkcloc(new_p))); if (new_p) { @@ -2082,7 +2082,7 @@ static val op_defsymacro(val form, val env) (void) env; - lisplib_try_load(sym); + lisplib_try_load_var(sym); remhash(top_vb, sym); if (!opt_compat || opt_compat > 143) remhash(special, sym); @@ -2092,7 +2092,7 @@ static val op_defsymacro(val form, val env) static val rt_defsymacro(val sym, val def) { - lisplib_try_load(sym); + lisplib_try_load_var(sym); remhash(top_vb, sym); remhash(special, sym); sethash(top_smb, sym, cons(sym, def)); @@ -2114,7 +2114,7 @@ void trace_check(val name) static val rt_defun(val name, val function) { - lisplib_try_load(name); + lisplib_try_load_fun(name); sethash(top_fb, name, cons(name, function)); uw_purge_deferred_warning(cons(fun_s, name)); uw_purge_deferred_warning(cons(sym_s, name)); @@ -2123,7 +2123,7 @@ static val rt_defun(val name, val function) static val rt_defmacro(val sym, val name, val function) { - lisplib_try_load(sym); + lisplib_try_load_fun(sym); sethash(top_mb, sym, cons(name, function)); return name; } @@ -5852,7 +5852,7 @@ static val makunbound(val sym) { val env; - lisplib_try_load(sym); + lisplib_try_load_var(sym); if (!opt_compat || opt_compat > 143) { for (env = dyn_env; env; env = env->e.up_env) { @@ -5875,7 +5875,7 @@ static val makunbound(val sym) static val fmakunbound(val sym) { - lisplib_try_load(sym); + lisplib_try_load_var(sym); remhash(top_fb, sym); if (opt_compat && opt_compat <= 127) remhash(top_mb, sym); @@ -5885,7 +5885,7 @@ static val fmakunbound(val sym) static val mmakunbound(val sym) { - lisplib_try_load(sym); + lisplib_try_load_fun(sym); remhash(top_mb, sym); return sym; } @@ -1042,10 +1042,10 @@ void lisplib_init(void) dlt_register(dl_table, pic_instantiate, pic_set_entries); dlt_register(dl_table, constfun_instantiate, constfun_set_entries); - reg_fun(intern(lit("try-load"), system_package), func_n1(lisplib_try_load)); + reg_fun(intern(lit("try-load-fun"), system_package), func_n1(lisplib_try_load_fun)); } -val lisplib_try_load(val sym) +static val lisplib_try_load(val sym) { val fun = gethash(dl_table, sym); @@ -1062,3 +1062,33 @@ val lisplib_try_load(val sym) } return nil; } + +val lisplib_try_load_fun(val sym) +{ + return lisplib_try_load(sym); +} + +val lisplib_try_load_var(val sym) +{ + return lisplib_try_load(sym); +} + +val lisplib_try_load_fun_var(val sym) +{ + return lisplib_try_load(sym); +} + +val lisplib_try_load_slot(val sym) +{ + return lisplib_try_load(sym); +} + +val lisplib_try_load_struct(val sym) +{ + return lisplib_try_load(sym); +} + +val lisplib_try_load_keyword(val sym) +{ + return lisplib_try_load(sym); +} @@ -29,7 +29,12 @@ extern val dl_table; extern val trace_loaded; void lisplib_init(void); -val lisplib_try_load(val sym); +val lisplib_try_load_fun(val sym); +val lisplib_try_load_var(val sym); +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), diff --git a/stdlib/place.tl b/stdlib/place.tl index 9716aca6..df3d09fb 100644 --- a/stdlib/place.tl +++ b/stdlib/place.tl @@ -61,7 +61,7 @@ (defun sys:get-place-macro (sym) (or [*place-macro* sym] - (progn (sys:try-load sym) [*place-macro* sym]))) + (progn (sys:try-load-fun sym) [*place-macro* sym]))) (defun sys:pl-expand (unex-place env) (while t @@ -442,7 +442,7 @@ val make_struct_type(val name, val supers, val self = lit("make-struct-type"); val iter; - lisplib_try_load(name); + lisplib_try_load_struct(name); if (built_in_type_p(name)) uw_throwf(error_s, lit("~a: ~s is a built-in type"), @@ -604,7 +604,7 @@ val find_struct_type(val sym) { uses_or2; return or2(gethash(struct_type_hash, sym), - if2(lisplib_try_load(sym), + if2(lisplib_try_load_struct(sym), gethash(struct_type_hash, sym))); } @@ -1199,7 +1199,7 @@ static loc lookup_slot_load(val inst, struct struct_inst *si, val sym) { loc ptr = lookup_slot(inst, si, sym); if (nullocp(ptr)) { - lisplib_try_load(sym); + lisplib_try_load_slot(sym); return lookup_slot(inst, si, sym); } return ptr; @@ -1209,7 +1209,7 @@ static loc lookup_static_slot_load(struct struct_type *st, val sym) { loc ptr = lookup_static_slot(st, sym); if (nullocp(ptr)) { - lisplib_try_load(sym); + lisplib_try_load_slot(sym); return lookup_static_slot(st, sym); } return ptr; @@ -1220,7 +1220,7 @@ static struct stslot *lookup_static_slot_desc_load(struct struct_type *st, { struct stslot *stsl = lookup_static_slot_desc(st, sym); if (stsl == 0) { - lisplib_try_load(sym); + lisplib_try_load_slot(sym); return lookup_static_slot_desc(st, sym); } return stsl; @@ -1995,7 +1995,7 @@ val slot_types(val slot) { uses_or2; return or2(gethash(slot_type_hash, slot), - if2(lisplib_try_load(slot), + if2(lisplib_try_load_slot(slot), gethash(slot_type_hash, slot))); } @@ -2003,7 +2003,7 @@ val static_slot_types(val slot) { uses_or2; return or2(gethash(static_slot_type_hash, slot), - if2(lisplib_try_load(slot), + if2(lisplib_try_load_slot(slot), gethash(static_slot_type_hash, slot))); } |