1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 11:09:54 +00:00

Fix some symbol mapping inside nested functions.

This commit is contained in:
Calvin Rose 2023-05-31 08:19:24 -05:00
parent 4f8f7f66ee
commit 77189b6e66
2 changed files with 7 additions and 5 deletions

View File

@ -170,6 +170,7 @@ void janet_bytecode_remove_noops(JanetFuncDef *def) {
}
def->bytecode_length = new_bytecode_length;
def->bytecode = janet_realloc(def->bytecode, def->bytecode_length * sizeof(uint32_t));
janet_sfree(pc_map);
}

View File

@ -971,12 +971,13 @@ JanetFuncDef *janetc_pop_funcdef(JanetCompiler *c) {
for (int32_t i = 0; i < janet_v_count(scope->syms); i++) {
SymPair pair = scope->syms[i];
if (pair.sym2) {
if (pair.death_pc == UINT32_MAX) {
pair.death_pc = def->bytecode_length;
}
JanetSymbolMap jsm;
jsm.birth_pc = pair.birth_pc;
jsm.death_pc = pair.death_pc;
if (pair.death_pc == UINT32_MAX) {
jsm.death_pc = def->bytecode_length;
} else {
jsm.death_pc = pair.death_pc - scope->bytecode_start;
}
jsm.birth_pc = pair.birth_pc - scope->bytecode_start;
jsm.slot_index = pair.slot.index;
jsm.symbol = pair.sym2;
janet_v_push(locals, jsm);