]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
fixing the messup of MUL_FV and _VF being swapped - getting rid of additions that...
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 2da9d8c9c04e39bb2a8f3babd0ff094357745708..beca3504a3bb4a5448b2ade23797d6c1dcb9267d 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -179,95 +179,6 @@ typedef char int64_size_is_correct  [sizeof(int64_t)  == 8?1:-1];
 typedef char uintptr_size_is_correct[sizeof(intptr_t) == sizeof(int*)?1:-1];
 typedef char intptr_size_is_correct [sizeof(uintptr_t)== sizeof(int*)?1:-1];
 
-/*===================================================================*/
-/*============================ lex.c ================================*/
-/*===================================================================*/
-typedef struct lex_file_t {
-    FILE *file;        /* file handler */
-    char *name;        /* name of file */
-    char  peek  [5];
-    char  lastok[8192];
-
-    int   last;    /* last token                   */
-    int   current; /* current token                */
-    int   length;  /* bytes left to parse          */
-    int   size;    /* never changes (size of file) */
-    int   line;    /* what line are we on?         */
-} lex_file;
-
-/*
- * It's important that this table never exceed 32 keywords, the ascii
- * table starts at 33 (and we don't want conflicts)
- */
-enum {
-    TOKEN_DO       ,
-    TOKEN_ELSE     ,
-    TOKEN_IF       ,
-    TOKEN_WHILE    ,
-    TOKEN_BREAK    ,
-    TOKEN_CONTINUE ,
-    TOKEN_RETURN   ,
-    TOKEN_GOTO     ,
-    TOKEN_FOR      ,   /* extension */
-    TOKEN_TYPEDEF  ,   /* extension */
-
-    /* ensure the token types are out of the  */
-    /* bounds of anyothers that may conflict. */
-    TOKEN_FLOAT    = 110,
-    TOKEN_VECTOR        ,
-    TOKEN_STRING        ,
-    TOKEN_ENTITY        ,
-    TOKEN_VOID
-};
-
-/*
- * Lexer state constants, these are numbers for where exactly in
- * the lexing the lexer is at. Or where it decided to stop if a lexer
- * error occurs.  These numbers must be > where the ascii-table ends
- * and > the last type token which is TOKEN_VOID
- */
-enum {
-    LEX_COMMENT = 1128,
-    LEX_CHRLIT        ,
-    LEX_STRLIT        ,
-    LEX_IDENT
-};
-
-int       lex_token  (lex_file *);
-void      lex_reset  (lex_file *);
-void      lex_close  (lex_file *);
-void      lex_parse  (lex_file *);
-lex_file *lex_include(lex_file *, const char *);
-void      lex_init   (const char *, lex_file **);
-
-/*===================================================================*/
-/*========================== error.c ================================*/
-/*===================================================================*/
-#define ERROR_LEX      (SHRT_MAX+0)
-#define ERROR_PARSE    (SHRT_MAX+1)
-#define ERROR_INTERNAL (SHRT_MAX+2)
-#define ERROR_COMPILER (SHRT_MAX+3)
-#define ERROR_PREPRO   (SHRT_MAX+4)
-int error(lex_file *, int, const char *, ...);
-
-/*===================================================================*/
-/*========================== parse.c ================================*/
-/*===================================================================*/
-int parse_gen(lex_file *);
-
-/*===================================================================*/
-/*========================== typedef.c ==============================*/
-/*===================================================================*/
-typedef struct typedef_node_t {
-    char      *name;
-} typedef_node;
-
-void          typedef_init();
-void          typedef_clear();
-typedef_node *typedef_find(const char *);
-int           typedef_add (lex_file *file, const char *, const char *);
-
-
 /*===================================================================*/
 /*=========================== util.c ================================*/
 /*===================================================================*/
@@ -367,12 +278,14 @@ enum {
     TYPE_FIELD    ,
     TYPE_FUNCTION ,
     TYPE_POINTER  ,
-    /* TYPE_INTEGER  , */
+    TYPE_INTEGER  ,
     TYPE_VARIANT  ,
 
     TYPE_COUNT
 };
 
+extern const char *type_name[TYPE_COUNT];
+
 extern size_t type_sizeof[TYPE_COUNT];
 extern uint16_t type_store_instr[TYPE_COUNT];
 /* could use type_store_instr + INSTR_STOREP_F - INSTR_STORE_F
@@ -671,6 +584,7 @@ static const struct {
     { "OR"        , 0, 2 },
     { "BITAND"    , 0, 6 },
     { "BITOR"     , 0, 5 },
+
     { "END"       , 0, 3 } /* virtual assembler instruction */
 };
 
@@ -831,6 +745,16 @@ void Tself##_##mem##_clear(Tself *self) \
     (owner)->mem##_alloc = 0;       \
 }
 
+#define MEM_VECTOR_MOVE(from, mem, to, tm)   \
+{                                            \
+    (to)->tm = (from)->mem;                  \
+    (to)->tm##_count = (from)->mem##_count;  \
+    (to)->tm##_alloc = (from)->mem##_alloc;  \
+    (from)->mem = NULL;                      \
+    (from)->mem##_count = 0;                 \
+    (from)->mem##_alloc = 0;                 \
+}
+
 #define MEM_VEC_FUNCTIONS(Tself, Twhat, mem) \
 MEM_VEC_FUN_REMOVE(Tself, Twhat, mem)        \
 MEM_VEC_FUN_ADD(Tself, Twhat, mem)
@@ -917,6 +841,7 @@ typedef struct qc_program_s {
     MEM_VECTOR_MAKE(char,                   strings);
     MEM_VECTOR_MAKE(qcint,                  globals);
     MEM_VECTOR_MAKE(qcint,                  entitydata);
+    MEM_VECTOR_MAKE(bool,                   entitypool);
 
     size_t tempstring_start;
     size_t tempstring_at;
@@ -990,13 +915,13 @@ static const opts_flag_def opts_flag_list[] = {
 };
 
 enum {
-# define GMQCC_DEFINE_FLAG(X) X,
+# define GMQCC_DEFINE_FLAG(X) WARN_##X,
 #  include "warns.def"
 # undef GMQCC_DEFINE_FLAG
     COUNT_WARNINGS
 };
 static const opts_flag_def opts_warn_list[] = {
-# define GMQCC_DEFINE_FLAG(X) { #X, LONGBIT(X) },
+# define GMQCC_DEFINE_FLAG(X) { #X, LONGBIT(WARN_##X) },
 #  include "warns.def"
 # undef GMQCC_DEFINE_FLAG
     { NULL, LONGBIT(0) }