]> git.sur5r.net Git - cc65/blob - src/common/exprdefs.c
EXPR_SECTION was missing from dump
[cc65] / src / common / exprdefs.c
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                exprdefs.c                                 */
4 /*                                                                           */
5 /*                        Expression tree definitions                        */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2000 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
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 #include <stdio.h>
37
38 #include "abend.h"
39 #include "exprdefs.h"
40
41
42
43 /*****************************************************************************/
44 /*                                   Code                                    */
45 /*****************************************************************************/
46
47
48
49 static void InternalDumpExpr (const ExprNode* Expr)
50 /* Dump an expression in RPN to stdout */
51 {
52     if (Expr == 0) {
53         return;
54     }
55     InternalDumpExpr (Expr->Left);
56     InternalDumpExpr (Expr->Right);
57
58     switch (Expr->Op) {
59
60         case EXPR_LITERAL:
61         case EXPR_ULABEL:
62             printf (" $%04lX", Expr->V.Val & 0xFFFF);
63             break;
64
65         case EXPR_SYMBOL:
66             printf (" SYM");
67             break;
68
69         case EXPR_SECTION:
70             printf (" SEC");
71             break;
72
73         case EXPR_SEGMENT:
74             printf (" SEG");
75             break;
76
77         case EXPR_PLUS:
78             printf (" +");
79             break;
80
81         case EXPR_MINUS:
82             printf (" -");
83             break;
84
85         case EXPR_MUL:
86             printf (" *");
87             break;
88
89         case EXPR_DIV:
90             printf (" /");
91             break;
92
93         case EXPR_MOD:
94             printf (" MOD");
95             break;
96
97         case EXPR_OR:
98             printf (" OR");
99             break;
100
101         case EXPR_XOR:
102             printf (" XOR");
103             break;
104
105         case EXPR_AND:
106             printf (" AND");
107             break;
108
109         case EXPR_SHL:
110             printf (" SHL");
111             break;
112
113         case EXPR_SHR:
114             printf (" SHR");
115             break;
116
117         case EXPR_EQ:
118             printf (" =");
119             break;
120
121         case EXPR_NE:
122             printf ("<>");
123             break;
124
125         case EXPR_LT:
126             printf (" <");
127             break;
128
129         case EXPR_GT:
130             printf (" >");
131             break;
132
133         case EXPR_UNARY_MINUS:
134             printf (" NEG");
135             break;
136
137         case EXPR_NOT:
138             printf (" ~");
139             break;
140
141         case EXPR_BYTE0:
142             printf (" BYTE0");
143             break;
144
145         case EXPR_BYTE1:
146             printf (" BYTE1");
147             break;
148
149         case EXPR_BYTE2:
150             printf (" BYTE2");
151             break;
152
153         case EXPR_BYTE3:
154             printf (" BYTE3");
155             break;
156
157         case EXPR_SWAP:
158             printf (" SWAP");
159             break;
160
161         case EXPR_BAND:
162             printf (" BOOL_AND");
163             break;       
164
165         case EXPR_BOR:
166             printf (" BOOL_OR");
167             break;
168
169         case EXPR_BXOR:
170             printf (" BOOL_XOR");
171             break;
172
173         case EXPR_BNOT:
174             printf (" BOOL_NOT");
175             break;
176
177         default:
178             AbEnd ("Unknown Op type: %u", Expr->Op);
179
180     }
181 }
182
183
184
185 void DumpExpr (const ExprNode* Expr)
186 /* Dump an expression tree to stdout */
187 {
188     InternalDumpExpr (Expr);
189     printf ("\n");
190 }
191
192
193