X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=main.c;h=4c8062d7dcdb1b125101c77348c26952c9ac592c;hp=195574ea1538c737b65aeb0f7bb4207a5d3066c8;hb=61fa54318c3aa1ce0c2099f9793d830e5896c016;hpb=ea09553b322d3b788c07043291ae532afa9cba99 diff --git a/main.c b/main.c index 195574e..4c8062d 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2012 * Dale Weiler + * Wolfgang Bumiller * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -21,19 +22,602 @@ * SOFTWARE. */ #include "gmqcc.h" +#include "lexer.h" + +uint32_t opts_flags[1 + (COUNT_FLAGS / 32)]; +uint32_t opts_warn [1 + (COUNT_WARNINGS / 32)]; + +uint32_t opts_O = 1; +const char *opts_output = "progs.dat"; +int opts_standard = COMPILER_GMQCC; +bool opts_debug = false; +bool opts_memchk = false; +bool opts_dump = false; +bool opts_werror = false; +bool opts_forcecrc = false; +bool opts_pp_only = false; +size_t opts_max_array_size = 1024; + +uint16_t opts_forced_crc; + +static bool opts_output_wasset = false; + +/* set by the standard */ +const oper_info *operators = NULL; +size_t operator_count = 0; + +typedef struct { char *filename; int type; } argitem; +static argitem *items = NULL; + +#define TYPE_QC 0 +#define TYPE_ASM 1 +#define TYPE_SRC 2 + +static const char *app_name; + +static int usage() { + con_out("usage: %s [options] [files...]", app_name); + con_out("options:\n" + " -h, --help show this help message\n" + " -debug turns on compiler debug messages\n" + " -memchk turns on compiler memory leak check\n"); + con_out(" -o, --output=file output file, defaults to progs.dat\n" + " -a filename add an asm file to be assembled\n" + " -s filename add a progs.src file to be used\n"); + con_out(" -E stop after preprocessing\n"); + con_out(" -f enable a flag\n" + " -fno- disable a flag\n" + " -std standard select one of the following standards\n" + " -std=qcc original QuakeC\n" + " -std=fteqcc fteqcc QuakeC\n" + " -std=gmqcc this compiler (default)\n"); + con_out(" -W enable a warning\n" + " -Wno- disable a warning\n" + " -Wall enable all warnings\n" + " -Werror treat warnings as errors\n"); + con_out(" -force-crc=num force a specific checksum into the header\n"); + con_out("\n"); + con_out("flags:\n" + " -fadjust-vector-fields\n" + " when assigning a vector field, its _y and _z fields also get assigned\n" + ); + return -1; +} + +static bool options_setflag_all(const char *name, bool on, uint32_t *flags, const opts_flag_def *list, size_t listsize) { + size_t i; + + for (i = 0; i < listsize; ++i) { + if (!strcmp(name, list[i].name)) { + longbit lb = list[i].bit; +#if 0 + if (on) + flags[lb.idx] |= (1<<(lb.bit)); + else + flags[lb.idx] &= ~(1<<(lb.bit)); +#else + if (on) + flags[0] |= (1<