diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-03-23 23:00:01 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-03-23 23:00:01 -0700 |
commit | 3f089edac96f9c0f37aa36b3ed3bc2ecc9b85ffa (patch) | |
tree | 7ce93ae75177d3982f2ab0066bd5b3b1925e3761 /struct.h | |
parent | 37e5a84d7483a6f323d7f069ac3b33ecd0c9d8e7 (diff) | |
download | txr-3f089edac96f9c0f37aa36b3ed3bc2ecc9b85ffa.tar.gz txr-3f089edac96f9c0f37aa36b3ed3bc2ecc9b85ffa.tar.bz2 txr-3f089edac96f9c0f37aa36b3ed3bc2ecc9b85ffa.zip |
Warn when a nonexistent slot is referenced.
Implementing warning for the situaton when the qref, uref, usl
and umeth macro operators are asked to refer to a slot that
doesn't exist in any struct type. This won't catch errors
referencing a slot on the wrong type, but it will catch slots
that are misspelled in such a way that the typo doesn't land
on any slot.
* share/txr/stdlib/struct.tl (defstruct): Register tenative
slot definitions for all slots to nuke warnings.
(sys:check-slot): New function.
(qref, usl, umeth): Check slots with sys:check-slot.
(uref): Drop :whole argument, which is unused.
(defmeth): Register tentative definition for slot.
* struct.c (slot_s, static_slot_s): New symbol variables.
(slot_type_hash, static_slot_type_hash): New hash tables,
associating symbols with lists of struct type names
in which they are defined.
(struct_init): Initialize and gc-protect hashes.
Initialize new symbols, interning in system package.
Register new intrinsic funtions sys:slot-types and
sys:static-slot-types.
(make_struct_type): Register slots in new hashes.
(static_slot_ens_rec): Register new slow in static
slot hash.
(slot_types, static_slot_types): New functions,
registered as intrinsics.
(slot_type_reg, static_slot_type_reg): New functions.
* struct.h (print_s): Declared.
(slot_s, static_slot_s): Declared.
(slot_types, static_slot_types, slot_type_reg,
static_slot_type_reg): Declared.
Diffstat (limited to 'struct.h')
-rw-r--r-- | struct.h | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -25,7 +25,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -extern val struct_type_s, meth_s, make_struct_lit_s; +extern val struct_type_s, meth_s, print_s, make_struct_lit_s; +extern val slot_s, static_slot_s; val make_struct_type(val name, val super, val static_slots, val slots, val static_initfun, val initfun, val boactor, @@ -64,4 +65,8 @@ val uslot(val slot); val umethod(val slot, struct args *); val method_name(val fun); val get_slot_syms(val package, val is_current, val method_only); +val slot_types(val slot); +val static_slot_types(val slot); +val slot_type_reg(val slot, val strct); +val static_slot_type_reg(val slot, val strct); void struct_init(void); |