1 /*****************************************************************************/
5 /* Expression descriptor structure */
9 /* (C) 2002 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@cc65.org */
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 /*****************************************************************************/
43 /*****************************************************************************/
45 /*****************************************************************************/
49 void MakeConstIntExpr (ExprDesc* Expr, long Value)
50 /* Make Expr a constant integer expression with the given value */
52 Expr->Flags = E_MCONST;
53 Expr->Type = type_int;
54 Expr->ConstVal = Value;
59 void PrintExprDesc (FILE* F, ExprDesc* E)
60 /* Print an ExprDesc */
62 fprintf (F, "Symbol: %s\n", E->Sym? E->Sym->Name : "(none)");
63 fprintf (F, "Type: ");
65 PrintType (F, E->Type);
67 fprintf (F, "(unknown)");
70 fprintf (F, "Value: 0x%08lX\n", E->ConstVal);
71 fprintf (F, "Flags: ");
72 switch (E->Flags & E_MCTYPE) {
73 case E_TCONST: fprintf (F, "E_TCONST "); break;
74 case E_TGLAB: fprintf (F, "E_TGLAB "); break;
75 case E_TLIT: fprintf (F, "E_TLIT "); break;
76 case E_TLOFFS: fprintf (F, "E_TLOFFS "); break;
77 case E_TLLAB: fprintf (F, "E_TLLAB "); break;
78 case E_TREGISTER: fprintf (F, "E_TREGISTER "); break;
79 default: fprintf (F, "0x%02X ", E->Flags & E_MCTYPE); break;
81 if ((E->Flags & E_MREG) == E_MREG) {
82 fprintf (F, "E_MREG ");
83 } else if ((E->Flags & E_MEOFFS) == E_MEOFFS) {
84 fprintf (F, "E_MEOFFS ");
85 } else if ((E->Flags & E_MEXPR) == E_MEXPR) {
86 fprintf (F, "E_MEXPR ");
88 if ((E->Flags & E_MGLOBAL) == E_MGLOBAL) {
89 fprintf (F, "E_MGLOBAL ");
91 if ((E->Flags & E_MLOCAL) == E_MLOCAL) {
92 fprintf (F, "E_MLOCAL ");
94 if ((E->Flags & E_MCONST) == E_MCONST) {
95 fprintf (F, "E_MCONST ");
99 fprintf (F, "Test: ");
100 if (E->Test & E_CC) {
101 fprintf (F, "E_CC ");
103 if (E->Test & E_FORCETEST) {
104 fprintf (F, "E_FORCETEST ");
108 fprintf (F, "Name: 0x%08lX\n", E->Name);
113 type* ReplaceType (ExprDesc* Expr, const type* NewType)
114 /* Replace the type of Expr by a copy of Newtype and return the old type string */
116 type* OldType = Expr->Type;
117 Expr->Type = TypeDup (NewType);