From a453603b9be99ee870d43855cdf93bcebefdb9db Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 2 Jan 2026 14:54:44 +0100 Subject: [PATCH] feat: no VoidValue, just Void type --- include/ir/ir.hpp | 9 ++------- include/ir/ops.hpp | 2 +- include/ir/value.hpp | 21 --------------------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/include/ir/ir.hpp b/include/ir/ir.hpp index 2bd5379..ae3c9ca 100644 --- a/include/ir/ir.hpp +++ b/include/ir/ir.hpp @@ -54,7 +54,7 @@ namespace IR argRegs.Push(arg); } // TODO: gather return type of the function - auto dst = VoidValue(); + auto dst = AllocateNamed(new ValueHandle::Type {ValueHandle::Type::Kind::Void}); m_ops->Push(new CallOp(dst, fn->name(), argRegs.view())); return dst; } @@ -75,7 +75,7 @@ namespace IR } assert(0 && "unreachable"); - return reinterpret_cast(new Void()); + return nullptr; } ValueHandle *ParseExpression(const Node *expression) @@ -187,11 +187,6 @@ namespace IR return new V(ValueHandle::kNoId, std::forward(args)...); } - ValueHandle *VoidValue() - { - return new Void(); - } - private: const Node *m_root = nullptr; diff --git a/include/ir/ops.hpp b/include/ir/ops.hpp index f069e77..14651fc 100644 --- a/include/ir/ops.hpp +++ b/include/ir/ops.hpp @@ -99,7 +99,7 @@ namespace IR { StringBuilder sb; sb.AppendIndent(indent); - sb << result()->Format() << " = load " << m_ptr->Format(); + sb << result()->Format() << " = load " << result()->GetType()->Format() << ", " << m_ptr->Format(); return sb.view(); } diff --git a/include/ir/value.hpp b/include/ir/value.hpp index 57c1bbf..465b608 100644 --- a/include/ir/value.hpp +++ b/include/ir/value.hpp @@ -129,27 +129,6 @@ namespace IR Type *m_value_typ; }; - class Void : public ValueHandle - { - public: - Void() - : ValueHandle() - { - m_type = new Type{Type::Kind::Void}; - } - - const Type *GetType() const override { return m_type; } - - public: - virtual StringView Format() const override - { - return m_type->Format(); - } - - private: - Type *m_type; - }; - class Instruction : public ValueHandle { public: