refactor: precompute compiler enum mappings

This commit is contained in:
2026-10-30 10:10:43 +01:00
parent d7e637dc3b
commit 30a98db379
13 changed files with 452 additions and 279 deletions
+8 -4
View File
@@ -1,6 +1,7 @@
import "@std/mem"
import "@std/strmap"
import "@std/arraylist"
import "@std/enummap"
import "@source/diagnostics"
import "@source/strpool"
@@ -474,12 +475,15 @@ is_digit proc(char u8) bool {
}
}
@hide:file
diagnostic_codes :: $enummap.init(ErrorCode, diagnostics.Code, {
float_must_end_with_digit = .float_must_end_with_digit,
unterminated_string = .unterminated_string,
})
@hide:file
diagnostic_code proc(code ErrorCode) diagnostics.Code {
return match code {
.float_must_end_with_digit: .float_must_end_with_digit
.unterminated_string: .unterminated_string
}
return enummap.get(&diagnostic_codes, code)?
}
@hide:file