/* * Copyright (c) 2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace JS::Bytecode { class Generator { public: static OwnPtr generate(ASTNode const&); Register allocate_register(); template OpType& emit(Args&&... args) { auto instruction = make(forward(args)...); auto* ptr = instruction.ptr(); append(move(instruction)); return *ptr; } Label make_label() const; private: Generator(); ~Generator(); void append(NonnullOwnPtr); OwnPtr m_block; u32 m_next_register { 1 }; }; }