]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - misc/source/fteqcc-src/qcc.h
Update fteqcc source
[voretournament/voretournament.git] / misc / source / fteqcc-src / qcc.h
index 5c2cd2ed79ca1e61d54be0ac78bb668665e484b4..1ee2ac62ae77c6e477cfcead9ebae6d22229f312 100644 (file)
@@ -42,7 +42,7 @@ extern float   (*PRLittleFloat) (float l);
 
 #define        MAX_ERRORS              10
 
-#define        MAX_NAME                128             // chars long
+#define        MAX_NAME                256             // chars long
 
 extern unsigned int MAX_REGS;
 
@@ -59,7 +59,7 @@ extern int    MAX_FUNCTIONS;
 #define        MAX_DATA_PATH   64
 
 extern int MAX_CONSTANTS;
-#define MAXCONSTANTLENGTH 64
+#define MAXCONSTANTNAMELENGTH 64
 #define MAXCONSTANTPARAMLENGTH 32
 #define MAXCONSTANTPARAMS 32
 
@@ -281,7 +281,7 @@ extern hashtable_t globalstable, localstable;
 #endif
 
 #ifdef WRITEASM
-FILE *asmfile;
+extern FILE *asmfile;
 #endif
 //=============================================================================
 
@@ -305,6 +305,8 @@ typedef struct QCC_type_s
 
        unsigned int ofs;       //inside a structure.
        unsigned int size;
+       unsigned int arraysize;
+       pbool typedefed;
        char *name;
 } QCC_type_t;
 int typecmp(QCC_type_t *a, QCC_type_t *b);
@@ -330,6 +332,7 @@ typedef struct QCC_def_s
        struct QCC_def_s        *nextlocal;     //provides a chain of local variables for the opt_locals_marshalling optimisation.
        gofs_t          ofs;
        struct QCC_def_s        *scope;         // function the var was defined in, or NULL
+       struct QCC_def_s        *deftail;       // arrays and structs create multiple globaldef objects providing different types at the different parts of the single object (struct), or alternative names (vectors). this allows us to correctly set the const type based upon how its initialised.
        int                     initialized;    // 1 when a declaration included "= immediate"
        int                     constant;               // 1 says we can use the value over and over again
 
@@ -340,10 +343,11 @@ typedef struct QCC_def_s
        int s_line;
 
        int arraysize;
-       pbool shared;
-       pbool saved;
-       pbool isstatic;
-       pbool subscoped_away;
+       pbool shared:1;
+       pbool saved:1;
+       pbool isstatic:1;
+       pbool subscoped_away:1;
+       pbool followptr:1;
 
        temp_t *temp;
 } QCC_def_t;
@@ -371,7 +375,7 @@ typedef union QCC_eval_s
 const extern   unsigned int            type_size[];
 //extern       QCC_def_t       *def_for_type[9];
 
-extern QCC_type_t      *type_void, *type_string, *type_float, *type_vector, *type_entity, *type_field, *type_function, *type_pointer, *type_integer, *type_variant, *type_floatfield;
+extern QCC_type_t      *type_void, *type_string, *type_float, *type_vector, *type_entity, *type_field, *type_function, *type_pointer, *type_floatpointer, *type_intpointer, *type_integer, *type_variant, *type_floatfield;
 
 struct QCC_function_s
 {
@@ -406,7 +410,7 @@ extern      QCC_pr_info_t   pr;
 
 typedef struct
 {
-       char name[MAXCONSTANTLENGTH];
+       char name[MAXCONSTANTNAMELENGTH];
        char *value;
        char params[MAXCONSTANTPARAMS][MAXCONSTANTPARAMLENGTH];
        int numparams;
@@ -440,6 +444,7 @@ extern pbool keyword_break;
 extern pbool keyword_case;
 extern pbool keyword_class;
 extern pbool keyword_const;
+extern pbool keyword_optional;
 extern pbool keyword_continue;
 extern pbool keyword_default;
 extern pbool keyword_do;
@@ -481,6 +486,7 @@ extern pbool flag_fasttrackarrays;
 extern pbool flag_assume_integer;
 extern pbool flag_msvcstyle;
 extern pbool flag_filetimes;
+extern pbool flag_typeexplicit;
 
 extern pbool opt_overlaptemps;
 extern pbool opt_shortenifnots;
@@ -532,8 +538,10 @@ void QCC_PR_PrintStatement (QCC_dstatement_t *s);
 void QCC_PR_Lex (void);
 // reads the next token into pr_token and classifies its type
 
-QCC_type_t *QCC_PR_NewType (char *name, int basictype);
-QCC_type_t *QCC_PR_ParseType (int newtype); extern pbool type_inlinefunction;
+QCC_type_t *QCC_PR_NewType (char *name, int basictype, pbool typedefed);
+QCC_type_t *QCC_PointerTypeTo(QCC_type_t *type);
+QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail);
+extern pbool type_inlinefunction;
 QCC_type_t *QCC_TypeForName(char *name);
 QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype);
 QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype);
