mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Allow OPT to toggle -h
This commit is contained in:
@@ -14,6 +14,7 @@ struct OptStackEntry {
|
||||
char binary[2];
|
||||
char gbgfx[4];
|
||||
int32_t fillByte;
|
||||
bool haltnop;
|
||||
bool optimizeLoads;
|
||||
bool warningsAreErrors;
|
||||
enum WarningState warningStates[NB_WARNINGS];
|
||||
@@ -37,6 +38,11 @@ void opt_P(uint8_t fill)
|
||||
fillByte = fill;
|
||||
}
|
||||
|
||||
void opt_h(bool halt)
|
||||
{
|
||||
haltnop = halt;
|
||||
}
|
||||
|
||||
void opt_L(bool optimize)
|
||||
{
|
||||
optimizeLoads = optimize;
|
||||
@@ -79,6 +85,13 @@ void opt_Parse(char *s)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
if (s[1] == '\0')
|
||||
opt_h(false);
|
||||
else
|
||||
error("Option 'h' does not take an argument\n");
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if (s[1] == '\0')
|
||||
opt_L(false);
|
||||
@@ -95,6 +108,13 @@ void opt_Parse(char *s)
|
||||
|
||||
case '!': // negates flag options that do not take an argument
|
||||
switch (s[1]) {
|
||||
case 'h':
|
||||
if (s[2] == '\0')
|
||||
opt_h(true);
|
||||
else
|
||||
error("Option '!h' does not take an argument\n");
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if (s[2] == '\0')
|
||||
opt_L(true);
|
||||
@@ -132,6 +152,8 @@ void opt_Push(void)
|
||||
|
||||
entry->fillByte = fillByte; // Pulled from section.h
|
||||
|
||||
entry->haltnop = haltnop; // Pulled from main.h
|
||||
|
||||
entry->optimizeLoads = optimizeLoads; // Pulled from main.h
|
||||
|
||||
// Both of these pulled from warning.h
|
||||
@@ -154,6 +176,7 @@ void opt_Pop(void)
|
||||
opt_B(entry->binary);
|
||||
opt_G(entry->gbgfx);
|
||||
opt_P(entry->fillByte);
|
||||
opt_h(entry->haltnop);
|
||||
opt_L(entry->optimizeLoads);
|
||||
|
||||
// opt_W does not apply a whole warning state; it processes one flag string
|
||||
|
||||
@@ -1957,15 +1957,18 @@ POPO
|
||||
.Ed
|
||||
.Pp
|
||||
The options that OPT can modify are currently:
|
||||
.Cm b , g , p , L ,
|
||||
.Cm b , g , p , h , L ,
|
||||
and
|
||||
.Cm W .
|
||||
The Boolean flag option
|
||||
The Boolean flag options
|
||||
.Cm h
|
||||
and
|
||||
.Cm L
|
||||
can be specified as
|
||||
.Ql OPT L
|
||||
or
|
||||
.Ql OPT !L .
|
||||
can be negated as
|
||||
.Ql OPT !h
|
||||
and
|
||||
.Ql OPT !L
|
||||
to act like omitting them from the command-line.
|
||||
.Pp
|
||||
.Ic POPO
|
||||
and
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
SECTION "test", ROM0
|
||||
|
||||
opt !L ; already the default, but tests parsing "!L"
|
||||
opt !h, !L ; already the default, but tests parsing "!"
|
||||
|
||||
pusho
|
||||
opt p42, L, Wno-div
|
||||
opt p42, h, L, Wno-div
|
||||
ds 1
|
||||
ld [$ff88], a
|
||||
halt
|
||||
println $8000_0000 / -1
|
||||
popo
|
||||
|
||||
ds 1
|
||||
ld [$ff88], a
|
||||
halt
|
||||
println $8000_0000 / -1
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
warning: opt.asm(14): [-Wdiv]
|
||||
warning: opt.asm(16): [-Wdiv]
|
||||
Division of -2147483648 by -1 yields -2147483648
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user