Initial revision
[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         char    name[ SDCC_NAME_MAX + 1 ]; /* operand accessing this value */   
30         link     *type ;                 /* start of type chain     */
31         link     *etype;                 /* end of type chain       */
32         symbol   *sym  ;                 /* Original Symbol         */
33         struct   value *next ;           /* used in initializer list*/
34         unsigned    vArgs  : 1 ;          /* arg list ended with variable arg           */
35
36 } value ;
37
38 enum  {
39    INIT_NODE   ,
40    INIT_DEEP   ,
41    INIT_HOLE   
42 };
43
44 /* initializer lists use this structure */
45 typedef  struct   initList {
46     int         type  ;
47     int         lineno ;
48     union  {
49         struct ast       *node ;
50         struct initList   *deep ;
51     } init ;
52     
53     struct   initList    *next ;
54 } initList ;
55
56 #define  IS_VARG(x)             (x->vArgs)
57
58 /* forward definitions for the symbol table related functions */
59 void                     initValue        (                     );
60 value                   *newValue         (                     );
61 value                   *constVal         (char    *            );
62 value                   *reverseVal       (value   *            );
63 value                   *reverseValWithType(value   *           );
64 value                   *copyValue        (value   *            );
65 value                   *copyValueChain   (value   *            );
66 value                   *strVal           (char    *            );
67 value                   *charVal          (char    *            );
68 value                   *symbolVal        (symbol  *            );
69 void                     printVal         (value   *            );
70 double                   floatFromVal     (value   *            );
71 value                   *array2Ptr        (value   *            );
72 value                   *valUnaryPM       (value   *            );
73 value                   *valComplement    (value   *            );
74 value                   *valNot           (value   *            );
75 value                   *valMult          (value   *, value *   );
76 value                   *valDiv           (value   *, value *   );
77 value                   *valMod           (value   *, value *   );
78 value                   *valPlus          (value   *, value *   );
79 value                   *valMinus         (value   *, value *   );
80 value                   *valShift         (value   *, value *,int);
81 value                   *valCompare       (value   *, value *,int);
82 value                   *valBitwise       (value   *, value *,int);
83 value                   *valLogicAndOr    (value   *, value *,int);
84 value                   *valCastLiteral   (link    *, double     );
85 value                   *valueFromLit     (float );
86 initList                *newiList         (int      , void  *   );
87 initList                *revinit          (initList  *          );
88 initList                *copyIlist        (initList  *          );
89 double                   list2int         (initList  *          );
90 value                   *list2val         (initList  *          );
91 struct ast              *list2expr        (initList  *          );
92 void                     resolveIvalSym   (initList  *          );
93 value                   *valFromType      (link *               );
94 value                   *constFloatVal    (char *               );
95 int                      getNelements     (link *, initList *   );
96 value                   *valForArray      (struct ast  *        );
97 value                   *valForStructElem (struct ast  *, struct ast *);
98  
99 #endif