selfhost: cgen for enum (member fold + as pass-through)
w6c_ww now compiles enum end-to-end and emits byte-identical
asm to the C w6c on the new 994 corpus case (`type mode = enum u8
{ R, W, RW = R | W }; main() { return (mode.RW): i32 }`). Mechanism
mirrors the C side:
- collectenums walks every `type X = enum {...}` at file scope and
pre-resolves each member's u64 value (auto-increment from prior,
sibling-ref folding for `RDWR = READ | WRITE`).
- cgdot recognises `EnumName.MEMBER` before the local lookup and
emits MOVQ $value, AX directly.
- cgtypeassert short-circuits when either side is enum: cgexpr on
the LHS lands the value in AX with the right integer width; no
tag/unwrap.
main.combined.ww (wwdump/ + w6c/) regenerated by ww build.
This commit is contained in:
@@ -279,6 +279,7 @@ export fn cgfile(c: *cgen, file: *node) void = {
|
||||
c.strlitseq = 0;
|
||||
collectaliases(c, file);
|
||||
collectstructs(c, file);
|
||||
collectenums(c, file);
|
||||
collectdefs(c, file);
|
||||
collectfnrets(c, file);
|
||||
fficollect(c, file);
|
||||
|
||||
Reference in New Issue
Block a user