aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-08-02 11:00:15 +0100
committergingerBill <gingerBill@users.noreply.github.com>2025-08-02 11:00:15 +0100
commit2561427dd396a69cd49eb02c0814c4e8e8b3a08f (patch)
treed390c6fe5c43b9469c312ebb2af07215eaf92fe1 /src/check_builtin.cpp
parent710203eadb605b41e652084297cde54754008b87 (diff)
Add `string16` and `cstring16` (UTF-16 based strings)
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 974224ed2..d36cf4520 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -2327,6 +2327,9 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
if (is_type_string(op_type) && id == BuiltinProc_len) {
if (operand->mode == Addressing_Constant) {
mode = Addressing_Constant;
+
+ GB_ASSERT_MSG(!is_type_string16(op_type), "TODO(bill): constant utf-16 string len");
+
String str = operand->value.value_string;
value = exact_value_i64(str.len);
type = t_untyped_integer;
@@ -2334,6 +2337,8 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
mode = Addressing_Value;
if (is_type_cstring(op_type)) {
add_package_dependency(c, "runtime", "cstring_len");
+ } else if (is_type_cstring16(op_type)) {
+ add_package_dependency(c, "runtime", "cstring16_len");
}
}
} else if (is_type_array(op_type)) {
@@ -4683,7 +4688,9 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
break;
case Type_Basic:
if (t->Basic.kind == Basic_string) {
- operand->type = alloc_type_multi_pointer(t_u8);
+ operand->type = t_u8_multi_ptr;
+ } else if (t->Basic.kind == Basic_string16) {
+ operand->type = t_u16_multi_ptr;
}
break;
case Type_Pointer: