From 75f1cea3f30e09b3ad85b4ae4d8d809d229f6261 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Mon, 30 Mar 2026 20:01:56 +0300 Subject: [PATCH] Support casting pointers <-> u64 --- libs/ast/source/type_check.cpp | 6 ++++++ libs/jit/source/arch/aarch64/compiler.cpp | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/ast/source/type_check.cpp b/libs/ast/source/type_check.cpp index a73c2bc..038a721 100644 --- a/libs/ast/source/type_check.cpp +++ b/libs/ast/source/type_check.cpp @@ -535,6 +535,12 @@ namespace pslang::ast } } + if (types::equal(*source_type, types::primitive_type{types::u64_type{}}) && types::is_pointer_type(*target_type)) + return; + + if (types::equal(*target_type, types::primitive_type{types::u64_type{}}) && types::is_pointer_type(*source_type)) + return; + if (auto source_array_type = std::get_if(source_type.get())) { if (auto target_pointer_type = std::get_if(target_type.get())) diff --git a/libs/jit/source/arch/aarch64/compiler.cpp b/libs/jit/source/arch/aarch64/compiler.cpp index 2593ae8..e736afc 100644 --- a/libs/jit/source/arch/aarch64/compiler.cpp +++ b/libs/jit/source/arch/aarch64/compiler.cpp @@ -591,7 +591,14 @@ namespace pslang::jit::aarch64 auto src_type = node.arg1->inferred_type; auto dst_type = node.target_type; - if (types::equal(*src_type, *dst_type) || (types::is_pointer_type(*src_type) && types::is_pointer_type(*dst_type))) + auto u64_type = types::primitive_type{types::u64_type{}}; + + if (false + || (types::is_builtin_type(*src_type) && types::equal(*src_type, *dst_type)) + || (types::is_pointer_type(*src_type) && types::is_pointer_type(*dst_type)) + || (types::equal(*src_type, u64_type) && types::is_pointer_type(*dst_type)) + || (types::equal(*dst_type, u64_type) && types::is_pointer_type(*src_type)) + ) { load(node.arg1, 0); store(it, 0);