]> git.sur5r.net Git - cc65/blob - src/cc65/expr.h
efd1777e66bf2a2be7161ebd67dd20ed72956aa8
[cc65] / src / cc65 / expr.h
1 /*
2  * expr.h
3  *
4  * Ullrich von Bassewitz, 21.06.1998
5  */
6
7
8
9 #ifndef EXPR_H
10 #define EXPR_H
11
12
13
14 /* cc65 */
15 #include "datatype.h"
16 #include "exprdesc.h"
17
18
19
20 /*****************************************************************************/
21 /*                                   code                                    */
22 /*****************************************************************************/
23
24
25
26 void PushAddr (ExprDesc* lval);
27 /* If the expression contains an address that was somehow evaluated,
28  * push this address on the stack. This is a helper function for all
29  * sorts of implicit or explicit assignment functions where the lvalue
30  * must be saved if it's not constant, before evaluating the rhs.
31  */
32
33 void ConstSubExpr (int (*F) (ExprDesc*), ExprDesc* Expr);
34 /* Will evaluate an expression via the given function. If the result is not
35  * a constant, a diagnostic will be printed, and the value is replaced by
36  * a constant one to make sure there are no internal errors that result
37  * from this input error.
38  */
39
40 void CheckBoolExpr (ExprDesc* lval);
41 /* Check if the given expression is a boolean expression, output a diagnostic
42  * if not.
43  */
44
45 unsigned assignadjust (type* lhst, ExprDesc* rhs);
46 /* Adjust the type of the right hand expression so that it can be assigned to
47  * the type on the left hand side. This function is used for assignment and
48  * for converting parameters in a function call. It returns the code generator
49  * flags for the operation.
50  */
51
52 void exprhs (unsigned flags, int k, ExprDesc *lval);
53 /* Put the result of an expression into the primary register */
54
55 void Store (ExprDesc* lval, const type* StoreType);
56 /* Store the primary register into the location denoted by lval. If StoreType
57  * is given, use this type when storing instead of lval->Type. If StoreType
58  * is NULL, use lval->Type instead.
59  */
60
61 void expression1 (ExprDesc* lval);
62 /* Evaluate an expression on level 1 (no comma operator) and put it into
63  * the primary register
64  */
65
66 void expression (ExprDesc* lval);
67 /* Evaluate an expression and put it into the primary register */
68
69 int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval);
70 /* Will evaluate an expression via the given function. If the result is a
71  * constant, 0 is returned and the value is put in the lval struct. If the
72  * result is not constant, exprhs is called to bring the value into the
73  * primary register and 1 is returned.
74  */
75
76 void ConstExpr (ExprDesc* lval);
77 /* Get a constant value */
78
79 void ConstIntExpr (ExprDesc* Val);
80 /* Get a constant int value */
81
82 void intexpr (ExprDesc* lval);
83 /* Get an integer expression */
84
85 int hie10 (ExprDesc* lval);
86 /* Handle ++, --, !, unary - etc. */
87
88 int hie1 (ExprDesc* lval);
89 /* Parse first level of expression hierarchy. */
90
91 void DefineData (ExprDesc* lval);
92 /* Output a data definition for the given expression */
93
94 void Test (unsigned Label, int Invert);
95 /* Evaluate a boolean test expression and jump depending on the result of
96  * the test and on Invert.
97  */
98
99 void TestInParens (unsigned Label, int Invert);
100 /* Evaluate a boolean test expression in parenthesis and jump depending on
101  * the result of the test * and on Invert.
102  */
103
104
105
106 /* End of expr.h */
107
108 #endif
109
110
111
112