bug fixes, name changes

This commit is contained in:
ceriel 1987-07-16 19:51:40 +00:00
parent 4804ab14b8
commit e04230a126
17 changed files with 85 additions and 82 deletions

View file

@ -34,7 +34,6 @@
#include "density.h"
struct switch_hdr {
struct switch_hdr *next; /* in the free list */
label sh_break; /* label of statement after this one */
label sh_default; /* label of ELSE part, or 0 */
int sh_nrofentries; /* number of cases */
@ -245,7 +244,7 @@ AddCases(sh, node, lbl)
AddOneCase(sh, node, lbl)
register struct switch_hdr *sh;
register struct node *node;
struct node *node;
label lbl;
{
register struct case_entry *ce = new_case_entry();

View file

@ -537,7 +537,7 @@ ChkProcCall(expp)
/* Check parameter list
*/
for (param = ParamList(left->nd_type); param; param = param->next) {
for (param = ParamList(left->nd_type); param; param = param->par_next) {
if (!(left = getarg(&expp, 0, IsVarParam(param), edf))) {
return 0;
}

View file

@ -348,8 +348,8 @@ CodeParameters(param, arg)
assert(param != 0 && arg != 0);
if (param->next) {
CodeParameters(param->next, arg->nd_right);
if (param->par_next) {
CodeParameters(param->par_next, arg->nd_right);
}
tp = TypeOfParam(param);

View file

@ -218,11 +218,11 @@ IdentList(struct node **p;)
IDENT { *p = q = MkLeaf(Value, &dot); }
[ %persistent
',' IDENT
{ q->next = MkLeaf(Value, &dot);
q = q->next;
{ q->nd_left = MkLeaf(Value, &dot);
q = q->nd_left;
}
]*
{ q->next = 0; }
{ q->nd_left = 0; }
;
SubrangeType(struct type **ptp;)
@ -416,7 +416,7 @@ SetType(struct type **ptp;) :
PointerType(register struct type **ptp;) :
POINTER TO
[ %if (type_or_forward(ptp))
type(&((*ptp)->next))
type(&((*ptp)->tp_next))
|
IDENT
]

View file

@ -76,7 +76,7 @@ struct forwtype {
};
struct def { /* list of definitions for a name */
struct def *next; /* next definition in definitions chain */
struct def *df_next; /* next definition in definitions chain */
struct def *df_nextinscope;
/* link all definitions in a scope */
struct idf *df_idf; /* link back to the name */

View file

@ -74,7 +74,7 @@ MkDef(id, scope, kind)
df->df_idf = id;
df->df_scope = scope;
df->df_kind = kind;
df->next = id->id_def;
df->df_next = id->id_def;
id->id_def = df;
/* enter the definition in the list of definitions in this scope
@ -211,13 +211,13 @@ RemoveFromIdList(df)
register struct idf *id = df->df_idf;
register struct def *df1;
if ((df1 = id->id_def) == df) id->id_def = df->next;
if ((df1 = id->id_def) == df) id->id_def = df->df_next;
else {
while (df1->next != df) {
assert(df1->next != 0);
df1 = df1->next;
while (df1->df_next != df) {
assert(df1->df_next != 0);
df1 = df1->df_next;
}
df1->next = df->next;
df1->df_next = df->df_next;
}
}

View file

@ -131,7 +131,7 @@ GetDefinitionModule(id, incr)
n = MkLeaf(Name, &dot);
n->nd_IDF = id;
n->nd_symb = IDENT;
if (nd_end) nd_end->next = n;
if (nd_end) nd_end->nd_left = n;
else Modules = n;
nd_end = n;
}

View file

@ -107,6 +107,7 @@ CodeValue(ds, tp)
/* Generate code to load the value of the designator described
in "ds"
*/
arith sz;
switch(ds->dsg_kind) {
case DSG_LOADED:
@ -117,13 +118,14 @@ CodeValue(ds, tp)
/* Fall through */
case DSG_PLOADED:
case DSG_PFIXED:
sz = WA(tp->tp_size);
if (properly(ds, tp->tp_size, tp->tp_align)) {
CodeAddress(ds);
C_loi(tp->tp_size);
break;
}
if (ds->dsg_kind == DSG_PLOADED) {
arith sz = WA(tp->tp_size) - pointer_size;
sz -= pointer_size;
C_asp(-sz);
C_lor((arith) 1);
@ -131,9 +133,9 @@ CodeValue(ds, tp)
C_loi(pointer_size);
}
else {
C_asp(-WA(tp->tp_size));
CodeAddress(ds);
C_asp(-sz);
}
CodeAddress(ds);
C_loc(tp->tp_size);
C_cal("_load");
C_asp(2 * word_size);

View file

@ -69,7 +69,7 @@ EnterEnumList(Idlist, type)
register struct node *idlist = Idlist;
type->enm_ncst = 0;
for (; idlist; idlist = idlist->next) {
for (; idlist; idlist = idlist->nd_left) {
df = define(idlist->nd_IDF, CurrentScope, D_ENUM);
df->df_type = type;
df->enm_val = (type->enm_ncst)++;
@ -93,7 +93,7 @@ EnterFieldList(Idlist, type, scope, addr)
register struct def *df;
register struct node *idlist = Idlist;
for (; idlist; idlist = idlist->next) {
for (; idlist; idlist = idlist->nd_left) {
df = define(idlist->nd_IDF, scope, D_FIELD);
df->df_type = type;
df->df_flags |= D_QEXPORTED;
@ -198,11 +198,11 @@ EnterParamList(ppr, Idlist, type, VARp, off)
/* Can only happen when a procedure type is defined */
dummy = Idlist = idlist = MkLeaf(Name, &dot);
}
for ( ; idlist; idlist = idlist->next) {
for ( ; idlist; idlist = idlist->nd_left) {
pr = new_paramlist();
pr->next = 0;
pr->par_next = 0;
if (!*ppr) *ppr = pr;
else last->next = pr;
else last->par_next = pr;
last = pr;
if (!DefinitionModule && idlist != dummy) {
df = define(idlist->nd_IDF, CurrentScope, D_VARIABLE);
@ -322,7 +322,7 @@ EnterExportList(Idlist, qualified)
register struct node *idlist = Idlist;
register struct def *df, *df1;
for (;idlist; idlist = idlist->next) {
for (;idlist; idlist = idlist->nd_left) {
df = lookup(idlist->nd_IDF, CurrentScope, 0);
if (!df) {
@ -354,7 +354,7 @@ EnterExportList(Idlist, qualified)
df1->imp_def == CurrentScope->sc_definedby) {
DoImport(df, df1->df_scope);
}
df1 = df1->next;
df1 = df1->df_next;
}
/* Also handle the definition as if the enclosing
@ -427,7 +427,7 @@ node_error(FromId,"identifier \"%s\" does not represent a module",module_name);
return;
}
for (; idlist; idlist = idlist->next) {
for (; idlist; idlist = idlist->nd_left) {
if (forwflag) df = ForwDef(idlist, vis->sc_scope);
else if (! (df = lookup(idlist->nd_IDF, vis->sc_scope, 1))) {
if (! is_anon_idf(idlist->nd_IDF)) {
@ -464,7 +464,7 @@ EnterImportList(Idlist, local)
struct scope *sc = enclosing(CurrVis)->sc_scope;
extern struct def *GetDefinitionModule();
for (; idlist; idlist = idlist->next) {
for (; idlist; idlist = idlist->nd_left) {
DoImport(local ?
ForwDef(idlist, sc) :
GetDefinitionModule(idlist->nd_IDF, 1) ,

View file

@ -40,7 +40,7 @@ lookup(id, scope, import)
*/
for (df = id->id_def, df1 = 0;
df && df->df_scope != scope;
df1 = df, df = df->next) { /* nothing */ }
df1 = df, df = df->df_next) { /* nothing */ }
if (df) {
/* Found it
@ -48,8 +48,8 @@ lookup(id, scope, import)
if (df1) {
/* Put the definition in front
*/
df1->next = df->next;
df->next = id->id_def;
df1->df_next = df->df_next;
df->df_next = id->id_def;
id->id_def = df;
}
if (import && df->df_kind == D_IMPORT) {

View file

@ -10,8 +10,7 @@
/* $Header$ */
struct node {
struct node *next;
#define nd_left next
struct node *nd_left;
struct node *nd_right;
int nd_class; /* kind of node */
#define Value 0 /* constant */

View file

@ -47,9 +47,9 @@ open_scope(scopetype)
ls->sc_scope = sc;
ls->sc_encl = CurrVis;
if (scopetype == OPENSCOPE) {
ls->next = ls->sc_encl;
ls->sc_next = ls->sc_encl;
}
else ls->next = PervVis;
else ls->sc_next = PervVis;
CurrVis = ls;
}
@ -73,7 +73,7 @@ InitScope()
sc->sc_def = 0;
sc->sc_level = proclevel;
PervasiveScope = sc;
ls->next = 0;
ls->sc_next = 0;
ls->sc_encl = 0;
ls->sc_scope = PervasiveScope;
PervVis = ls;
@ -126,7 +126,7 @@ chk_forw(pdf)
node_error(nd, "\"%s\" is not a type", df1->df_idf->id_text);
}
while (nd) {
nd->nd_type->next = df->df_type;
nd->nd_type->tp_next = df->df_type;
nd = nd->nd_right;
}
FreeNode(df1->df_forw_node);
@ -138,7 +138,7 @@ node_error(nd, "\"%s\" is not a type", df1->df_idf->id_text);
df->df_kind = D_TYPE;
while (nd) {
nd->nd_type->next = df->df_type;
nd->nd_type->tp_next = df->df_type;
nd = nd->nd_right;
}
FreeNode(df->df_forw_node);
@ -166,7 +166,7 @@ df->df_idf->id_text);
struct def *df1 = df->df_nextinscope;
if (df->df_kind == D_FORWMODULE) {
df->for_vis->next = ls;
df->for_vis->sc_next = ls;
}
df->df_nextinscope = ls->sc_scope->sc_def;
ls->sc_scope->sc_def = df;

View file

@ -23,7 +23,7 @@
*/
struct scope {
struct scope *next;
/* struct scope *next; */
char *sc_name; /* name of this scope */
struct def *sc_def; /* list of definitions in this scope */
arith sc_off; /* offsets of variables in this scope */
@ -33,7 +33,7 @@ struct scope {
};
struct scopelist {
struct scopelist *next;
struct scopelist *sc_next;
struct scope *sc_scope;
struct scopelist *sc_encl;
};
@ -48,6 +48,6 @@ extern struct scopelist
#define GlobalScope (GlobalVis->sc_scope)
#define enclosing(x) ((x)->sc_encl)
#define scopeclosed(x) ((x)->sc_scopeclosed)
#define nextvisible(x) ((x)->next) /* use with scopelists */
#define nextvisible(x) ((x)->sc_next) /* use with scopelists */
struct scope *open_and_close_scope();

View file

@ -10,7 +10,7 @@
/* $Header$ */
struct paramlist { /* structure for parameterlist of a PROCEDURE */
struct paramlist *next;
struct paramlist *par_next;
struct def *par_def; /* "df" of parameter */
#define IsVarParam(xpar) ((int) ((xpar)->par_def->df_flags & D_VARPAR))
#define TypeOfParam(xpar) ((xpar)->par_def->df_type)
@ -27,6 +27,8 @@ struct enume {
#define enm_rck tp_value.tp_enum->en_rck
};
/* ALLOCDEF "enume" 5 */
struct subrange {
arith su_lb, su_ub; /* lower bound and upper bound */
label su_rck; /* label of range check descriptor */
@ -35,6 +37,8 @@ struct subrange {
#define sub_rck tp_value.tp_subrange->su_rck
};
/* ALLOCDEF "subrange" 5 */
struct array {
struct type *ar_elem; /* type of elements */
label ar_descr; /* label of array descriptor */
@ -44,6 +48,8 @@ struct array {
#define arr_elsize tp_value.tp_arr->ar_elsize
};
/* ALLOCDEF "array" 5 */
struct record {
struct scope *rc_scope; /* scope of this record */
/* members are in the symbol table */
@ -58,7 +64,7 @@ struct proc {
};
struct type {
struct type *next; /* used with ARRAY, PROCEDURE, POINTER, SET,
struct type *tp_next; /* used with ARRAY, PROCEDURE, POINTER, SET,
SUBRANGE, EQUAL
*/
int tp_fund; /* fundamental type or constructor */
@ -146,29 +152,29 @@ struct type
#define NULLTYPE ((struct type *) 0)
#define IsConformantArray(tpx) ((tpx)->tp_fund==T_ARRAY && (tpx)->next==0)
#define IsConformantArray(tpx) ((tpx)->tp_fund==T_ARRAY && (tpx)->tp_next==0)
#define bounded(tpx) ((tpx)->tp_fund & T_INDEX)
#define complex(tpx) ((tpx)->tp_fund & (T_RECORD|T_ARRAY))
#define WA(sz) (align(sz, (int) word_size))
#ifdef DEBUG
#define ResultType(tpx) (assert((tpx)->tp_fund == T_PROCEDURE),\
(tpx)->next)
(tpx)->tp_next)
#define ParamList(tpx) (assert((tpx)->tp_fund == T_PROCEDURE),\
(tpx)->prc_params)
#define IndexType(tpx) (assert((tpx)->tp_fund == T_ARRAY),\
(tpx)->next)
(tpx)->tp_next)
#define ElementType(tpx) (assert((tpx)->tp_fund == T_SET),\
(tpx)->next)
(tpx)->tp_next)
#define PointedtoType(tpx) (assert((tpx)->tp_fund == T_POINTER),\
(tpx)->next)
(tpx)->tp_next)
#else DEBUG
#define ResultType(tpx) ((tpx)->next)
#define ResultType(tpx) ((tpx)->tp_next)
#define ParamList(tpx) ((tpx)->prc_params)
#define IndexType(tpx) ((tpx)->next)
#define ElementType(tpx) ((tpx)->next)
#define PointedtoType(tpx) ((tpx)->next)
#define IndexType(tpx) ((tpx)->tp_next)
#define ElementType(tpx) ((tpx)->tp_next)
#define PointedtoType(tpx) ((tpx)->tp_next)
#endif DEBUG
#define BaseType(tpx) ((tpx)->tp_fund == T_SUBRANGE ? (tpx)->next : \
#define BaseType(tpx) ((tpx)->tp_fund == T_SUBRANGE ? (tpx)->tp_next : \
(tpx))
#define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED)

View file

@ -91,15 +91,13 @@ construct_type(fund, tp)
break;
case T_ARRAY:
dtp->tp_value.tp_arr =
(struct array *) Malloc(sizeof(struct array));
dtp->tp_value.tp_arr = new_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_value.tp_subrange = new_subrange();
dtp->tp_align = tp->tp_align;
dtp->tp_size = tp->tp_size;
break;
@ -108,7 +106,7 @@ construct_type(fund, tp)
crash("funny type constructor");
}
dtp->next = tp;
dtp->tp_next = tp;
return dtp;
}
@ -135,8 +133,7 @@ standard_type(fund, align, size)
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));
tp->tp_value.tp_enum = new_enume();
}
return tp;
@ -293,26 +290,26 @@ chk_basesubrange(tp, base)
if (base->sub_lb > tp->sub_lb || base->sub_ub < tp->sub_ub) {
error("base type has insufficient range");
}
base = base->next;
base = base->tp_next;
}
if (base->tp_fund & (T_ENUMERATION|T_CHAR)) {
if (tp->next != base) {
if (tp->tp_next != base) {
error("specified base does not conform");
}
}
else if (base != card_type && base != int_type) {
error("illegal base for a subrange");
}
else if (base == int_type && tp->next == card_type &&
else if (base == int_type && tp->tp_next == card_type &&
(tp->sub_ub > max_int || tp->sub_ub < 0)) {
error("upperbound to large for type INTEGER");
}
else if (base != tp->next && base != int_type) {
else if (base != tp->tp_next && base != int_type) {
error("specified base does not conform");
}
tp->next = base;
tp->tp_next = base;
tp->tp_size = base->tp_size;
tp->tp_align = base->tp_align;
}
@ -533,7 +530,7 @@ FreeType(tp)
pr = ParamList(tp);
while (pr) {
pr1 = pr;
pr = pr->next;
pr = pr->par_next;
free_def(pr1->par_def);
free_paramlist(pr1);
}
@ -559,10 +556,10 @@ DeclareType(nd, df, tp)
"opaque type \"%s\" is not a pointer type",
df->df_idf->id_text);
}
df->df_type->next = tp;
df->df_type->tp_next = tp;
df->df_type->tp_fund = T_EQUAL;
while (tp != df->df_type && tp->tp_fund == T_EQUAL) {
tp = tp->next;
tp = tp->tp_next;
}
if (tp == df->df_type) {
/* Circular definition! */
@ -579,7 +576,7 @@ RemoveEqual(tpx)
register struct type *tpx;
{
if (tpx) while (tpx->tp_fund == T_EQUAL) tpx = tpx->next;
if (tpx) while (tpx->tp_fund == T_EQUAL) tpx = tpx->tp_next;
return tpx;
}
@ -631,7 +628,7 @@ type_or_forward(ptp)
define(nd->nd_IDF, CurrentScope, D_FORWTYPE);
if (df->df_kind == D_TYPE) {
(*ptp)->next = df->df_type;
(*ptp)->tp_next = df->df_type;
free_node(nd);
}
else {
@ -716,7 +713,7 @@ DumpType(tp)
while(par) {
if (IsVarParam(par)) print("VAR ");
DumpType(TypeOfParam(par));
par = par->next;
par = par->par_next;
}
}
break;
@ -726,7 +723,7 @@ DumpType(tp)
print("; element:");
DumpType(tp->arr_elem);
print("; index:");
DumpType(tp->next);
DumpType(tp->tp_next);
print(";");
return;
case T_STRING:
@ -736,11 +733,11 @@ DumpType(tp)
default:
crash("DumpType");
}
if (tp->next && tp->tp_fund != T_POINTER) {
if (tp->tp_next && tp->tp_fund != T_POINTER) {
/* Avoid printing recursive types!
*/
print(" next:(");
DumpType(tp->next);
DumpType(tp->tp_next);
print(")");
}
print(";");

View file

@ -83,8 +83,8 @@ TstProcEquiv(tp1, tp2)
while (p1 && p2) {
if (IsVarParam(p1) != IsVarParam(p2) ||
!TstParEquiv(TypeOfParam(p1), TypeOfParam(p2))) return 0;
p1 = p1->next;
p2 = p2->next;
p1 = p1->par_next;
p2 = p2->par_next;
}
/* Here, at least one of the parameterlists is exhausted.

View file

@ -136,7 +136,7 @@ WalkModule(module)
C_ine_dlb(data_label, (arith) 0);
}
for (; nd; nd = nd->next) {
for (; nd; nd = nd->nd_left) {
C_cal(nd->nd_IDF->id_text);
}
}
@ -213,7 +213,7 @@ WalkProcedure(procedure)
*/
for (param = ParamList(procedure->df_type);
param;
param = param->next) {
param = param->par_next) {
if (! IsVarParam(param)) {
register struct type *TpParam = TypeOfParam(param);
@ -544,10 +544,10 @@ WalkStat(nd, exit_label)
/* the record is indirectly available */
wds.w_desig = ds;
link.sc_scope = wds.w_scope;
link.next = CurrVis;
link.sc_next = CurrVis;
CurrVis = &link;
WalkNode(right, exit_label);
CurrVis = link.next;
CurrVis = link.sc_next;
WithDesigs = wds.w_next;
FreePtr(ds.dsg_offset);
break;