Cleaned up ComptimeStringMaps

This commit is contained in:
Alexandros Naskos 2020-06-16 15:45:16 +03:00
parent fc921f10a4
commit cad6b78a49
2 changed files with 23 additions and 24 deletions

View File

@ -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;

View File

@ -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);