LAD Project: the VALTYPE Module


Summary: The VALTYPE object serves the following purpose. It represents a the type of a dynamically typed value. Compound types are permitted, made from the basic concept of a sequence.
Abstract Datatype: valtype
Current legal [primtype]s:

int bool real string sequence They are denoted by the following #defined constants (from [primtype] module): INT_VALUE BOOL_VALUE REAL_VALUE STRING_VALUE A compound type is a SEQUENCE. It is either a

List [ (valtype) ] if it is a variable-length sequence with subtypes all of the form valtype.

or it is Tuple [ (valtype1) , (valtype2) ... (valtypeN) ] if it is a fixed length tuple of (possibly varying) subtypes.


valtype *mk_prim_valtype(int primtype)
primtype must be one of the primtype constants described above, but not SEQUENCE.
valtype *mk_list_valtype(valtype *subtype);
makes a List valtype in which the subtype is a COPY of new_subtype.
valtype *mk_empty_tuple();
valtype *add_to_tuple_valtype(valtype *tuple,valtype *new_subtype);
Beforehand, tuple was a tuple valtype with n subtypes indexed 0... n-1. After, it has become a tuple with n+1 subtypes indexed 0..n. The subtype indexed by n is a COPY of new_subtype.
void fprintf_valtype(FILE *s,char *m1,valtype *vt,char *m2);
void free_valtype(valtype *vt);