From: ceriel Date: Thu, 16 Jul 1987 09:34:44 +0000 (+0000) Subject: fixes with error_type, make "type" struct more compact. X-Git-Tag: release-5-5~4007 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d843ec9f7a4fe1297695f1e79fc932ff90362793;p=ack.git fixes with error_type, make "type" struct more compact. --- diff --git a/lang/m2/comp/Version.c b/lang/m2/comp/Version.c index 4d0d18f87..5fbfc3909 100644 --- a/lang/m2/comp/Version.c +++ b/lang/m2/comp/Version.c @@ -1 +1 @@ -static char Version[] = "ACK Modula-2 compiler Version 0.11"; +static char Version[] = "ACK Modula-2 compiler Version 0.12"; diff --git a/lang/m2/comp/type.H b/lang/m2/comp/type.H index 028a0e431..bf55b40e3 100644 --- a/lang/m2/comp/type.H +++ b/lang/m2/comp/type.H @@ -22,26 +22,26 @@ struct enume { struct def *en_enums; /* Definitions of enumeration literals */ arith en_ncst; /* Number of constants */ label en_rck; /* Label of range check descriptor */ -#define enm_enums tp_value.tp_enum.en_enums -#define enm_ncst tp_value.tp_enum.en_ncst -#define enm_rck tp_value.tp_enum.en_rck +#define enm_enums tp_value.tp_enum->en_enums +#define enm_ncst tp_value.tp_enum->en_ncst +#define enm_rck tp_value.tp_enum->en_rck }; struct subrange { arith su_lb, su_ub; /* lower bound and upper bound */ label su_rck; /* label of range check descriptor */ -#define sub_lb tp_value.tp_subrange.su_lb -#define sub_ub tp_value.tp_subrange.su_ub -#define sub_rck tp_value.tp_subrange.su_rck +#define sub_lb tp_value.tp_subrange->su_lb +#define sub_ub tp_value.tp_subrange->su_ub +#define sub_rck tp_value.tp_subrange->su_rck }; struct array { struct type *ar_elem; /* type of elements */ label ar_descr; /* label of array descriptor */ arith ar_elsize; /* size of elements */ -#define arr_elem tp_value.tp_arr.ar_elem -#define arr_descr tp_value.tp_arr.ar_descr -#define arr_elsize tp_value.tp_arr.ar_elsize +#define arr_elem tp_value.tp_arr->ar_elem +#define arr_descr tp_value.tp_arr->ar_descr +#define arr_elsize tp_value.tp_arr->ar_elsize }; struct record { @@ -85,9 +85,9 @@ struct type { int tp_align; /* alignment requirement of this type */ arith tp_size; /* size of this type */ union { - struct enume tp_enum; - struct subrange tp_subrange; - struct array tp_arr; + struct enume *tp_enum; + struct subrange *tp_subrange; + struct array *tp_arr; struct record tp_record; struct proc tp_proc; } tp_value; @@ -174,5 +174,5 @@ struct type 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) diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index a0604ba5d..b4dd3ecd3 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -91,11 +91,15 @@ construct_type(fund, tp) break; case T_ARRAY: + dtp->tp_value.tp_arr = + (struct array *) Malloc(sizeof(struct array)); if (tp) dtp->tp_align = tp->tp_align; break; case T_SUBRANGE: assert(tp != 0); + dtp->tp_value.tp_subrange = + (struct subrange *) Malloc(sizeof(struct subrange)); dtp->tp_align = tp->tp_align; dtp->tp_size = tp->tp_size; break; @@ -130,6 +134,10 @@ standard_type(fund, align, size) tp->tp_fund = fund; tp->tp_align = align; tp->tp_size = size; + if (fund == T_ENUMERATION || fund == T_CHAR) { + tp->tp_value.tp_enum = + (struct enume *) Malloc(sizeof(struct enume)); + } return tp; } @@ -204,7 +212,8 @@ InitTypes() /* a unique type indicating an error */ - error_type = standard_type(T_CHAR, 1, (arith) 1); + error_type = new_type(); + *error_type = *char_type; } STATIC @@ -241,7 +250,6 @@ struct type * qualified_type(nd) register struct node *nd; { - struct type *tp = error_type; register struct def *df; if (ChkDesignator(nd)) {