1 /*****************************************************************************/
5 /* Expression node structure for the cc65 C compiler */
9 /* (C) 2000 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
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 /*****************************************************************************/
49 /*****************************************************************************/
51 /*****************************************************************************/
60 /*****************************************************************************/
62 /*****************************************************************************/
68 NT_NONE, /* None (invalid) op */
71 NT_CONST, /* A constant of some sort */
72 NT_ASM, /* Inline assembler */
74 NT_REG_A, /* A register */
75 NT_REG_X, /* X register */
76 NT_REG_Y, /* Y register */
77 NT_REG_AX, /* AX register */
78 NT_REG_EAX, /* EAX register */
80 NT_ARRAY_SUBSCRIPT, /* Array subscript */
81 NT_STRUCT_ACCESS, /* Access of a struct field */
82 NT_STRUCTPTR_ACCESS, /* Access via struct ptr */
83 NT_FUNCTION_CALL, /* Call a function */
99 NT_PLUS_ASSIGN, /* += */
100 NT_MINUS_ASSIGN, /* -= */
101 NT_MUL_ASSIGN, /* *= */
102 NT_DIV_ASSIGN, /* /= */
103 NT_SHL_ASSIGN, /* <<= */
104 NT_SHR_ASSIGN, /* >>= */
105 NT_AND_ASSIGN, /* &= */
106 NT_OR_ASSIGN, /* |= */
107 NT_XOR_ASSIGN, /* ^= */
110 NT_POST_DEC, /* -- */
112 NT_POST_INC, /* ++ */
116 NT_BOOL_AND, /* && */
125 NT_DEREF, /* * and others */
127 NT_COUNT /* Operation count */
132 /* Struct describing one node in an expression tree */
133 typedef struct ExprNode ExprNode;
136 /* Management data */
138 struct ExprHeap* Owner; /* Heap, this node is in */
139 struct ExprNode* Next; /* Next in free list */
142 Collection List; /* List of subexpressions */
143 nodetype_t NT; /* Node type */
144 type* Type; /* Resulting type */
145 int LValue; /* True if this is an lvalue */
148 long I; /* Constant int value if any */
149 double F; /* Constant float value if any */
155 /* Predefined indices for node items in List */
162 /* Some other constants for better readability */
170 /*****************************************************************************/
172 /*****************************************************************************/
176 ExprNode* InitExprNode (ExprNode* E, nodetype_t NT, type* Type,
177 int LValue, struct ExprHeap* Owner);
178 /* Initialize a new expression node */
180 void* GetItem (ExprNode* N, unsigned Index);
181 /* Return one of the items from the nodes item list */
183 void AppendItem (ExprNode* N, void* Item);
184 /* Append an item to the nodes item list */
186 void SetItem (ExprNode* N, void* Item, unsigned Index);
187 /* Set a specific node item. The item list is filled with null pointers as
191 ExprNode* GetLeftNode (ExprNode* N);
192 /* Get the left sub-node from the list */
194 void SetLeftNode (ExprNode* Root, ExprNode* Left);
195 /* Set the left node in Root */
197 ExprNode* GetRightNode (ExprNode* N);
198 /* Get the right sub-node from the list */
200 void SetRightNode (ExprNode* Root, ExprNode* Right);
201 /* Set the right node in Root */
203 struct SymEntry* GetNodeSym (ExprNode* N);
204 /* Get the symbol entry for a NT_SYM node */
206 void SetNodeSym (ExprNode* N, struct SymEntry* Sym);
207 /* Set the symbol entry in a NT_SYM node */
211 /* End of exprnode.h */