1 /*****************************************************************************/
5 /* Expression descriptor structure */
9 /* (C) 2002 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
51 /*****************************************************************************/
53 /*****************************************************************************/
57 /* Defines for the flags field of the expression descriptor */
58 #define E_MREG 0x0110U /* Special: Expression is primary register */
59 #define E_MGLOBAL 0x0080U /* Reference to static variable */
60 #define E_MLOCAL 0x0040U /* Reference to local variable (stack offset) */
61 #define E_MCONST 0x0020U /* Constant value */
62 #define E_MEXPR 0x0010U /* Result is in primary register */
63 #define E_MEOFFS 0x0011U /* Base is in primary register, const offset */
65 #define E_MCTYPE 0x0007U /* Type of a constant */
66 #define E_TCONST 0x0000U /* Constant */
67 #define E_TGLAB 0x0001U /* Global label */
68 #define E_TLIT 0x0002U /* Literal of some kind */
69 #define E_TLOFFS 0x0003U /* Constant stack offset */
70 #define E_TLLAB 0x0004U /* Local label */
71 #define E_TREGISTER 0x0005U /* Register variable */
73 /* Defines for the test field of the expression descriptor */
74 #define E_CC 0x0001U /* expr has set cond codes apropos result value */
75 #define E_FORCETEST 0x0002U /* if expr has NOT set CC, force a test */
77 /* Describe the result of an expression */
78 typedef struct ExprDesc ExprDesc;
80 struct SymEntry* Sym; /* Symbol table entry if known */
81 type* Type; /* Type array of expression */
82 long ConstVal;/* Value if expression constant */
84 unsigned short Test; /* */
85 unsigned long Name; /* Name or label number */
90 /*****************************************************************************/
92 /*****************************************************************************/
96 #if defined(HAVE_INLINE)
97 INLINE ExprDesc* InitExprDesc (ExprDesc* Expr)
98 /* Initialize an ExprDesc */
100 return memset (Expr, 0, sizeof (*Expr));
103 # define InitExprDesc(E) memset ((E), 0, sizeof (*(E)))
106 void MakeConstIntExpr (ExprDesc* Expr, long Value);
107 /* Make Expr a constant integer expression with the given value */
109 void PrintExprDesc (FILE* F, ExprDesc* Expr);
110 /* Print an ExprDesc */
112 type* ReplaceType (ExprDesc* Expr, const type* NewType);
113 /* Replace the type of Expr by a copy of Newtype and return the old type string */
117 /* End of exprdesc.h */