diff options
author | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-16 08:04:29 +0100 |
---|---|---|
committer | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-16 08:04:29 +0100 |
commit | 464803d2bb297fcd33e7853ee307bb4029867b72 (patch) | |
tree | 3c7c6214e4707df1f29492db50ae9c133cad9789 | |
parent | 853653d1acc59ae1179af723bd7637a7a0920dd0 (diff) |
[c] Initialize Match() variables.
-rw-r--r-- | GenC.fu | 2 | ||||
-rw-r--r-- | libfut.cpp | 3 | ||||
-rw-r--r-- | libfut.cs | 2 | ||||
-rw-r--r-- | libfut.js | 3 |
4 files changed, 6 insertions, 4 deletions
@@ -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) { @@ -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) @@ -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) { @@ -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) |