diff options
| author | 2024-02-13 13:50:22 -0400 | |
|---|---|---|
| committer | 2024-02-13 13:50:22 -0400 | |
| commit | bbe4bc5a08a042b47a3474e8e9caf20e216634a8 (patch) | |
| tree | 3a2d19765f560481d74b6c2abb3696db573a70e3 /src/gbp_gen.zig | |
| parent | Merge table (diff) | |
| download | zg-bbe4bc5a08a042b47a3474e8e9caf20e216634a8.tar.gz zg-bbe4bc5a08a042b47a3474e8e9caf20e216634a8.tar.xz zg-bbe4bc5a08a042b47a3474e8e9caf20e216634a8.zip | |
Passing ziglyph tests
Diffstat (limited to 'src/gbp_gen.zig')
| -rw-r--r-- | src/gbp_gen.zig | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/gbp_gen.zig b/src/gbp_gen.zig index afc54fc..7e27f35 100644 --- a/src/gbp_gen.zig +++ b/src/gbp_gen.zig | |||
| @@ -62,8 +62,6 @@ pub fn main() !void { | |||
| 62 | var blocks_map = BlockMap.init(allocator); | 62 | var blocks_map = BlockMap.init(allocator); |
| 63 | defer blocks_map.deinit(); | 63 | defer blocks_map.deinit(); |
| 64 | 64 | ||
| 65 | const no_prop = std.math.maxInt(u16); | ||
| 66 | |||
| 67 | var stage1 = std.ArrayList(u16).init(allocator); | 65 | var stage1 = std.ArrayList(u16).init(allocator); |
| 68 | defer stage1.deinit(); | 66 | defer stage1.deinit(); |
| 69 | 67 | ||
| @@ -101,12 +99,7 @@ pub fn main() !void { | |||
| 101 | try stage2.appendSlice(block[0..block_len]); | 99 | try stage2.appendSlice(block[0..block_len]); |
| 102 | } | 100 | } |
| 103 | 101 | ||
| 104 | if (prop == .none) { | 102 | try stage1.append(gop.value_ptr.*); |
| 105 | try stage1.append(no_prop); | ||
| 106 | } else { | ||
| 107 | try stage1.append(gop.value_ptr.*); | ||
| 108 | } | ||
| 109 | |||
| 110 | block_len = 0; | 103 | block_len = 0; |
| 111 | } | 104 | } |
| 112 | 105 | ||
| @@ -120,8 +113,6 @@ pub fn main() !void { | |||
| 120 | const writer = out_buf.writer(); | 113 | const writer = out_buf.writer(); |
| 121 | 114 | ||
| 122 | const prop_code = | 115 | const prop_code = |
| 123 | \\const std = @import("std"); | ||
| 124 | \\ | ||
| 125 | \\const Prop = enum { | 116 | \\const Prop = enum { |
| 126 | \\ none, | 117 | \\ none, |
| 127 | \\ | 118 | \\ |
| @@ -161,11 +152,8 @@ pub fn main() !void { | |||
| 161 | try writer.writeAll("};\n"); | 152 | try writer.writeAll("};\n"); |
| 162 | 153 | ||
| 163 | const code = | 154 | const code = |
| 164 | \\const no_prop = std.math.maxInt(u16); | ||
| 165 | \\ | ||
| 166 | \\inline fn getProp(cp: u21) Prop { | 155 | \\inline fn getProp(cp: u21) Prop { |
| 167 | \\ const stage_1_index = cp >> 8; | 156 | \\ const stage_1_index = cp >> 8; |
| 168 | \\ if (stage_1[stage_1_index] == no_prop) return .none; | ||
| 169 | \\ const stage_2_index = stage_1[stage_1_index] + (cp & 0xff); | 157 | \\ const stage_2_index = stage_1[stage_1_index] + (cp & 0xff); |
| 170 | \\ const stage_3_index = stage_2[stage_2_index]; | 158 | \\ const stage_3_index = stage_2[stage_2_index]; |
| 171 | \\ return stage_3[stage_3_index]; | 159 | \\ return stage_3[stage_3_index]; |