fixes with error_type, make "type" struct more compact.
This commit is contained in:
parent
287a122d85
commit
d843ec9f7a
3 changed files with 24 additions and 16 deletions
|
@ -1 +1 @@
|
|||
static char Version[] = "ACK Modula-2 compiler Version 0.11";
|
||||
static char Version[] = "ACK Modula-2 compiler Version 0.12";
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue