Dump annotations on RubyVM::ISeq.disasm (#9667)

Make it easier to check what annotations an ISEQ has. SINGLE_NOARG_LEAF
is added automatically, so it's hard to be sure about the annotation by
just reading code. It's also unclear to me what happens to it with
Primitive.mandatory_only?, but this at least explains that LEAF
annotation is not added to the non-mandatory_only ISEQ.
This commit is contained in:
Takashi Kokubun 2024-01-23 14:54:39 -08:00 коммит произвёл GitHub
Родитель 909a710a69
Коммит c0cabc0a69
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 9 добавлений и 0 удалений

9
iseq.c
Просмотреть файл

@ -2526,6 +2526,15 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
rb_str_modify_expand(str, header_minlen - l);
memset(RSTRING_END(str), '=', header_minlen - l);
}
if (iseq->body->builtin_attrs) {
#define disasm_builtin_attr(str, iseq, attr) \
if (iseq->body->builtin_attrs & BUILTIN_ATTR_ ## attr) { \
rb_str_cat2(str, " " #attr); \
}
disasm_builtin_attr(str, iseq, LEAF);
disasm_builtin_attr(str, iseq, SINGLE_NOARG_LEAF);
disasm_builtin_attr(str, iseq, INLINE_BLOCK);
}
rb_str_cat2(str, "\n");
/* show catch table information */