summaryrefslogtreecommitdiff
path: root/codegen
diff options
context:
space:
mode:
authorGravatar Jose Colon Rodriguez2024-02-14 21:44:23 -0400
committerGravatar Jose Colon Rodriguez2024-02-14 21:44:23 -0400
commit99a12fda4b1c3343231516b4b041e81367206d49 (patch)
treea61aedef6eaaebf3ec9c17e31d052ed63e393a89 /codegen
parentgbp and indic direct array access (diff)
downloadzg-99a12fda4b1c3343231516b4b041e81367206d49.tar.gz
zg-99a12fda4b1c3343231516b4b041e81367206d49.tar.xz
zg-99a12fda4b1c3343231516b4b041e81367206d49.zip
emoji direct array access
Diffstat (limited to 'codegen')
-rw-r--r--codegen/emoji.zig15
1 files changed, 2 insertions, 13 deletions
diff --git a/codegen/emoji.zig b/codegen/emoji.zig
index acad0ca..6dbb74f 100644
--- a/codegen/emoji.zig
+++ b/codegen/emoji.zig
@@ -66,28 +66,17 @@ pub fn main() !void {
66 var out_buf = std.io.bufferedWriter(out_file.writer()); 66 var out_buf = std.io.bufferedWriter(out_file.writer());
67 const writer = out_buf.writer(); 67 const writer = out_buf.writer();
68 68
69 try writer.print("const stage_1 = [{}]u16{{", .{stage1.items.len}); 69 try writer.print("pub const stage_1 = [{}]u16{{", .{stage1.items.len});
70 for (stage1.items) |v| { 70 for (stage1.items) |v| {
71 _ = try writer.print("{},", .{v}); 71 _ = try writer.print("{},", .{v});
72 } 72 }
73 try writer.writeAll("};\n"); 73 try writer.writeAll("};\n");
74 74
75 try writer.print("const stage_2 = [{}]bool{{", .{stage2.items.len}); 75 try writer.print("pub const stage_2 = [{}]bool{{", .{stage2.items.len});
76 for (stage2.items) |v| { 76 for (stage2.items) |v| {
77 _ = try writer.print("{},", .{v}); 77 _ = try writer.print("{},", .{v});
78 } 78 }
79 try writer.writeAll("};\n"); 79 try writer.writeAll("};\n");
80 80
81 const code =
82 \\pub inline fn isExtendedPictographic(cp: u21) bool {
83 \\ const stage_1_index = cp >> 8;
84 \\ const stage_2_index = stage_1[stage_1_index] + (cp & 0xff);
85 \\ return stage_2[stage_2_index];
86 \\}
87 \\
88 ;
89
90 try writer.writeAll(code);
91
92 try out_buf.flush(); 81 try out_buf.flush();
93} 82}