def.c
defmodule.c
desig.c
-desig.H
+desig.h
em_m2.6
enter.c
error.c
GENH = errout.h \
idfsize.h numsize.h strsize.h target_sizes.h bigresult.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
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 \
walk.h warning.h SYSTEM.h $(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
type.h: make.allocd
real.h: make.allocd
node.h: make.allocd
-desig.h: make.allocd
scope.c: make.allocd
tmpvar.c: make.allocd
casestat.c: make.allocd
MkSet(size)
unsigned size;
{
- register arith *s;
+ register arith *s, *t;
- s = (arith *) Malloc(size);
+ s = t = (arith *) Malloc(size);
clear((char *) s , size);
s++;
+ size /= sizeof(arith);
+ while (size--) *t++ = 0;
inc_refcount(s);
return s;
}
extern char *symbol2str();
extern int proclevel;
extern char options[];
+extern t_desig null_desig;
int fp_used;
CodeConst(cst, size)
case OR:
case AND: {
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) {
true_label = ++text_label;
}
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);
- clear((char *) Des, sizeof(t_desig));
- CodeExpr(rightop, Des, true_label, false_label);
+ Des = null_desig;
+ CodeExpr(rightop, &Des, true_label, false_label);
if (l_end != NO_LABEL) {
def_ilb(true_label);
c_loc(1);
c_loc(0);
def_ilb(l_end);
}
- free_desig(Des);
break;
}
default:
/* Generate code to push the value of the expression "nd"
on the stack.
*/
- register t_desig *designator = new_desig();
+ t_desig designator;
- CodeExpr(nd, designator, NO_LABEL, NO_LABEL);
- CodeValue(designator, nd->nd_type);
- free_desig(designator);
+ designator = null_desig;
+ CodeExpr(nd, &designator, NO_LABEL, NO_LABEL);
+ CodeValue(&designator, nd->nd_type);
}
CodeDAddress(nd, chk_controlvar)
on the stack.
*/
- register t_desig *designator = new_desig();
+ t_desig designator;
int chkptr;
+ designator = null_desig;
if (chk_controlvar) ChkForFOR(nd);
- CodeDesig(nd, designator);
- chkptr = designator->dsg_kind==DSG_PLOADED ||
- designator->dsg_kind==DSG_PFIXED;
- CodeAddress(designator);
+ CodeDesig(nd, &designator);
+ chkptr = designator.dsg_kind==DSG_PLOADED ||
+ designator.dsg_kind==DSG_PFIXED;
+ CodeAddress(&designator);
/* Generate dummy use of pointer, to get possible error message
as soon as possible
C_loi((arith) 1);
C_asp(word_size);
}
- free_desig(designator);
}
CodeDStore(nd)
designator "nd".
*/
- register t_desig *designator = new_desig();
+ t_desig designator;
+ designator = null_desig;
ChkForFOR(nd);
- CodeDesig(nd, designator);
- CodeStore(designator, nd->nd_type);
- free_desig(designator);
+ CodeDesig(nd, &designator);
+ CodeStore(&designator, nd->nd_type);
}
DoHIGH(df)
}
}
+t_desig null_desig;
+
CodeMove(rhs, left, rtp)
register t_desig *rhs;
register t_node *left;
Go through some (considerable) trouble to see if a BLM can be
generated.
*/
- register t_desig *lhs = new_desig();
+ t_desig lhs;
register t_type *tp = left->nd_type;
int loadedflag = 0;
+ lhs = null_desig;
ChkForFOR(left);
switch(rhs->dsg_kind) {
case DSG_LOADED:
- CodeDesig(left, lhs);
+ CodeDesig(left, &lhs);
if (rtp->tp_fund == T_STRING) {
/* size of a string literal fits in an
int of size word_size
*/
- CodeAddress(lhs);
+ CodeAddress(&lhs);
C_loc(rtp->tp_size);
C_loc(tp->tp_size);
CAL("StringAssign", (int)pointer_size + (int)pointer_size + (int)dword_size);
break;
}
- CodeStore(lhs, tp);
+ CodeStore(&lhs, tp);
break;
case DSG_FIXED:
- CodeDesig(left, lhs);
- if (lhs->dsg_kind == DSG_FIXED &&
+ CodeDesig(left, &lhs);
+ if (lhs.dsg_kind == DSG_FIXED &&
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) {
register int sz = 1;
arith size = tp->tp_size;
/* First copy up to word-aligned
boundaries
*/
- if (!((int)(lhs->dsg_offset)%(sz+sz))) {
+ if (!((int)(lhs.dsg_offset)%(sz+sz))) {
sz += sz;
}
- else CodeCopy(lhs, rhs, (arith) sz, &size);
+ else CodeCopy(&lhs, rhs, (arith) sz, &size);
}
/* Now copy the bulk
*/
sz = (int) size % (int) word_size;
size -= sz;
- CodeCopy(lhs, rhs, size, &size);
+ CodeCopy(&lhs, rhs, size, &size);
size = sz;
sz = word_size;
while (size) {
*/
sz >>= 1;
if (size >= sz) {
- CodeCopy(lhs, rhs, (arith) sz, &size);
+ CodeCopy(&lhs, rhs, (arith) sz, &size);
}
}
break;
}
- CodeAddress(lhs);
+ CodeAddress(&lhs);
loadedflag = 1;
/* Fall through */
case DSG_PLOADED:
C_exg(pointer_size);
}
else {
- CodeDesig(left, lhs);
- CodeAddress(lhs);
+ CodeDesig(left, &lhs);
+ CodeAddress(&lhs);
}
switch (suitable_move(tp)) {
case USE_BLM:
default:
crash("CodeMove");
}
- free_desig(lhs);
}
CodeAddress(ds)
*/
struct desig {
- int dsg_kind;
+ short dsg_kind;
#define DSG_INIT 0 /* don't know anything yet */
#define DSG_LOADED 1 /* designator loaded on top of the stack */
#define DSG_PLOADED 2 /* designator accessible through pointer on
*/
};
+typedef struct desig t_desig;
+
/* The next structure describes the designator in a with-statement.
We have a linked list of them, as with-statements may be nested.
*/
struct withdesig {
struct withdesig *w_next;
+ int w_flags; /* D_USED|D_DEFINED */
struct scope *w_scope; /* scope in which fields of this record
reside
*/
- struct desig w_desig; /* a desig structure for this particular
+ t_desig w_desig; /* a desig structure for this particular
designator
*/
};
extern struct withdesig *WithDesigs;
-extern struct desig InitDesig;
#define NO_LABEL ((label) 0)
WalkLink,
};
+extern t_desig null_desig;
+
ExpectBool(pnd, true_label, false_label)
register t_node **pnd;
label true_label, false_label;
/* "pnd" must indicate a boolean expression. Check this and
generate code to evaluate the expression.
*/
- register t_desig *ds = new_desig();
+ t_desig ds;
+ ds = null_desig;
if (ChkExpression(pnd)) {
if ((*pnd)->nd_type != bool_type &&
(*pnd)->nd_type != error_type) {
node_error(*pnd, "boolean expression expected");
}
- CodeExpr(*pnd, ds, true_label, false_label);
+ CodeExpr(*pnd, &ds, true_label, false_label);
}
- free_desig(ds);
}
int
if (! ChkVariable(pnd, flags)) return 0;
- clear((char *) ds, sizeof(t_desig));
+ *ds = null_desig;
CodeDesig(*pnd, ds);
return 1;
}
it sais that the left hand side is evaluated first.
DAMN THE BOOK!
*/
- register t_desig *dsr;
+ t_desig dsr;
register t_type *tp;
if (! (ChkExpression(&(nd->nd_RIGHT)) &
if (! ChkAssCompat(&(nd->nd_RIGHT), tp, "assignment")) {
return;
}
- dsr = new_desig();
+ dsr = null_desig;
-#define StackNeededFor(ds) ((ds)->dsg_kind == DSG_PLOADED \
- || (ds)->dsg_kind == DSG_INDEXED)
- CodeExpr(nd->nd_RIGHT, dsr, NO_LABEL, NO_LABEL);
+#define StackNeededFor(ds) ((ds).dsg_kind == DSG_PLOADED \
+ || (ds).dsg_kind == DSG_INDEXED)
+ CodeExpr(nd->nd_RIGHT, &dsr, NO_LABEL, NO_LABEL);
tp = nd->nd_RIGHT->nd_type;
if (complex(tp)) {
- if (StackNeededFor(dsr)) CodeAddress(dsr);
+ if (StackNeededFor(dsr)) CodeAddress(&dsr);
}
else {
- CodeValue(dsr, tp);
+ CodeValue(&dsr, tp);
}
- CodeMove(dsr, nd->nd_LEFT, tp);
- free_desig(dsr);
+ CodeMove(&dsr, nd->nd_LEFT, tp);
}
static