1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-20 17:24:48 +00:00

Add support for debugging upvalues.

Upvalues are stored in the symbol slots structure as well, but
since they are always live, we repurpose the death_pc field to
refer to the environment index that we want to look at at runtime.
This commit is contained in:
Calvin Rose
2023-02-05 15:27:39 -06:00
parent c7fb7b4451
commit 7a1c9c7798
5 changed files with 63 additions and 14 deletions

View File

@@ -928,10 +928,15 @@ static Janet janet_disasm_symbolslots(JanetFuncDef *def) {
return janet_wrap_nil();
}
JanetArray *symbolslots = janet_array(def->symbolmap_length);
Janet upvaluekw = janet_ckeywordv("upvalue");
for (int32_t i = 0; i < def->symbolmap_length; i++) {
JanetSymbolMap ss = def->symbolmap[i];
Janet *t = janet_tuple_begin(4);
t[0] = janet_wrap_integer(ss.birth_pc);
if (ss.birth_pc == UINT32_MAX) {
t[0] = upvaluekw;
} else {
t[0] = janet_wrap_integer(ss.birth_pc);
}
t[1] = janet_wrap_integer(ss.death_pc);
t[2] = janet_wrap_integer(ss.slot_index);
t[3] = janet_wrap_symbol(ss.symbol);