Added enums
git-svn-id: svn://svn.cc65.org/cc65/trunk@2665 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -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 */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user