]> git.sur5r.net Git - cc65/blob - src/common/exprdefs.c
Add #pragma charmap()
[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_SEGMENT:
70             printf (" SEG");
71             break;
72
73         case EXPR_PLUS:
74             printf (" +");
75             break;
76
77         case EXPR_MINUS:
78             printf (" -");
79             break;
80
81         case EXPR_MUL:
82             printf (" *");
83             break;
84
85         case EXPR_DIV:
86             printf (" /");
87             break;
88
89         case EXPR_MOD:
90             printf (" MOD");
91             break;
92
93         case EXPR_OR:
94             printf (" OR");
95             break;
96
97         case EXPR_XOR:
98             printf (" XOR");
99             break;
100
101         case EXPR_AND:
102             printf (" AND");
103             break;
104
105         case EXPR_SHL:
106             printf (" SHL");
107             break;
108
109         case EXPR_SHR:
110             printf (" SHR");
111             break;
112
113         case EXPR_EQ:
114             printf (" =");
115             break;
116
117         case EXPR_NE:
118             printf ("<>");
119             break;
120
121         case EXPR_LT:
122             printf (" <");
123             break;
124
125         case EXPR_GT:
126             printf (" >");
127             break;
128
129         case EXPR_UNARY_MINUS:
130             printf (" NEG");
131             break;
132
133         case EXPR_NOT:
134             printf (" ~");
135             break;
136
137         case EXPR_BYTE0:
138             printf (" BYTE0");
139             break;
140
141         case EXPR_BYTE1:
142             printf (" BYTE1");
143             break;
144
145         case EXPR_BYTE2:
146             printf (" BYTE2");
147             break;
148
149         case EXPR_BYTE3:
150             printf (" BYTE3");
151             break;
152
153         case EXPR_SWAP:
154             printf (" SWAP");
155             break;
156
157         case EXPR_BAND:
158             printf (" BOOL_AND");
159             break;
160
161         case EXPR_BOR:
162             printf (" BOOL_OR");
163             break;
164
165         case EXPR_BXOR:
166             printf (" BOOL_XOR");
167             break;       
168
169         case EXPR_BNOT:
170             printf (" BOOL_NOT");
171             break;
172
173         default:
174             AbEnd ("Unknown Op type: %u", Expr->Op);
175
176     }
177 }
178
179
180
181 void DumpExpr (const ExprNode* Expr)
182 /* Dump an expression tree to stdout */
183 {
184     InternalDumpExpr (Expr);
185     printf ("\n");
186 }
187
188
189