Add an extended mode to qfcc.

Extended mode allows extra keywords (switch, for, etc) that are compatible
with v6 progs.
This commit is contained in:
Bill Currie 2012-07-14 16:32:48 +09:00
parent 4055d9a435
commit 1364bff91b
4 changed files with 36 additions and 23 deletions

View file

@ -68,6 +68,9 @@ Define a symbol for the preprocessor, if it is in use.
Only preprocess.
No compilation or linking is done.
.TP
.B \-\-extended
Allow extended keywords in traditional mode.
.TP
.B \-F, \-\-files
Generate \fIfiles.dat\fP.
This list is created by checking the parameters to the precache_* functions.

View file

@ -89,7 +89,7 @@ typedef struct {
qboolean files_dat; // generate files.dat
qboolean progdefs_h; // generate progdefs.h
qboolean qccx_escapes; // use qccx escapes instead of standard C
qboolean traditional; // behave more like qcc
int traditional; // behave more like qcc
qboolean advanced; // behold the power of Ruamoko
qboolean compile; // serparate compilation mode
qboolean partial_link; // partial linking

View file

@ -62,6 +62,7 @@ enum {
OPT_ADVANCED,
OPT_BLOCK_DOT,
OPT_CPP,
OPT_EXTENDED,
OPT_INCLUDE,
OPT_NO_DEFAULT_PATHS,
OPT_PROGDEFS,
@ -75,6 +76,7 @@ static struct option const long_options[] = {
{"code", required_argument, 0, 'C'},
{"cpp", required_argument, 0, OPT_CPP},
{"define", required_argument, 0, 'D'},
{"extended", no_argument, 0, OPT_EXTENDED},
{"files", no_argument, 0, 'F'},
{"help", no_argument, 0, 'h'},
{"include", required_argument, 0, OPT_INCLUDE},
@ -139,6 +141,7 @@ usage (int status)
" --cpp CPPSPEC cpp execution command line\n"
" -D, --define SYMBOL[=VAL] Define symbols for the preprocessor\n"
" -E Only preprocess\n"
" --extended Allow extended keywords in traditional mode\n"
" -F, --files Generate files.dat\n"
" -g Generate debugging info\n"
" -h, --help Display this help and exit\n"
@ -351,13 +354,18 @@ DecodeArgs (int argc, char **argv)
case 'g': // debug
options.code.debug = true;
break;
case OPT_EXTENDED:
options.traditional = 1;
options.advanced = false;
options.code.progsversion = PROG_ID_VERSION;
break;
case OPT_TRADITIONAL:
options.traditional = true;
options.traditional = 2;
options.advanced = false;
options.code.progsversion = PROG_ID_VERSION;
break;
case OPT_ADVANCED:
options.traditional = false;
options.traditional = 0;
options.advanced = true;
options.code.progsversion = PROG_VERSION;
break;
@ -593,7 +601,9 @@ DecodeArgs (int argc, char **argv)
options.preprocess_only = 0;
if (!source_files && !options.advanced) {
// progs.src mode without --advanced implies --traditional
options.traditional = true;
// but --extended overrides
if (!options.traditional)
options.traditional = 2;
options.advanced = false;
if (!options.code.progsversion)
options.code.progsversion = PROG_ID_VERSION;

View file

@ -256,17 +256,17 @@ typedef struct {
const char *name;
int value;
type_t *type;
unsigned int traditional;
unsigned int version;
int traditional;
unsigned version;
int objc;
} keyword_t;
static keyword_t keywords[] = {
{"void", TYPE, &type_void, 1, PROG_ID_VERSION, 0},
{"float", TYPE, &type_float, 1, PROG_ID_VERSION, 0},
{"string", TYPE, &type_string, 1, PROG_ID_VERSION, 0},
{"vector", TYPE, &type_vector, 1, PROG_ID_VERSION, 0},
{"entity", TYPE, &type_entity, 1, PROG_ID_VERSION, 0},
{"void", TYPE, &type_void, 2, PROG_ID_VERSION, 0},
{"float", TYPE, &type_float, 2, PROG_ID_VERSION, 0},
{"string", TYPE, &type_string, 2, PROG_ID_VERSION, 0},
{"vector", TYPE, &type_vector, 2, PROG_ID_VERSION, 0},
{"entity", TYPE, &type_entity, 2, PROG_ID_VERSION, 0},
{"quaternion", TYPE, &type_quaternion, 0, PROG_VERSION, 0},
{"int", TYPE, &type_integer, 0, PROG_VERSION, 0},
{"unsigned", TYPE, &type_integer, 0, PROG_VERSION, 0},//FIXME
@ -278,18 +278,18 @@ static keyword_t keywords[] = {
{"Super", TYPE, &type_Super, 0, PROG_VERSION, 1},
{"SEL", TYPE, &type_SEL, 0, PROG_VERSION, 1},
{"IMP", TYPE, &type_IMP, 0, PROG_VERSION, 1},
{"local", LOCAL, 0, 1, PROG_ID_VERSION, 0},
{"return", RETURN, 0, 1, PROG_ID_VERSION, 0},
{"while", WHILE, 0, 1, PROG_ID_VERSION, 0},
{"do", DO, 0, 1, PROG_ID_VERSION, 0},
{"if", IF, 0, 1, PROG_ID_VERSION, 0},
{"else", ELSE, 0, 1, PROG_ID_VERSION, 0},
{"for", FOR, 0, 0, PROG_ID_VERSION, 0},
{"break", BREAK, 0, 1, PROG_ID_VERSION, 0},
{"continue", CONTINUE, 0, 0, PROG_ID_VERSION, 0},
{"switch", SWITCH, 0, 0, PROG_ID_VERSION, 0},
{"case", CASE, 0, 0, PROG_ID_VERSION, 0},
{"default", DEFAULT, 0, 0, PROG_ID_VERSION, 0},
{"local", LOCAL, 0, 2, PROG_ID_VERSION, 0},
{"return", RETURN, 0, 2, PROG_ID_VERSION, 0},
{"while", WHILE, 0, 2, PROG_ID_VERSION, 0},
{"do", DO, 0, 2, PROG_ID_VERSION, 0},
{"if", IF, 0, 2, PROG_ID_VERSION, 0},
{"else", ELSE, 0, 2, PROG_ID_VERSION, 0},
{"for", FOR, 0, 1, PROG_ID_VERSION, 0},
{"break", BREAK, 0, 2, PROG_ID_VERSION, 0},
{"continue", CONTINUE, 0, 1, PROG_ID_VERSION, 0},
{"switch", SWITCH, 0, 1, PROG_ID_VERSION, 0},
{"case", CASE, 0, 1, PROG_ID_VERSION, 0},
{"default", DEFAULT, 0, 1, PROG_ID_VERSION, 0},
{"nil", NIL, 0, 0, PROG_ID_VERSION, 0},
{"struct", STRUCT, 0, 0, PROG_VERSION, 0},
{"union", STRUCT, 0, 0, PROG_VERSION, 0},