changed some names of field selectors
This commit is contained in:
parent
50a71251a1
commit
8e9f1f781c
6 changed files with 120 additions and 120 deletions
|
@ -111,23 +111,23 @@ void code_val(e) register struct expr *e;
|
|||
case E_VAR: {
|
||||
register struct symbol *var=e->u.var;
|
||||
|
||||
if (var->type&T_BUILTIN)
|
||||
Loe(var->info.vc.st.builtin, var->info.vc.offset);
|
||||
if (var->s_type&T_BUILTIN)
|
||||
Loe(var->s_info.vc.st.builtin, var->s_info.vc.offset);
|
||||
else
|
||||
if (var->info.vc.st.level==curr_level)
|
||||
if (var->type&T_PARAM && (var->type&T_TYPE)!=T_VALUE)
|
||||
Lil(var->info.vc.offset);
|
||||
if (var->s_info.vc.st.level==curr_level)
|
||||
if (var->s_type&T_PARAM && (var->s_type&T_TYPE)!=T_VALUE)
|
||||
Lil(var->s_info.vc.offset);
|
||||
else
|
||||
Lol(var->info.vc.offset);
|
||||
Lol(var->s_info.vc.offset);
|
||||
else {
|
||||
if (var->info.vc.offset<0)
|
||||
lxl(curr_level-var->info.vc.st.level);
|
||||
if (var->s_info.vc.offset<0)
|
||||
lxl(curr_level-var->s_info.vc.st.level);
|
||||
else
|
||||
lxa(curr_level-var->info.vc.st.level);
|
||||
if (var->type&T_PARAM && (var->type&T_TYPE)!=T_VALUE)
|
||||
Lif(var->info.vc.offset);
|
||||
lxa(curr_level-var->s_info.vc.st.level);
|
||||
if (var->s_type&T_PARAM && (var->s_type&T_TYPE)!=T_VALUE)
|
||||
Lif(var->s_info.vc.offset);
|
||||
else
|
||||
Lof(var->info.vc.offset);
|
||||
Lof(var->s_info.vc.offset);
|
||||
}
|
||||
}break;
|
||||
case E_CONST:
|
||||
|
@ -233,25 +233,25 @@ void code_addr(e) register struct expr *e;
|
|||
case E_VAR: { /* variable or channel */
|
||||
register struct symbol *var=e->u.var;
|
||||
|
||||
if (var->type&T_BUILTIN)
|
||||
lae(var->info.vc.st.builtin, var->info.vc.offset);
|
||||
if (var->s_type&T_BUILTIN)
|
||||
lae(var->s_info.vc.st.builtin, var->s_info.vc.offset);
|
||||
else
|
||||
if (var->info.vc.st.level==curr_level)
|
||||
if (var->type&T_PARAM
|
||||
&& (var->type&(T_TYPE|T_ARR))!=T_VALUE)
|
||||
Lolp(var->info.vc.offset);
|
||||
if (var->s_info.vc.st.level==curr_level)
|
||||
if (var->s_type&T_PARAM
|
||||
&& (var->s_type&(T_TYPE|T_ARR))!=T_VALUE)
|
||||
Lolp(var->s_info.vc.offset);
|
||||
else
|
||||
lal(var->info.vc.offset);
|
||||
lal(var->s_info.vc.offset);
|
||||
else {
|
||||
if (var->info.vc.offset<0)
|
||||
lxl(curr_level-var->info.vc.st.level);
|
||||
if (var->s_info.vc.offset<0)
|
||||
lxl(curr_level-var->s_info.vc.st.level);
|
||||
else
|
||||
lxa(curr_level-var->info.vc.st.level);
|
||||
if (var->type&T_PARAM
|
||||
&& (var->type&(T_TYPE|T_ARR))!=T_VALUE)
|
||||
Lofp(var->info.vc.offset);
|
||||
lxa(curr_level-var->s_info.vc.st.level);
|
||||
if (var->s_type&T_PARAM
|
||||
&& (var->s_type&(T_TYPE|T_ARR))!=T_VALUE)
|
||||
Lofp(var->s_info.vc.offset);
|
||||
else
|
||||
adp(var->info.vc.offset);
|
||||
adp(var->s_info.vc.offset);
|
||||
}
|
||||
} break;
|
||||
case E_TABLE:
|
||||
|
@ -440,12 +440,12 @@ void code_void(e) register struct expr *e;
|
|||
break;
|
||||
case E_CALL: {
|
||||
register size=0;
|
||||
register struct expr_list *elp=e->u.call.args;
|
||||
register struct symbol *proc=e->u.call.proc->u.var;
|
||||
register struct par_list *pars=proc->info.proc.pars;
|
||||
register struct expr_list *elp=e->u.call.c_args;
|
||||
register struct symbol *proc=e->u.call.c_proc->u.var;
|
||||
register struct par_list *pars=proc->s_info.proc.pars;
|
||||
|
||||
while (elp!=nil) {
|
||||
if (pars->type==T_VALUE) {
|
||||
if (pars->pr_type==T_VALUE) {
|
||||
code_val(elp->arg);
|
||||
size+=vz;
|
||||
} else {
|
||||
|
@ -453,27 +453,27 @@ void code_void(e) register struct expr *e;
|
|||
size+=pz;
|
||||
}
|
||||
elp=elp->next;
|
||||
pars=pars->next;
|
||||
pars=pars->pr_next;
|
||||
}
|
||||
if (proc->type&T_BUILTIN) {
|
||||
cal(proc->info.proc.st.builtin);
|
||||
if (proc->s_type&T_BUILTIN) {
|
||||
cal(proc->s_info.proc.st.builtin);
|
||||
asp(size);
|
||||
} else {
|
||||
if (proc->info.proc.st.level>curr_level) {
|
||||
if (proc->s_info.proc.st.level>curr_level) {
|
||||
/* Call down */
|
||||
lor0();
|
||||
} else
|
||||
if (proc->info.proc.st.level==curr_level) {
|
||||
if (proc->s_info.proc.st.level==curr_level) {
|
||||
/* Call at same level */
|
||||
Lolp(0);
|
||||
} else {
|
||||
/* Call up */
|
||||
lxa(curr_level-proc->info.proc.st.level);
|
||||
lxa(curr_level-proc->s_info.proc.st.level);
|
||||
loi(pz);
|
||||
}
|
||||
cal(proc_label(proc->info.proc.label, proc->name));
|
||||
cal(proc_label(proc->s_info.proc.label, proc->s_name));
|
||||
asp(size+pz);
|
||||
if (proc->info.proc.file!=curr_file) fil();
|
||||
if (proc->s_info.proc.file!=curr_file) fil();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
@ -486,11 +486,11 @@ void prologue(proc) register struct symbol *proc;
|
|||
|
||||
if (err) return;
|
||||
|
||||
proc->info.proc.st.level= ++curr_level;
|
||||
proc->info.proc.file= curr_file;
|
||||
proc->info.proc.label= ++P;
|
||||
proc->s_info.proc.st.level= ++curr_level;
|
||||
proc->s_info.proc.file= curr_file;
|
||||
proc->s_info.proc.label= ++P;
|
||||
curr_offset=min_offset=0;
|
||||
pro(proc_label(proc->info.proc.label, proc->name));
|
||||
pro(proc_label(proc->s_info.proc.label, proc->s_name));
|
||||
if (curr_level==1) fil();
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ void rep_init(v, e1, e2, r_info)
|
|||
r_info->BEGIN=r_info->END=0;
|
||||
|
||||
code_val(e1);
|
||||
Stl(v->info.vc.offset);
|
||||
Stl(v->s_info.vc.offset);
|
||||
|
||||
if (!constant(e1) || !constant(e2)) {
|
||||
if (constant(e2) && word_constant(e2->u.const)) {
|
||||
|
@ -540,10 +540,10 @@ void rep_test(v, e1, e2, r_info)
|
|||
{
|
||||
if (err) return;
|
||||
|
||||
Inl(v->info.vc.offset);
|
||||
Inl(v->s_info.vc.offset);
|
||||
|
||||
if (constant(e1) && constant(e2)) {
|
||||
Lol(v->info.vc.offset);
|
||||
Lol(v->s_info.vc.offset);
|
||||
Loc(e1->u.const+e2->u.const);
|
||||
if (vz>wz) {
|
||||
cmi();
|
||||
|
|
|
@ -114,13 +114,13 @@ struct expr *new_var(var)
|
|||
|
||||
pe->kind=E_VAR;
|
||||
|
||||
if ((var->type&T_TYPE)==T_VAR || var->type&T_NOTDECL) {
|
||||
pe->type=(var->type&(~T_TYPE));
|
||||
if ((var->s_type&T_TYPE)==T_VAR || var->s_type&T_NOTDECL) {
|
||||
pe->type=(var->s_type&(~T_TYPE));
|
||||
pe->type|=T_VALUE|T_LVALUE;
|
||||
} else
|
||||
pe->type=var->type;
|
||||
pe->type=var->s_type;
|
||||
|
||||
pe->arr_siz=var->arr_siz;
|
||||
pe->arr_siz=var->s_arr_siz;
|
||||
|
||||
pe->u.var=var;
|
||||
|
||||
|
@ -242,8 +242,8 @@ struct expr *new_call(proc, args)
|
|||
|
||||
pe->kind=E_CALL;
|
||||
pe->type=T_VOID;
|
||||
pe->u.call.proc=proc;
|
||||
pe->u.call.args=args;
|
||||
pe->u.call.c_proc=proc;
|
||||
pe->u.call.c_args=args;
|
||||
|
||||
return pe;
|
||||
}
|
||||
|
@ -299,12 +299,12 @@ static void assigned(e) register struct expr *e;
|
|||
) {
|
||||
register struct symbol *var;
|
||||
|
||||
if ((var=e->u.var)->type&T_REP) {
|
||||
if ((var=e->u.var)->s_type&T_REP) {
|
||||
warning("replicator index %s may not be assigned",
|
||||
var->name);
|
||||
var->type&= ~T_REP;
|
||||
var->s_name);
|
||||
var->s_type&= ~T_REP;
|
||||
}
|
||||
var->type|=T_ASSIGNED;
|
||||
var->s_type|=T_ASSIGNED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,11 +315,11 @@ void used(e) register struct expr *e;
|
|||
) {
|
||||
register struct symbol *var;
|
||||
|
||||
if ( ! ( (var=e->u.var)->type&(T_ASSIGNED|T_BUILTIN))
|
||||
&& (var->type&T_TYPE)==T_VAR
|
||||
&& var->info.vc.st.level==curr_level)
|
||||
warning("%s used before assigned", var->name);
|
||||
var->type|=(T_USED|T_ASSIGNED);
|
||||
if ( ! ( (var=e->u.var)->s_type&(T_ASSIGNED|T_BUILTIN))
|
||||
&& (var->s_type&T_TYPE)==T_VAR
|
||||
&& var->s_info.vc.st.level==curr_level)
|
||||
warning("%s used before assigned", var->s_name);
|
||||
var->s_type|=(T_USED|T_ASSIGNED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,10 +416,10 @@ void check_param(aform, act, err)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((form->type&T_ARR)!=(act->type&T_ARR) && !(act->type&T_NOTDECL) ) {
|
||||
if ((form->pr_type&T_ARR)!=(act->type&T_ARR) && !(act->type&T_NOTDECL) ) {
|
||||
report(NONCORR);
|
||||
} else {
|
||||
switch (form->type&T_TYPE) {
|
||||
switch (form->pr_type&T_TYPE) {
|
||||
case T_VAR:
|
||||
if ( ! (
|
||||
(act->type&T_TYPE)==T_VALUE
|
||||
|
@ -442,7 +442,7 @@ void check_param(aform, act, err)
|
|||
break;
|
||||
}
|
||||
}
|
||||
*aform= form->next;
|
||||
*aform= form->pr_next;
|
||||
}
|
||||
|
||||
void destroy(e) register struct expr *e;
|
||||
|
@ -456,11 +456,11 @@ void destroy(e) register struct expr *e;
|
|||
break;
|
||||
case E_IO:
|
||||
case E_CALL:
|
||||
destroy(e->kind==E_IO ? e->u.io.chan : e->u.call.proc);
|
||||
destroy(e->kind==E_IO ? e->u.io.chan : e->u.call.c_proc);
|
||||
{
|
||||
register struct expr_list *elp, *junk;
|
||||
|
||||
elp= e->kind==E_IO ? e->u.io.args : e->u.call.args;
|
||||
elp= e->kind==E_IO ? e->u.io.args : e->u.call.c_args;
|
||||
|
||||
while (elp!=nil) {
|
||||
destroy(elp->arg);
|
||||
|
|
|
@ -13,15 +13,15 @@
|
|||
#define E_CALL 7
|
||||
|
||||
struct table {
|
||||
long val;
|
||||
struct table *next;
|
||||
long val;
|
||||
};
|
||||
|
||||
struct expr;
|
||||
|
||||
struct expr_list {
|
||||
struct expr *arg;
|
||||
struct expr_list *next;
|
||||
struct expr *arg;
|
||||
};
|
||||
|
||||
struct expr {
|
||||
|
@ -47,8 +47,8 @@ struct expr {
|
|||
} io;
|
||||
|
||||
struct {
|
||||
struct expr *proc;
|
||||
struct expr_list *args;
|
||||
struct expr *c_proc;
|
||||
struct expr_list *c_args;
|
||||
} call;
|
||||
} u;
|
||||
};
|
||||
|
|
|
@ -407,11 +407,11 @@ proc_declaration { struct par_list *pars=nil;
|
|||
prologue(proc);
|
||||
}
|
||||
form_parms(&pars) ? { form_offsets(pars);
|
||||
proc->info.proc.pars=pars;
|
||||
proc->s_info.proc.pars=pars;
|
||||
}
|
||||
'=' process { epilogue(proc);
|
||||
sym_up();
|
||||
proc->type&= ~T_RECURS;
|
||||
proc->s_type&= ~T_RECURS;
|
||||
min_offset=old_min_offset;
|
||||
Label(OVER);
|
||||
}
|
||||
|
@ -457,10 +457,10 @@ item(register struct expr **e;)
|
|||
var=searchall(token.t_sval);
|
||||
|
||||
if (var_constant(var))
|
||||
*e=copy_const(var->info.const);
|
||||
*e=copy_const(var->s_info.const);
|
||||
else {
|
||||
if (var_proc(var))
|
||||
pars=var->info.proc.pars;
|
||||
pars=var->s_info.proc.pars;
|
||||
*e=new_var(var);
|
||||
}
|
||||
}
|
||||
|
@ -468,13 +468,13 @@ item(register struct expr **e;)
|
|||
[ subscript(&byte, &e1)
|
||||
{ *e=new_node('[', *e, e1, byte); }
|
||||
| '(' { if (!var_declared(var)) {
|
||||
var->type=T_PROC|T_USED|T_NOTDECL;
|
||||
var->info.proc.pars=nil;
|
||||
var->s_type=T_PROC|T_USED|T_NOTDECL;
|
||||
var->s_info.proc.pars=nil;
|
||||
err=1;
|
||||
}
|
||||
if (!var_proc(var)) {
|
||||
report("%s is not a named process",
|
||||
var->name);
|
||||
var->s_name);
|
||||
err=1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ static struct symbol **search_sym(tree, name)
|
|||
register struct symbol **aps=tree, *ps;
|
||||
register cmp;
|
||||
|
||||
while ((ps= *aps)!=nil && (cmp=strcmp(name, ps->name))!=0)
|
||||
aps= cmp<0 ? &ps->left : &ps->right;
|
||||
while ((ps= *aps)!=nil && (cmp=strcmp(name, ps->s_name))!=0)
|
||||
aps= cmp<0 ? &ps->s_left : &ps->s_right;
|
||||
|
||||
return aps;
|
||||
}
|
||||
|
@ -48,14 +48,14 @@ struct symbol *insert(name, type, arr_siz, info)
|
|||
|
||||
ps= (struct symbol *) malloc(sizeof *ps);
|
||||
|
||||
ps->name=name;
|
||||
ps->s_name=name;
|
||||
|
||||
if (included && curr_level==0) /* Top_level symbol in include file */
|
||||
type|=T_USED; /* are always used */
|
||||
ps->type=type;
|
||||
ps->arr_siz=arr_siz;
|
||||
ps->info= *info;
|
||||
ps->left=ps->right=nil;
|
||||
ps->s_type=type;
|
||||
ps->s_arr_siz=arr_siz;
|
||||
ps->s_info= *info;
|
||||
ps->s_left=ps->s_right=nil;
|
||||
*aps=ps;
|
||||
|
||||
return ps;
|
||||
|
@ -81,7 +81,7 @@ struct symbol *searchall(name) char *name;
|
|||
void check_recursion(proc)
|
||||
register struct expr *proc;
|
||||
{
|
||||
if (proc->kind==E_VAR && proc->u.var->type&T_RECURS)
|
||||
if (proc->kind==E_VAR && proc->u.var->s_type&T_RECURS)
|
||||
warning("recursion not allowed");
|
||||
}
|
||||
|
||||
|
@ -101,28 +101,28 @@ void sym_down()
|
|||
static void sym_destroy(ps) register struct symbol *ps;
|
||||
{
|
||||
if (ps!=nil) {
|
||||
sym_destroy(ps->left);
|
||||
sym_destroy(ps->right);
|
||||
if ( !(ps->type&T_NOTDECL) ) {
|
||||
if ( !(ps->type&T_USED) )
|
||||
warning("%s: never used", ps->name);
|
||||
sym_destroy(ps->s_left);
|
||||
sym_destroy(ps->s_right);
|
||||
if ( !(ps->s_type&T_NOTDECL) ) {
|
||||
if ( !(ps->s_type&T_USED) )
|
||||
warning("%s: never used", ps->s_name);
|
||||
else
|
||||
if ( !(ps->type&T_ASSIGNED) && (ps->type&T_TYPE)==T_VAR)
|
||||
warning("%s: never assigned", ps->name);
|
||||
if ( !(ps->s_type&T_ASSIGNED) && (ps->s_type&T_TYPE)==T_VAR)
|
||||
warning("%s: never assigned", ps->s_name);
|
||||
}
|
||||
if ((ps->type&T_TYPE)==T_PROC) {
|
||||
if ((ps->s_type&T_TYPE)==T_PROC) {
|
||||
register struct par_list *par, *junk;
|
||||
|
||||
par=ps->info.proc.pars;
|
||||
par=ps->s_info.proc.pars;
|
||||
while (par!=nil) {
|
||||
junk=par;
|
||||
par=par->next;
|
||||
par=par->pr_next;
|
||||
free(junk);
|
||||
}
|
||||
} else
|
||||
if ((ps->type&T_TYPE)==T_CONST)
|
||||
destroy(ps->info.const);
|
||||
free(ps->name);
|
||||
if ((ps->s_type&T_TYPE)==T_CONST)
|
||||
destroy(ps->s_info.const);
|
||||
free(ps->s_name);
|
||||
free(ps);
|
||||
}
|
||||
}
|
||||
|
@ -174,12 +174,12 @@ void pars_add(aapars, type, var)
|
|||
|
||||
pl= (struct par_list *) malloc(sizeof *pl);
|
||||
|
||||
pl->type=type;
|
||||
pl->var=var;
|
||||
pl->next= **aapars;
|
||||
pl->pr_type=type;
|
||||
pl->pr_var=var;
|
||||
pl->pr_next= **aapars;
|
||||
|
||||
**aapars=pl;
|
||||
*aapars= &pl->next;
|
||||
*aapars= &pl->pr_next;
|
||||
}
|
||||
|
||||
int form_offsets(pars) register struct par_list *pars;
|
||||
|
@ -189,19 +189,19 @@ int form_offsets(pars) register struct par_list *pars;
|
|||
|
||||
if (pars==nil) return pz;
|
||||
|
||||
if ((var=pars->var)!=nil) {
|
||||
register offset=form_offsets(pars->next);
|
||||
if ((var=pars->pr_var)!=nil) {
|
||||
register offset=form_offsets(pars->pr_next);
|
||||
|
||||
switch (var->type&T_TYPE) {
|
||||
switch (var->s_type&T_TYPE) {
|
||||
case T_VAR:
|
||||
case T_CHAN:
|
||||
var->info.vc.st.level=curr_level;
|
||||
var->info.vc.offset=offset;
|
||||
var->s_info.vc.st.level=curr_level;
|
||||
var->s_info.vc.offset=offset;
|
||||
return offset+pz;
|
||||
case T_VALUE:
|
||||
var->info.vc.st.level=curr_level;
|
||||
var->info.vc.offset=offset;
|
||||
return offset+ ((var->type&T_ARR) ? pz : vz);
|
||||
var->s_info.vc.st.level=curr_level;
|
||||
var->s_info.vc.offset=offset;
|
||||
return offset+ ((var->s_type&T_ARR) ? pz : vz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
struct symbol;
|
||||
|
||||
struct par_list { /* List of parameter types for a proc object */
|
||||
struct par_list *next;
|
||||
struct symbol *var; /* The formal parameter while visible */
|
||||
int type; /* Its type */
|
||||
struct par_list *pr_next;
|
||||
struct symbol *pr_var; /* The formal parameter while visible */
|
||||
int pr_type; /* Its type */
|
||||
};
|
||||
|
||||
struct expr;
|
||||
|
@ -65,11 +65,11 @@ union type_info {
|
|||
};
|
||||
|
||||
struct symbol {
|
||||
char *name;
|
||||
short type;
|
||||
int arr_siz;
|
||||
union type_info info;
|
||||
struct symbol *left, *right;
|
||||
char *s_name;
|
||||
short s_type;
|
||||
int s_arr_siz;
|
||||
union type_info s_info;
|
||||
struct symbol *s_left, *s_right;
|
||||
};
|
||||
|
||||
struct symtab {
|
||||
|
@ -89,8 +89,8 @@ void pars_add();
|
|||
int form_offsets();
|
||||
void check_recursion();
|
||||
|
||||
#define var_constant(v) (((v)->type&T_TYPE)==T_CONST)
|
||||
#define var_proc(v) (((v)->type&T_TYPE)==T_PROC)
|
||||
#define var_declared(v) (! ((v)->type&T_NOTDECL))
|
||||
#define var_constant(v) (((v)->s_type&T_TYPE)==T_CONST)
|
||||
#define var_proc(v) (((v)->s_type&T_TYPE)==T_PROC)
|
||||
#define var_declared(v) (! ((v)->s_type&T_NOTDECL))
|
||||
|
||||
extern union type_info none;
|
||||
|
|
Loading…
Reference in a new issue