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 */
84 NT_TYPECAST, /* A cast */
85 NT_ADDRESS, /* Address operator (&) */
86 NT_INDIRECT, /* Indirection operator (*) */
89 NT_COMPLEMENT, /* ~ */
103 NT_PLUS_ASSIGN, /* += */
104 NT_MINUS_ASSIGN, /* -= */
105 NT_MUL_ASSIGN, /* *= */
106 NT_DIV_ASSIGN, /* /= */
107 NT_SHL_ASSIGN, /* <<= */
108 NT_SHR_ASSIGN, /* >>= */
109 NT_AND_ASSIGN, /* &= */
110 NT_OR_ASSIGN, /* |= */
111 NT_XOR_ASSIGN, /* ^= */
114 NT_POST_DEC, /* -- */
116 NT_POST_INC, /* ++ */
119 NT_BOOL_AND, /* && */
128 NT_DEREF, /* * and others */
130 NT_COUNT /* Operation count */
135 /* Struct describing one node in an expression tree */
136 typedef struct ExprNode ExprNode;
139 /* Management data */
141 struct ExprHeap* Owner; /* Heap, this node is in */
142 struct ExprNode* Next; /* Next in free list */
145 Collection List; /* List of subexpressions */
146 nodetype_t NT; /* Node type */
147 type* Type; /* Resulting type */
148 int LValue; /* True if this is an lvalue */
151 long I; /* Constant int value if any */
152 double F; /* Constant float value if any */
158 /* Predefined indices for node items in List */
165 /* Some other constants for better readability */
173 /*****************************************************************************/
175 /*****************************************************************************/
179 ExprNode* InitExprNode (ExprNode* E, nodetype_t NT, type* Type,
180 int LValue, struct ExprHeap* Owner);
181 /* Initialize a new expression node */
183 void* GetItem (ExprNode* N, unsigned Index);
184 /* Return one of the items from the nodes item list */
186 void AppendItem (ExprNode* N, void* Item);
187 /* Append an item to the nodes item list */
189 void SetItem (ExprNode* N, void* Item, unsigned Index);
190 /* Set a specific node item. The item list is filled with null pointers as
194 ExprNode* GetLeftNode (ExprNode* N);
195 /* Get the left sub-node from the list */
197 void SetLeftNode (ExprNode* Root, ExprNode* Left);
198 /* Set the left node in Root */
200 ExprNode* GetRightNode (ExprNode* N);
201 /* Get the right sub-node from the list */
203 void SetRightNode (ExprNode* Root, ExprNode* Right);
204 /* Set the right node in Root */
206 struct SymEntry* GetNodeSym (ExprNode* N);
207 /* Get the symbol entry for a NT_SYM node */
209 void SetNodeSym (ExprNode* N, struct SymEntry* Sym);
210 /* Set the symbol entry in a NT_SYM node */
214 /* End of exprnode.h */