Implement enums for Cmm
Using ANSI C enums is documented as a preferred way of defining constants: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Conventions#Syntacticdetails
Basically instead of writing:
#define INVALID_OBJECT 0
#define CONSTR 1
you would write:
typedef enum {
INVALID_OBJECT = 0,
CONSTR = 1
} ClosureType;
What you get is easier debugging in gdb, perhaps even better type checking.
Unfortunately some files (most vexingly rts/storage/ClosureTypes.h) are included in both C and Cmm and Cmm doesn't support this syntax. As far as I can tell all constants in Cmm are defined with preprocessor #defines.
Implementing enums/constants may seem like an overkill, but I haven't found a good workaround for this.
Trac metadata
| Trac field | Value |
|---|---|
| Version | |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | low |
| Resolution | Unresolved |
| Component | Compiler (CodeGen) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |