Assembler #6

Merged
andre merged 12 commits from assembler into master 2026-05-01 10:12:41 -05:00
2 changed files with 3 additions and 1 deletions
Showing only changes of commit 9104f0b7e2 - Show all commits

View File

@@ -31,6 +31,8 @@ ByteArray Assembler::assemble()
} else if (std::get<std::string>(t.token) == ".func") {
section = Section::Function;
function_id = std::get<int>(expect_token(TokenType::Integer));
if (function_id >= bp.functions.size())
bp.functions.resize(function_id + 1, { 0, 0 });
expect_token(TokenType::Enter);
} else {
throw AssemblyError("Invalid directive " + std::get<std::string>(t.token), t.line, t.column);

View File

@@ -14,7 +14,7 @@ struct BytecodePrototype {
struct Function {
uint16_t n_pars;
uint16_t n_locals;
ByteArray code;
ByteArray code {};
Function(uint16_t n_pars_, uint16_t n_locals_) : n_pars(n_pars_), n_locals(n_locals_), code(ByteArray {}) {}
};