#pragma once #include "ir/op.hpp" #include "prelude/linkedlist.hpp" namespace IR { using BlockID = unsigned int; class Block { public: Block(BlockID id, DoubleLinkedList ops) : m_id(id), m_ops(ops) {} public: DoubleLinkedList& ops() { return m_ops; } public: StringView Format(int indent) const { StringBuilder sb; sb.AppendIndent(indent); sb.AppendFormat("b%d:\n", m_id); for (ListNode* cur = m_ops.Begin(); cur != nullptr; cur = cur->next) { sb << cur->value->Format(indent + 2) << '\n'; } return sb.view(); } private: BlockID m_id; DoubleLinkedList m_ops; }; } // namespace IR