Show anonymous and ambiguous params in ISeq disassembly

Previously, in the disasesmbly for ISeqs, there's no way to know if the
anon_rest, anon_kwrest, or ambiguous_param0 flags are set. This commit
extends the names of the rest, kwrest, and lead params to display this
information. They are relevant for the ISeqs' runtime behavior.
This commit is contained in:
Kevin Newton 2024-08-15 12:59:30 -04:00 committed by GitHub
parent 33bffde923
commit 2d66ef717d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-08-15 16:59:54 +00:00
Merged: https://github.com/ruby/ruby/pull/11237

Merged-By: XrXr

6
iseq.c
View File

@ -2735,11 +2735,11 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
}
snprintf(argi, sizeof(argi), "%s%s%s%s%s%s", /* arg, opts, rest, post, kwrest, block */
body->param.lead_num > li ? "Arg" : "",
(body->param.lead_num > li) ? (body->param.flags.ambiguous_param0 ? "AmbiguousArg" : "Arg") : "",
opti,
(body->param.flags.has_rest && body->param.rest_start == li) ? "Rest" : "",
(body->param.flags.has_rest && body->param.rest_start == li) ? (body->param.flags.anon_rest ? "AnonRest" : "Rest") : "",
(body->param.flags.has_post && body->param.post_start <= li && li < body->param.post_start + body->param.post_num) ? "Post" : "",
(body->param.flags.has_kwrest && keyword->rest_start == li) ? "Kwrest" : "",
(body->param.flags.has_kwrest && keyword->rest_start == li) ? (body->param.flags.anon_kwrest ? "AnonKwrest" : "Kwrest") : "",
(body->param.flags.has_block && body->param.block_start == li) ? "Block" : "");
rb_str_cat(str, indent_str, indent_len);