Use enums to make debugging easier

When we're dealing with a field which is guaranteed to have an enum type,
then declare it as such so it shows up in debuggers.
This commit is contained in:
H. Peter Anvin 2007-09-11 22:14:18 +00:00
parent 2ba7ed7122
commit b79f0d0cc3
3 changed files with 11 additions and 9 deletions

View File

@ -186,7 +186,7 @@ if ( !defined($output) || $output eq 'n' ) {
print N "\n};\n\n";
print N "/* and the corresponding opcodes */\n";
print N "static const int ico[] = {";
print N "static const enum opcode ico[] = {";
$first = 1;
foreach $i (@opcodes_cc) {
print N "," if ( !$first );

14
nasm.h
View File

@ -543,7 +543,7 @@ enum { /* condition code names */
* prefixes, we must ensure the enumerations for prefixes and
* register names do not overlap.
*/
enum { /* instruction prefixes */
enum prefixes { /* instruction prefixes */
PREFIX_ENUM_START = REG_ENUM_LIMIT,
P_A16 = PREFIX_ENUM_START, P_A32, P_LOCK, P_O16, P_O32,
P_REP, P_REPE, P_REPNE, P_REPNZ, P_REPZ, P_TIMES
@ -562,7 +562,7 @@ enum { /* special EA flags */
EAF_FSGS = 32 /* fs/gs segment override present */
};
enum { /* values for `hinttype' */
enum eval_hint { /* values for `hinttype' */
EAH_NOHINT = 0, /* no hint at all - our discretion */
EAH_MAKEBASE = 1, /* try to make given reg the base */
EAH_NOTBASE = 2 /* try _not_ to make reg the base */
@ -571,8 +571,10 @@ enum { /* values for `hinttype' */
typedef struct { /* operand to an instruction */
int32_t type; /* type of operand */
int addr_size; /* 0 means default; 16; 32; 64 */
int basereg, indexreg, scale; /* registers and scale involved */
int hintbase, hinttype; /* hint as to real base register */
enum reg_enum basereg, indexreg; /* address registers */
int scale; /* index scale */
int hintbase;
enum eval_hint hinttype; /* hint as to real base register */
int32_t segment; /* immediate segment, if needed */
int64_t offset; /* any immediate number */
int32_t wrt; /* segment base it's relative to */
@ -597,7 +599,7 @@ typedef struct extop { /* extended operand */
typedef struct { /* an instruction itself */
char *label; /* the label defined, or NULL */
int prefixes[MAXPREFIX]; /* instruction prefixes, if any */
enum prefixes prefixes[MAXPREFIX]; /* instruction prefixes, if any */
int nprefix; /* number of entries in above */
int opcode; /* the opcode - not just the string */
int condition; /* the condition code, if Jcc/SETcc */
@ -931,7 +933,7 @@ struct dfmt {
* -----
*/
enum {
enum special_tokens {
S_ABS, S_BYTE, S_DWORD, S_FAR, S_LONG, S_NEAR, S_NOSPLIT, S_QWORD, S_REL,
S_SHORT, S_STRICT, S_TO, S_TWORD, S_WORD
};

View File

@ -99,7 +99,7 @@ if ( $fmt eq 'h' ) {
} elsif ( $fmt eq 'c' ) {
# Output regs.c
print "/* automatically generated from $file - do not edit */\n";
print "static const char *reg_names[] = "; $ch = '{';
print "static const char * const reg_names[] = "; $ch = '{';
# This one has no dummy entry for 0
foreach $reg ( sort(keys(%regs)) ) {
print "$ch\n \"${reg}\"";
@ -128,7 +128,7 @@ if ( $fmt eq 'h' ) {
# Output regdis.c
print "/* automatically generated from $file - do not edit */\n";
foreach $class ( sort(keys(%disclass)) ) {
printf "static const int rd_%-8s[] = {", $class;
printf "static const enum reg_enum rd_%-8s[] = {", $class;
@foo = @{$disclass{$class}};
@bar = ();
for ( $i = 0 ; $i < scalar(@foo) ; $i++ ) {