add 'on demand' integer promotion
[fw/sdcc] / src / SDCCast.h
index 2306354fd5a1139d97195f1aca655c322d099d62..7af66517130c6d3e620c60dcdd5204345fe38e1f 100644 (file)
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 
+#ifndef SDCCEXPR_H
+#define SDCCEXPR_H
+
 #include "SDCCglobl.h"
 #include "SDCCsymt.h"
 #include "SDCCval.h"
-
-#ifndef SDCCEXPR_H
-#define SDCCEXPR_H
+#include "SDCCset.h"
 
 #define  EX_OP       0
 #define  EX_VALUE    1
@@ -51,7 +52,7 @@ typedef  struct   ast {
     /* union of values expression can have */
     union {
        value *val        ;  /* value if type = EX_VALUE */
-       link  *lnk        ;  /* link * if type= EX_LINK  */
+       sym_link  *lnk    ;  /* sym_link * if type= EX_LINK  */
        struct operand *oprnd; /* used only for side effecting function calls */
        unsigned stmnt    ;  /* statement if type=EX_STMNT */
        unsigned op       ;  /* operator if type= EX_OP  */
@@ -83,8 +84,8 @@ typedef  struct   ast {
     int   lineno         ;  /* source file line number     */   
     char  *filename      ;  /* filename of the source file */
     
-    link  *ftype         ;  /* start of type chain for this subtree */
-    link  *etype         ;  /* end of type chain for this subtree   */
+    sym_link  *ftype     ;  /* start of type chain for this subtree */
+    sym_link  *etype     ;  /* end of type chain for this subtree   */
     
     symbol  *argSym      ;  /* argument symbols            */
     value   *args        ;  /* args of a function          */
@@ -106,6 +107,7 @@ typedef  struct   ast {
 #define  IS_AST_VALUE(x)       (x && x->type == EX_VALUE && x->opval.val)
 #define  IS_AST_LINK(x)                (x->type == EX_LINK)   
 #define  IS_AST_NOT_OPER(x)    (x && IS_AST_OP(x) && x->opval.op == '!')
+#define  IS_ARRAY_OP(x) (IS_AST_OP(x) && x->opval.op == '[')
 #define  IS_COMPARE_OP(x)      (IS_AST_OP(x)           &&              \
                                  (x->opval.op == '>'   ||              \
                                   x->opval.op == '<'   ||              \
@@ -148,15 +150,20 @@ typedef  struct   ast {
                          x == AND_ASSIGN || x == OR_ASSIGN || x == INC_OP || x == DEC_OP)
 #define IS_DEREF_OP(x) (( x->opval.op == '*' && x->right == NULL) || x->opval.op == '.')
 
-/* forward declrations for global variables */
+/* forward declarations for global variables */
 extern ast     *staticAutos    ;
+extern FILE *codeOutFile;
 
 /* forward definitions for functions   */
-ast     *newAst       (int  ,  void  *        );
+ast* newAst_VALUE(value*val);
+ast* newAst_OP   (unsigned op);
+ast* newAst_LINK (sym_link*val);
+ast* newAst_STMNT(unsigned val);
+
 void      initAst      (                       );
-ast     *newNode       (int  ,ast *  ,ast *  );
+ast     *newNode       (long  ,ast *  ,ast *  );
 ast     *copyAst      (ast *                 );
-value    *sizeofOp      (link *                 );
+value    *sizeofOp      (sym_link *            );
 value    *evalStmnt     (ast *                 );
 ast     *createFunction(symbol  *,ast   *     );
 ast     *createBlock   (symbol  *,ast   *     );
@@ -174,9 +181,13 @@ ast     *createDo       (symbol *,symbol *,symbol *,ast *,ast *);
 ast     *createFor      (symbol *,symbol *,symbol *,symbol *,ast *,ast *,ast *, ast *);
 void     eval2icode     (ast *);
 value   *constExprValue (ast *,int);
-symbol  *funcOfType     (char *,link *,link *,int,int);
+symbol  *funcOfType     (char *,sym_link *,sym_link *,int,int);
 ast     *initAggregates ( symbol *,initList *, ast *);
 bool     hasSEFcalls    ( ast *);
 void     addSymToBlock (symbol *, ast *) ;
 
+// exported variables 
+extern set *operKeyReset;
+extern int noAlloc;
+
 #endif