]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
Update doc/specification.tex
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 553197ab6b997c062db38abc328b424aaec1e7df..ae443014678ec7a4aed55688691b8c63952c9395 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -102,8 +102,10 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
  */
 #if defined(__GNUC__) || defined(__CLANG__)
 #   define GMQCC_WARN __attribute__((warn_unused_result))
+#   define GMQCC_USED __attribute__((used))
 #else
 #   define GMQCC_WARN
+#   define GMQCC_USED
 #endif
 /*
  * This is a hack to silent clang regarding empty
@@ -451,7 +453,8 @@ GMQCC_INLINE FILE   *file_open   (const char *, const char *);
 /*=========================== correct.c =============================*/
 /*===================================================================*/
 typedef struct {
-    char ***edits;
+    char   ***edits;
+    size_t  **lens;
 } correction_t;
 
 void  correct_del (correct_trie_t*, size_t **);
@@ -681,17 +684,11 @@ enum {
     INSTR_BITAND,
     INSTR_BITOR,
 
-    /*
-     * Virtual instructions used by the assembler
-     * keep at the end but before virtual instructions
-     * for the IR below.
-     */
-    AINSTR_END,
-
     /*
      * Virtual instructions used by the IR
      * Keep at the end!
      */
+    VINSTR_END,
     VINSTR_PHI,
     VINSTR_JUMP,
     VINSTR_COND,
@@ -975,7 +972,7 @@ typedef struct qc_program_s {
     int    argc; /* current arg count for debugging */
 } qc_program;
 
-qc_program* prog_load(const char *filename);
+qc_program* prog_load(const char *filename, bool ignoreversion);
 void        prog_delete(qc_program *prog);
 
 bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long maxjumps);
@@ -1123,6 +1120,14 @@ static const unsigned int opts_opt_oflag[] = {
 #  include "opts.def"
     0
 };
+
+enum {
+#   define GMQCC_TYPE_OPTIONS
+#   define GMQCC_DEFINE_FLAG(X) OPTION_##X,
+#   include "opts.def"
+    OPTION_COUNT
+};
+
 extern unsigned int opts_optimizationcount[COUNT_OPTIMIZATIONS];
 
 /* other options: */
@@ -1133,29 +1138,22 @@ typedef enum {
     COMPILER_GMQCC    /* this   QuakeC */
 } opts_std_t;
 
-/* TODO: cleanup this */
+typedef union {
+    bool     B;
+    uint16_t U16;
+    uint32_t U32;
+    char    *STR;
+} opt_value_t;
+
+
 typedef struct {
-    uint32_t    O;              /* -Ox           */
-    const char *output;         /* -o file       */
-    bool        quiet;          /* -q --quiet    */
-    bool        g;              /* -g            */
-    opts_std_t  standard;       /* -std=         */
-    bool        debug;          /* -debug        */
-    bool        memchk;         /* -memchk       */
-    bool        dumpfin;        /* -dumpfin      */
-    bool        dump;           /* -dump         */
-    bool        forcecrc;       /* --force-crc=  */
-    uint16_t    forced_crc;     /* --force-crc=  */
-    bool        pp_only;        /* -E            */
-    size_t      max_array_size; /* --max-array=  */
-    bool        add_info;       /* --add-info    */
-
-    uint32_t flags        [1 + (COUNT_FLAGS         / 32)];
-    uint32_t warn         [1 + (COUNT_WARNINGS      / 32)];
-    uint32_t werror       [1 + (COUNT_WARNINGS      / 32)];
-    uint32_t warn_backup  [1 + (COUNT_WARNINGS      / 32)];
-    uint32_t werror_backup[1 + (COUNT_WARNINGS      / 32)];
-    uint32_t optimization [1 + (COUNT_OPTIMIZATIONS / 32)];
+    opt_value_t  options      [OPTION_COUNT];
+    uint32_t     flags        [1 + (COUNT_FLAGS         / 32)];
+    uint32_t     warn         [1 + (COUNT_WARNINGS      / 32)];
+    uint32_t     werror       [1 + (COUNT_WARNINGS      / 32)];
+    uint32_t     warn_backup  [1 + (COUNT_WARNINGS      / 32)];
+    uint32_t     werror_backup[1 + (COUNT_WARNINGS      / 32)];
+    uint32_t     optimization [1 + (COUNT_OPTIMIZATIONS / 32)];
 } opts_cmd_t;
 
 extern opts_cmd_t opts;
@@ -1165,5 +1163,9 @@ extern opts_cmd_t opts;
 #define OPTS_WARN(i)         OPTS_GENERIC(opts.warn,         (i))
 #define OPTS_WERROR(i)       OPTS_GENERIC(opts.werror,       (i))
 #define OPTS_OPTIMIZATION(i) OPTS_GENERIC(opts.optimization, (i))
+#define OPTS_OPTION_BOOL(X) (opts.options[X].B)
+#define OPTS_OPTION_U16(X)  (opts.options[X].U16)
+#define OPTS_OPTION_U32(X)  (opts.options[X].U32)
+#define OPTS_OPTION_STR(X)  (opts.options[X].STR)
 
 #endif