Do not use the allocation mechanism for the desig structure; overkill
This commit is contained in:
parent
86bc055fa1
commit
5ebc2017a0
7 changed files with 66 additions and 58 deletions
|
@ -20,7 +20,7 @@ def.H
|
||||||
def.c
|
def.c
|
||||||
defmodule.c
|
defmodule.c
|
||||||
desig.c
|
desig.c
|
||||||
desig.H
|
desig.h
|
||||||
em_m2.6
|
em_m2.6
|
||||||
enter.c
|
enter.c
|
||||||
error.c
|
error.c
|
||||||
|
|
|
@ -76,15 +76,15 @@ OBJ = $(COBJ) $(LOBJ) Lpars.o $(EXTRA_O)
|
||||||
GENH = errout.h \
|
GENH = errout.h \
|
||||||
idfsize.h numsize.h strsize.h target_sizes.h bigresult.h \
|
idfsize.h numsize.h strsize.h target_sizes.h bigresult.h \
|
||||||
inputtype.h density.h squeeze.h nocross.h nostrict.h \
|
inputtype.h density.h squeeze.h nocross.h nostrict.h \
|
||||||
def.h debugcst.h type.h Lpars.h node.h desig.h strict3rd.h real.h \
|
def.h debugcst.h type.h Lpars.h node.h strict3rd.h real.h \
|
||||||
use_insert.h dbsymtab.h uns_arith.h
|
use_insert.h dbsymtab.h uns_arith.h
|
||||||
HFILES =LLlex.h \
|
HFILES =LLlex.h \
|
||||||
chk_expr.h class.h debug.h f_info.h idf.h \
|
chk_expr.h class.h debug.h desig.h f_info.h idf.h \
|
||||||
input.h main.h misc.h scope.h standards.h tokenname.h \
|
input.h main.h misc.h scope.h standards.h tokenname.h \
|
||||||
walk.h warning.h SYSTEM.h $(GENH)
|
walk.h warning.h SYSTEM.h $(GENH)
|
||||||
#
|
#
|
||||||
GENFILES = $(GENGFILES) $(GENC) $(GENH)
|
GENFILES = $(GENGFILES) $(GENC) $(GENH)
|
||||||
NEXTFILES = def.H type.H node.H desig.H real.H scope.C tmpvar.C casestat.C
|
NEXTFILES = def.H type.H node.H real.H scope.C tmpvar.C casestat.C
|
||||||
|
|
||||||
#EXCLEXCLEXCLEXCL
|
#EXCLEXCLEXCLEXCL
|
||||||
|
|
||||||
|
@ -161,7 +161,6 @@ def.h: make.allocd
|
||||||
type.h: make.allocd
|
type.h: make.allocd
|
||||||
real.h: make.allocd
|
real.h: make.allocd
|
||||||
node.h: make.allocd
|
node.h: make.allocd
|
||||||
desig.h: make.allocd
|
|
||||||
scope.c: make.allocd
|
scope.c: make.allocd
|
||||||
tmpvar.c: make.allocd
|
tmpvar.c: make.allocd
|
||||||
casestat.c: make.allocd
|
casestat.c: make.allocd
|
||||||
|
|
|
@ -490,11 +490,13 @@ arith *
|
||||||
MkSet(size)
|
MkSet(size)
|
||||||
unsigned size;
|
unsigned size;
|
||||||
{
|
{
|
||||||
register arith *s;
|
register arith *s, *t;
|
||||||
|
|
||||||
s = (arith *) Malloc(size);
|
s = t = (arith *) Malloc(size);
|
||||||
clear((char *) s , size);
|
clear((char *) s , size);
|
||||||
s++;
|
s++;
|
||||||
|
size /= sizeof(arith);
|
||||||
|
while (size--) *t++ = 0;
|
||||||
inc_refcount(s);
|
inc_refcount(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ extern char *long2str();
|
||||||
extern char *symbol2str();
|
extern char *symbol2str();
|
||||||
extern int proclevel;
|
extern int proclevel;
|
||||||
extern char options[];
|
extern char options[];
|
||||||
|
extern t_desig null_desig;
|
||||||
int fp_used;
|
int fp_used;
|
||||||
|
|
||||||
CodeConst(cst, size)
|
CodeConst(cst, size)
|
||||||
|
@ -880,7 +881,9 @@ CodeOper(expr, true_label, false_label)
|
||||||
case OR:
|
case OR:
|
||||||
case AND: {
|
case AND: {
|
||||||
label l_maybe = ++text_label, l_end = NO_LABEL;
|
label l_maybe = ++text_label, l_end = NO_LABEL;
|
||||||
t_desig *Des = new_desig();
|
t_desig Des;
|
||||||
|
|
||||||
|
Des = null_desig;
|
||||||
|
|
||||||
if (true_label == NO_LABEL) {
|
if (true_label == NO_LABEL) {
|
||||||
true_label = ++text_label;
|
true_label = ++text_label;
|
||||||
|
@ -889,12 +892,12 @@ CodeOper(expr, true_label, false_label)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr->nd_symb == OR) {
|
if (expr->nd_symb == OR) {
|
||||||
CodeExpr(leftop, Des, true_label, l_maybe);
|
CodeExpr(leftop, &Des, true_label, l_maybe);
|
||||||
}
|
}
|
||||||
else CodeExpr(leftop, Des, l_maybe, false_label);
|
else CodeExpr(leftop, &Des, l_maybe, false_label);
|
||||||
def_ilb(l_maybe);
|
def_ilb(l_maybe);
|
||||||
clear((char *) Des, sizeof(t_desig));
|
Des = null_desig;
|
||||||
CodeExpr(rightop, Des, true_label, false_label);
|
CodeExpr(rightop, &Des, true_label, false_label);
|
||||||
if (l_end != NO_LABEL) {
|
if (l_end != NO_LABEL) {
|
||||||
def_ilb(true_label);
|
def_ilb(true_label);
|
||||||
c_loc(1);
|
c_loc(1);
|
||||||
|
@ -903,7 +906,6 @@ CodeOper(expr, true_label, false_label)
|
||||||
c_loc(0);
|
c_loc(0);
|
||||||
def_ilb(l_end);
|
def_ilb(l_end);
|
||||||
}
|
}
|
||||||
free_desig(Des);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1048,11 +1050,11 @@ CodePExpr(nd)
|
||||||
/* Generate code to push the value of the expression "nd"
|
/* Generate code to push the value of the expression "nd"
|
||||||
on the stack.
|
on the stack.
|
||||||
*/
|
*/
|
||||||
register t_desig *designator = new_desig();
|
t_desig designator;
|
||||||
|
|
||||||
CodeExpr(nd, designator, NO_LABEL, NO_LABEL);
|
designator = null_desig;
|
||||||
CodeValue(designator, nd->nd_type);
|
CodeExpr(nd, &designator, NO_LABEL, NO_LABEL);
|
||||||
free_desig(designator);
|
CodeValue(&designator, nd->nd_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeDAddress(nd, chk_controlvar)
|
CodeDAddress(nd, chk_controlvar)
|
||||||
|
@ -1062,14 +1064,15 @@ CodeDAddress(nd, chk_controlvar)
|
||||||
on the stack.
|
on the stack.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
register t_desig *designator = new_desig();
|
t_desig designator;
|
||||||
int chkptr;
|
int chkptr;
|
||||||
|
|
||||||
|
designator = null_desig;
|
||||||
if (chk_controlvar) ChkForFOR(nd);
|
if (chk_controlvar) ChkForFOR(nd);
|
||||||
CodeDesig(nd, designator);
|
CodeDesig(nd, &designator);
|
||||||
chkptr = designator->dsg_kind==DSG_PLOADED ||
|
chkptr = designator.dsg_kind==DSG_PLOADED ||
|
||||||
designator->dsg_kind==DSG_PFIXED;
|
designator.dsg_kind==DSG_PFIXED;
|
||||||
CodeAddress(designator);
|
CodeAddress(&designator);
|
||||||
|
|
||||||
/* Generate dummy use of pointer, to get possible error message
|
/* Generate dummy use of pointer, to get possible error message
|
||||||
as soon as possible
|
as soon as possible
|
||||||
|
@ -1079,7 +1082,6 @@ CodeDAddress(nd, chk_controlvar)
|
||||||
C_loi((arith) 1);
|
C_loi((arith) 1);
|
||||||
C_asp(word_size);
|
C_asp(word_size);
|
||||||
}
|
}
|
||||||
free_desig(designator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeDStore(nd)
|
CodeDStore(nd)
|
||||||
|
@ -1089,12 +1091,12 @@ CodeDStore(nd)
|
||||||
designator "nd".
|
designator "nd".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
register t_desig *designator = new_desig();
|
t_desig designator;
|
||||||
|
|
||||||
|
designator = null_desig;
|
||||||
ChkForFOR(nd);
|
ChkForFOR(nd);
|
||||||
CodeDesig(nd, designator);
|
CodeDesig(nd, &designator);
|
||||||
CodeStore(designator, nd->nd_type);
|
CodeStore(&designator, nd->nd_type);
|
||||||
free_desig(designator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DoHIGH(df)
|
DoHIGH(df)
|
||||||
|
|
|
@ -341,6 +341,8 @@ CodeCopy(lhs, rhs, sz, psize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t_desig null_desig;
|
||||||
|
|
||||||
CodeMove(rhs, left, rtp)
|
CodeMove(rhs, left, rtp)
|
||||||
register t_desig *rhs;
|
register t_desig *rhs;
|
||||||
register t_node *left;
|
register t_node *left;
|
||||||
|
@ -351,31 +353,32 @@ CodeMove(rhs, left, rtp)
|
||||||
Go through some (considerable) trouble to see if a BLM can be
|
Go through some (considerable) trouble to see if a BLM can be
|
||||||
generated.
|
generated.
|
||||||
*/
|
*/
|
||||||
register t_desig *lhs = new_desig();
|
t_desig lhs;
|
||||||
register t_type *tp = left->nd_type;
|
register t_type *tp = left->nd_type;
|
||||||
int loadedflag = 0;
|
int loadedflag = 0;
|
||||||
|
|
||||||
|
lhs = null_desig;
|
||||||
ChkForFOR(left);
|
ChkForFOR(left);
|
||||||
switch(rhs->dsg_kind) {
|
switch(rhs->dsg_kind) {
|
||||||
case DSG_LOADED:
|
case DSG_LOADED:
|
||||||
CodeDesig(left, lhs);
|
CodeDesig(left, &lhs);
|
||||||
if (rtp->tp_fund == T_STRING) {
|
if (rtp->tp_fund == T_STRING) {
|
||||||
/* size of a string literal fits in an
|
/* size of a string literal fits in an
|
||||||
int of size word_size
|
int of size word_size
|
||||||
*/
|
*/
|
||||||
CodeAddress(lhs);
|
CodeAddress(&lhs);
|
||||||
C_loc(rtp->tp_size);
|
C_loc(rtp->tp_size);
|
||||||
C_loc(tp->tp_size);
|
C_loc(tp->tp_size);
|
||||||
CAL("StringAssign", (int)pointer_size + (int)pointer_size + (int)dword_size);
|
CAL("StringAssign", (int)pointer_size + (int)pointer_size + (int)dword_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CodeStore(lhs, tp);
|
CodeStore(&lhs, tp);
|
||||||
break;
|
break;
|
||||||
case DSG_FIXED:
|
case DSG_FIXED:
|
||||||
CodeDesig(left, lhs);
|
CodeDesig(left, &lhs);
|
||||||
if (lhs->dsg_kind == DSG_FIXED &&
|
if (lhs.dsg_kind == DSG_FIXED &&
|
||||||
fit(tp->tp_size, (int) word_size) &&
|
fit(tp->tp_size, (int) word_size) &&
|
||||||
(int) (lhs->dsg_offset) % word_align ==
|
(int) (lhs.dsg_offset) % word_align ==
|
||||||
(int) (rhs->dsg_offset) % word_align) {
|
(int) (rhs->dsg_offset) % word_align) {
|
||||||
register int sz = 1;
|
register int sz = 1;
|
||||||
arith size = tp->tp_size;
|
arith size = tp->tp_size;
|
||||||
|
@ -384,16 +387,16 @@ CodeMove(rhs, left, rtp)
|
||||||
/* First copy up to word-aligned
|
/* First copy up to word-aligned
|
||||||
boundaries
|
boundaries
|
||||||
*/
|
*/
|
||||||
if (!((int)(lhs->dsg_offset)%(sz+sz))) {
|
if (!((int)(lhs.dsg_offset)%(sz+sz))) {
|
||||||
sz += sz;
|
sz += sz;
|
||||||
}
|
}
|
||||||
else CodeCopy(lhs, rhs, (arith) sz, &size);
|
else CodeCopy(&lhs, rhs, (arith) sz, &size);
|
||||||
}
|
}
|
||||||
/* Now copy the bulk
|
/* Now copy the bulk
|
||||||
*/
|
*/
|
||||||
sz = (int) size % (int) word_size;
|
sz = (int) size % (int) word_size;
|
||||||
size -= sz;
|
size -= sz;
|
||||||
CodeCopy(lhs, rhs, size, &size);
|
CodeCopy(&lhs, rhs, size, &size);
|
||||||
size = sz;
|
size = sz;
|
||||||
sz = word_size;
|
sz = word_size;
|
||||||
while (size) {
|
while (size) {
|
||||||
|
@ -401,12 +404,12 @@ CodeMove(rhs, left, rtp)
|
||||||
*/
|
*/
|
||||||
sz >>= 1;
|
sz >>= 1;
|
||||||
if (size >= sz) {
|
if (size >= sz) {
|
||||||
CodeCopy(lhs, rhs, (arith) sz, &size);
|
CodeCopy(&lhs, rhs, (arith) sz, &size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CodeAddress(lhs);
|
CodeAddress(&lhs);
|
||||||
loadedflag = 1;
|
loadedflag = 1;
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case DSG_PLOADED:
|
case DSG_PLOADED:
|
||||||
|
@ -417,8 +420,8 @@ CodeMove(rhs, left, rtp)
|
||||||
C_exg(pointer_size);
|
C_exg(pointer_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CodeDesig(left, lhs);
|
CodeDesig(left, &lhs);
|
||||||
CodeAddress(lhs);
|
CodeAddress(&lhs);
|
||||||
}
|
}
|
||||||
switch (suitable_move(tp)) {
|
switch (suitable_move(tp)) {
|
||||||
case USE_BLM:
|
case USE_BLM:
|
||||||
|
@ -440,7 +443,6 @@ CodeMove(rhs, left, rtp)
|
||||||
default:
|
default:
|
||||||
crash("CodeMove");
|
crash("CodeMove");
|
||||||
}
|
}
|
||||||
free_desig(lhs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeAddress(ds)
|
CodeAddress(ds)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct desig {
|
struct desig {
|
||||||
int dsg_kind;
|
short dsg_kind;
|
||||||
#define DSG_INIT 0 /* don't know anything yet */
|
#define DSG_INIT 0 /* don't know anything yet */
|
||||||
#define DSG_LOADED 1 /* designator loaded on top of the stack */
|
#define DSG_LOADED 1 /* designator loaded on top of the stack */
|
||||||
#define DSG_PLOADED 2 /* designator accessible through pointer on
|
#define DSG_PLOADED 2 /* designator accessible through pointer on
|
||||||
|
@ -45,21 +45,23 @@ struct desig {
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct desig t_desig;
|
||||||
|
|
||||||
/* The next structure describes the designator in a with-statement.
|
/* The next structure describes the designator in a with-statement.
|
||||||
We have a linked list of them, as with-statements may be nested.
|
We have a linked list of them, as with-statements may be nested.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct withdesig {
|
struct withdesig {
|
||||||
struct withdesig *w_next;
|
struct withdesig *w_next;
|
||||||
|
int w_flags; /* D_USED|D_DEFINED */
|
||||||
struct scope *w_scope; /* scope in which fields of this record
|
struct scope *w_scope; /* scope in which fields of this record
|
||||||
reside
|
reside
|
||||||
*/
|
*/
|
||||||
struct desig w_desig; /* a desig structure for this particular
|
t_desig w_desig; /* a desig structure for this particular
|
||||||
designator
|
designator
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct withdesig *WithDesigs;
|
extern struct withdesig *WithDesigs;
|
||||||
extern struct desig InitDesig;
|
|
||||||
|
|
||||||
#define NO_LABEL ((label) 0)
|
#define NO_LABEL ((label) 0)
|
||||||
|
|
|
@ -857,6 +857,8 @@ int (*WalkTable[])() = {
|
||||||
WalkLink,
|
WalkLink,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern t_desig null_desig;
|
||||||
|
|
||||||
ExpectBool(pnd, true_label, false_label)
|
ExpectBool(pnd, true_label, false_label)
|
||||||
register t_node **pnd;
|
register t_node **pnd;
|
||||||
label true_label, false_label;
|
label true_label, false_label;
|
||||||
|
@ -864,17 +866,17 @@ ExpectBool(pnd, true_label, false_label)
|
||||||
/* "pnd" must indicate a boolean expression. Check this and
|
/* "pnd" must indicate a boolean expression. Check this and
|
||||||
generate code to evaluate the expression.
|
generate code to evaluate the expression.
|
||||||
*/
|
*/
|
||||||
register t_desig *ds = new_desig();
|
t_desig ds;
|
||||||
|
|
||||||
|
ds = null_desig;
|
||||||
if (ChkExpression(pnd)) {
|
if (ChkExpression(pnd)) {
|
||||||
if ((*pnd)->nd_type != bool_type &&
|
if ((*pnd)->nd_type != bool_type &&
|
||||||
(*pnd)->nd_type != error_type) {
|
(*pnd)->nd_type != error_type) {
|
||||||
node_error(*pnd, "boolean expression expected");
|
node_error(*pnd, "boolean expression expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeExpr(*pnd, ds, true_label, false_label);
|
CodeExpr(*pnd, &ds, true_label, false_label);
|
||||||
}
|
}
|
||||||
free_desig(ds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -887,7 +889,7 @@ WalkDesignator(pnd, ds, flags)
|
||||||
|
|
||||||
if (! ChkVariable(pnd, flags)) return 0;
|
if (! ChkVariable(pnd, flags)) return 0;
|
||||||
|
|
||||||
clear((char *) ds, sizeof(t_desig));
|
*ds = null_desig;
|
||||||
CodeDesig(*pnd, ds);
|
CodeDesig(*pnd, ds);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -967,7 +969,7 @@ DoAssign(nd)
|
||||||
it sais that the left hand side is evaluated first.
|
it sais that the left hand side is evaluated first.
|
||||||
DAMN THE BOOK!
|
DAMN THE BOOK!
|
||||||
*/
|
*/
|
||||||
register t_desig *dsr;
|
t_desig dsr;
|
||||||
register t_type *tp;
|
register t_type *tp;
|
||||||
|
|
||||||
if (! (ChkExpression(&(nd->nd_RIGHT)) &
|
if (! (ChkExpression(&(nd->nd_RIGHT)) &
|
||||||
|
@ -979,20 +981,19 @@ DoAssign(nd)
|
||||||
if (! ChkAssCompat(&(nd->nd_RIGHT), tp, "assignment")) {
|
if (! ChkAssCompat(&(nd->nd_RIGHT), tp, "assignment")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dsr = new_desig();
|
dsr = null_desig;
|
||||||
|
|
||||||
#define StackNeededFor(ds) ((ds)->dsg_kind == DSG_PLOADED \
|
#define StackNeededFor(ds) ((ds).dsg_kind == DSG_PLOADED \
|
||||||
|| (ds)->dsg_kind == DSG_INDEXED)
|
|| (ds).dsg_kind == DSG_INDEXED)
|
||||||
CodeExpr(nd->nd_RIGHT, dsr, NO_LABEL, NO_LABEL);
|
CodeExpr(nd->nd_RIGHT, &dsr, NO_LABEL, NO_LABEL);
|
||||||
tp = nd->nd_RIGHT->nd_type;
|
tp = nd->nd_RIGHT->nd_type;
|
||||||
if (complex(tp)) {
|
if (complex(tp)) {
|
||||||
if (StackNeededFor(dsr)) CodeAddress(dsr);
|
if (StackNeededFor(dsr)) CodeAddress(&dsr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CodeValue(dsr, tp);
|
CodeValue(&dsr, tp);
|
||||||
}
|
}
|
||||||
CodeMove(dsr, nd->nd_LEFT, tp);
|
CodeMove(&dsr, nd->nd_LEFT, tp);
|
||||||
free_desig(dsr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
Loading…
Add table
Reference in a new issue