diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2022-11-17 15:29:28 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-17 15:29:28 +0000 |
| commit | 15bbdb2030510b9d15918536c7da8af3a376c0be (patch) | |
| tree | 60210e6a4ea6d6a34f286f1f4770e4f6fbd2737d /src/check_builtin.cpp | |
| parent | 48c9c1682c347adb7e743a6a6f8c70f08420c197 (diff) | |
| parent | 3949e2220feca6c718a27ecc0fd5cb1cde56f7b7 (diff) | |
Merge pull request #2181 from odin-lang/map-dev
New `map` internals
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 51306bd7b..809d1d9a5 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -5370,6 +5370,43 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 break; } + case BuiltinProc_type_map_info: + { + Operand op = {}; + Type *bt = check_type(c, ce->args[0]); + Type *type = base_type(bt); + if (type == nullptr || type == t_invalid) { + error(ce->args[0], "Expected a type for '%.*s'", LIT(builtin_name)); + return false; + } + if (!is_type_map(type)) { + gbString t = type_to_string(type); + error(ce->args[0], "Expected a map type for '%.*s', got %s", LIT(builtin_name), t); + gb_string_free(t); + return false; + } + + add_map_key_type_dependencies(c, type); + + operand->mode = Addressing_Value; + operand->type = t_map_info_ptr; + break; + } + case BuiltinProc_type_map_cell_info: + { + Operand op = {}; + Type *bt = check_type(c, ce->args[0]); + Type *type = base_type(bt); + if (type == nullptr || type == t_invalid) { + error(ce->args[0], "Expected a type for '%.*s'", LIT(builtin_name)); + return false; + } + + operand->mode = Addressing_Value; + operand->type = t_map_cell_info_ptr; + break; + } + case BuiltinProc_constant_utf16_cstring: { String value = {}; |