* src/SDCCsymt.h,
[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     char *filename;
61     union
62       {
63         struct ast *node;
64         struct initList *deep;
65       }
66     init;
67
68     struct initList *next;
69   }
70 initList;
71
72 #define  IS_VARG(x)             (x->vArgs)
73
74 /* forward definitions for the symbol table related functions */
75 void initValue ();
76 value *newValue ();
77 value *constVal (char *);
78 value *reverseVal (value *);
79 value *reverseValWithType (value *);
80 value *copyValue (value *);
81 value *copyValueChain (value *);
82 value *strVal (char *);
83 value *charVal (char *);
84 value *symbolVal (symbol *);
85 void printVal (value *);
86 double floatFromVal (value *);
87 value *array2Ptr (value *);
88 value *valUnaryPM (value *);
89 value *valComplement (value *);
90 value *valNot (value *);
91 value *valMult (value *, value *);
92 value *valDiv (value *, value *);
93 value *valMod (value *, value *);
94 value *valPlus (value *, value *);
95 value *valMinus (value *, value *);
96 value *valShift (value *, value *, int);
97 value *valCompare (value *, value *, int);
98 value *valBitwise (value *, value *, int);
99 value *valLogicAndOr (value *, value *, int);
100 value *valCastLiteral (sym_link *, double);
101 value *valueFromLit (double);
102 initList *newiList (int, void *);
103 initList *revinit (initList *);
104 initList *copyIlist (initList *);
105 double list2int (initList *);
106 value *list2val (initList *);
107 struct ast *list2expr (initList *);
108 void resolveIvalSym (initList *, sym_link *);
109 value *valFromType (sym_link *);
110 value *constFloatVal (char *);
111 int getNelements (sym_link *, initList *);
112 value *valForArray (struct ast *);
113 value *valForStructElem (struct ast *, struct ast *);
114 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
115 value *valForCastArr (struct ast * , sym_link *);
116 bool convertIListToConstList(initList *src, literalList **lList);
117 literalList *copyLiteralList(literalList *src);
118 #endif