]> git.sur5r.net Git - cc65/blob - src/cc65/exprdesc.h
ValidSegName now defined in segnames.h
[cc65] / src / cc65 / exprdesc.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                exprdesc.h                                 */
4 /*                                                                           */
5 /*                      Expression descriptor structure                      */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2002      Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@cc65.org                                                 */
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 EXPRDESC_H
37 #define EXPRDESC_H
38
39
40
41 #include <string.h>
42
43 /* common */
44 #include "inline.h"
45
46 /* cc65 */
47 #include "datatype.h"
48
49
50
51 /*****************************************************************************/
52 /*                                   Data                                    */
53 /*****************************************************************************/
54
55
56
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 */
64
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 */
72
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 */
76
77 /* Describe the result of an expression */
78 typedef struct ExprDesc ExprDesc;
79 struct ExprDesc {
80     struct SymEntry*    Sym;     /* Symbol table entry if known */
81     type*               Type;    /* Type array of expression */
82     long                ConstVal;/* Value if expression constant */
83     unsigned short      Flags;
84     unsigned short      Test;    /* */
85     unsigned long       Name;    /* Name or label number */
86 };
87
88
89
90 /*****************************************************************************/
91 /*                                   Code                                    */
92 /*****************************************************************************/
93
94
95
96 #if defined(HAVE_INLINE)
97 INLINE ExprDesc* InitExprDesc (ExprDesc* Expr)
98 /* Initialize an ExprDesc */
99 {
100     return memset (Expr, 0, sizeof (*Expr));
101 }
102 #else
103 #  define InitExprDesc(E)       memset ((E), 0, sizeof (*(E)))
104 #endif
105
106 void MakeConstIntExpr (ExprDesc* Expr, long Value);
107 /* Make Expr a constant integer expression with the given value */
108
109 void PrintExprDesc (FILE* F, ExprDesc* Expr);
110 /* Print an ExprDesc */
111
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 */
114
115
116
117 /* End of exprdesc.h */
118 #endif
119
120
121