compiler could not handle using addresses of procedures declared

in imported definition modules. This is corrected
This commit is contained in:
ceriel 1987-08-24 11:42:37 +00:00
parent 469b3cc1e1
commit f0fc857cb4
5 changed files with 18 additions and 17 deletions

View file

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

View file

@ -37,6 +37,19 @@ extern int proclevel;
extern char options[]; extern char options[];
int fp_used; 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) CodeConst(cst, size)
arith cst; arith cst;
int size; int size;
@ -293,7 +306,6 @@ CodeCall(nd)
and result is already done. and result is already done.
*/ */
register struct node *left = nd->nd_left; register struct node *left = nd->nd_left;
register struct def *df;
register struct node *right = nd->nd_right; register struct node *right = nd->nd_right;
register struct type *result_tp; register struct type *result_tp;
@ -319,19 +331,13 @@ CodeCall(nd)
switch(left->nd_class) { switch(left->nd_class) {
case Def: { case Def: {
df = left->nd_def; if (left->nd_def->df_kind & (D_PROCEDURE|D_PROCHEAD)) {
int level = left->nd_def->df_scope->sc_level;
if (df->df_kind == D_PROCEDURE) {
int level = df->df_scope->sc_level;
if (level > 0) { if (level > 0) {
C_lxl((arith) (proclevel - level)); C_lxl((arith) (proclevel - level));
} }
C_cal(NameOfProc(df)); C_cal(NameOfProc(left->nd_def));
break;
}
else if (df->df_kind == D_PROCHEAD) {
C_cal(df->for_name);
break; break;
}} }}
/* Fall through */ /* Fall through */

View file

@ -53,7 +53,6 @@ struct dfproc {
struct node *pr_body; /* body of this procedure */ struct node *pr_body; /* body of this procedure */
#define prc_vis df_value.df_proc.pr_vis #define prc_vis df_value.df_proc.pr_vis
#define prc_body df_value.df_proc.pr_body #define prc_body df_value.df_proc.pr_body
#define NameOfProc(xdf) ((xdf)->prc_vis->sc_scope->sc_name)
}; };
struct import { struct import {

View file

@ -279,8 +279,8 @@ DeclProc(type, id)
scope = CurrentScope; scope = CurrentScope;
scope->sc_name = name; scope->sc_name = name;
scope->sc_definedby = df; scope->sc_definedby = df;
df->prc_vis = CurrVis;
} }
df->prc_vis = CurrVis;
return df; return df;
} }

View file

@ -313,8 +313,6 @@ chk_basesubrange(tp, base)
} }
tp->tp_next = base; tp->tp_next = base;
tp->tp_size = base->tp_size;
tp->tp_align = base->tp_align;
} }
int int
@ -374,8 +372,6 @@ subr_type(lb, ub)
res = construct_type(T_SUBRANGE, tp); res = construct_type(T_SUBRANGE, tp);
res->sub_lb = lb->nd_INT; res->sub_lb = lb->nd_INT;
res->sub_ub = ub->nd_INT; res->sub_ub = ub->nd_INT;
res->tp_size = tp->tp_size;
res->tp_align = tp->tp_align;
if (tp == card_type) { if (tp == card_type) {
u_small(res, res->sub_ub); u_small(res, res->sub_ub);
} }