Added enums

git-svn-id: svn://svn.cc65.org/cc65/trunk@2665 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-11-14 09:03:32 +00:00
parent 742b1ffd8e
commit 0e392b79bd
12 changed files with 235 additions and 31 deletions

View File

@@ -1523,30 +1523,6 @@ static void StudyExpr (ExprNode* Expr, ExprDesc* D, int Sign)
static ExprNode* SimplifyExpr (ExprNode* Expr)
/* Try to simplify the given expression tree */
{
if (Expr && Expr->Op != EXPR_LITERAL) {
/* Create an expression description and initialize it */
ExprDesc D;
InitExprDesc (&D);
/* Study the expression */
StudyExpr (Expr, &D, 1);
/* Now check if we can generate a literal value */
if (ExprDescIsConst (&D)) {
/* No external references */
FreeExpr (Expr);
Expr = GenLiteralExpr (D.Val);
}
}
return Expr;
}
ExprNode* Expression (void)
/* Evaluate an expression, build the expression tree on the heap and return
* a pointer to the root of the tree.
@@ -1610,6 +1586,30 @@ void FreeExpr (ExprNode* Root)
ExprNode* SimplifyExpr (ExprNode* Expr)
/* Try to simplify the given expression tree */
{
if (Expr && Expr->Op != EXPR_LITERAL) {
/* Create an expression description and initialize it */
ExprDesc D;
InitExprDesc (&D);
/* Study the expression */
StudyExpr (Expr, &D, 1);
/* Now check if we can generate a literal value */
if (ExprDescIsConst (&D)) {
/* No external references */
FreeExpr (Expr);
Expr = GenLiteralExpr (D.Val);
}
}
return Expr;
}
ExprNode* GenLiteralExpr (long Val)
/* Return an expression tree that encodes the given literal value */
{