diff options
| author | 2026-02-04 18:36:18 -0500 | |
|---|---|---|
| committer | 2026-02-04 18:36:18 -0500 | |
| commit | e476250ea9326b2550847b301c265115ff375a31 (patch) | |
| tree | cf627ced47cecce80020b7a1f30aa51852c0c59b /codegen/core_props.zig | |
| parent | Normalization and case folding (diff) | |
| download | zg-e476250ea9326b2550847b301c265115ff375a31.tar.gz zg-e476250ea9326b2550847b301c265115ff375a31.tar.xz zg-e476250ea9326b2550847b301c265115ff375a31.zip | |
Rest of the 'easy' stuff
This gets us up to feature parity with Jacob's work. I want to
eliminate that last allocation using the comptime hash map, and then
see about eliminating allocations from case comparisons as well.
That should just about do it.
Diffstat (limited to 'codegen/core_props.zig')
| -rw-r--r-- | codegen/core_props.zig | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/codegen/core_props.zig b/codegen/core_props.zig index 6ffdf91..99a55e2 100644 --- a/codegen/core_props.zig +++ b/codegen/core_props.zig | |||
| @@ -120,17 +120,29 @@ pub fn main() anyerror!void { | |||
| 120 | _ = args_iter.skip(); | 120 | _ = args_iter.skip(); |
| 121 | const output_path = args_iter.next() orelse @panic("No output file arg!"); | 121 | const output_path = args_iter.next() orelse @panic("No output file arg!"); |
| 122 | 122 | ||
| 123 | var out_buf: [4096]u8 = undefined; | 123 | var write_buf: [4096]u8 = undefined; |
| 124 | var out_file = try std.fs.cwd().createFile(output_path, .{}); | 124 | var out_file = try std.fs.cwd().createFile(output_path, .{}); |
| 125 | defer out_file.close(); | 125 | defer out_file.close(); |
| 126 | var writer = out_file.writer(&out_buf); | 126 | var writer = out_file.writer(&write_buf); |
| 127 | 127 | ||
| 128 | const endian = builtin.cpu.arch.endian(); | 128 | try writer.interface.print( |
| 129 | try writer.interface.writeInt(u16, @intCast(stage1.items.len), endian); | 129 | \\//! This file is auto-generated. Do not edit. |
| 130 | for (stage1.items) |i| try writer.interface.writeInt(u16, i, endian); | 130 | \\ |
| 131 | 131 | \\pub const s1: [{}]u16 = .{{ | |
| 132 | try writer.interface.writeInt(u16, @intCast(stage2.items.len), endian); | 132 | , .{stage1.items.len}); |
| 133 | try writer.interface.writeAll(stage2.items); | 133 | for (stage1.items) |entry| try writer.interface.print("{}, ", .{entry}); |
| 134 | |||
| 135 | try writer.interface.print( | ||
| 136 | \\ | ||
| 137 | \\}}; | ||
| 138 | \\ | ||
| 139 | \\pub const s2: [{}]u8 = .{{ | ||
| 140 | , .{stage2.items.len}); | ||
| 141 | for (stage2.items) |entry| try writer.interface.print("{}, ", .{entry}); | ||
| 142 | |||
| 143 | try writer.interface.writeAll( | ||
| 144 | \\}; | ||
| 145 | ); | ||
| 134 | 146 | ||
| 135 | try writer.interface.flush(); | 147 | try writer.interface.flush(); |
| 136 | } | 148 | } |