]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Rename
authorDale Weiler <killfieldengine@gmail.com>
Wed, 30 Jan 2013 05:35:07 +0000 (05:35 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 30 Jan 2013 05:35:07 +0000 (05:35 +0000)
ast.c
code.c
ftepp.c
gmqcc.h
ir.c
lexer.c
main.c
opts.c
parser.c
test.c
util.c

diff --git a/ast.c b/ast.c
index 41eadfa56b83fbfa8f0c9ed77d0550c682e52037..3a4f1d7b2782f39983174d686a889a9f1e497dae 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1124,9 +1124,9 @@ const char* ast_function_label(ast_function *self, const char *prefix)
     size_t len;
     char  *from;
 
-    if (!OPTION_VALUE_BOOL(OPTION_DUMP)    &&
-        !OPTION_VALUE_BOOL(OPTION_DUMPFIN) &&
-        !OPTION_VALUE_BOOL(OPTION_DEBUG))
+    if (!OPTS_OPTION_BOOL(OPTION_DUMP)    &&
+        !OPTS_OPTION_BOOL(OPTION_DUMPFIN) &&
+        !OPTS_OPTION_BOOL(OPTION_DEBUG))
     {
         return NULL;
     }
@@ -1235,7 +1235,7 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
             }
 
             /* we are lame now - considering the way QC works we won't tolerate arrays > 1024 elements */
-            if (!array->expression.count || array->expression.count > OPTION_VALUE_U32(OPTION_MAX_ARRAY_SIZE))
+            if (!array->expression.count || array->expression.count > OPTS_OPTION_U32(OPTION_MAX_ARRAY_SIZE))
                 compile_error(ast_ctx(self), "Invalid array of size %lu", (unsigned long)array->expression.count);
 
             elemtype = &array->expression.next->expression;
@@ -1297,7 +1297,7 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
         int vtype = elemtype->vtype;
 
         /* same as with field arrays */
-        if (!self->expression.count || self->expression.count > OPTION_VALUE_U32(OPTION_MAX_ARRAY_SIZE))
+        if (!self->expression.count || self->expression.count > OPTS_OPTION_U32(OPTION_MAX_ARRAY_SIZE))
             compile_error(ast_ctx(self), "Invalid array of size %lu", (unsigned long)self->expression.count);
 
         v = ir_builder_create_global(ir, self->name, vtype);
@@ -1434,7 +1434,7 @@ bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
         }
 
         /* we are lame now - considering the way QC works we won't tolerate arrays > 1024 elements */
