fixes with error_type, make "type" struct more compact.

This commit is contained in:
ceriel 1987-07-16 09:34:44 +00:00
parent 287a122d85
commit d843ec9f7a
3 changed files with 24 additions and 16 deletions

View file

@ -1 +1 @@
static char Version[] = "ACK Modula-2 compiler Version 0.11"; static char Version[] = "ACK Modula-2 compiler Version 0.12";

View file

@ -22,26 +22,26 @@ struct enume {
struct def *en_enums; /* Definitions of enumeration literals */ struct def *en_enums; /* Definitions of enumeration literals */
arith en_ncst; /* Number of constants */ arith en_ncst; /* Number of constants */
label en_rck; /* Label of range check descriptor */ label en_rck; /* Label of range check descriptor */
#define enm_enums tp_value.tp_enum.en_enums #define enm_enums tp_value.tp_enum->en_enums
#define enm_ncst tp_value.tp_enum.en_ncst #define enm_ncst tp_value.tp_enum->en_ncst
#define enm_rck tp_value.tp_enum.en_rck #define enm_rck tp_value.tp_enum->en_rck
}; };
struct subrange { struct subrange {
arith su_lb, su_ub; /* lower bound and upper bound */ arith su_lb, su_ub; /* lower bound and upper bound */
label su_rck; /* label of range check descriptor */ label su_rck; /* label of range check descriptor */
#define sub_lb tp_value.tp_subrange.su_lb #define sub_lb tp_value.tp_subrange->su_lb
#define sub_ub tp_value.tp_subrange.su_ub #define sub_ub tp_value.tp_subrange->su_ub
#define sub_rck tp_value.tp_subrange.su_rck #define sub_rck tp_value.tp_subrange->su_rck
}; };
struct array { struct array {
struct type *ar_elem; /* type of elements */ struct type *ar_elem; /* type of elements */
label ar_descr; /* label of array descriptor */ label ar_descr; /* label of array descriptor */
arith ar_elsize; /* size of elements */ arith ar_elsize; /* size of elements */
#define arr_elem tp_value.tp_arr.ar_elem #define arr_elem tp_value.tp_arr->ar_elem
#define arr_descr tp_value.tp_arr.ar_descr #define arr_descr tp_value.tp_arr->ar_descr
#define arr_elsize tp_value.tp_arr.ar_elsize #define arr_elsize tp_value.tp_arr->ar_elsize
}; };
struct record { struct record {
@ -85,9 +85,9 @@ struct type {
int tp_align; /* alignment requirement of this type */ int tp_align; /* alignment requirement of this type */
arith tp_size; /* size of this type */ arith tp_size; /* size of this type */
union { union {
struct enume tp_enum; struct enume *tp_enum;
struct subrange tp_subrange; struct subrange *tp_subrange;
struct array tp_arr; struct array *tp_arr;
struct record tp_record; struct record tp_record;
struct proc tp_proc; struct proc tp_proc;
} tp_value; } tp_value;
@ -174,5 +174,5 @@ struct type
extern long full_mask[]; extern long full_mask[];
#define fit(n, i) (((n) + (0x80<<(((i)-1)*8)) & ~full_mask[(i)]) == 0) #define fit(n, i) (((n) + ((arith)0x80<<(((i)-1)*8)) & ~full_mask[(i)]) == 0)
#define ufit(n, i) (((n) & ~full_mask[(i)]) == 0) #define ufit(n, i) (((n) & ~full_mask[(i)]) == 0)

View file

@ -91,11 +91,15 @@ construct_type(fund, tp)
break; break;
case T_ARRAY: case T_ARRAY:
dtp->tp_value.tp_arr =
(struct array *) Malloc(sizeof(struct array));
if (tp) dtp->tp_align = tp->tp_align; if (tp) dtp->tp_align = tp->tp_align;
break; break;
case T_SUBRANGE: case T_SUBRANGE:
assert(tp != 0); assert(tp != 0);
dtp->tp_value.tp_subrange =
(struct subrange *) Malloc(sizeof(struct subrange));
dtp->tp_align = tp->tp_align; dtp->tp_align = tp->tp_align;
dtp->tp_size = tp->tp_size; dtp->tp_size = tp->tp_size;
break; break;
@ -130,6 +134,10 @@ standard_type(fund, align, size)
tp->tp_fund = fund; tp->tp_fund = fund;
tp->tp_align = align; tp->tp_align = align;
tp->tp_size = size; tp->tp_size = size;
if (fund == T_ENUMERATION || fund == T_CHAR) {
tp->tp_value.tp_enum =
(struct enume *) Malloc(sizeof(struct enume));
}
return tp; return tp;
} }
@ -204,7 +212,8 @@ InitTypes()
/* a unique type indicating an error /* a unique type indicating an error
*/ */
error_type = standard_type(T_CHAR, 1, (arith) 1); error_type = new_type();
*error_type = *char_type;
} }
STATIC STATIC
@ -241,7 +250,6 @@ struct type *
qualified_type(nd) qualified_type(nd)
register struct node *nd; register struct node *nd;
{ {
struct type *tp = error_type;
register struct def *df; register struct def *df;
if (ChkDesignator(nd)) { if (ChkDesignator(nd)) {