summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorHASUMI Hitoshi <[email protected]>2024-04-26 21:43:35 +0900
committerYuichiro Kaneko <[email protected]>2024-04-27 12:08:26 +0900
commit55a402bb759597487905a94d5b1bbff4a672499c (patch)
tree9a6309c61f0f6871de0d47c135d4270bb270dfc7 /vm.c
parentbf1f16ef47966e33401e5b9656a4ae4152dd1e60 (diff)
Add line_count field to rb_ast_body_t
This patch adds `int line_count` field to `rb_ast_body_t` structure. Instead, we no longer cast `script_lines` to Fixnum. ## Background Ref https://github.com/ruby/ruby/pull/10618 In the PR above, we have decoupled IMEMO from `rb_ast_t`. This means we could lift the five-words-restriction of the structure that forced us to unionize `rb_ast_t *` and `FIXNUM` in one field. ## Relating refactor - Remove the second parameter of `rb_ruby_ast_new()` function ## Attention I will remove a code that assigns -1 to line_count, in `rb_binding_add_dynavars()` of vm.c, because I don't think it is necessary. But I will make another PR for this so that we can atomically revert in case I was wrong (See the comment on the code)
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index 4bd95034cc..e2813c9cc0 100644
--- a/vm.c
+++ b/vm.c
@@ -1480,7 +1480,17 @@ rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const I
tmp_node.nd_body = 0;
tmp_node.nd_args = 0;
- VALUE vast = rb_ruby_ast_new(RNODE(&tmp_node), (rb_parser_ary_t *)INT2FIX(-1));
+ VALUE vast = rb_ruby_ast_new(RNODE(&tmp_node));
+ { /*
+ * TODO:
+ * Assigning -1 to line_count is to maintain the previous code.
+ * However, the author of this patch guesses this code is no longer necessary.
+ * We will try to remove this code in the next commit which is atomically
+ * revertable if the author is wrong.
+ */
+ rb_ast_t *ast = (rb_ast_t *)DATA_PTR(vast);
+ ast->body.line_count = -1;
+ }
if (base_iseq) {
iseq = rb_iseq_new(vast, ISEQ_BODY(base_iseq)->location.label, path, realpath, base_iseq, ISEQ_TYPE_EVAL);