]> git.sur5r.net Git - cc65/blob - src/ca65/expr.h
Renamed EXP_INITIALIZER
[cc65] / src / ca65 / expr.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  expr.h                                   */
4 /*                                                                           */
5 /*             Expression evaluation for the ca65 macroassembler             */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998     Ullrich von Bassewitz                                        */
10 /*              Wacholderweg 14                                              */
11 /*              D-70597 Stuttgart                                            */
12 /* EMail:       uz@musoftware.de                                             */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef EXPR_H
37 #define EXPR_H
38
39
40
41 /* common */
42 #include "exprdefs.h"
43
44
45
46 /*****************************************************************************/
47 /*                                   Code                                    */
48 /*****************************************************************************/
49
50
51
52 ExprNode* Expression (void);
53 /* Evaluate an expression, build the expression tree on the heap and return
54  * a pointer to the root of the tree.
55  */
56
57 long ConstExpression (void);
58 /* Parse an expression. Check if the expression is const, and print an error
59  * message if not. Return the value of the expression, or a dummy, if it is
60  * not constant.
61  */
62
63 void FreeExpr (ExprNode* Root);
64 /* Free the expression tree, Root is pointing to. */
65
66 ExprNode* LiteralExpr (long Val);
67 /* Return an expression tree that encodes the given literal value */
68
69 ExprNode* CurrentPC (void);
70 /* Return the current program counter as expression */
71
72 ExprNode* SwapExpr (ExprNode* Expr);
73 /* Return an extended expression with lo and hi bytes swapped */
74
75 ExprNode* BranchExpr (unsigned Offs);
76 /* Return an expression that encodes the difference between current PC plus
77  * offset and the target expression (that is, Expression() - (*+Offs) ).
78  */
79
80 ExprNode* ULabelExpr (unsigned Num);
81 /* Return an expression for an unnamed label with the given index */
82
83 ExprNode* ForceWordExpr (ExprNode* Expr);
84 /* Force the given expression into a word and return the result. */
85
86 int IsConstExpr (ExprNode* Root);
87 /* Return true if the given expression is a constant expression, that is, one
88  * with no references to external symbols.
89  */
90
91 int IsByteExpr (ExprNode* Root);
92 /* Return true if this is a byte expression */
93
94 long GetExprVal (ExprNode* Expr);
95 /* Get the value of a constant expression */
96
97 int IsByteRange (long Val);
98 /* Return true if this is a byte value */
99
100 int IsWordRange (long Val);
101 /* Return true if this is a word value */
102
103 ExprNode* FinalizeExpr (ExprNode* Expr);
104 /* Resolve any symbols by cloning the symbol expression tree instead of the
105  * symbol reference, then try to simplify the expression as much as possible.
106  * This function must only be called if all symbols are resolved (no undefined
107  * symbol errors).
108  */
109
110 ExprNode* CloneExpr (ExprNode* Expr);
111 /* Clone the given expression tree. The function will simply clone symbol
112  * nodes, it will not resolve them.
113  */
114
115 void WriteExpr (ExprNode* Expr);
116 /* Write the given expression to the object file */
117
118
119
120 /* End of expr.h */
121
122 #endif
123
124
125