X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fca65%2Fexpr.h;h=8d492a3dba42094742db8c4628a9bcc6c276dff5;hb=112ae0e3db511ddd92e769c11328646ebe2a6240;hp=58b787a4a9b1000746e4194e2a95d23e5b7f24fc;hpb=cdedb311997c2da932368177aa824195c8fceae0;p=cc65 diff --git a/src/ca65/expr.h b/src/ca65/expr.h index 58b787a4a..8d492a3db 100644 --- a/src/ca65/expr.h +++ b/src/ca65/expr.h @@ -6,8 +6,8 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ +/* (C) 1998-2006 Ullrich von Bassewitz */ +/* Römerstraße 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ @@ -44,7 +44,17 @@ /*****************************************************************************/ -/* Code */ +/* Forwards */ +/*****************************************************************************/ + + + +struct ExprDesc; + + + +/*****************************************************************************/ +/* Code */ /*****************************************************************************/ @@ -63,9 +73,21 @@ long ConstExpression (void); void FreeExpr (ExprNode* Root); /* Free the expression tree, Root is pointing to. */ +ExprNode* SimplifyExpr (ExprNode* Expr, const struct ExprDesc* D); +/* Try to simplify the given expression tree */ + ExprNode* GenLiteralExpr (long Val); /* Return an expression tree that encodes the given literal value */ +ExprNode* GenLiteral0 (void); +/* Return an expression tree that encodes the the number zero */ + +ExprNode* GenSymExpr (struct SymEntry* Sym); +/* Return an expression node that encodes the given symbol */ + +ExprNode* GenAddExpr (ExprNode* Left, ExprNode* Right); +/* Generate an addition from the two operands */ + ExprNode* GenCurrentPC (void); /* Return the current program counter as expression */ @@ -89,29 +111,23 @@ ExprNode* GenWordExpr (ExprNode* Expr); ExprNode* GenNE (ExprNode* Expr, long Val); /* Generate an expression that compares Expr and Val for inequality */ -int IsConstExpr (ExprNode* Root); +int IsConstExpr (ExprNode* Expr, long* Val); /* Return true if the given expression is a constant expression, that is, one - * with no references to external symbols. + * with no references to external symbols. If Val is not NULL and the + * expression is constant, the constant value is stored here. */ int IsByteExpr (ExprNode* Root); /* Return true if this is a byte expression */ -long GetExprVal (ExprNode* Expr); -/* Get the value of a constant expression */ - int IsByteRange (long Val); /* Return true if this is a byte value */ int IsWordRange (long Val); /* Return true if this is a word value */ -ExprNode* FinalizeExpr (ExprNode* Expr); -/* Resolve any symbols by cloning the symbol expression tree instead of the - * symbol reference, then try to simplify the expression as much as possible. - * This function must only be called if all symbols are resolved (no undefined - * symbol errors). - */ +int IsFarRange (long Val); +/* Return true if this is a far (24 bit) value */ ExprNode* CloneExpr (ExprNode* Expr); /* Clone the given expression tree. The function will simply clone symbol @@ -121,6 +137,23 @@ ExprNode* CloneExpr (ExprNode* Expr); void WriteExpr (ExprNode* Expr); /* Write the given expression to the object file */ +void ExprGuessedAddrSize (const ExprNode* Expr, unsigned char AddrSize); +/* Mark the address size of the given expression tree as guessed. The address + * size passed as argument is the one NOT used, because the actual address + * size wasn't known. Example: Zero page addressing was not used because symbol + * is undefined, and absolute addressing was available. + * This function will actually parse the expression tree for undefined symbols, + * and mark these symbols accordingly. + */ + +ExprNode* FuncBankByte (void); +/* Handle the .BANKBYTE builtin function */ + +ExprNode* FuncLoByte (void); +/* Handle the .LOBYTE builtin function */ + +ExprNode* FuncHiByte (void); +/* Handle the .HIBYTE builtin function */ /* End of expr.h */