1 /*----------------------------------------------------------------------
2 SDCCval.h - value wrapper related header information
3 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1997)
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 In other words, you are welcome to use, share and improve this program.
20 You are forbidden to forbid anyone else to use, share and improve
21 what you give them. Help stamp out software-hoarding!
22 -------------------------------------------------------------------------*/
29 /* double to unsigned long conversion */
30 #define double2ul(val) (((val) < 0) ? (unsigned long) -((long) -(val)) : (unsigned long) (val))
35 char name[SDCC_NAME_MAX + 1]; /* operand accessing this value */
36 sym_link *type; /* start of type chain */
37 sym_link *etype; /* end of type chain */
38 symbol *sym; /* Original Symbol */
39 struct value *next; /* used in initializer list */
40 unsigned vArgs:1; /* arg list ended with variable arg */
45 typedef struct literalList
49 struct literalList *next;
60 /* initializer lists use this structure */
61 typedef struct initList
69 struct initList *deep;
73 struct initList *next;
77 /* return values from checkConstantRange */
80 CCR_OK, /* evaluate at runtime */
87 #define IS_VARG(x) (x->vArgs)
89 /* forward definitions for the symbol table related functions */
92 value *constVal (const char *);
93 value *reverseVal (value *);
94 value *reverseValWithType (value *);
95 value *copyValue (value *);
96 value *copyValueChain (value *);
97 value *strVal (const char *);
98 value *charVal (const char *);
99 value *symbolVal (symbol *);
100 void printVal (value *);
101 double floatFromVal (value *);
102 unsigned long ulFromVal (value *);
104 /* convert a fixed16x16 type to double */
105 double doubleFromFixed16x16(TYPE_TARGET_ULONG value);
107 /* convert a double type to fixed16x16 */
108 TYPE_TARGET_ULONG fixed16x16FromDouble(double value);
110 CCR_RESULT checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeOps);
111 value *array2Ptr (value *);
112 value *valUnaryPM (value *);
113 value *valComplement (value *);
114 value *valNot (value *);
115 value *valMult (value *, value *);
116 value *valDiv (value *, value *);
117 value *valMod (value *, value *);
118 value *valPlus (value *, value *);
119 value *valMinus (value *, value *);
120 value *valShift (value *, value *, int);
121 value *valCompare (value *, value *, int);
122 value *valBitwise (value *, value *, int);
123 value *valLogicAndOr (value *, value *, int);
124 value *valCastLiteral (sym_link *, double);
125 value *valueFromLit (double);
126 initList *newiList (int, void *);
127 initList *revinit (initList *);
128 initList *copyIlist (initList *);
129 double list2int (initList *);
130 value *list2val (initList *);
131 struct ast *list2expr (initList *);
132 void resolveIvalSym (initList *, sym_link *);
133 value *valFromType (sym_link *);
134 value *constFloatVal (char *);
135 value *constFixed16x16Val (char *);
136 int getNelements (sym_link *, initList *);
137 value *valForArray (struct ast *);
138 value *valForStructElem (struct ast *, struct ast *);
139 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
140 value *valForCastArr (struct ast * , sym_link *);
141 bool convertIListToConstList(initList *src, literalList **lList);
142 literalList *copyLiteralList(literalList *src);