From cad6b78a49616fe2de728d5840fd9cd8aa44ef19 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Tue, 16 Jun 2020 15:45:16 +0300 Subject: [PATCH] Cleaned up ComptimeStringMaps --- src/analysis.zig | 23 +++++++++++------------ src/semantic_tokens.zig | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/analysis.zig b/src/analysis.zig index e66cdb9..ce5b4d5 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -667,19 +667,18 @@ fn resolveTypeOfNodeInternal( return innermostContainer(handle, handle.tree.token_locs[builtin_call.firstToken()].start); } - // TODO: https://github.com/ziglang/zig/issues/4335 const cast_map = std.ComptimeStringMap(void, .{ - .{ .@"0" = "@as" }, - .{ .@"0" = "@bitCast" }, - .{ .@"0" = "@fieldParentPtr" }, - .{ .@"0" = "@floatCast" }, - .{ .@"0" = "@floatToInt" }, - .{ .@"0" = "@intCast" }, - .{ .@"0" = "@intToEnum" }, - .{ .@"0" = "@intToFloat" }, - .{ .@"0" = "@intToPtr" }, - .{ .@"0" = "@truncate" }, - .{ .@"0" = "@ptrCast" }, + .{ "@as" }, + .{ "@bitCast" }, + .{ "@fieldParentPtr" }, + .{ "@floatCast" }, + .{ "@floatToInt" }, + .{ "@intCast" }, + .{ "@intToEnum" }, + .{ "@intToFloat" }, + .{ "@intToPtr" }, + .{ "@truncate" }, + .{ "@ptrCast" }, }); if (cast_map.has(call_name)) { if (builtin_call.params_len < 1) return null; diff --git a/src/semantic_tokens.zig b/src/semantic_tokens.zig index 16388a6..ae376bb 100644 --- a/src/semantic_tokens.zig +++ b/src/semantic_tokens.zig @@ -84,18 +84,18 @@ fn isAllDigit(str: []const u8) bool { fn isTypeIdent(tree: *ast.Tree, token_idx: ast.TokenIndex) bool { const PrimitiveTypes = std.ComptimeStringMap(void, .{ - .{ .@"0" = "isize" }, .{ .@"0" = "usize" }, - .{ .@"0" = "c_short" }, .{ .@"0" = "c_ushort" }, - .{ .@"0" = "c_int" }, .{ .@"0" = "c_uint" }, - .{ .@"0" = "c_long" }, .{ .@"0" = "c_ulong" }, - .{ .@"0" = "c_longlong" }, .{ .@"0" = "c_ulonglong" }, - .{ .@"0" = "c_longdouble" }, .{ .@"0" = "c_void" }, - .{ .@"0" = "f16" }, .{ .@"0" = "f32" }, - .{ .@"0" = "f64" }, .{ .@"0" = "f128" }, - .{ .@"0" = "bool" }, .{ .@"0" = "void" }, - .{ .@"0" = "noreturn" }, .{ .@"0" = "type" }, - .{ .@"0" = "anyerror" }, .{ .@"0" = "comptime_int" }, - .{ .@"0" = "comptime_float" }, .{ .@"0" = "anyframe" }, + .{ "isize" }, .{ "usize" }, + .{ "c_short" }, .{ "c_ushort" }, + .{ "c_int" }, .{ "c_uint" }, + .{ "c_long" }, .{ "c_ulong" }, + .{ "c_longlong" }, .{ "c_ulonglong" }, + .{ "c_longdouble" }, .{ "c_void" }, + .{ "f16" }, .{ "f32" }, + .{ "f64" }, .{ "f128" }, + .{ "bool" }, .{ "void" }, + .{ "noreturn" }, .{ "type" }, + .{ "anyerror" }, .{ "comptime_int" }, + .{ "comptime_float" }, .{ "anyframe" }, }); const text = tree.tokenSlice(token_idx);