X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCsymt.h;h=aae73278c3a7b010a976fa5209a3b72d800f3245;hb=90bdb43b342189fcb94a398855d43f3f47f96738;hp=c9668d2d28192d9e9daeafab1084d07cd73658a9;hpb=edae25c7ae2b0749ca7d491b391b99967652a0fd;p=fw%2Fsdcc diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index c9668d2d..aae73278 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -60,10 +60,17 @@ enum { }; // values for first byte (or 3 most significant bits) of generic pointer. +#if 0 #define GPTYPE_FAR 0x00 #define GPTYPE_NEAR 0x40 #define GPTYPE_XSTACK 0x60 #define GPTYPE_CODE 0x80 +#else +#define GPTYPE_FAR (port->gp_tags.tag_far) +#define GPTYPE_NEAR (port->gp_tags.tag_near) +#define GPTYPE_XSTACK (port->gp_tags.tag_xstack) +#define GPTYPE_CODE (port->gp_tags.tag_code) +#endif #define HASHTAB_SIZE 256 @@ -86,6 +93,8 @@ typedef struct structdef struct symbol *fields; /* pointer to fields */ unsigned size; /* sizeof the table in bytes */ int type; /* STRUCT or UNION */ + bool b_flexArrayMember; /* has got an flexible array member, + only needed for syntax checks */ } structdef; @@ -127,6 +136,13 @@ typedef enum } STORAGE_CLASS; +#define TYPE_TARGET_CHAR TYPE_BYTE +#define TYPE_TARGET_INT TYPE_WORD +#define TYPE_TARGET_LONG TYPE_DWORD +#define TYPE_TARGET_UCHAR TYPE_UBYTE +#define TYPE_TARGET_UINT TYPE_UWORD +#define TYPE_TARGET_ULONG TYPE_UDWORD + /* specifier is the last in the type-chain */ typedef struct specifier { @@ -152,14 +168,14 @@ typedef struct specifier int argreg; /* reg no for regparm */ union { /* Values if constant or enum */ - TYPE_WORD v_int; /* 2 bytes: int and char values */ - char *v_char; /* character string */ - TYPE_UWORD v_uint; /* 2 bytes: unsigned int const value */ - TYPE_DWORD v_long; /* 4 bytes: long constant value */ - TYPE_UDWORD v_ulong; /* 4 bytes: unsigned long constant value */ - double v_float; /* floating point constant value */ - TYPE_UDWORD v_fixed16x16; /* 4 bytes: fixed floating point constant value */ - struct symbol *v_enum; /* ptr to enum_list if enum==1 */ + TYPE_TARGET_INT v_int; /* 2 bytes: int and char values */ + TYPE_TARGET_CHAR *v_char; /* character string */ + TYPE_TARGET_UINT v_uint; /* 2 bytes: unsigned int const value */ + TYPE_TARGET_LONG v_long; /* 4 bytes: long constant value */ + TYPE_TARGET_ULONG v_ulong; /* 4 bytes: unsigned long constant value */ + double v_float; /* floating point constant value */ + TYPE_TARGET_ULONG v_fixed16x16; /* 4 bytes: fixed floating point constant value */ + struct symbol *v_enum; /* ptr to enum_list if enum==1 */ } const_val; struct structdef *v_struct; /* structure pointer */ @@ -185,7 +201,8 @@ DECLARATOR_TYPE; typedef struct declarator { DECLARATOR_TYPE dcl_type; /* POINTER,ARRAY or FUNCTION */ - unsigned int num_elem; /* # of elems if type==array */ + unsigned int num_elem; /* # of elems if type==array, */ + /* always 0 for flexible arrays */ unsigned ptr_const:1; /* pointer is constant */ unsigned ptr_volatile:1; /* pointer is volatile */ struct sym_link *tspec; /* pointer type specifier */ @@ -243,11 +260,17 @@ typedef struct symbol char name[SDCC_SYMNAME_MAX + 1]; /* Input Variable Name */ char rname[SDCC_NAME_MAX + 1]; /* internal name */ - short level; /* declration lev,fld offset */ - short block; /* sequential block # of defintion */ + short level; /* declaration lev,fld offset */ + short block; /* sequential block # of definition */ int key; + unsigned flexArrayLength; /* if the symbol specifies a struct + with a "flexible array member", then the additional length in bytes for + the "fam" is stored here. Because the lenght can be different from symbol + to symbol AND v_struct isn't copied in copyLinkChain(), it's located here + in the symbol and not in v_struct or the declarator */ unsigned implicit:1; /* implicit flag */ unsigned undefined:1; /* undefined variable */ + unsigned infertype:1; /* type should be inferred from first assign */ unsigned _isparm:1; /* is a parameter */ unsigned ismyparm:1; /* is parameter of the function being generated */ unsigned isitmp:1; /* is an intermediate temp */ @@ -558,7 +581,6 @@ void printSymChain (symbol *, int); void printStruct (structdef *, int); char *genSymName (int); sym_link *getSpec (sym_link *); -char *genSymName (int); int compStructSize (int, structdef *); sym_link *copyLinkChain (sym_link *); int checkDecl (symbol *, int); @@ -568,7 +590,6 @@ value *checkStructIval (symbol *, value *); value *checkArrayIval (sym_link *, value *); value *checkIval (sym_link *, value *); unsigned int getSize (sym_link *); -unsigned int getAllocSize (sym_link *); unsigned int bitsForType (sym_link *); sym_link *newIntLink (); sym_link *newCharLink (); @@ -584,9 +605,10 @@ void addSymChain (symbol **); sym_link *structElemType (sym_link *, value *); symbol *getStructElement (structdef *, symbol *); sym_link *computeType (sym_link *, sym_link *, RESULT_TYPE, int); +void processFuncPtrArgs (sym_link *); void processFuncArgs (symbol *); int isSymbolEqual (symbol *, symbol *); -int powof2 (TYPE_UDWORD); +int powof2 (TYPE_TARGET_ULONG); void printTypeChain (sym_link *, FILE *); void printTypeChainRaw (sym_link *, FILE *); void initCSupport ();