1.1 --- a/templates/types.h Sun Feb 12 23:24:42 2017 +0100
1.2 +++ b/templates/types.h Mon Feb 13 15:35:36 2017 +0100
1.3 @@ -51,44 +51,35 @@
1.4 const __param params[];
1.5 } __ptable;
1.6
1.7 -/* Attributes are context and value pairs.
1.8 +/* Attributes are values referring to objects or encoding other information.
1.9 Objects are collections of attributes.
1.10 Object references are references to tables and collections of attributes.
1.11 Attribute references are references to single attributes. */
1.12
1.13 typedef struct __obj __obj;
1.14 typedef struct __fragment __fragment;
1.15 +typedef union __attr __attr;
1.16 +typedef __obj * __ref;
1.17
1.18 -typedef struct __attr
1.19 +typedef union __attr
1.20 {
1.21 - /* One of... */
1.22 - union
1.23 - {
1.24 - struct {
1.25 - __obj * context; /* attribute context */
1.26 - __obj * value; /* attribute value */
1.27 - };
1.28 - struct {
1.29 - __ppos min; /* minimum number of parameters */
1.30 - const __ptable * ptable; /* parameter table */
1.31 - };
1.32 - struct {
1.33 - __pcode code; /* parameter table code for key */
1.34 - __ppos pos; /* parameter table position for key */
1.35 - };
1.36 - struct {
1.37 - struct __attr (*inv)(); /* unbound callable details */
1.38 - struct __attr (*fn)(); /* callable details */
1.39 - };
1.40 - union
1.41 - {
1.42 - int intvalue; /* integer value */
1.43 - double floatvalue; /* floating point value */
1.44 - char * strvalue; /* string value */
1.45 - __fragment * seqvalue; /* sequence data */
1.46 - void * datavalue; /* object-specific data */
1.47 - };
1.48 + __ref value; /* attribute value */
1.49 + struct {
1.50 + __ppos min; /* minimum number of parameters */
1.51 + const __ptable * ptable; /* parameter table */
1.52 + };
1.53 + struct {
1.54 + __pcode code; /* parameter table code for key */
1.55 + __ppos pos; /* parameter table position for key */
1.56 };
1.57 + struct {
1.58 + __attr (*fn)(); /* callable details */
1.59 + };
1.60 + int intvalue; /* integer value */
1.61 + double floatvalue; /* floating point value */
1.62 + char * strvalue; /* string value */
1.63 + __fragment * seqvalue; /* sequence data */
1.64 + void * datavalue; /* object-specific data */
1.65 } __attr;
1.66
1.67 typedef struct __obj
1.68 @@ -98,7 +89,7 @@
1.69 __attr attrs[]; /* attributes */
1.70 } __obj;
1.71
1.72 -typedef __obj * __ref;
1.73 +#define __INSTANCE_SIZE(NUMBER) ((NUMBER) * sizeof(__attr) + sizeof(__table *) + sizeof(__ppos))
1.74
1.75 /* Fragments are simple collections of attributes employed by sequence types.
1.76 They provide the basis of lists and tuples. */
1.77 @@ -109,7 +100,7 @@
1.78 __attr attrs[];
1.79 } __fragment;
1.80
1.81 -#define __FRAGMENT_SIZE(NUMBER) (NUMBER * sizeof(__attr) + 2 * sizeof(unsigned int))
1.82 +#define __FRAGMENT_SIZE(NUMBER) ((NUMBER) * sizeof(__attr) + 2 * sizeof(unsigned int))
1.83
1.84 /* Special instance position value. The pos member of __obj refers to the
1.85 special type attribute for classes, indicating which position holds the
1.86 @@ -119,7 +110,7 @@
1.87
1.88 /* Special null values. */
1.89
1.90 -#define __NULL ((__attr) {{.context=0, .value=0}})
1.91 +#define __NULL ((__attr) {.value=0})
1.92
1.93 /* Function pointer type. */
1.94