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 -------------------------------------------------------------------------*/
31 char name[SDCC_NAME_MAX + 1]; /* operand accessing this value */
32 sym_link *type; /* start of type chain */
33 sym_link *etype; /* end of type chain */
34 symbol *sym; /* Original Symbol */
35 struct value *next; /* used in initializer list */
36 unsigned vArgs:1; /* arg list ended with variable arg */
41 typedef struct literalList
45 struct literalList *next;
56 /* initializer lists use this structure */
57 typedef struct initList
65 struct initList *deep;
69 struct initList *next;
73 /* return values from checkConstantRange */
76 CCR_OK, /* evaluate at runtime */
83 #define IS_VARG(x) (x->vArgs)
85 /* forward definitions for the symbol table related functions */
88 value *constVal (char *);
89 value *reverseVal (value *);
90 value *reverseValWithType (value *);
91 value *copyValue (value *);
92 value *copyValueChain (value *);
93 value *strVal (char *);
94 value *charVal (char *);
95 value *symbolVal (symbol *);
96 void printVal (value *);
97 double floatFromVal (value *);
98 CCR_RESULT checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeOps);
99 value *array2Ptr (value *);
100 value *valUnaryPM (value *);
101 value *valComplement (value *);
102 value *valNot (value *);
103 value *valMult (value *, value *);
104 value *valDiv (value *, value *);
105 value *valMod (value *, value *);
106 value *valPlus (value *, value *);
107 value *valMinus (value *, value *);
108 value *valShift (value *, value *, int);
109 value *valCompare (value *, value *, int);
110 value *valBitwise (value *, value *, int);
111 value *valLogicAndOr (value *, value *, int);
112 value *valCastLiteral (sym_link *, double);
113 value *valueFromLit (double);
114 initList *newiList (int, void *);
115 initList *revinit (initList *);
116 initList *copyIlist (initList *);
117 double list2int (initList *);
118 value *list2val (initList *);
119 struct ast *list2expr (initList *);
120 void resolveIvalSym (initList *, sym_link *);
121 value *valFromType (sym_link *);
122 value *constFloatVal (char *);
123 value *constFixed16x16Val (char *);
124 int getNelements (sym_link *, initList *);
125 value *valForArray (struct ast *);
126 value *valForStructElem (struct ast *, struct ast *);
127 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
128 value *valForCastArr (struct ast * , sym_link *);
129 bool convertIListToConstList(initList *src, literalList **lList);
130 literalList *copyLiteralList(literalList *src);