-        if (!self->expression.count || self->expression.count > OPTION_VALUE_U32(OPTION_MAX_ARRAY_SIZE)) {
+        if (!self->expression.count || self->expression.count > OPTS_OPTION_U32(OPTION_MAX_ARRAY_SIZE)) {
             compile_error(ast_ctx(self), "Invalid array of size %lu", (unsigned long)self->expression.count);
         }
 
@@ -1706,7 +1706,7 @@ bool ast_block_codegen(ast_block *self, ast_function *func, bool lvalue, ir_valu
     for (i = 0; i < vec_size(self->locals); ++i)
     {
         if (!ast_local_codegen(self->locals[i], func->ir_func, false)) {
-            if (OPTION_VALUE_BOOL(OPTION_DEBUG))
+            if (OPTS_OPTION_BOOL(OPTION_DEBUG))
                 compile_error(ast_ctx(self), "failed to generate local `%s`", self->locals[i]->name);
             return false;
         }
diff --git a/code.c b/code.c
index e480ed21df2dc8cb6f4cd902546cca322b1e91d0..43a34c9de78aec26749824fc03d436b502538c5c 100644 (file)
--- a/code.c
+++ b/code.c
@@ -137,8 +137,8 @@ bool code_write(const char *filename, const char *lnofile) {
     code_header.strings.offset    = code_header.globals.offset    + (sizeof(int32_t)                * vec_size(code_globals));
     code_header.strings.length    = vec_size(code_chars);
     code_header.version           = 6;
-    if (OPTION_VALUE_BOOL(OPTION_FORCECRC))
-        code_header.crc16         = OPTION_VALUE_U16(OPTION_FORCED_CRC);
+    if (OPTS_OPTION_BOOL(OPTION_FORCECRC))
+        code_header.crc16         = OPTS_OPTION_U16(OPTION_FORCED_CRC);
     else
         code_header.crc16         = code_crc;
     code_header.entfield          = code_entfields;
diff --git a/ftepp.c b/ftepp.c
index 04d64e70997c806ceb5b4c310e4fa40d39c87dd7..34eec593bc8754019c635a4ddf1accc604cb54cb 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -1011,7 +1011,7 @@ static bool ftepp_if_value(ftepp_t *ftepp, bool *out, double *value_out)
 
         default:
             ftepp_error(ftepp, "junk in #if: `%s` ...", ftepp_tokval(ftepp));
-            if (OPTION_VALUE_BOOL(OPTION_DEBUG))
+            if (OPTS_OPTION_BOOL(OPTION_DEBUG))
                 ftepp_error(ftepp, "internal: token %i\n", ftepp->token);
             return false;
     }
@@ -1670,7 +1670,7 @@ bool ftepp_init()
 
     /* set the right macro based on the selected standard */
     ftepp_add_define(NULL, "GMQCC");
-    if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_FTEQCC) {
+    if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_FTEQCC) {
         ftepp_add_define(NULL, "__STD_FTEQCC__");
         /* 1.00 */
         major[0] = '"';
@@ -1680,15 +1680,15 @@ bool ftepp_init()
         minor[0] = '"';
         minor[1] = '0';
         minor[2] = '"';
-    } else if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
+    } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
         ftepp_add_define(NULL, "__STD_GMQCC__");
         sprintf(major, "\"%d\"", GMQCC_VERSION_MAJOR);
         sprintf(minor, "\"%d\"", GMQCC_VERSION_MINOR);
-    } else if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCCX) {
+    } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCCX) {
         ftepp_add_define(NULL, "__STD_QCCX__");
         sprintf(major, "\"%d\"", GMQCC_VERSION_MAJOR);
         sprintf(minor, "\"%d\"", GMQCC_VERSION_MINOR);
-    } else if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC) {
+    } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
         ftepp_add_define(NULL, "__STD_QCC__");
         /* 1.0 */
         major[0] = '"';
diff --git a/gmqcc.h b/gmqcc.h
index fed9b31f422d1452454ec8104606432bd5117b64..0b97e2f40c4d6fb9f8f55c4f8df96cd45be55224 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -1131,12 +1131,16 @@ enum {
 #   include "opts.def"
     OPTION_COUNT
 };
+
+/* disabled for now */
+#if 0
 static const char *opts_options_descriptions[OPTION_COUNT + 1] = {
 #   define GMQCC_TYPE_OPTIONS
 #   define GMQCC_DEFINE_FLAG(X, Y) Y,
 #   include "opts.def"
     ""
 };
+#endif
 
 extern unsigned int opts_optimizationcount[COUNT_OPTIMIZATIONS];
 
@@ -1163,10 +1167,6 @@ typedef union {
 } opt_value_t;
 
 
