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)");
64 fprintf (F, "Type: ");
65 PrintType (F, E->Type);
66 fprintf (F, "\nRaw type: ");
67 PrintRawType (F, E->Type);
69 fprintf (F, "Type: (unknown)\n"
70 "Raw type: (unknown)\n");
72 fprintf (F, "Value: 0x%08lX\n", E->ConstVal);
73 fprintf (F, "Flags: ");
74 switch (E->Flags & E_MCTYPE) {
75 case E_TCONST: fprintf (F, "E_TCONST "); break;
76 case E_TGLAB: fprintf (F, "E_TGLAB "); break;
77 case E_TLIT: fprintf (F, "E_TLIT "); break;
78 case E_TLOFFS: fprintf (F, "E_TLOFFS "); break;
79 case E_TLLAB: fprintf (F, "E_TLLAB "); break;
80 case E_TREGISTER: fprintf (F, "E_TREGISTER "); break;
81 default: fprintf (F, "0x%02X ", E->Flags & E_MCTYPE); break;
83 if ((E->Flags & E_MREG) == E_MREG) {
84 fprintf (F, "E_MREG ");
85 } else if ((E->Flags & E_MEOFFS) == E_MEOFFS) {
86 fprintf (F, "E_MEOFFS ");
87 } else if ((E->Flags & E_MEXPR) == E_MEXPR) {
88 fprintf (F, "E_MEXPR ");
90 if ((E->Flags & E_MGLOBAL) == E_MGLOBAL) {
91 fprintf (F, "E_MGLOBAL ");
93 if ((E->Flags & E_MLOCAL) == E_MLOCAL) {
94 fprintf (F, "E_MLOCAL ");
96 if ((E->Flags & E_MCONST) == E_MCONST) {
97 fprintf (F, "E_MCONST ");
100 fprintf (F, "\nTest: ");
101 if (E->Test & E_CC) {
102 fprintf (F, "E_CC ");
104 if (E->Test & E_FORCETEST) {
105 fprintf (F, "E_FORCETEST ");
108 fprintf (F, "\nName: 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);