Beautified (indented) compiler source tree
[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 enum
41   {
42     INIT_NODE,
43     INIT_DEEP,
44     INIT_HOLE
45   };
46
47 /* initializer lists use this structure */
48 typedef struct initList
49   {
50     int type;
51     int lineno;
52     union
53       {
54         struct ast *node;
55         struct initList *deep;
56       }
57     init;
58
59     struct initList *next;
60   }
61 initList;
62
63 #define  IS_VARG(x)             (x->vArgs)
64
65 /* forward definitions for the symbol table related functions */
66 void initValue ();
67 value *newValue ();
68 value *constVal (char *);
69 value *reverseVal (value *);
70 value *reverseValWithType (value *);
71 value *copyValue (value *);
72 value *copyValueChain (value *);
73 value *strVal (char *);
74 value *charVal (char *);
75 value *symbolVal (symbol *);
76 void printVal (value *);
77 double floatFromVal (value *);
78 value *array2Ptr (value *);
79 value *valUnaryPM (value *);
80 value *valComplement (value *);
81 value *valNot (value *);
82 value *valMult (value *, value *);
83 value *valDiv (value *, value *);
84 value *valMod (value *, value *);
85 value *valPlus (value *, value *);
86 value *valMinus (value *, value *);
87 value *valShift (value *, value *, int);
88 value *valCompare (value *, value *, int);
89 value *valBitwise (value *, value *, int);
90 value *valLogicAndOr (value *, value *, int);
91 value *valCastLiteral (sym_link *, double);
92 value *valueFromLit (float);
93 initList *newiList (int, void *);
94 initList *revinit (initList *);
95 initList *copyIlist (initList *);
96 double list2int (initList *);
97 value *list2val (initList *);
98 struct ast *list2expr (initList *);
99 void resolveIvalSym (initList *);
100 value *valFromType (sym_link *);
101 value *constFloatVal (char *);
102 int getNelements (sym_link *, initList *);
103 value *valForArray (struct ast *);
104 value *valForStructElem (struct ast *, struct ast *);
105 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
106 #endif