newer version
This commit is contained in:
parent
1cfe2b5dac
commit
f56f8f56f3
|
@ -121,7 +121,6 @@ LLlex()
|
||||||
return tk->tk_symb;
|
return tk->tk_symb;
|
||||||
}
|
}
|
||||||
tk->tk_lineno = LineNumber;
|
tk->tk_lineno = LineNumber;
|
||||||
tk->tk_filename = FileName;
|
|
||||||
|
|
||||||
again:
|
again:
|
||||||
LoadChar(ch);
|
LoadChar(ch);
|
||||||
|
|
|
@ -8,9 +8,8 @@ struct string {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct token {
|
struct token {
|
||||||
int tk_symb; /* token itself */
|
short tk_symb; /* token itself */
|
||||||
char *tk_filename; /* filename in which it occurred */
|
unsigned short tk_lineno; /* linenumber on which it occurred */
|
||||||
int tk_lineno; /* linenumber on which it occurred */
|
|
||||||
union {
|
union {
|
||||||
struct idf *tk_idf; /* IDENT */
|
struct idf *tk_idf; /* IDENT */
|
||||||
struct string *tk_str; /* STRING */
|
struct string *tk_str; /* STRING */
|
||||||
|
|
|
@ -503,15 +503,12 @@ df->df_idf->id_text);
|
||||||
expp->nd_symb = INTEGER;
|
expp->nd_symb = INTEGER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *fn;
|
unsigned int ln;
|
||||||
int ln;
|
|
||||||
|
|
||||||
assert(df->df_kind == D_CONST);
|
assert(df->df_kind == D_CONST);
|
||||||
ln = expp->nd_lineno;
|
ln = expp->nd_lineno;
|
||||||
fn = expp->nd_filename;
|
|
||||||
*expp = *(df->con_const);
|
*expp = *(df->con_const);
|
||||||
expp->nd_lineno = ln;
|
expp->nd_lineno = ln;
|
||||||
expp->nd_filename = fn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ CodeConst(cst, size)
|
||||||
CodeString(nd)
|
CodeString(nd)
|
||||||
struct node *nd;
|
struct node *nd;
|
||||||
{
|
{
|
||||||
|
|
||||||
label lab;
|
label lab;
|
||||||
|
|
||||||
if (nd->nd_type == charc_type) {
|
if (nd->nd_type == charc_type) {
|
||||||
|
@ -75,8 +74,8 @@ CodeReal(nd)
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeExpr(nd, ds, true_label, false_label)
|
CodeExpr(nd, ds, true_label, false_label)
|
||||||
struct node *nd;
|
register struct node *nd;
|
||||||
struct desig *ds;
|
register struct desig *ds;
|
||||||
label true_label, false_label;
|
label true_label, false_label;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -135,9 +134,22 @@ CodeExpr(nd, ds, true_label, false_label)
|
||||||
ds->dsg_kind = DSG_LOADED;
|
ds->dsg_kind = DSG_LOADED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Set: {
|
||||||
|
arith *st;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
st = nd->nd_set;
|
||||||
|
for (i = nd->nd_type->tp_size / word_size, st = nd->nd_set + i;
|
||||||
|
i > 0;
|
||||||
|
i--) {
|
||||||
|
C_loc(*--st);
|
||||||
|
}
|
||||||
|
ds->dsg_kind = DSG_LOADED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case Xset:
|
case Xset:
|
||||||
case Set:
|
CodeSet(nd);
|
||||||
/* ??? */
|
|
||||||
ds->dsg_kind = DSG_LOADED;
|
ds->dsg_kind = DSG_LOADED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -160,7 +172,7 @@ CodeCoercion(t1, t2)
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeCall(nd)
|
CodeCall(nd)
|
||||||
struct node *nd;
|
register struct node *nd;
|
||||||
{
|
{
|
||||||
/* Generate code for a procedure call. Checking of parameters
|
/* Generate code for a procedure call. Checking of parameters
|
||||||
and result is already done.
|
and result is already done.
|
||||||
|
@ -250,7 +262,7 @@ CodeAssign(nd, dst, dss)
|
||||||
}
|
}
|
||||||
|
|
||||||
Operands(leftop, rightop)
|
Operands(leftop, rightop)
|
||||||
struct node *leftop, *rightop;
|
register struct node *leftop, *rightop;
|
||||||
{
|
{
|
||||||
struct desig Des;
|
struct desig Des;
|
||||||
|
|
||||||
|
@ -514,7 +526,7 @@ CodeOper(expr, true_label, false_label)
|
||||||
/* compare() serves as an auxiliary function of CodeOper */
|
/* compare() serves as an auxiliary function of CodeOper */
|
||||||
compare(relop, lbl)
|
compare(relop, lbl)
|
||||||
int relop;
|
int relop;
|
||||||
label lbl;
|
register label lbl;
|
||||||
{
|
{
|
||||||
switch (relop) {
|
switch (relop) {
|
||||||
case '<':
|
case '<':
|
||||||
|
@ -596,3 +608,42 @@ CodeUoper(nd)
|
||||||
crash("Bad unary operator");
|
crash("Bad unary operator");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodeSet(nd)
|
||||||
|
register struct node *nd;
|
||||||
|
{
|
||||||
|
struct type *tp = nd->nd_type;
|
||||||
|
|
||||||
|
nd = nd->nd_right;
|
||||||
|
while (nd) {
|
||||||
|
assert(nd->nd_class == Link && nd->nd_symb == ',');
|
||||||
|
|
||||||
|
CodeEl(nd->nd_left, tp);
|
||||||
|
nd = nd->nd_right;
|
||||||
|
if (nd) {
|
||||||
|
C_ior(tp->tp_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeEl(nd, tp)
|
||||||
|
register struct node *nd;
|
||||||
|
struct type *tp;
|
||||||
|
{
|
||||||
|
|
||||||
|
if (nd->nd_class == Link && nd->nd_symb == UPTO) {
|
||||||
|
C_zer(tp->tp_size); /* empty set */
|
||||||
|
C_lor((arith) 1); /* SP: address of set */
|
||||||
|
Operands(nd->nd_left, nd->nd_right);
|
||||||
|
C_cal("_LtoUset"); /* library routine to fill set */
|
||||||
|
C_asp(2 * word_size + pointer_size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct desig Des;
|
||||||
|
|
||||||
|
Des = InitDesig;
|
||||||
|
CodeExpr(nd, &Des, NO_LABEL, NO_LABEL);
|
||||||
|
CodeValue(nd, word_size);
|
||||||
|
C_set(tp->tp_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ struct dforward {
|
||||||
char *fo_name;
|
char *fo_name;
|
||||||
#define for_node df_value.df_forward.fo_node
|
#define for_node df_value.df_forward.fo_node
|
||||||
#define for_vis df_value.df_forward.fo_vis
|
#define for_vis df_value.df_forward.fo_vis
|
||||||
#define for_scopes df_value.df_forward.fo_scopes
|
|
||||||
#define for_name df_value.df_forward.fo_name
|
#define for_name df_value.df_forward.fo_name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -329,6 +329,7 @@ CodeDesig(nd, ds)
|
||||||
|
|
||||||
case Oper:
|
case Oper:
|
||||||
assert(nd->nd_symb == '[');
|
assert(nd->nd_symb == '[');
|
||||||
|
|
||||||
CodeDesig(nd->nd_left, ds);
|
CodeDesig(nd->nd_left, ds);
|
||||||
CodeAddress(ds);
|
CodeAddress(ds);
|
||||||
*ds = InitDesig;
|
*ds = InitDesig;
|
||||||
|
@ -348,6 +349,7 @@ CodeDesig(nd, ds)
|
||||||
|
|
||||||
case Uoper:
|
case Uoper:
|
||||||
assert(nd->nd_symb == '^');
|
assert(nd->nd_symb == '^');
|
||||||
|
|
||||||
CodeDesig(nd->nd_right, ds);
|
CodeDesig(nd->nd_right, ds);
|
||||||
switch(ds->dsg_kind) {
|
switch(ds->dsg_kind) {
|
||||||
case DSG_LOADED:
|
case DSG_LOADED:
|
||||||
|
|
|
@ -137,9 +137,8 @@ _error(class, node, fmt, argv)
|
||||||
static unsigned int last_ln = 0;
|
static unsigned int last_ln = 0;
|
||||||
unsigned int ln = 0;
|
unsigned int ln = 0;
|
||||||
static char * last_fn = 0;
|
static char * last_fn = 0;
|
||||||
char *fn = 0;
|
|
||||||
static int e_seen = 0;
|
static int e_seen = 0;
|
||||||
char *remark = 0;
|
register char *remark = 0;
|
||||||
|
|
||||||
/* Since name and number are gathered from different places
|
/* Since name and number are gathered from different places
|
||||||
depending on the class, we first collect the relevant
|
depending on the class, we first collect the relevant
|
||||||
|
@ -185,7 +184,6 @@ _error(class, node, fmt, argv)
|
||||||
switch (class) {
|
switch (class) {
|
||||||
case WARNING:
|
case WARNING:
|
||||||
case ERROR:
|
case ERROR:
|
||||||
fn = node ? node->nd_filename : dot.tk_filename;
|
|
||||||
ln = node ? node->nd_lineno : dot.tk_lineno;
|
ln = node ? node->nd_lineno : dot.tk_lineno;
|
||||||
break;
|
break;
|
||||||
case LEXWARNING:
|
case LEXWARNING:
|
||||||
|
@ -196,14 +194,13 @@ _error(class, node, fmt, argv)
|
||||||
case VDEBUG:
|
case VDEBUG:
|
||||||
#endif DEBUG
|
#endif DEBUG
|
||||||
ln = LineNumber;
|
ln = LineNumber;
|
||||||
fn = FileName;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (class != VDEBUG) {
|
if (class != VDEBUG) {
|
||||||
#endif
|
#endif
|
||||||
if (fn == last_fn && ln == last_ln) {
|
if (FileName == last_fn && ln == last_ln) {
|
||||||
/* we've seen this place before */
|
/* we've seen this place before */
|
||||||
e_seen++;
|
e_seen++;
|
||||||
if (e_seen == MAXERR_LINE) fmt = "etc ...";
|
if (e_seen == MAXERR_LINE) fmt = "etc ...";
|
||||||
|
@ -215,14 +212,14 @@ _error(class, node, fmt, argv)
|
||||||
else {
|
else {
|
||||||
/* brand new place */
|
/* brand new place */
|
||||||
last_ln = ln;
|
last_ln = ln;
|
||||||
last_fn = fn;
|
last_fn = FileName;
|
||||||
e_seen = 0;
|
e_seen = 0;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
}
|
}
|
||||||
#endif DEBUG
|
#endif DEBUG
|
||||||
|
|
||||||
if (fn) fprint(ERROUT, "\"%s\", line %u: ", fn, ln);
|
if (FileName) fprint(ERROUT, "\"%s\", line %u: ", FileName, ln);
|
||||||
|
|
||||||
if (remark) fprint(ERROUT, "%s ", remark);
|
if (remark) fprint(ERROUT, "%s ", remark);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
struct f_info {
|
struct f_info {
|
||||||
unsigned int f_lineno;
|
unsigned short f_lineno;
|
||||||
char *f_filename;
|
char *f_filename;
|
||||||
char *f_workingdir;
|
char *f_workingdir;
|
||||||
};
|
};
|
||||||
|
|
|
@ -140,7 +140,7 @@ AddStandards()
|
||||||
{
|
{
|
||||||
register struct def *df;
|
register struct def *df;
|
||||||
struct def *Enter();
|
struct def *Enter();
|
||||||
static struct node nilnode = { 0, 0, Value, 0, { INTEGER, 0, 0}};
|
static struct node nilnode = { 0, 0, Value, 0, { INTEGER, 0}};
|
||||||
|
|
||||||
(void) Enter("ABS", D_PROCEDURE, std_type, S_ABS);
|
(void) Enter("ABS", D_PROCEDURE, std_type, S_ABS);
|
||||||
(void) Enter("CAP", D_PROCEDURE, std_type, S_CAP);
|
(void) Enter("CAP", D_PROCEDURE, std_type, S_CAP);
|
||||||
|
|
|
@ -24,7 +24,6 @@ struct node {
|
||||||
#define nd_lab nd_token.tk_data.tk_lab
|
#define nd_lab nd_token.tk_data.tk_lab
|
||||||
#define nd_symb nd_token.tk_symb
|
#define nd_symb nd_token.tk_symb
|
||||||
#define nd_lineno nd_token.tk_lineno
|
#define nd_lineno nd_token.tk_lineno
|
||||||
#define nd_filename nd_token.tk_filename
|
|
||||||
#define nd_IDF nd_token.TOK_IDF
|
#define nd_IDF nd_token.TOK_IDF
|
||||||
#define nd_STR nd_token.TOK_STR
|
#define nd_STR nd_token.TOK_STR
|
||||||
#define nd_SLE nd_token.TOK_SLE
|
#define nd_SLE nd_token.TOK_SLE
|
||||||
|
|
|
@ -43,8 +43,8 @@ FreeNode(nd)
|
||||||
list
|
list
|
||||||
*/
|
*/
|
||||||
if (!nd) return;
|
if (!nd) return;
|
||||||
if (nd->nd_left) FreeNode(nd->nd_left);
|
FreeNode(nd->nd_left);
|
||||||
if (nd->nd_right) FreeNode(nd->nd_right);
|
FreeNode(nd->nd_right);
|
||||||
free_node(nd);
|
free_node(nd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,8 @@ struct subrange {
|
||||||
|
|
||||||
struct array {
|
struct array {
|
||||||
struct type *ar_elem; /* Type of elements */
|
struct type *ar_elem; /* Type of elements */
|
||||||
arith ar_lb, ar_ub; /* Lower bound and upper bound */
|
|
||||||
label ar_descr; /* Label of array descriptor */
|
label ar_descr; /* Label of array descriptor */
|
||||||
#define arr_elem tp_value.tp_arr.ar_elem
|
#define arr_elem tp_value.tp_arr.ar_elem
|
||||||
#define arr_lb tp_value.tp_arr.ar_lb
|
|
||||||
#define arr_ub tp_value.tp_arr.ar_ub
|
|
||||||
#define arr_descr tp_value.tp_arr.ar_descr
|
#define arr_descr tp_value.tp_arr.ar_descr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -387,15 +387,11 @@ ArraySizes(tp)
|
||||||
*/
|
*/
|
||||||
switch(index_type->tp_fund) {
|
switch(index_type->tp_fund) {
|
||||||
case T_SUBRANGE:
|
case T_SUBRANGE:
|
||||||
tp->arr_lb = index_type->sub_lb;
|
|
||||||
tp->arr_ub = index_type->sub_ub;
|
|
||||||
tp->tp_size = elem_size *
|
tp->tp_size = elem_size *
|
||||||
(index_type->sub_ub - index_type->sub_lb + 1);
|
(index_type->sub_ub - index_type->sub_lb + 1);
|
||||||
break;
|
break;
|
||||||
case T_CHAR:
|
case T_CHAR:
|
||||||
case T_ENUMERATION:
|
case T_ENUMERATION:
|
||||||
tp->arr_lb = 0;
|
|
||||||
tp->arr_ub = index_type->enm_ncst - 1;
|
|
||||||
tp->tp_size = elem_size * index_type->enm_ncst;
|
tp->tp_size = elem_size * index_type->enm_ncst;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -453,6 +449,8 @@ lcm(m, n)
|
||||||
DumpType(tp)
|
DumpType(tp)
|
||||||
register struct type *tp;
|
register struct type *tp;
|
||||||
{
|
{
|
||||||
|
if (!tp) return;
|
||||||
|
|
||||||
print(" a:%d; s:%ld;", tp->tp_align, (long) tp->tp_size);
|
print(" a:%d; s:%ld;", tp->tp_align, (long) tp->tp_size);
|
||||||
if (tp->next && tp->tp_fund != T_POINTER) {
|
if (tp->next && tp->tp_fund != T_POINTER) {
|
||||||
/* Avoid printing recursive types!
|
/* Avoid printing recursive types!
|
||||||
|
@ -501,9 +499,11 @@ DumpType(tp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case T_ARRAY:
|
case T_ARRAY:
|
||||||
print("ARRAY %ld-%ld", (long) tp->arr_lb, (long) tp->arr_ub);
|
print("ARRAY");
|
||||||
print("; el:");
|
print("; el:");
|
||||||
DumpType(tp->arr_elem);
|
DumpType(tp->arr_elem);
|
||||||
|
print("; index:");
|
||||||
|
DumpType(tp->next);
|
||||||
break;
|
break;
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
print("STRING"); break;
|
print("STRING"); break;
|
||||||
|
|
|
@ -128,11 +128,12 @@ TstCompat(tp1, tp2)
|
||||||
|
|
||||||
int
|
int
|
||||||
TstAssCompat(tp1, tp2)
|
TstAssCompat(tp1, tp2)
|
||||||
struct type *tp1, *tp2;
|
register struct type *tp1, *tp2;
|
||||||
{
|
{
|
||||||
/* Test if two types are assignment compatible.
|
/* Test if two types are assignment compatible.
|
||||||
See Def 9.1.
|
See Def 9.1.
|
||||||
*/
|
*/
|
||||||
|
register struct type *tp;
|
||||||
|
|
||||||
if (TstCompat(tp1, tp2)) return 1;
|
if (TstCompat(tp1, tp2)) return 1;
|
||||||
|
|
||||||
|
@ -145,11 +146,16 @@ TstAssCompat(tp1, tp2)
|
||||||
if (tp1 == char_type && tp2 == charc_type) return 1;
|
if (tp1 == char_type && tp2 == charc_type) return 1;
|
||||||
|
|
||||||
if (tp1->tp_fund == T_ARRAY) {
|
if (tp1->tp_fund == T_ARRAY) {
|
||||||
|
/* check for string
|
||||||
|
*/
|
||||||
arith size;
|
arith size;
|
||||||
|
|
||||||
if (! tp1->next) return 0;
|
if (!(tp = tp1->next)) return 0;
|
||||||
|
|
||||||
size = tp1->arr_ub - tp1->arr_lb + 1;
|
if (tp->tp_fund == T_SUBRANGE) {
|
||||||
|
size = tp->sub_ub - tp->sub_lb + 1;
|
||||||
|
}
|
||||||
|
else size = tp->enm_ncst;
|
||||||
tp1 = tp1->arr_elem;
|
tp1 = tp1->arr_elem;
|
||||||
if (tp1->tp_fund == T_SUBRANGE) tp1 = tp1->next;
|
if (tp1->tp_fund == T_SUBRANGE) tp1 = tp1->next;
|
||||||
return
|
return
|
||||||
|
|
|
@ -69,10 +69,12 @@ WalkModule(module)
|
||||||
Also generate code for its body.
|
Also generate code for its body.
|
||||||
*/
|
*/
|
||||||
register struct def *df = module->mod_vis->sc_scope->sc_def;
|
register struct def *df = module->mod_vis->sc_scope->sc_def;
|
||||||
|
register struct scope *sc;
|
||||||
struct scopelist *vis;
|
struct scopelist *vis;
|
||||||
|
|
||||||
vis = CurrVis;
|
vis = CurrVis;
|
||||||
CurrVis = module->mod_vis;
|
CurrVis = module->mod_vis;
|
||||||
|
sc = CurrentScope;
|
||||||
|
|
||||||
if (!proclevel && module != Defined) {
|
if (!proclevel && module != Defined) {
|
||||||
/* This module is a local module, but not within a
|
/* This module is a local module, but not within a
|
||||||
|
@ -80,12 +82,12 @@ WalkModule(module)
|
||||||
variables. This is done by generating a "bss",
|
variables. This is done by generating a "bss",
|
||||||
with label "_<modulenumber><modulename>".
|
with label "_<modulenumber><modulename>".
|
||||||
*/
|
*/
|
||||||
arith size = align(CurrentScope->sc_off, word_align);
|
arith size = align(sc->sc_off, word_align);
|
||||||
|
|
||||||
if (size == 0) size = word_size;
|
if (size == 0) size = word_size;
|
||||||
/* WHY ??? because we generated an INA for it ??? */
|
/* WHY ??? because we generated an INA for it ??? */
|
||||||
|
|
||||||
C_df_dnam(&(CurrentScope->sc_name[1]));
|
C_df_dnam(&(sc->sc_name[1]));
|
||||||
C_bss_cst(size, (arith) 0, 0);
|
C_bss_cst(size, (arith) 0, 0);
|
||||||
}
|
}
|
||||||
else if (CurrVis == Defined->mod_vis) {
|
else if (CurrVis == Defined->mod_vis) {
|
||||||
|
@ -104,22 +106,22 @@ WalkModule(module)
|
||||||
|
|
||||||
/* Now, walk through it's local definitions
|
/* Now, walk through it's local definitions
|
||||||
*/
|
*/
|
||||||
WalkDef(CurrentScope->sc_def);
|
WalkDef(sc->sc_def);
|
||||||
|
|
||||||
/* Now, generate initialization code for this module.
|
/* Now, generate initialization code for this module.
|
||||||
First call initialization routines for modules defined within
|
First call initialization routines for modules defined within
|
||||||
this module.
|
this module.
|
||||||
*/
|
*/
|
||||||
CurrentScope->sc_off = 0;
|
sc->sc_off = 0;
|
||||||
instructionlabel = 2;
|
instructionlabel = 2;
|
||||||
func_type = 0;
|
func_type = 0;
|
||||||
C_pro_narg(CurrentScope->sc_name);
|
C_pro_narg(sc->sc_name);
|
||||||
DoProfil();
|
DoProfil();
|
||||||
MkCalls(CurrentScope->sc_def);
|
MkCalls(sc->sc_def);
|
||||||
WalkNode(module->mod_body, (label) 0);
|
WalkNode(module->mod_body, (label) 0);
|
||||||
C_df_ilb((label) 1);
|
C_df_ilb((label) 1);
|
||||||
C_ret(0);
|
C_ret(0);
|
||||||
C_end(-CurrentScope->sc_off);
|
C_end(-sc->sc_off);
|
||||||
TmpClose();
|
TmpClose();
|
||||||
|
|
||||||
CurrVis = vis;
|
CurrVis = vis;
|
||||||
|
@ -132,20 +134,22 @@ WalkProcedure(procedure)
|
||||||
local definitions
|
local definitions
|
||||||
*/
|
*/
|
||||||
struct scopelist *vis = CurrVis;
|
struct scopelist *vis = CurrVis;
|
||||||
|
register struct scope *sc;
|
||||||
|
|
||||||
proclevel++;
|
proclevel++;
|
||||||
CurrVis = procedure->prc_vis;
|
CurrVis = procedure->prc_vis;
|
||||||
|
sc = CurrentScope;
|
||||||
|
|
||||||
WalkDef(CurrentScope->sc_def);
|
WalkDef(sc->sc_def);
|
||||||
|
|
||||||
/* Generate code for this procedure
|
/* Generate code for this procedure
|
||||||
*/
|
*/
|
||||||
C_pro_narg(CurrentScope->sc_name);
|
C_pro_narg(sc->sc_name);
|
||||||
DoProfil();
|
DoProfil();
|
||||||
/* generate calls to initialization routines of modules defined within
|
/* generate calls to initialization routines of modules defined within
|
||||||
this procedure
|
this procedure
|
||||||
*/
|
*/
|
||||||
MkCalls(CurrentScope->sc_def);
|
MkCalls(sc->sc_def);
|
||||||
return_expr_occurred = 0;
|
return_expr_occurred = 0;
|
||||||
instructionlabel = 2;
|
instructionlabel = 2;
|
||||||
func_type = procedure->df_type->next;
|
func_type = procedure->df_type->next;
|
||||||
|
@ -158,7 +162,7 @@ node_error(procedure->prc_body,"function procedure does not return a value");
|
||||||
C_ret((int) align(func_type->tp_size, word_align));
|
C_ret((int) align(func_type->tp_size, word_align));
|
||||||
}
|
}
|
||||||
else C_ret(0);
|
else C_ret(0);
|
||||||
C_end(-CurrentScope->sc_off);
|
C_end(-sc->sc_off);
|
||||||
TmpClose();
|
TmpClose();
|
||||||
CurrVis = vis;
|
CurrVis = vis;
|
||||||
proclevel--;
|
proclevel--;
|
||||||
|
@ -215,7 +219,7 @@ WalkNode(nd, lab)
|
||||||
}
|
}
|
||||||
|
|
||||||
WalkStat(nd, lab)
|
WalkStat(nd, lab)
|
||||||
register struct node *nd;
|
struct node *nd;
|
||||||
label lab;
|
label lab;
|
||||||
{
|
{
|
||||||
/* Walk through a statement, generating code for it.
|
/* Walk through a statement, generating code for it.
|
||||||
|
@ -224,8 +228,7 @@ WalkStat(nd, lab)
|
||||||
*/
|
*/
|
||||||
register struct node *left = nd->nd_left;
|
register struct node *left = nd->nd_left;
|
||||||
register struct node *right = nd->nd_right;
|
register struct node *right = nd->nd_right;
|
||||||
|
register struct desig *pds = &Desig;
|
||||||
if (options['p']) C_lin((arith) nd->nd_lineno);
|
|
||||||
|
|
||||||
if (!nd) {
|
if (!nd) {
|
||||||
/* Empty statement
|
/* Empty statement
|
||||||
|
@ -233,6 +236,8 @@ WalkStat(nd, lab)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options['p']) C_lin((arith) nd->nd_lineno);
|
||||||
|
|
||||||
if (nd->nd_class == Call) {
|
if (nd->nd_class == Call) {
|
||||||
if (chk_call(nd)) CodeCall(nd);
|
if (chk_call(nd)) CodeCall(nd);
|
||||||
return;
|
return;
|
||||||
|
@ -253,7 +258,7 @@ WalkStat(nd, lab)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeAssign(nd, &ds, &Desig);
|
CodeAssign(nd, &ds, pds);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -341,16 +346,16 @@ WalkStat(nd, lab)
|
||||||
wds.w_next = WithDesigs;
|
wds.w_next = WithDesigs;
|
||||||
WithDesigs = &wds;
|
WithDesigs = &wds;
|
||||||
wds.w_scope = left->nd_type->rec_scope;
|
wds.w_scope = left->nd_type->rec_scope;
|
||||||
if (Desig.dsg_kind != DSG_PFIXED) {
|
if (pds->dsg_kind != DSG_PFIXED) {
|
||||||
/* In this case, we use a temporary variable
|
/* In this case, we use a temporary variable
|
||||||
*/
|
*/
|
||||||
CodeAddress(&Desig);
|
CodeAddress(pds);
|
||||||
Desig.dsg_kind = DSG_FIXED;
|
pds->dsg_kind = DSG_FIXED;
|
||||||
/* Only for the store ... */
|
/* Only for the store ... */
|
||||||
Desig.dsg_offset = tmp = NewPtr();
|
pds->dsg_offset = tmp = NewPtr();
|
||||||
Desig.dsg_name = 0;
|
pds->dsg_name = 0;
|
||||||
CodeStore(&Desig, pointer_size);
|
CodeStore(pds, pointer_size);
|
||||||
Desig.dsg_kind = DSG_PFIXED;
|
pds->dsg_kind = DSG_PFIXED;
|
||||||
/* the record is indirectly available */
|
/* the record is indirectly available */
|
||||||
}
|
}
|
||||||
wds.w_desig = Desig;
|
wds.w_desig = Desig;
|
||||||
|
@ -390,7 +395,7 @@ node_error(right, "type incompatibility in RETURN statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpectBool(nd, true_label, false_label)
|
ExpectBool(nd, true_label, false_label)
|
||||||
struct node *nd;
|
register struct node *nd;
|
||||||
label true_label, false_label;
|
label true_label, false_label;
|
||||||
{
|
{
|
||||||
/* "nd" must indicate a boolean expression. Check this and
|
/* "nd" must indicate a boolean expression. Check this and
|
||||||
|
|
Loading…
Reference in a new issue