4 * Ullrich von Bassewitz, 21.06.1998
18 /*****************************************************************************/
20 /*****************************************************************************/
24 /* Defines for the flags field of the expression descriptor */
25 #define E_MREG 0x0110U /* Special: Expression is primary register */
26 #define E_MGLOBAL 0x0080U /* Reference to static variable */
27 #define E_MLOCAL 0x0040U /* Reference to local variable (stack offset) */
28 #define E_MCONST 0x0020U /* Constant value */
29 #define E_MEXPR 0x0010U /* Result is in primary register */
30 #define E_MEOFFS 0x0011U /* Base is in primary register, const offset */
32 #define E_MCTYPE 0x0007U /* Type of a constant */
33 #define E_TCONST 0x0000U /* Constant */
34 #define E_TGLAB 0x0001U /* Global label */
35 #define E_TLIT 0x0002U /* Literal of some kind */
36 #define E_TLOFFS 0x0003U /* Constant stack offset */
37 #define E_TLLAB 0x0004U /* Local label */
38 #define E_TREGISTER 0x0005U /* Register variable */
40 /* Defines for the test field of the expression descriptor */
41 #define E_CC 0x0001U /* expr has set cond codes apropos result value */
42 #define E_FORCETEST 0x0002U /* if expr has NOT set CC, force a test */
44 /* Describe the result of an expression */
45 typedef struct ExprDesc ExprDesc;
47 struct SymEntry* Sym; /* Symbol table entry if known */
48 type* Type; /* Type array of expression */
49 long ConstVal;/* Value if expression constant */
51 unsigned short Test; /* */
52 unsigned long Name; /* Name or label number */
57 /*****************************************************************************/
59 /*****************************************************************************/
63 void ConstSubExpr (int (*F) (ExprDesc*), ExprDesc* Expr);
64 /* Will evaluate an expression via the given function. If the result is not
65 * a constant, a diagnostic will be printed, and the value is replaced by
66 * a constant one to make sure there are no internal errors that result
67 * from this input error.
70 unsigned assignadjust (type* lhst, ExprDesc* rhs);
71 /* Adjust the type of the right hand expression so that it can be assigned to
72 * the type on the left hand side. This function is used for assignment and
73 * for converting parameters in a function call. It returns the code generator
74 * flags for the operation.
77 void exprhs (unsigned flags, int k, ExprDesc *lval);
78 /* Put the result of an expression into the primary register */
80 void expression1 (ExprDesc* lval);
81 /* Evaluate an expression on level 1 (no comma operator) and put it into
82 * the primary register
85 void expression (ExprDesc* lval);
86 /* Evaluate an expression and put it into the primary register */
88 int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval);
89 /* Will evaluate an expression via the given function. If the result is a
90 * constant, 0 is returned and the value is put in the lval struct. If the
91 * result is not constant, exprhs is called to bring the value into the
92 * primary register and 1 is returned.
95 void constexpr (ExprDesc* lval);
96 /* Get a constant value */
98 void intexpr (ExprDesc* lval);
99 /* Get an integer expression */
101 void boolexpr (ExprDesc* lval);
102 /* Get a boolean expression */
104 void test (unsigned label, int cond);
105 /* Generate code to perform test and jump if false. */
107 int hie1 (ExprDesc* lval);
108 /* Parse first level of expression hierarchy. */
110 int hie0 (ExprDesc* lval);
111 /* Parse comma operator (highest level of expression hierarchy) */
113 void DefineData (ExprDesc* lval);
114 /* Output a data definition for the given expression */