* src/SDCCast.c (processParams): added new type flow and restructured
[fw/sdcc] / src / SDCCval.h
1 /*----------------------------------------------------------------------
2   SDCCval.h - value wrapper related header information
3   Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1997)
4
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
8   later version.
9   
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.
14   
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.
18   
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 -------------------------------------------------------------------------*/
23 #include "SDCCsymt.h"
24 #ifndef SDCCVAL_H
25 #define SDCCVAL_H
26
27 /* value wrapper */
28 typedef struct value
29   {
30     char name[SDCC_NAME_MAX + 1];       /* operand accessing this value */
31     sym_link *type;             /* start of type chain     */
32     sym_link *etype;            /* end of type chain       */
33     symbol *sym;                /* Original Symbol         */
34     struct value *next;         /* used in initializer list */
35     unsigned vArgs:1;           /* arg list ended with variable arg           */
36
37   }
38 value;
39
40 typedef struct literalList
41 {
42     double    literalValue;
43     unsigned  count;
44     struct literalList *next;
45 } literalList;
46
47
48 enum
49   {
50     INIT_NODE,
51     INIT_DEEP,
52     INIT_HOLE
53   };
54
55 /* initializer lists use this structure */
56 typedef struct initList
57   {
58     int type;
59     int lineno;
60     union
61       {
62         struct ast *node;
63         struct initList *deep;
64       }
65     init;
66
67     struct initList *next;
68   }
69 initList;
70
71 #define  IS_VARG(x)             (x->vArgs)
72
73 /* forward definitions for the symbol table related functions */
74 void initValue ();
75 value *newValue ();
76 value *constVal (char *);
77 value *reverseVal (value *);
78 value *reverseValWithType (value *);
79 value *copyValue (value *);
80 value *copyValueChain (value *);
81 value *strVal (char *);
82 value *charVal (char *);
83 value *symbolVal (symbol *);
84 void printVal (value *);
85 double floatFromVal (value *);
86 value *array2Ptr (value *);
87 value *valUnaryPM (value *);
88 value *valComplement (value *);
89 value *valNot (value *);
90 value *valMult (value *, value *);
91 value *valDiv (value *, value *);
92 value *valMod (value *, value *);
93 value *valPlus (value *, value *);
94 value *valMinus (value *, value *);
95 value *valShift (value *, value *, int);
96 value *valCompare (value *, value *, int);
97 value *valBitwise (value *, value *, int);
98 value *valLogicAndOr (value *, value *, int);
99 value *valCastLiteral (sym_link *, double);
100 value *valueFromLit (double);
101 initList *newiList (int, void *);
102 initList *revinit (initList *);
103 initList *copyIlist (initList *);
104 double list2int (initList *);
105 value *list2val (initList *);
106 struct ast *list2expr (initList *);
107 void resolveIvalSym (initList *, sym_link *);
108 value *valFromType (sym_link *);
109 value *constFloatVal (char *);
110 int getNelements (sym_link *, initList *);
111 value *valForArray (struct ast *);
112 value *valForStructElem (struct ast *, struct ast *);
113 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
114 value *valForCastArr (struct ast * , sym_link *);
115 bool convertIListToConstList(initList *src, literalList **lList);
116 literalList *copyLiteralList(literalList *src);
117 #endif