ex->level = NestLevel;
ex->block = currBlockno;
ex->initMode = inInitMode;
+ ex->seqPoint = seqPointNo;
return ex;
}
return tree;
}
+/*-----------------------------------------------------------------*/
+/* removePreIncDecOps: remove for side effects in *_ASSIGN's */
+/* "*++s += 3" -> "*++s = *++s + 3" */
+/*-----------------------------------------------------------------*/
+ast *removePreIncDecOps (ast * tree) {
+
+ // traverse the tree and remove pre-inc/dec ops
+
+ if (!tree)
+ return NULL;
+
+ if (tree->type == EX_OP &&
+ (tree->opval.op == INC_OP || tree->opval.op == DEC_OP)) {
+ if (tree->right)
+ tree=tree->right;
+ }
+
+ tree->left=removePreIncDecOps(tree->left);
+ tree->right=removePreIncDecOps(tree->right);
+
+ return tree;
+}
+
+/*-----------------------------------------------------------------*/
+/* removePostIncDecOps: remove for side effects in *_ASSIGN's */
+/* "*s++ += 3" -> "*s++ = *s++ + 3" */
+/*-----------------------------------------------------------------*/
+ast *removePostIncDecOps (ast * tree) {
+
+ // traverse the tree and remove pre-inc/dec ops
+
+ if (!tree)
+ return NULL;
+
+ if (tree->type == EX_OP &&
+ (tree->opval.op == INC_OP || tree->opval.op == DEC_OP)) {
+ if (tree->left)
+ tree=tree->left;
+ }
+
+ tree->left=removePostIncDecOps(tree->left);
+ tree->right=removePostIncDecOps(tree->right);
+
+ return tree;
+}
+
/*-----------------------------------------------------------------*/
/* hasSEFcalls - returns TRUE if tree has a function call */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* isAstEqual - compares two asts & returns 1 if they are equal */
/*-----------------------------------------------------------------*/
-int
+static int
isAstEqual (ast * t1, ast * t2)
{
if (!t1 && !t2)
tree->trueLabel->name)))
tree->trueLabel = csym;
else
- werror (E_LABEL_UNDEF, tree->trueLabel->name);
+ werrorfl (tree->filename, tree->lineno, E_LABEL_UNDEF,
+ tree->trueLabel->name);
}
if (tree->falseLabel)
tree->falseLabel->name)))
tree->falseLabel = csym;
else
- werror (E_LABEL_UNDEF, tree->falseLabel->name);
+ werrorfl (tree->filename, tree->lineno, E_LABEL_UNDEF,
+ tree->falseLabel->name);
}
}
tree->opval.val->sym->name);
if (!csym)
- werror (E_LABEL_UNDEF, tree->opval.val->sym->name);
+ werrorfl (tree->filename, tree->lineno, E_LABEL_UNDEF,
+ tree->opval.val->sym->name);
else
tree->opval.val->sym = csym;
tree->opval.val->sym->etype = newIntLink ();
tree->opval.val->etype = tree->opval.val->etype;
tree->opval.val->type = tree->opval.val->sym->type;
- werror (W_IMPLICIT_FUNC, tree->opval.val->sym->name);
+ werrorfl (tree->filename, tree->lineno, W_IMPLICIT_FUNC,
+ tree->opval.val->sym->name);
+ //tree->opval.val->sym->undefined = 1;
allocVariables (tree->opval.val->sym);
}
else
/* exist and this is not defined as a variable arg */
if (!defParm && actParm && !IFFUNC_HASVARARGS(func->ftype))
{
+ //if (func->type==EX_VALUE && func->opval.val->sym->undefined)
+ // return 1; /* Already gave them an undefined function error */
werror (E_TOO_MANY_PARMS);
return 1;
}
}
if (iloop) {
- werror (W_EXCESS_INITIALIZERS, "struct",
- sym->opval.val->sym->name, sym->opval.val->sym->lineDef);
+ werrorfl (filename, sym->opval.val->sym->lineDef,
+ W_EXCESS_INITIALIZERS, "struct",
+ sym->opval.val->sym->name);
}
return rast;
char *name=sym->opval.val->sym->name;
int lineno=sym->opval.val->sym->lineDef;
- werror (W_EXCESS_INITIALIZERS, "array", name, lineno);
+ werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
}
}
else
// there has to be a better way
char *name=sym->opval.val->sym->name;
int lineno=sym->opval.val->sym->lineDef;
- werror (W_EXCESS_INITIALIZERS, "array", name, lineno);
+ werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
break;
}
/* to the array element */
char *s = SPEC_CVAL (iexpr->etype).v_char;
int i = 0;
+ int size = getSize (iexpr->ftype);
+ int symsize = getSize (type);
+
+ if (size>symsize)
+ {
+ if (size>(symsize+1))
+ werrorfl (iexpr->filename, iexpr->lineno, W_EXCESS_INITIALIZERS,
+ "string", sym->opval.val->sym->name);
+ size = symsize;
+ }
- while (*s)
+ for (i=0;i<size;i++)
{
rast = newNode (NULLOP,
rast,
newNode ('[', sym,
newAst_VALUE (valueFromLit ((float) i))),
newAst_VALUE (valueFromLit (*s))));
- i++;
s++;
}
- rast = newNode (NULLOP,
- rast,
- newNode ('=',
- newNode ('[', sym,
- newAst_VALUE (valueFromLit ((float) i))),
- newAst_VALUE (valueFromLit (*s))));
// now WE don't need iexpr's symbol anymore
freeStringSymbol(AST_SYMBOL(iexpr));
work = initAggregates (sym, sym->ival, NULL);
} else {
if (getNelements(sym->type, sym->ival)>1) {
- werror (W_EXCESS_INITIALIZERS, "scalar",
- sym->name, sym->lineDef);
+ werrorfl (filename, sym->lineDef,
+ W_EXCESS_INITIALIZERS, "scalar",
+ sym->name);
}
work = newNode ('=', newAst_VALUE (symbolVal (newSym)),
list2expr (sym->ival));
work = initAggregates (sym, sym->ival, NULL);
} else {
if (getNelements(sym->type, sym->ival)>1) {
- werror (W_EXCESS_INITIALIZERS, "scalar",
- sym->name, sym->lineDef);
+ werrorfl (filename, sym->lineDef,
+ W_EXCESS_INITIALIZERS, "scalar",
+ sym->name);
}
work = newNode ('=', newAst_VALUE (symbolVal (sym)),
list2expr (sym->ival));
static int charLbl = 0;
symbol *sym;
set *sp;
+ int size;
// have we heard this before?
for (sp=statsg->syms; sp; sp=sp->next) {
sym=sp->item;
- if (sym->isstrlit &&
- !strcmp(SPEC_CVAL(sym->etype).v_char, SPEC_CVAL(val->etype).v_char)) {
+ size = getSize (sym->type);
+ if (sym->isstrlit && size == getSize (val->type) &&
+ !memcmp(SPEC_CVAL(sym->etype).v_char, SPEC_CVAL(val->etype).v_char, size)) {
// yes, this is old news. Don't publish it again.
sym->isstrlit++; // but raise the usage count
return symbolVal(sym);
else
return FALSE;
}
-
+
return astHasSymbol (tree->left, sym) ||
astHasSymbol (tree->right, sym);
}
{
ast *dtl, *dtr;
+ #if 0
+ if (tree->opval.op == NULLOP || tree->opval.op == BLOCK)
+ {
+ if (tree->left && tree->left->type == EX_OPERAND
+ && (tree->left->opval.op == INC_OP
+ || tree->left->opval.op == DEC_OP)
+ && tree->left->left)
+ {
+ tree->left->right = tree->left->left;
+ tree->left->left = NULL;
+ }
+ if (tree->right && tree->right->type == EX_OPERAND
+ && (tree->right->opval.op == INC_OP
+ || tree->right->opval.op == DEC_OP)
+ && tree->right->left)
+ {
+ tree->right->right = tree->right->left;
+ tree->right->left = NULL;
+ }
+ }
+ #endif
+
dtl = decorateType (tree->left);
/* delay right side for '?' operator since conditional macro expansions might
rely on this */
/* adjust the storage class */
switch (DCL_TYPE(tree->left->ftype)) {
case POINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_DATA;
break;
case FPOINTER:
SPEC_SCLS(TETYPE(tree)) = S_XDATA;
SPEC_SCLS(TETYPE(tree)) = S_CODE;
break;
case GPOINTER:
+ SPEC_SCLS (TETYPE (tree)) = 0;
break;
case PPOINTER:
SPEC_SCLS(TETYPE(tree)) = S_XSTACK;
SPEC_SCLS(TETYPE(tree)) = S_EEPROM;
break;
case UPOINTER:
+ SPEC_SCLS (TETYPE (tree)) = 0;
+ break;
case ARRAY:
case FUNCTION:
break;
}
+ /* This breaks with extern declarations, bitfields, and perhaps other */
+ /* cases (gcse). Let's leave this optimization disabled for now and */
+ /* ponder if there's a safe way to do this. -- EEP */
+ #if 0
if (IS_ADDRESS_OF_OP (tree->left) && IS_AST_SYM_VALUE(tree->left->left)
&& SPEC_ABSA (AST_SYMBOL (tree->left->left)->etype))
{
tree->left = NULL;
tree->right = NULL;
}
-
+ #endif
+
return tree;
/*------------------------------------------------------------------*/
}
TTYPE (tree) =
- computeType (LTYPE (tree), RTYPE (tree));
+ computeType (LTYPE (tree), RTYPE (tree), FALSE);
TETYPE (tree) = getSpec (TTYPE (tree));
/* if left is a literal exchange left & right */
goto errorTreeReturn;
}
- if (SPEC_SCLS (tree->left->etype) == S_REGISTER)
+ if (LETYPE(tree) && SPEC_SCLS (tree->left->etype) == S_REGISTER)
{
werror (E_ILLEGAL_ADDR, "address of register variable");
goto errorTreeReturn;
werror (E_LVALUE_REQUIRED, "address of");
goto errorTreeReturn;
}
- if (SPEC_SCLS (tree->left->etype) == S_CODE)
+ if (!LETYPE (tree))
+ DCL_TYPE (p) = POINTER;
+ else if (SPEC_SCLS (tree->left->etype) == S_CODE)
DCL_TYPE (p) = CPOINTER;
else if (SPEC_SCLS (tree->left->etype) == S_XDATA)
DCL_TYPE (p) = FPOINTER;
wtree = optimizeSWAP (tree);
if (wtree != tree)
return decorateType (wtree);
-
- // fall through
}
/* if left is a literal exchange left & right */
decorateType (parent);
}
}
+ /* fall through */
+
/*------------------------------------------------------------------*/
/*----------------------------*/
/* bitwise xor */
/* if right is a literal and */
/* we can find a 2nd literal in a xor-tree then */
/* rearrange the tree */
- if (IS_LITERAL (RTYPE (tree)))
+ if (IS_LITERAL (RTYPE (tree)) &&
+ tree->opval.op == '^') /* the same source is used by 'bitwise or' */
{
ast *parent;
ast *litTree = searchLitOp (tree, &parent, "^");
LRVAL (tree) = RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ FALSE));
+
+ return tree;
/*------------------------------------------------------------------*/
/*----------------------------*/
LRVAL (tree) = RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ TRUE));
/* if right is a literal and */
/* left is also a division by a literal then */
LRVAL (tree) = RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ TRUE));
return tree;
/*------------------------------------------------------------------*/
}
TTYPE (tree) = copyLinkChain (LTYPE (tree)->next);
TETYPE (tree) = getSpec (TTYPE (tree));
+ /* adjust the storage class */
+ switch (DCL_TYPE(tree->left->ftype)) {
+ case POINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_DATA;
+ break;
+ case FPOINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_XDATA;
+ break;
+ case CPOINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_CODE;
+ break;
+ case GPOINTER:
+ SPEC_SCLS (TETYPE (tree)) = 0;
+ break;
+ case PPOINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_XSTACK;
+ break;
+ case IPOINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_IDATA;
+ break;
+ case EEPPOINTER:
+ SPEC_SCLS(TETYPE(tree)) = S_EEPROM;
+ break;
+ case UPOINTER:
+ SPEC_SCLS (TETYPE (tree)) = 0;
+ break;
+ case ARRAY:
+ case FUNCTION:
+ break;
+ }
return tree;
}
LRVAL (tree) = RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
-
- /* promote result to int if left & right are char
- this will facilitate hardware multiplies 8bit x 8bit = 16bit */
- if (IS_CHAR(LETYPE(tree)) && IS_CHAR(RETYPE(tree))) {
- SPEC_NOUN(TETYPE(tree)) = V_INT;
- }
+ RTYPE (tree),
+ TRUE));
return tree;
/* if unary plus */
if (!tree->right)
{
- if (!IS_INTEGRAL (LTYPE (tree)))
+ if (!IS_ARITHMETIC (LTYPE (tree)))
{
werror (E_UNARY_OP, '+');
goto errorTreeReturn;
else
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ FALSE));
return tree;
/*------------------------------------------------------------------*/
else
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ FALSE));
LRVAL (tree) = RRVAL (tree) = 1;
return tree;
}
+ LRVAL (tree) = RRVAL (tree) = 1;
+ if (tree->opval.op == LEFT_OP)
+ {
+ /* promote char to int */
+ TETYPE (tree) = getSpec (TTYPE (tree) =
+ computeType (LTYPE (tree),
+ LTYPE (tree), /* no, not RTYPE! */
+ TRUE));
+ }
+ else /* RIGHT_OP */
+ {
+ /* no promotion necessary */
+ TTYPE (tree) = TETYPE (tree) = copyLinkChain (LTYPE (tree));
+ if (IS_LITERAL (TTYPE (tree)))
+ SPEC_SCLS (TTYPE (tree)) &= ~S_LITERAL;
+ }
+
/* if only the right side is a literal & we are
shifting more than size of the left operand then zero */
if (IS_LITERAL (RTYPE (tree)) &&
- ((unsigned) floatFromVal (valFromType (RETYPE (tree)))) >=
- (getSize (LTYPE (tree)) * 8))
+ ((TYPE_UDWORD) floatFromVal (valFromType (RETYPE (tree)))) >=
+ (getSize (TETYPE (tree)) * 8))
{
if (tree->opval.op==LEFT_OP ||
- (tree->opval.op==RIGHT_OP && SPEC_USIGN(LETYPE(tree)))) {
- lineno=tree->lineno;
- werror (W_SHIFT_CHANGED,
- (tree->opval.op == LEFT_OP ? "left" : "right"));
- tree->type = EX_VALUE;
- tree->left = tree->right = NULL;
- tree->opval.val = constVal ("0");
- TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
- return tree;
- }
+ (tree->opval.op==RIGHT_OP && SPEC_USIGN(LETYPE(tree))))
+ {
+ lineno=tree->lineno;
+ werror (W_SHIFT_CHANGED,
+ (tree->opval.op == LEFT_OP ? "left" : "right"));
+ tree->type = EX_VALUE;
+ tree->left = tree->right = NULL;
+ tree->opval.val = constVal ("0");
+ TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
+ return tree;
+ }
}
- LRVAL (tree) = RRVAL (tree) = 1;
- TTYPE (tree) = TETYPE (tree) = copyLinkChain (LTYPE (tree));
- if (IS_LITERAL (TTYPE (tree)))
- SPEC_SCLS (TTYPE (tree)) &= ~S_LITERAL;
+
return tree;
/*------------------------------------------------------------------*/
tree->opval.val = valCastLiteral (
LTYPE (tree),
element->offset
- + floatFromVal (valFromType (RETYPE (tree->right->left->left)))
+ + floatFromVal (valFromType (RTYPE (tree->right->left->left)))
);
TTYPE (tree) = tree->opval.val->type;
/* if the right is a literal replace the tree */
if (IS_LITERAL (RETYPE (tree))) {
- if (IS_PTR (LTYPE (tree)) && !IS_GENPTR (LTYPE (tree)) ) {
+ #if 0
+ if (IS_PTR (LTYPE (tree)) && !IS_GENPTR (LTYPE (tree)) ) {
/* rewrite (type *)litaddr
as &temp
and define type at litaddr temp
sym->cdef = 1;
sym->isref = 1;
SPEC_STAT (sym->etype) = 1;
- SPEC_ADDR(sym->etype) = floatFromVal (valFromType (RETYPE (tree)));
+ SPEC_ADDR(sym->etype) = floatFromVal (valFromType (RTYPE (tree)));
SPEC_ABSA(sym->etype) = 1;
addSym (SymbolTab, sym, sym->name, 0, 0, 0);
allocGlobal (sym);
TLVAL (newTree) = 1;
return newTree;
}
+ #endif
if (!IS_PTR (LTYPE (tree))) {
tree->type = EX_VALUE;
tree->opval.val =
valCastLiteral (LTYPE (tree),
- floatFromVal (valFromType (RETYPE (tree))));
+ floatFromVal (valFromType (RTYPE (tree))));
TTYPE (tree) = tree->opval.val->type;
tree->left = NULL;
tree->right = NULL;
IS_LITERAL (LTYPE (tree)))
{
tree->type = EX_VALUE;
- tree->opval.val = valLogicAndOr (valFromType (LETYPE (tree)),
- valFromType (RETYPE (tree)),
+ tree->opval.val = valLogicAndOr (valFromType (LTYPE (tree)),
+ valFromType (RTYPE (tree)),
tree->opval.op);
tree->right = tree->left = NULL;
TETYPE (tree) = getSpec (TTYPE (tree) =
if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
werror (E_COMPARE_OP);
- fprintf (stderr, "comparring type ");
+ fprintf (stderr, "comparing type ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, "to type ");
printTypeChain (RTYPE (tree), stderr);
}
/* if unsigned value < 0 then always false */
/* if (unsigned value) > 0 then (unsigned value) */
- if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree)) &&
- ((int) floatFromVal (valFromType (RETYPE (tree)))) == 0) {
-
- if (tree->opval.op == '<') {
+ if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree)) &&
+ ((int) floatFromVal (valFromType (RETYPE (tree)))) == 0)
+ {
+ if (tree->opval.op == '<')
+ {
return tree->right;
- }
- if (tree->opval.op == '>') {
+ }
+ if (tree->opval.op == '>')
+ {
return tree->left;
- }
- }
+ }
+ }
/* if they are both literal then */
/* rewrite the tree */
if (IS_LITERAL (RTYPE (tree)) &&
goto errorTreeReturn;
}
- TTYPE (tree) = computeType (LTYPE (tree), RTYPE (tree));
+ TTYPE (tree) = computeType (LTYPE (tree), RTYPE (tree), FALSE);
TETYPE (tree) = getSpec (TTYPE (tree));
return tree;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
- werror (E_CODE_WRITE, *tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
+ werror (E_CODE_WRITE, tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, *tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
+ werror (E_LVALUE_REQUIRED, tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
goto errorTreeReturn;
}
LLVAL (tree) = 1;
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ FALSE));
if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "-=");
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
- RTYPE (tree)));
+ RTYPE (tree),
+ FALSE));
if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "+=");
if (compareType (currFunc->type->next, RTYPE (tree)) == 0)
{
- werror (W_RETURN_MISMATCH);
+ werrorfl (tree->filename, tree->lineno, W_RETURN_MISMATCH);
printFromToType (RTYPE(tree), currFunc->type->next);
goto errorTreeReturn;
}
&& tree->right &&
!IS_VOID (RTYPE (tree)))
{
- werror (E_FUNC_VOID);
+ werrorfl (tree->filename, tree->lineno, E_FUNC_VOID);
goto errorTreeReturn;
}
/* the switch value must be an integer */
if (!IS_INTEGRAL (LTYPE (tree)))
{
- werror (E_SWITCH_NON_INTEGER);
+ werrorfl (tree->filename, tree->lineno, E_SWITCH_NON_INTEGER);
goto errorTreeReturn;
}
LRVAL (tree) = 1;
/* then case is out of context */
if (!swStat)
{
- werror (E_CASE_CONTEXT);
+ werrorfl (caseVal->filename, caseVal->lineno, E_CASE_CONTEXT);
return NULL;
}
/* if not a constant then error */
if (!IS_LITERAL (caseVal->ftype))
{
- werror (E_CASE_CONSTANT);
+ werrorfl (caseVal->filename, caseVal->lineno, E_CASE_CONSTANT);
return NULL;
}
/* if not a integer than error */
if (!IS_INTEGRAL (caseVal->ftype))
{
- werror (E_CASE_NON_INTEGER);
+ werrorfl (caseVal->filename, caseVal->lineno, E_CASE_NON_INTEGER);
return NULL;
}
{
pval->next = caseVal->opval.val;
}
+ else if ((int) floatFromVal (val) == cVal)
+ {
+ werrorfl (caseVal->filename, caseVal->lineno, E_DUPLICATE_LABEL,
+ "case");
+ return NULL;
+ }
else
{
/* we found a value greater than */
/* createDefault - creates the parse tree for the default statement */
/*-----------------------------------------------------------------*/
ast *
-createDefault (ast * swStat, ast * stmnt)
+createDefault (ast * swStat, ast * defaultVal, ast * stmnt)
{
char defLbl[SDCC_NAME_MAX + 1];
/* then case is out of context */
if (!swStat)
{
- werror (E_CASE_CONTEXT);
+ werrorfl (defaultVal->filename, defaultVal->lineno, E_CASE_CONTEXT);
+ return NULL;
+ }
+
+ if (swStat->values.switchVals.swDefault)
+ {
+ werrorfl (defaultVal->filename, defaultVal->lineno, E_DUPLICATE_LABEL,
+ "default");
return NULL;
}
fprintf(outfile,"%u", (TYPE_UDWORD) floatFromVal(tree->opval.val));
else
fprintf(outfile,"%d", (TYPE_DWORD) floatFromVal(tree->opval.val));
- fprintf(outfile,", 0x%x, %g", (TYPE_UDWORD) floatFromVal(tree->opval.val),
+ fprintf(outfile,", 0x%x, %f", (TYPE_UDWORD) floatFromVal(tree->opval.val),
floatFromVal(tree->opval.val));
} else if (tree->opval.val->sym) {
/* if the undefined flag is set then give error message */
{
ast_print(t,stdout,0);
}
+
+
+
+/*-----------------------------------------------------------------*/
+/* astErrors : returns non-zero if errors present in tree */
+/*-----------------------------------------------------------------*/
+int astErrors(ast *t)
+{
+ int errors=0;
+
+ if (t)
+ {
+ if (t->isError)
+ errors++;
+
+ if (t->type == EX_VALUE
+ && t->opval.val->sym
+ && t->opval.val->sym->undefined)
+ errors++;
+
+ errors += astErrors(t->left);
+ errors += astErrors(t->right);
+ }
+
+ return errors;
+}