.
This commit is contained in:
@@ -90,8 +90,8 @@ ByteArray Bytecode::generate(BytecodePrototype const& bp)
|
||||
std::vector<std::pair<FunctionDef, uint32_t>> functions;
|
||||
ByteArray code;
|
||||
for (auto const& f: bp.functions) {
|
||||
functions.emplace_back(std::make_pair(FunctionDef { f.n_pars, f.n_locals }, code.size()));
|
||||
code.append_bytearray(f.code);
|
||||
functions.emplace_back(std::make_pair(FunctionDef { f.n_pars, f.n_locals }, code.size()));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -117,13 +117,13 @@ ByteArray Bytecode::generate(BytecodePrototype const& bp)
|
||||
}
|
||||
|
||||
// functions
|
||||
size_t functions_start = idx + (constant_table.size() * 4) + ba.size();
|
||||
idx += functions_start;
|
||||
size_t functions_start = idx + (constant_table.size() * 4);
|
||||
idx = functions_start;
|
||||
uint32_t code_idx = 0;
|
||||
for (auto const& f: functions) {
|
||||
ba.set_uint32(idx, code_idx);
|
||||
ba.set_uint16(idx + 4, f.first.n_params);
|
||||
ba.set_uint16(idx + 6, f.first.n_params);
|
||||
ba.set_uint16(idx + 6, f.first.locals);
|
||||
idx += 8;
|
||||
code_idx += f.second;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user