* src/Makefile.in (dep): include SLIBOBJS in dependency check
[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 #ifndef SDCCVAL_H
24 #define SDCCVAL_H
25
26 #include "SDCCsymt.h"
27
28 /* value wrapper */
29 typedef struct value
30   {
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           */
37
38   }
39 value;
40
41 typedef struct literalList
42 {
43     double    literalValue;
44     unsigned  count;
45     struct literalList *next;
46 } literalList;
47
48
49 enum
50   {
51     INIT_NODE,
52     INIT_DEEP,
53     INIT_HOLE
54   };
55
56 /* initializer lists use this structure */
57 typedef struct initList
58   {
59     int type;
60     int lineno;
61     char *filename;
62     union
63       {
64         struct ast *node;
65         struct initList *deep;
66       }
67     init;
68
69     struct initList *next;
70   }
71 initList;
72
73 #define  IS_VARG(x)             (x->vArgs)
74
75 /* forward definitions for the symbol table related functions */
76 void initValue ();
77 value *newValue ();
78 value *constVal (char *);
79 value *reverseVal (value *);
80 value *reverseValWithType (value *);
81 value *copyValue (value *);
82 value *copyValueChain (value *);
83 value *strVal (char *);
84 value *charVal (char *);
85 value *symbolVal (symbol *);
86 void printVal (value *);
87 double floatFromVal (value *);
88 value *array2Ptr (value *);
89 value *valUnaryPM (value *);
90 value *valComplement (value *);
91 value *valNot (value *);
92 value *valMult (value *, value *);
93 value *valDiv (value *, value *);
94 value *valMod (value *, value *);
95 value *valPlus (value *, value *);
96 value *valMinus (value *, value *);
97 value *valShift (value *, value *, int);
98 value *valCompare (value *, value *, int);
99 value *valBitwise (value *, value *, int);
100 value *valLogicAndOr (value *, value *, int);
101 value *valCastLiteral (sym_link *, double);
102 value *valueFromLit (double);
103 initList *newiList (int, void *);
104 initList *revinit (initList *);
105 initList *copyIlist (initList *);
106 double list2int (initList *);
107 value *list2val (initList *);
108 struct ast *list2expr (initList *);
109 void resolveIvalSym (initList *, sym_link *);
110 value *valFromType (sym_link *);
111 value *constFloatVal (char *);
112 int getNelements (sym_link *, initList *);
113 value *valForArray (struct ast *);
114 value *valForStructElem (struct ast *, struct ast *);
115 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
116 value *valForCastArr (struct ast * , sym_link *);
117 bool convertIListToConstList(initList *src, literalList **lList);
118 literalList *copyLiteralList(literalList *src);
119 #endif