@@ -542,6 +550,8 @@ CompilerConstant_t *QCC_PR_DefineName(char *name);
 
 void QCC_RemapOffsets(unsigned int firststatement, unsigned int laststatement, unsigned int min, unsigned int max, unsigned int newmin);
 
+int QCC_PR_IntConstExpr(void);
+
 #ifndef COMMONINLINES
 pbool QCC_PR_CheckImmediate (char *string);
 pbool QCC_PR_CheckToken (char *string);
@@ -551,7 +561,7 @@ pbool QCC_PR_CheckKeyword(int keywordenabled, char *string);
 #endif
 void VARGS QCC_PR_ParseError (int errortype, char *error, ...);
 void VARGS QCC_PR_ParseWarning (int warningtype, char *error, ...);
-void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...);
+pbool VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...);
 void VARGS QCC_PR_Note (int type, char *file, int line, char *error, ...);
 void QCC_PR_ParsePrintDef (int warningtype, QCC_def_t *def);
 void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error, ...);
@@ -614,6 +624,7 @@ enum {
        WARN_SAMENAMEASGLOBAL,
        WARN_CONSTANTCOMPARISON,
        WARN_UNSAFEFUNCTIONRETURNTYPE,
+       WARN_MISSINGOPTIONAL,
 
        ERR_PARSEERRORS,        //caused by qcc_pr_parseerror being called.
 
@@ -846,23 +857,32 @@ extern int numtemps;
 
 typedef char PATHSTRING[MAX_DATA_PATH];
 
-PATHSTRING             *precache_sounds;
-int                    *precache_sounds_block;
-int                    *precache_sounds_used;
-int                    numsounds;
-
-PATHSTRING             *precache_textures;
-int                    *precache_textures_block;
-int                    numtextures;
-
-PATHSTRING             *precache_models;
-int                    *precache_models_block;
-int                    *precache_models_used;
-int                    nummodels;
-
-PATHSTRING             *precache_files;
-int                    *precache_files_block;
-int                    numfiles;
+extern PATHSTRING              *precache_sounds;
+extern int                     *precache_sounds_block;
+extern int                     *precache_sounds_used;
+extern int                     numsounds;
+
+extern PATHSTRING              *precache_textures;
+extern int                     *precache_textures_block;
+extern int                     numtextures;
+
+extern PATHSTRING              *precache_models;
+extern int                     *precache_models_block;
+extern int                     *precache_models_used;
+extern int                     nummodels;
+
+extern PATHSTRING              *precache_files;
+extern int                     *precache_files_block;
+extern int                     numfiles;
+
+typedef struct qcc_includechunk_s {
+       struct qcc_includechunk_s *prev;
+       char *filename;
+       char *currentdatapoint;
+       int currentlinenumber;
+       CompilerConstant_t *cnst;
+} qcc_includechunk_t;
+extern qcc_includechunk_t *currentchunk;
 
 int    QCC_CopyString (char *str);