short circuit logic can now be controlled (see man page)

This commit is contained in:
Bill Currie 2003-10-22 08:27:38 +00:00
parent 945006494f
commit 72ae59f882
4 changed files with 21 additions and 0 deletions

View file

@ -148,6 +148,13 @@ diagnosing progs crashes. This option tells \fBqfcc\fP to generate this
information. It is written to a secondary file with the extension "sym" \(em
if your output file is "progs.dat", the symbol file will be "progs.sym".
.TP
.B short\-circuit
Generate short circuit code for logical operators (\fB&&\fP and \fB||\fP). For
\fBA && B\fP, if \fBA\fP is false, the expression is known to be false and the
code for \fBB\fP will not be executed. Similar for \fBA || B\fP, but if \fBA\fP
true, the expression is known to be true and the code for \fBB\fP will not be
executed. Defaults to off for traditional and on for advanced.
.TP
.B v6only
Restrict the compiler to only version 6 progs (original Quake/QuakeWorld)
features. This means that the compiled data file should be able to run on

View file

@ -37,6 +37,7 @@
typedef struct {
qboolean cow; // Turn constants into variables if written to
qboolean debug; // Generate debug info for the engine
qboolean short_circuit; // short circuit logic for && and ||
unsigned int progsversion; // Progs version to generate code for
} code_options_t;

View file

@ -1542,6 +1542,9 @@ bool_expr (int op, expr_t *label, expr_t *e1, expr_t *e2)
{
expr_t *block;
if (!options.code.short_circuit)
return binary_expr (op, e1, e2);
e1 = convert_bool (e1, 0);
e2 = convert_bool (e2, 0);

View file

@ -170,6 +170,7 @@ DecodeArgs (int argc, char **argv)
add_cpp_def ("-D__QUAKEC__=1");
options.code.progsversion = PROG_VERSION;
options.code.short_circuit = -1;
options.warnings.uninited_variable = true;
options.save_temps = false;
@ -262,6 +263,10 @@ DecodeArgs (int argc, char **argv)
options.code.debug = true;
} else if (!(strcasecmp (temp, "no-debug"))) {
options.code.debug = false;
} else if (!(strcasecmp (temp, "short-circuit"))) {
options.code.short_circuit = true;
} else if (!(strcasecmp (temp, "no-short-circuit"))) {
options.code.short_circuit = false;
} else if (!(strcasecmp (temp, "v6only"))) {
options.code.progsversion = PROG_ID_VERSION;
} else if (!(strcasecmp (temp, "no-v6only"))) {
@ -398,10 +403,15 @@ DecodeArgs (int argc, char **argv)
options.traditional = true;
options.advanced = false;
options.code.progsversion = PROG_ID_VERSION;
if (options.code.short_circuit == -1)
options.code.short_circuit = false;
}
if (!options.traditional) {
options.advanced = true;
add_cpp_def ("-D__RUAMOKO__=1");
add_cpp_def ("-D__RAUMOKO__=1");
if (options.code.short_circuit == -1)
options.code.short_circuit = true;
}
if (options.code.progsversion == PROG_ID_VERSION)
add_cpp_def ("-D__VERSION6__=1");