From f0fc857cb4574272d963380a9b439cd10f469775 Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 24 Aug 1987 11:42:37 +0000 Subject: [PATCH] compiler could not handle using addresses of procedures declared in imported definition modules. This is corrected --- lang/m2/comp/Version.c | 2 +- lang/m2/comp/code.c | 26 ++++++++++++++++---------- lang/m2/comp/def.H | 1 - lang/m2/comp/def.c | 2 +- lang/m2/comp/type.c | 4 ---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lang/m2/comp/Version.c b/lang/m2/comp/Version.c index 29da44a6c..037046d2e 100644 --- a/lang/m2/comp/Version.c +++ b/lang/m2/comp/Version.c @@ -1 +1 @@ -static char Version[] = "ACK Modula-2 compiler Version 0.14"; +static char Version[] = "ACK Modula-2 compiler Version 0.15"; diff --git a/lang/m2/comp/code.c b/lang/m2/comp/code.c index 96ba137f1..4fa5c8c78 100644 --- a/lang/m2/comp/code.c +++ b/lang/m2/comp/code.c @@ -37,6 +37,19 @@ extern int proclevel; extern char options[]; int fp_used; +STATIC char * +NameOfProc(df) + register struct def *df; +{ + + assert(df->df_kind & (D_PROCHEAD|D_PROCEDURE)); + + if (df->df_kind == D_PROCEDURE) { + return df->prc_vis->sc_scope->sc_name; + } + return df->for_name; +} + CodeConst(cst, size) arith cst; int size; @@ -293,7 +306,6 @@ CodeCall(nd) and result is already done. */ register struct node *left = nd->nd_left; - register struct def *df; register struct node *right = nd->nd_right; register struct type *result_tp; @@ -319,19 +331,13 @@ CodeCall(nd) switch(left->nd_class) { case Def: { - df = left->nd_def; - - if (df->df_kind == D_PROCEDURE) { - int level = df->df_scope->sc_level; + if (left->nd_def->df_kind & (D_PROCEDURE|D_PROCHEAD)) { + int level = left->nd_def->df_scope->sc_level; if (level > 0) { C_lxl((arith) (proclevel - level)); } - C_cal(NameOfProc(df)); - break; - } - else if (df->df_kind == D_PROCHEAD) { - C_cal(df->for_name); + C_cal(NameOfProc(left->nd_def)); break; }} /* Fall through */ diff --git a/lang/m2/comp/def.H b/lang/m2/comp/def.H index 0635fd01b..ebedc9736 100644 --- a/lang/m2/comp/def.H +++ b/lang/m2/comp/def.H @@ -53,7 +53,6 @@ struct dfproc { struct node *pr_body; /* body of this procedure */ #define prc_vis df_value.df_proc.pr_vis #define prc_body df_value.df_proc.pr_body -#define NameOfProc(xdf) ((xdf)->prc_vis->sc_scope->sc_name) }; struct import { diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 6cbe9bade..ca11c871e 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -279,8 +279,8 @@ DeclProc(type, id) scope = CurrentScope; scope->sc_name = name; scope->sc_definedby = df; - df->prc_vis = CurrVis; } + df->prc_vis = CurrVis; return df; } diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index 91430f91c..bde89b719 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -313,8 +313,6 @@ chk_basesubrange(tp, base) } tp->tp_next = base; - tp->tp_size = base->tp_size; - tp->tp_align = base->tp_align; } int @@ -374,8 +372,6 @@ subr_type(lb, ub) res = construct_type(T_SUBRANGE, tp); res->sub_lb = lb->nd_INT; res->sub_ub = ub->nd_INT; - res->tp_size = tp->tp_size; - res->tp_align = tp->tp_align; if (tp == card_type) { u_small(res, res->sub_ub); }