X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCast.h;h=9e8ac52631d8cc26728331d56915f26ed89ebf08;hb=1d1257b95e7011f5d9621b43aafd45bd87fbc34a;hp=7620e47f45f4a80185594826a9dc3115525627a6;hpb=c1156eac66b833f3c65dc82c3e92bd21004e2150;p=fw%2Fsdcc diff --git a/src/SDCCast.h b/src/SDCCast.h index 7620e47f..9e8ac526 100644 --- a/src/SDCCast.h +++ b/src/SDCCast.h @@ -31,32 +31,34 @@ #include "SDCCset.h" #include "SDCCmem.h" -#define EX_OP 0 -#define EX_VALUE 1 -#define EX_LINK 2 -#define EX_STMNT 3 -#define EX_OPERAND 4 +typedef enum { + EX_OP=0, + EX_VALUE, + EX_LINK, + EX_OPERAND +} ASTTYPE; /* expression tree */ typedef struct ast { - unsigned type:3; + ASTTYPE type; unsigned decorated:1; unsigned isError:1; unsigned funcName:1; unsigned rvalue:1; unsigned lvalue:1; unsigned initMode:1; + unsigned reversed:1; int level; /* level for expr */ int block; /* block number */ + int seqPoint; /* sequence point */ /* union of values expression can have */ union { value *val; /* value if type = EX_VALUE */ 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 */ } opval; @@ -91,6 +93,7 @@ typedef struct ast unsigned literalFromCast; /* true if this is an EX_VALUE of LITERAL * type resulting from a typecast. */ + int argreg; /* argreg number when operand type == EX_OPERAND */ } values; @@ -109,7 +112,7 @@ ast; /* easy access macros */ -#define IS_AST_OP(x) (x && x->type == EX_OP) +#define IS_AST_OP(x) ((x) && (x)->type == EX_OP) #define IS_CALLOP(x) (IS_AST_OP(x) && x->opval.op == CALL) #define IS_BITOR(x) (IS_AST_OP(x) && x->opval.op == '|') #define IS_BITAND(x) (IS_AST_OP(x) && x->opval.op == '&' && \ @@ -117,7 +120,7 @@ ast; #define IS_FOR_STMT(x) (IS_AST_OP(x) && x->opval.op == FOR) #define IS_LEFT_OP(x) (IS_AST_OP(x) && x->opval.op == LEFT_OP) #define IS_RIGHT_OP(x) (IS_AST_OP(x) && x->opval.op == RIGHT_OP) -#define IS_AST_VALUE(x) (x && x->type == EX_VALUE && x->opval.val) +#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 == '[') @@ -128,20 +131,22 @@ ast; x->opval.op == GE_OP || \ x->opval.op == EQ_OP || \ x->opval.op == NE_OP )) -#define IS_CAST_OP(x) (IS_AST_OP(x) && x->opval.op == CAST) +#define IS_CAST_OP(x) (IS_AST_OP(x) && (x)->opval.op == CAST) #define IS_TERNARY_OP(x) (IS_AST_OP(x) && x->opval.op == '?') #define IS_COLON_OP(x) (IS_AST_OP(x) && x->opval.op == ':') #define IS_ADDRESS_OF_OP(x) (IS_AST_OP(x) && \ x->opval.op == '&' && \ x->right == NULL ) #define IS_AST_LIT_VALUE(x) (IS_AST_VALUE(x) && \ - IS_LITERAL(x->opval.val->etype)) + IS_LITERAL((x)->opval.val->etype)) #define IS_AST_SYM_VALUE(x) (IS_AST_VALUE(x) && x->opval.val->sym) #define AST_LIT_VALUE(x) (floatFromVal(x->opval.val)) #define AST_SYMBOL(x) (x->opval.val->sym) #define AST_VALUE(x) (x->opval.val) #define AST_VALUES(x,y) (x->values.y) #define AST_FOR(x,y) x->values.forVals.y +#define AST_ARGREG(x) x->values.argreg + #define IS_AST_PARAM(x) (IS_AST_OP(x) && x->opval.op == PARAM) #define CAN_EVAL(x) ( x == '[' || x == '.' || x == PTR_OP || \ @@ -175,23 +180,24 @@ extern struct memmap *GcurMemmap; 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 (long, ast *, ast *); ast *copyAst (ast *); +ast *removeIncDecOps (ast *); +ast *removePreIncDecOps (ast *); +ast *removePostIncDecOps (ast *); value *sizeofOp (sym_link *); value *evalStmnt (ast *); ast *createFunction (symbol *, ast *); ast *createBlock (symbol *, ast *); ast *createLabel (symbol *, ast *); ast *createCase (ast *, ast *, ast *); -ast *createDefault (ast *, ast *); -ast *optimizeCompare (ast *); +ast *createDefault (ast *, ast *, ast *); ast *forLoopOptForm (ast *); ast *argAst (ast *); ast *resolveSymbols (ast *); -ast *decorateType (ast *); +ast *decorateType (ast *, RESULT_TYPE); ast *createWhile (symbol *, symbol *, symbol *, ast *, ast *); ast *createIf (ast *, ast *, ast *); ast *createDo (symbol *, symbol *, symbol *, ast *, ast *); @@ -199,11 +205,16 @@ ast *createFor (symbol *, symbol *, symbol *, symbol *, ast *, ast *, ast *, ast void eval2icode (ast *); value *constExprValue (ast *, int); bool constExprTree (ast *); +int setAstLineno (ast *, int); symbol *funcOfType (char *, sym_link *, sym_link *, int, int); symbol * funcOfTypeVarg (char *, char * , int , char **); ast *initAggregates (symbol *, initList *, ast *); bool hasSEFcalls (ast *); void addSymToBlock (symbol *, ast *); +void freeStringSymbol(symbol *); +DEFSETFUNC(resetParmKey); +int astErrors(ast *); +RESULT_TYPE getResultTypeFromType (sym_link *); // exported variables extern set *operKeyReset;