summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Fusik <piotr@fusion-lang.org>2024-02-16 08:04:29 +0100
committerPiotr Fusik <piotr@fusion-lang.org>2024-02-16 08:04:29 +0100
commit464803d2bb297fcd33e7853ee307bb4029867b72 (patch)
tree3c7c6214e4707df1f29492db50ae9c133cad9789
parent853653d1acc59ae1179af723bd7637a7a0920dd0 (diff)
[c] Initialize Match() variables.
-rw-r--r--GenC.fu2
-rw-r--r--libfut.cpp3
-rw-r--r--libfut.cs2
-rw-r--r--libfut.js3
4 files changed, 6 insertions, 4 deletions
diff --git a/GenC.fu b/GenC.fu
index 6a17a1a..5f887b6 100644
--- a/GenC.fu
+++ b/GenC.fu
@@ -607,7 +607,7 @@ public class GenC : GenCCpp
Write("NULL");
}
- static bool IsHeapAllocated(FuType type) => type.Id == FuId.StringStorageType || type is FuDynamicPtrType;
+ static bool IsHeapAllocated(FuType type) => type.Id == FuId.StringStorageType || type is FuDynamicPtrType || (type is FuStorageType storage && storage.Class.Id == FuId.MatchClass);
static bool NeedToDestructType(FuType type)
{
diff --git a/libfut.cpp b/libfut.cpp
index b809bf4..57ece61 100644
--- a/libfut.cpp
+++ b/libfut.cpp
@@ -9494,7 +9494,8 @@ void GenC::writeXstructorPtr(bool need, const FuClass * klass, std::string_view
bool GenC::isHeapAllocated(const FuType * type)
{
- return type->id == FuId::stringStorageType || dynamic_cast<const FuDynamicPtrType *>(type);
+ const FuStorageType * storage;
+ return type->id == FuId::stringStorageType || dynamic_cast<const FuDynamicPtrType *>(type) || ((storage = dynamic_cast<const FuStorageType *>(type)) && storage->class_->id == FuId::matchClass);
}
bool GenC::needToDestructType(const FuType * type)
diff --git a/libfut.cs b/libfut.cs
index 082540b..eee9825 100644
--- a/libfut.cs
+++ b/libfut.cs
@@ -9788,7 +9788,7 @@ namespace Fusion
Write("NULL");
}
- static bool IsHeapAllocated(FuType type) => type.Id == FuId.StringStorageType || type is FuDynamicPtrType;
+ static bool IsHeapAllocated(FuType type) => type.Id == FuId.StringStorageType || type is FuDynamicPtrType || (type is FuStorageType storage && storage.Class.Id == FuId.MatchClass);
static bool NeedToDestructType(FuType type)
{
diff --git a/libfut.js b/libfut.js
index a14c1df..2da4917 100644
--- a/libfut.js
+++ b/libfut.js
@@ -10134,7 +10134,8 @@ export class GenC extends GenCCpp
static #isHeapAllocated(type)
{
- return type.id == FuId.STRING_STORAGE_TYPE || type instanceof FuDynamicPtrType;
+ let storage;
+ return type.id == FuId.STRING_STORAGE_TYPE || type instanceof FuDynamicPtrType || ((storage = type) instanceof FuStorageType && storage.class.id == FuId.MATCH_CLASS);
}
static #needToDestructType(type)