-#define OPTION_VALUE_BOOL(X) (opts.options[X].B)
-#define OPTION_VALUE_U16(X)  (opts.options[X].U16)
-#define OPTION_VALUE_U32(X)  (opts.options[X].U32)
-#define OPTION_VALUE_STR(X)  (opts.options[X].STR)
 typedef struct {
     opt_value_t  options      [OPTION_COUNT];
     uint32_t     flags        [1 + (COUNT_FLAGS         / 32)];
@@ -1184,5 +1184,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
diff --git a/ir.c b/ir.c
index 0f437aaeb0551ae220cf39fa766d8b12655ed181..0d7d90e459caee83b55e7e0937e9c7453d853af9 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -3228,7 +3228,7 @@ static bool gen_function_locals(ir_builder *ir, ir_value *global)
     irfun = global->constval.vfunc;
     def   = code_functions + irfun->code_function_def;
 
-    if (OPTION_VALUE_BOOL(OPTION_G) ||
+    if (OPTS_OPTION_BOOL(OPTION_G) ||
         !OPTS_OPTIMIZATION(OPTIM_OVERLAP_LOCALS)        ||
         (irfun->flags & IR_FLAG_MASK_NO_OVERLAP))
     {
@@ -3379,7 +3379,7 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     def.type   = global->vtype;
     def.offset = vec_size(code_globals);
     def.name   = 0;
-    if (OPTION_VALUE_BOOL(OPTION_G) || !islocal)
+    if (OPTS_OPTION_BOOL(OPTION_G) || !islocal)
     {
         pushdef = true;
 
@@ -3555,7 +3555,7 @@ static bool ir_builder_gen_field(ir_builder *self, ir_value *field)
     def.offset = (uint16_t)vec_size(code_globals);
 
     /* create a global named the same as the field */
-    if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
+    if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
         /* in our standard, the global gets a dot prefix */
         size_t len = strlen(field->name);
         char name[1024];
@@ -3693,7 +3693,7 @@ bool ir_builder_generate(ir_builder *self, const char *filename)
         code_push_statement(&stmt, vec_last(code_linenums));
     }
 
-    if (OPTION_VALUE_BOOL(OPTION_PP_ONLY))
+    if (OPTS_OPTION_BOOL(OPTION_PP_ONLY))
         return true;
 
     if (vec_size(code_statements) != vec_size(code_linenums)) {
@@ -3714,7 +3714,7 @@ bool ir_builder_generate(ir_builder *self, const char *filename)
         memcpy(vec_add(lnofile, 5), ".lno", 5);
     }
 
-    if (!OPTION_VALUE_BOOL(OPTION_QUIET)) {
+    if (!OPTS_OPTION_BOOL(OPTION_QUIET)) {
         if (lnofile)
             con_out("writing '%s' and '%s'...\n", filename, lnofile);
         else
diff --git a/lexer.c b/lexer.c
index c8001d6b303790c80fd4656911a494ae43a7a424..f345e47be5b8dfc7589a84abe03e38ef967a91ce 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -1387,7 +1387,7 @@ int lex_do(lex_file *lex)
                 if (!strcmp(v, keywords_qc[kw]))
                     return (lex->tok.ttype = TOKEN_KEYWORD);
             }
-            if (OPTION_VALUE_U32(OPTION_STANDARD) != COMPILER_QCC) {
+            if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_QCC) {
                 for (kw = 0; kw < num_keywords_fg; ++kw) {
                     if (!strcmp(v, keywords_fg[kw]))
                         return (lex->tok.ttype = TOKEN_KEYWORD);
diff --git a/main.c b/main.c
index 5849b53528e3a509f4c8fd8024d966a483c8fc11..dee9a3293b0bc6765c81ef485265214accc0ce7a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -174,14 +174,14 @@ static bool options_parse(int argc, char **argv) {
                     opts_set(opts.werror, WARN_MISSING_RETURN_VALUES,   true);
 
 
-                    OPTION_VALUE_U32(OPTION_STANDARD) = COMPILER_GMQCC;
+                    OPTS_OPTION_U32(OPTION_STANDARD) = COMPILER_GMQCC;
 
                 } else if (!strcmp(argarg, "qcc")) {
 
                     opts_set(opts.flags, ADJUST_VECTOR_FIELDS,  false);
                     opts_set(opts.flags, ASSIGN_FUNCTION_TYPES, true);
 
-                    OPTION_VALUE_U32(OPTION_STANDARD) = COMPILER_QCC;
+                    OPTS_OPTION_U32(OPTION_STANDARD) = COMPILER_QCC;
 
                 } else if (!strcmp(argarg, "fte") || !strcmp(argarg, "fteqcc")) {
 
@@ -192,12 +192,12 @@ static bool options_parse(int argc, char **argv) {
                     opts_set(opts.flags, CORRECT_TERNARY,          false);
                     opts_set(opts.warn, WARN_TERNARY_PRECEDENCE,   true);
 
-                    OPTION_VALUE_U32(OPTION_STANDARD) = COMPILER_FTEQCC;
+                    OPTS_OPTION_U32(OPTION_STANDARD) = COMPILER_FTEQCC;
 
                 } else if (!strcmp(argarg, "qccx")) {
 
                     opts_set(opts.flags, ADJUST_VECTOR_FIELDS,  false);
-                    OPTION_VALUE_U32(OPTION_STANDARD) = COMPILER_QCCX;
+                    OPTS_OPTION_U32(OPTION_STANDARD) = COMPILER_QCCX;
 
                 } else {
                     con_out("Unknown standard: %s\n", argarg);
@@ -207,8 +207,8 @@ static bool options_parse(int argc, char **argv) {
             }
             if (options_long_gcc("force-crc", &argc, &argv, &argarg)) {
 
-                OPTION_VALUE_BOOL(OPTION_FORCECRC)   = true;
-                OPTION_VALUE_U16 (OPTION_FORCED_CRC) = strtol(argarg, NULL, 0);
+                OPTS_OPTION_BOOL(OPTION_FORCECRC)   = true;
+                OPTS_OPTION_U16 (OPTION_FORCED_CRC) = strtol(argarg, NULL, 0);
                 continue;
             }
             if (options_long_gcc("redirout", &argc, &argv, &redirout)) {
@@ -248,19 +248,19 @@ static bool options_parse(int argc, char **argv) {
             }
 
             if (!strcmp(argv[0]+1, "debug")) {
-                OPTION_VALUE_BOOL(OPTION_DEBUG) = true;
+                OPTS_OPTION_BOOL(OPTION_DEBUG) = true;
                 continue;
             }
             if (!strcmp(argv[0]+1, "dump")) {
-                OPTION_VALUE_BOOL(OPTION_DUMP)  = true;
+                OPTS_OPTION_BOOL(OPTION_DUMP)  = true;
                 continue;
             }
             if (!strcmp(argv[0]+1, "dumpfin")) {
-                OPTION_VALUE_BOOL(OPTION_DUMPFIN) = true;
+                OPTS_OPTION_BOOL(OPTION_DUMPFIN) = true;
                 continue;
             }
             if (!strcmp(argv[0]+1, "memchk")) {
-                OPTION_VALUE_BOOL(OPTION_MEMCHK) = true;
+                OPTS_OPTION_BOOL(OPTION_MEMCHK) = true;
                 continue;
             }
             if (!strcmp(argv[0]+1, "nocolor")) {
@@ -280,18 +280,18 @@ static bool options_parse(int argc, char **argv) {
                     exit(0);
 
                 case 'E':
-                    OPTION_VALUE_BOOL(OPTION_PP_ONLY) = true;
+                    OPTS_OPTION_BOOL(OPTION_PP_ONLY) = true;
                     opts_set(opts.flags, FTEPP_PREDEFS, true); /* predefs on for -E */
                     break;
 
                 /* debug turns on -flno */
                 case 'g':
                     opts_setflag("LNO", true);
-                    OPTION_VALUE_BOOL(OPTION_G) = true;
+                    OPTS_OPTION_BOOL(OPTION_G) = true;
                     break;
 
                 case 'q':
-                    OPTION_VALUE_BOOL(OPTION_QUIET) = true;
+                    OPTS_OPTION_BOOL(OPTION_QUIET) = true;
                     break;
 
                 case 'D':
@@ -402,7 +402,7 @@ static bool options_parse(int argc, char **argv) {
                     }
                     if (isdigit(argarg[0])) {
                         uint32_t val = atoi(argarg);
-                        OPTION_VALUE_U32(OPTION_O) = val;
+                        OPTS_OPTION_U32(OPTION_O) = val;
                         opts_setoptimlevel(val);
                     } else {
                         util_strtocmd(argarg, argarg, strlen(argarg)+1);
@@ -415,7 +415,7 @@ static bool options_parse(int argc, char **argv) {
                             exit(0);
                         }
                         else if (!strcmp(argarg, "ALL"))
-                            opts_setoptimlevel(OPTION_VALUE_U32(OPTION_O) = 9999);
+                            opts_setoptimlevel(OPTS_OPTION_U32(OPTION_O) = 9999);
                         else if (!strncmp(argarg, "NO_", 3)) {
                             if (!opts_setoptim(argarg+3, false)) {
                                 con_out("unknown optimization: %s\n", argarg+3);
@@ -436,7 +436,7 @@ static bool options_parse(int argc, char **argv) {
                         con_out("option -o requires an argument: the output file name\n");
                         return false;
                     }
-                    OPTION_VALUE_STR(OPTION_OUTPUT) = argarg;
+                    OPTS_OPTION_STR(OPTION_OUTPUT) = argarg;
                     opts_output_wasset = true;
                     break;
 
@@ -468,25 +468,25 @@ static bool options_parse(int argc, char **argv) {
                         exit(0);
                     }
                     else if (!strcmp(argv[0]+2, "quiet")) {
-                        OPTION_VALUE_BOOL(OPTION_QUIET) = true;
+                        OPTS_OPTION_BOOL(OPTION_QUIET) = true;
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "correct")) {
-                        OPTION_VALUE_BOOL(OPTION_CORRECTION) = true;
+                        OPTS_OPTION_BOOL(OPTION_CORRECTION) = true;
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "no-correct")) {
-                        OPTION_VALUE_BOOL(OPTION_CORRECTION) = false;
+                        OPTS_OPTION_BOOL(OPTION_CORRECTION) = false;
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "add-info")) {
-                        OPTION_VALUE_BOOL(OPTION_ADD_INFO) = true;
+                        OPTS_OPTION_BOOL(OPTION_ADD_INFO) = true;
                         break;
                     }
                     else {
             /* All long options with arguments */
                         if (options_long_witharg("output", &argc, &argv, &argarg)) {
-                            OPTION_VALUE_STR(OPTION_OUTPUT) = argarg;
+                            OPTS_OPTION_STR(OPTION_OUTPUT) = argarg;
                             opts_output_wasset = true;
                         } else {
                             con_out("Unknown parameter: %s\n", argv[0]);
@@ -562,10 +562,10 @@ int main(int argc, char **argv) {
     }
 
     /* the standard decides which set of operators to use */
-    if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
+    if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_GMQCC) {
         operators      = c_operators;
         operator_count = c_operator_count;
-    } else if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_FTEQCC) {
+    } else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_FTEQCC) {
         operators      = fte_operators;
         operator_count = fte_operator_count;
     } else {
@@ -593,22 +593,22 @@ int main(int argc, char **argv) {
         }
     }
 
-    if (OPTION_VALUE_BOOL(OPTION_DUMP)) {
+    if (OPTS_OPTION_BOOL(OPTION_DUMP)) {
         for (itr = 0; itr < COUNT_FLAGS; ++itr)
             con_out("Flag %s = %i\n",    opts_flag_list[itr].name, OPTS_FLAG(itr));
         for (itr = 0; itr < COUNT_WARNINGS; ++itr)
             con_out("Warning %s = %i\n", opts_warn_list[itr].name, OPTS_WARN(itr));
 
-        con_out("output             = %s\n", OPTION_VALUE_STR(OPTION_OUTPUT));
-        con_out("optimization level = %u\n", OPTION_VALUE_U32(OPTION_O));
-        con_out("standard           = %u\n", OPTION_VALUE_U32(OPTION_STANDARD));
+        con_out("output             = %s\n", OPTS_OPTION_STR(OPTION_OUTPUT));
+        con_out("optimization level = %u\n", OPTS_OPTION_U32(OPTION_O));
+        con_out("standard           = %u\n", OPTS_OPTION_U32(OPTION_STANDARD));
     }
 
-    if (OPTION_VALUE_BOOL(OPTION_PP_ONLY)) {
+    if (OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
         if (opts_output_wasset) {
-            outfile = file_open(OPTION_VALUE_STR(OPTION_OUTPUT), "wb");
+            outfile = file_open(OPTS_OPTION_STR(OPTION_OUTPUT), "wb");
             if (!outfile) {
-                con_err("failed to open `%s` for writing\n", OPTION_VALUE_STR(OPTION_OUTPUT));
+                con_err("failed to open `%s` for writing\n", OPTS_OPTION_STR(OPTION_OUTPUT));
                 retval = 1;
                 goto cleanup;
             }
@@ -618,7 +618,7 @@ int main(int argc, char **argv) {
         }
     }
 
-    if (!OPTION_VALUE_BOOL(OPTION_PP_ONLY)) {
+    if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
         if (!parser_init()) {
             con_err("failed to initialize parser\n");
             retval = 1;
@@ -626,7 +626,7 @@ int main(int argc, char **argv) {
         }
     }
 
-    if (OPTION_VALUE_BOOL(OPTION_PP_ONLY) || OPTS_FLAG(FTEPP)) {
+    if (OPTS_OPTION_BOOL(OPTION_PP_ONLY) || OPTS_FLAG(FTEPP)) {
         if (!ftepp_init()) {
             con_err("failed to initialize parser\n");
             retval = 1;
@@ -640,7 +640,7 @@ int main(int argc, char **argv) {
     util_debug("COM", "starting ...\n");
 
     /* add macros */
-    if (OPTION_VALUE_BOOL(OPTION_PP_ONLY) || OPTS_FLAG(FTEPP)) {
+    if (OPTS_OPTION_BOOL(OPTION_PP_ONLY) || OPTS_FLAG(FTEPP)) {
         for (itr = 0; itr < vec_size(ppems); itr++) {
             ftepp_add_macro(ppems[itr].name, ppems[itr].value);
             mem_d(ppems[itr].name);
@@ -673,7 +673,7 @@ int main(int argc, char **argv) {
         }
 
         if (!opts_output_wasset) {
-            OPTION_VALUE_STR(OPTION_OUTPUT) = util_strdup(line);
+            OPTS_OPTION_STR(OPTION_OUTPUT) = util_strdup(line);
             opts_output_free = true;
         }
 
@@ -695,15 +695,15 @@ srcdone:
         goto cleanup;
 
     if (vec_size(items)) {
-        if (!OPTION_VALUE_BOOL(OPTION_QUIET) &&
-            !OPTION_VALUE_BOOL(OPTION_PP_ONLY))
+        if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
+            !OPTS_OPTION_BOOL(OPTION_PP_ONLY))
         {
             con_out("Mode: %s\n", (progs_src ? "progs.src" : "manual"));
             con_out("There are %lu items to compile:\n", (unsigned long)vec_size(items));
         }
         for (itr = 0; itr < vec_size(items); ++itr) {
-            if (!OPTION_VALUE_BOOL(OPTION_QUIET) &&
-                !OPTION_VALUE_BOOL(OPTION_PP_ONLY))
+            if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
+                !OPTS_OPTION_BOOL(OPTION_PP_ONLY))
             {
                 con_out("  item: %s (%s)\n",
                        items[itr].filename,
@@ -713,7 +713,7 @@ srcdone:
                          ("unknown"))))));
             }
 
-            if (OPTION_VALUE_BOOL(OPTION_PP_ONLY)) {
+            if (OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
                 const char *out;
                 if (!ftepp_preprocess_file(items[itr].filename)) {
                     retval = 1;
@@ -755,8 +755,8 @@ srcdone:
         }
 
         ftepp_finish();
-        if (!OPTION_VALUE_BOOL(OPTION_PP_ONLY)) {
-            if (!parser_finish(OPTION_VALUE_STR(OPTION_OUTPUT))) {
+        if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
+            if (!parser_finish(OPTS_OPTION_STR(OPTION_OUTPUT))) {
                 retval = 1;
                 goto cleanup;
             }
@@ -764,8 +764,8 @@ srcdone:
     }
 
     /* stuff */
-    if (!OPTION_VALUE_BOOL(OPTION_QUIET) &&
-        !OPTION_VALUE_BOOL(OPTION_PP_ONLY))
+    if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
+        !OPTS_OPTION_BOOL(OPTION_PP_ONLY))
     {
         for (itr = 0; itr < COUNT_OPTIMIZATIONS; ++itr) {
             if (opts_optimizationcount[itr]) {
@@ -781,10 +781,10 @@ cleanup:
     vec_free(items);
     vec_free(ppems);
 
-    if (!OPTION_VALUE_BOOL(OPTION_PP_ONLY))
+    if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY))
         parser_cleanup();
     if (opts_output_free)
-        mem_d(OPTION_VALUE_STR(OPTION_OUTPUT));
+        mem_d(OPTS_OPTION_STR(OPTION_OUTPUT));
     if (operators_free)
         mem_d((void*)operators);
 
diff --git a/opts.c b/opts.c
index 5ea4f6e85ff2654cdfab6834d69bfcd4eff390e8..c0be2dd113215b3f7f5060a1d5c287885bad6a1f 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -27,7 +27,7 @@ opts_cmd_t   opts; /* command lien options */
 
 static void opts_setdefault() {
     memset(&opts, 0, sizeof(opts_cmd_t));
-    OPTION_VALUE_BOOL(OPTION_CORRECTION) = true;
+    OPTS_OPTION_BOOL(OPTION_CORRECTION) = true;
 
     /* warnings */
     opts_set(opts.warn,  WARN_UNUSED_VARIABLE,           true);
@@ -92,9 +92,9 @@ void opts_restore_non_Werror_all() {
 void opts_init(const char *output, int standard, size_t arraysize) {
     opts_setdefault();
 
-    OPTION_VALUE_STR(OPTION_OUTPUT)         = (char*)output;
-    OPTION_VALUE_U32(OPTION_STANDARD)       = standard;
-    OPTION_VALUE_U32(OPTION_MAX_ARRAY_SIZE) = arraysize;
+    OPTS_OPTION_STR(OPTION_OUTPUT)         = (char*)output;
+    OPTS_OPTION_U32(OPTION_STANDARD)       = standard;
+    OPTS_OPTION_U32(OPTION_MAX_ARRAY_SIZE) = arraysize;
 }
 
 static bool opts_setflag_all(const char *name, bool on, uint32_t *flags, const opts_flag_def *list, size_t listsize) {
index f407690d555e161cc5955bbebdbb093f3fad88e3..a54094a841f32beb80f736f756f7b00fee1226f8 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -630,7 +630,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
             {
 #if 0
                 /* This is not broken in fteqcc anymore */
-                if (OPTION_VALUE_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
+                if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
                     /* this error doesn't need to make us bail out */
                     (void)!parsewarning(parser, WARN_EXTENSIONS,
                                         "accessing array-field members of an entity without parenthesis\n"
@@ -1784,7 +1784,7 @@ static bool parse_sya_operand(parser_t *parser, shunt *sy, bool with_labels)
                  * We should also consider adding correction tables for
                  * other things as well.
                  */
-                if (OPTION_VALUE_BOOL(OPTION_CORRECTION)) {
+                if (OPTS_OPTION_BOOL(OPTION_CORRECTION)) {
                     correction_t corr;
                     correct_init(&corr);
 
@@ -2635,7 +2635,7 @@ static bool parse_for_go(parser_t *parser, ast_block *block, ast_expression **ou
 
     if (typevar || parser->tok == TOKEN_TYPENAME) {
 #if 0
-        if (OPTION_VALUE_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
+        if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
             if (parsewarning(parser, WARN_EXTENSIONS,
                              "current standard does not allow variable declarations in for-loop initializers"))
                 goto onerr;
@@ -3440,7 +3440,7 @@ static bool parse_statement(parser_t *parser, ast_block *block, ast_expression *
             parseerror(parser, "cannot declare a variable from here");
             return false;
         }
-        if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC) {
+        if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
             if (parsewarning(parser, WARN_EXTENSIONS, "missing 'local' keyword when declaring a local variable"))
                 return false;
         }
@@ -3507,7 +3507,7 @@ static bool parse_statement(parser_t *parser, ast_block *block, ast_expression *
         }
         else if (!strcmp(parser_tokval(parser), "for"))
         {
-            if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC) {
+            if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
                 if (parsewarning(parser, WARN_EXTENSIONS, "for loops are not recognized in the original Quake C standard, to enable try an alternate standard --std=?"))
                     return false;
             }
@@ -4109,7 +4109,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
 
     if (parser->tok == ';')
         return parser_next(parser);
-    else if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC)
+    else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC)
         parseerror(parser, "missing semicolon after function body (mandatory with -std=qcc)");
     return retval;
 
@@ -4625,7 +4625,7 @@ static ast_value *parse_parameter_list(parser_t *parser, ast_value *var)
         vec_free(params);
 
     /* sanity check */
-    if (vec_size(params) > 8 && OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC)
+    if (vec_size(params) > 8 && OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC)
         (void)!parsewarning(parser, WARN_EXTENSIONS, "more than 8 parameters are not supported by this standard");
 
     /* parse-out */
@@ -4839,7 +4839,7 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va
     }
 
     /* now there may be function parens again */
-    if (parser->tok == '(' && OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC)
+    if (parser->tok == '(' && OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC)
         parseerror(parser, "C-style function syntax is not allowed in -std=qcc");
     if (parser->tok == '(' && wasarray)
         parseerror(parser, "arrays as part of a return type is not supported");
@@ -4978,7 +4978,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
 
         /* Part 0: finish the type */
         if (parser->tok == '(') {
-            if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC)
+            if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC)
                 parseerror(parser, "C-style function syntax is not allowed in -std=qcc");
             var = parse_parameter_list(parser, var);
             if (!var) {
@@ -5001,7 +5001,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
         }
         /* for functions returning functions */
         while (parser->tok == '(') {
-            if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC)
+            if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC)
                 parseerror(parser, "C-style function syntax is not allowed in -std=qcc");
             var = parse_parameter_list(parser, var);
             if (!var) {
@@ -5071,7 +5071,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
                     goto cleanup;
                     */
                 }
-                if ((OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC || OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_FTEQCC) &&
+                if ((OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC || OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_FTEQCC) &&
                     (old = parser_find_global(parser, var->name)))
                 {
                     parseerror(parser, "cannot declare a field and a global of the same name with -std=qcc");
@@ -5143,7 +5143,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
                         ast_delete(var);
                         var = proto;
                     }
-                    if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC &&
+                    if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC &&
                         (old = parser_find_field(parser, var->name)))
                     {
                         parseerror(parser, "cannot declare a field and a global of the same name with -std=qcc");
@@ -5174,7 +5174,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
                     retval = false;
                     goto cleanup;
                 }
-                if (OPTION_VALUE_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
+                if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
                     ast_delete(var);
                     var = NULL;
                     goto skipvar;
@@ -5354,7 +5354,7 @@ skipvar:
             break;
         }
 
-        if (localblock && OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC) {
+        if (localblock && OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
             if (parsewarning(parser, WARN_LOCAL_CONSTANTS,
                              "initializing expression turns variable `%s` into a constant in this standard",
                              var->name) )
@@ -5374,7 +5374,7 @@ skipvar:
                 break;
             }
         }
-        else if (OPTION_VALUE_U32(OPTION_STANDARD) == COMPILER_QCC) {
+        else if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_QCC) {
             parseerror(parser, "expected '=' before function body in this standard");
         }
 
@@ -5735,7 +5735,7 @@ bool parser_init()
     parser->const_vec[1] = ast_value_new(empty_ctx, "<vector.y>", TYPE_NOEXPR);
     parser->const_vec[2] = ast_value_new(empty_ctx, "<vector.z>", TYPE_NOEXPR);
 
-    if (OPTION_VALUE_BOOL(OPTION_ADD_INFO)) {
+    if (OPTS_OPTION_BOOL(OPTION_ADD_INFO)) {
         parser->reserved_version = ast_value_new(empty_ctx, "reserved:version", TYPE_STRING);
         parser->reserved_version->cvq = CV_CONST;
         parser->reserved_version->hasvalue = true;
@@ -6024,7 +6024,7 @@ bool parser_finish(const char *output)
             return false;
         }
     }
-    if (OPTION_VALUE_BOOL(OPTION_DUMP))
+    if (OPTS_OPTION_BOOL(OPTION_DUMP))
         ir_builder_dump(ir, con_out);
     for (i = 0; i < vec_size(parser->functions); ++i) {
         if (!ir_function_finalize(parser->functions[i]->ir_func)) {
@@ -6041,7 +6041,7 @@ bool parser_finish(const char *output)
     }
 
     if (retval) {
-        if (OPTION_VALUE_BOOL(OPTION_DUMPFIN))
+        if (OPTS_OPTION_BOOL(OPTION_DUMPFIN))
             ir_builder_dump(ir, con_out);
 
         generate_checksum(parser);
diff --git a/test.c b/test.c
index c33b4ac38d8a80f0de156b9ff1d7620592154583..a7b02c7e53ee7aaa95abba520327dd610ee98651 100644 (file)
--- a/test.c
+++ b/test.c
@@ -1242,11 +1242,11 @@ int main(int argc, char **argv) {
             con_change(redirout, redirerr);
 
             if (!strcmp(argv[0]+1, "debug")) {
-                OPTION_VALUE_BOOL(OPTION_DEBUG) = true;
+                OPTS_OPTION_BOOL(OPTION_DEBUG) = true;
                 continue;
             }
             if (!strcmp(argv[0]+1, "memchk")) {
-                OPTION_VALUE_BOOL(OPTION_MEMCHK) = true;
+                OPTS_OPTION_BOOL(OPTION_MEMCHK) = true;
                 continue;
             }
             if (!strcmp(argv[0]+1, "nocolor")) {
diff --git a/util.c b/util.c
index 0ac4df3993de087c3568f664163d963328332898..1810adfce16c94d710e063db835d5d15e21cd911 100644 (file)
--- a/util.c
+++ b/util.c
@@ -132,7 +132,7 @@ void *util_memory_r(void *ptrn, size_t byte, unsigned int line, const char *file
 void util_meminfo() {
     struct memblock_t *info;
 
-    if (!OPTION_VALUE_BOOL(OPTION_MEMCHK))
+    if (!OPTS_OPTION_BOOL(OPTION_MEMCHK))
         return;
 
     for (info = mem_start; info; info = info->next) {
@@ -175,10 +175,10 @@ char *util_strdup(const char *s) {
 
 void util_debug(const char *area, const char *ms, ...) {
     va_list  va;
-    if (!OPTION_VALUE_BOOL(OPTION_DEBUG))
+    if (!OPTS_OPTION_BOOL(OPTION_DEBUG))
         return;
 
-    if (!strcmp(area, "MEM") && !OPTION_VALUE_BOOL(OPTION_MEMCHK))
+    if (!strcmp(area, "MEM") && !OPTS_OPTION_BOOL(OPTION_MEMCHK))
         return;
 
     va_start(va, ms);