<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/node.h, branch v4.0.4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Make node line macros inline functions</title>
<updated>2025-01-30T09:19:53+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-01-30T07:59:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4bde1493a792ee88110717e6cf20619ee0bc99c2'/>
<id>4bde1493a792ee88110717e6cf20619ee0bc99c2</id>
<content type='text'>
To suppress -Waddress warning and for the debugging purpose.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To suppress -Waddress warning and for the debugging purpose.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix possible dereference of NULL</title>
<updated>2025-01-29T01:35:28+00:00</updated>
<author>
<name>Anastasia Belova</name>
<email>abelova@astralinux.ru</email>
</author>
<published>2025-01-28T12:08:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ff64806ae51c2813f0c6334c0c52082b027c255c'/>
<id>ff64806ae51c2813f0c6334c0c52082b027c255c</id>
<content type='text'>
In some places in compile.c (for example in compile_builtin_arg)
ERROR_ARGS macro is used while node = NULL. This macro uses nd_line
which dereferences node. Add check for NULL to prevent such errors.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In some places in compile.c (for example in compile_builtin_arg)
ERROR_ARGS macro is used while node = NULL. This macro uses nd_line
which dereferences node. Add check for NULL to prevent such errors.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add `rb_node_get_type` for debuggers</title>
<updated>2025-01-09T10:24:27+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-01-09T00:44:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d44a41d81423c2362af3dfc6d9f9f7c2f21038c1'/>
<id>d44a41d81423c2362af3dfc6d9f9f7c2f21038c1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Universal parser] Improve AST structure</title>
<updated>2024-04-28T03:08:21+00:00</updated>
<author>
<name>HASUMI Hitoshi</name>
<email>hasumikin@gmail.com</email>
</author>
<published>2024-04-27T07:28:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ddd8da4b6ba3dfcca21ca710e7cef2fa3b9632d7'/>
<id>ddd8da4b6ba3dfcca21ca710e7cef2fa3b9632d7</id>
<content type='text'>
This patch moves `ast-&gt;node_buffer-&gt;config` to `ast-&gt;config` aiming to improve readability and maintainability of the source.

## Background

We could not add the `config` field to the `rb_ast_t *` due to the five-word restriction of the IMEMO object.
But it is now doable by merging https://github.com/ruby/ruby/pull/10618

## About assigning `&amp;rb_global_parser_config` to `ast-&gt;config` in `ast_alloc()`

The approach of not setting `ast-&gt;config` in `ast_alloc()` means that the client, CRuby in this scenario, that directly calls `ast_alloc()` will be responsible for releasing it if a resource that is passed to AST needs to be released.

However, we have put on hold whether we can guarantee the above so far, thus, this patch looks like that.

```
// ruby_parser.c
static VALUE
ast_alloc(void)
{
    rb_ast_t *ast;
    VALUE vast = TypedData_Make_Struct(0, rb_ast_t, &amp;ast_data_type, ast);
#ifdef UNIVERSAL_PARSER
    ast = (rb_ast_t *)DATA_PTR(vast);
    ast-&gt;config = &amp;rb_global_parser_config;
#endif
    return vast;
}
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch moves `ast-&gt;node_buffer-&gt;config` to `ast-&gt;config` aiming to improve readability and maintainability of the source.

## Background

We could not add the `config` field to the `rb_ast_t *` due to the five-word restriction of the IMEMO object.
But it is now doable by merging https://github.com/ruby/ruby/pull/10618

## About assigning `&amp;rb_global_parser_config` to `ast-&gt;config` in `ast_alloc()`

The approach of not setting `ast-&gt;config` in `ast_alloc()` means that the client, CRuby in this scenario, that directly calls `ast_alloc()` will be responsible for releasing it if a resource that is passed to AST needs to be released.

However, we have put on hold whether we can guarantee the above so far, thus, this patch looks like that.

```
// ruby_parser.c
static VALUE
ast_alloc(void)
{
    rb_ast_t *ast;
    VALUE vast = TypedData_Make_Struct(0, rb_ast_t, &amp;ast_data_type, ast);
#ifdef UNIVERSAL_PARSER
    ast = (rb_ast_t *)DATA_PTR(vast);
    ast-&gt;config = &amp;rb_global_parser_config;
#endif
    return vast;
}
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove dependency on NODE from coverage structure</title>
<updated>2024-04-26T16:25:45+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2024-04-18T17:37:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=af800bef210f5cca5acdcfd874b1391d44eec29c'/>
<id>af800bef210f5cca5acdcfd874b1391d44eec29c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Universal parser] DeVALUE of p-&gt;debug_lines and ast-&gt;body.script_lines</title>
<updated>2024-04-15T11:51:54+00:00</updated>
<author>
<name>HASUMI Hitoshi</name>
<email>hasumikin@gmail.com</email>
</author>
<published>2024-03-28T01:26:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9b1e97b211565b605b8eb7fab277efe117fe2604'/>
<id>9b1e97b211565b605b8eb7fab277efe117fe2604</id>
<content type='text'>
This patch is part of universal parser work.

## Summary
- Decouple VALUE from members below:
  - `(struct parser_params *)-&gt;debug_lines`
  - `(rb_ast_t *)-&gt;body.script_lines`
- Instead, they are now `rb_parser_ary_t *`
  - They can also be a `(VALUE)FIXNUM` as before to hold line count
- `ISEQ_BODY(iseq)-&gt;variable.script_lines` remains VALUE
  - In order to do this,
  - Add `VALUE script_lines` param to `rb_iseq_new_with_opt()`
  - Introduce `rb_parser_build_script_lines_from()` to convert `rb_parser_ary_t *` into `VALUE`

## Other details
- Extend `rb_parser_ary_t *`. It previously could only store `rb_parser_ast_token *`, now can store script_lines, too
- Change tactics of building the top-level `SCRIPT_LINES__` in `yycompile0()`
  - Before: While parsing, each line of the script is added to `SCRIPT_LINES__[path]`
  - After: After `yyparse(p)`, `SCRIPT_LINES__[path]` will be built from `p-&gt;debug_lines`
- Remove the second parameter of `rb_parser_set_script_lines()` to make it simple
- Introduce `script_lines_free()` to be called from `rb_ast_free()` because the GC no longer takes care of the script_lines
- Introduce `rb_parser_string_deep_copy()` in parse.y to maintain script_lines when `rb_ruby_parser_free()` called
  - With regard to this, please see *Future tasks* below

## Future tasks
- Decouple IMEMO from `rb_ast_t *`
  - This lifts the five-members-restriction of Ruby object,
  - So we will be able to move the ownership of the `lex.string_buffer` from parser to AST
  - Then we remove `rb_parser_string_deep_copy()` to make the whole thing simple
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch is part of universal parser work.

## Summary
- Decouple VALUE from members below:
  - `(struct parser_params *)-&gt;debug_lines`
  - `(rb_ast_t *)-&gt;body.script_lines`
- Instead, they are now `rb_parser_ary_t *`
  - They can also be a `(VALUE)FIXNUM` as before to hold line count
- `ISEQ_BODY(iseq)-&gt;variable.script_lines` remains VALUE
  - In order to do this,
  - Add `VALUE script_lines` param to `rb_iseq_new_with_opt()`
  - Introduce `rb_parser_build_script_lines_from()` to convert `rb_parser_ary_t *` into `VALUE`

## Other details
- Extend `rb_parser_ary_t *`. It previously could only store `rb_parser_ast_token *`, now can store script_lines, too
- Change tactics of building the top-level `SCRIPT_LINES__` in `yycompile0()`
  - Before: While parsing, each line of the script is added to `SCRIPT_LINES__[path]`
  - After: After `yyparse(p)`, `SCRIPT_LINES__[path]` will be built from `p-&gt;debug_lines`
- Remove the second parameter of `rb_parser_set_script_lines()` to make it simple
- Introduce `script_lines_free()` to be called from `rb_ast_free()` because the GC no longer takes care of the script_lines
- Introduce `rb_parser_string_deep_copy()` in parse.y to maintain script_lines when `rb_ruby_parser_free()` called
  - With regard to this, please see *Future tasks* below

## Future tasks
- Decouple IMEMO from `rb_ast_t *`
  - This lifts the five-members-restriction of Ruby object,
  - So we will be able to move the ownership of the `lex.string_buffer` from parser to AST
  - Then we remove `rb_parser_string_deep_copy()` to make the whole thing simple
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove needless check</title>
<updated>2024-04-05T00:19:57+00:00</updated>
<author>
<name>yui-knk</name>
<email>spiketeika@gmail.com</email>
</author>
<published>2024-04-04T14:53:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cebbe18eed2e09843e9c24be9a8ea9db6d241050'/>
<id>cebbe18eed2e09843e9c24be9a8ea9db6d241050</id>
<content type='text'>
`nodetype_markable_p` always returns `false` then
`rb_ast_node_type_change` never calls `rb_bug`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`nodetype_markable_p` always returns `false` then
`rb_ast_node_type_change` never calls `rb_bug`.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge two `node_buffer_list_t` fields into one</title>
<updated>2024-04-05T00:19:57+00:00</updated>
<author>
<name>yui-knk</name>
<email>spiketeika@gmail.com</email>
</author>
<published>2024-04-04T14:19:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fc8fe78c073eb4a7a531444de103dd89d379bdae'/>
<id>fc8fe78c073eb4a7a531444de103dd89d379bdae</id>
<content type='text'>
All types of Node are managed by `node_buffer_list_t unmarkable`
therefore merge them into `node_buffer_list_t buffer_list`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All types of Node are managed by `node_buffer_list_t unmarkable`
therefore merge them into `node_buffer_list_t buffer_list`.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove `rb_imemo_tmpbuf_t` from parser</title>
<updated>2024-04-02T10:37:27+00:00</updated>
<author>
<name>yui-knk</name>
<email>spiketeika@gmail.com</email>
</author>
<published>2024-04-01T05:33:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e816ab0b0ce97a49cc1a642c3fb6f78c9e838f97'/>
<id>e816ab0b0ce97a49cc1a642c3fb6f78c9e838f97</id>
<content type='text'>
No parser semantic value types are `VALUE` then no need to
use imemo for managing semantic value stack anymore.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
No parser semantic value types are `VALUE` then no need to
use imemo for managing semantic value stack anymore.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Universal parser] Fix -Wsuggest-attribute=format warnings</title>
<updated>2024-03-15T13:14:57+00:00</updated>
<author>
<name>HASUMI Hitoshi</name>
<email>hasumikin@gmail.com</email>
</author>
<published>2024-03-15T13:14:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=40ecad0ad796f1515c654c127ae498854c9a6120'/>
<id>40ecad0ad796f1515c654c127ae498854c9a6120</id>
<content type='text'>
Under a configuration including `cppflags=-DUNIVERSAL_PARSER`, warnings listed below show in build time:

```
node.c:396:30: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  396 |     bug_report_func rb_bug = ast-&gt;node_buffer-&gt;config-&gt;bug;
      |                              ^~~
```

```
ruby_parser.c:655:21: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  655 |     .compile_warn = rb_compile_warn,
      |                     ^~~~~~~~~~~~~~~
ruby_parser.c:656:24: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  656 |     .compile_warning = rb_compile_warning,
      |                        ^~~~~~~~~~~~~~~~~~
ruby_parser.c:657:12: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  657 |     .bug = rb_bug,
      |            ^~~~~~
ruby_parser.c:658:14: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  658 |     .fatal = rb_fatal,
      |              ^~~~~~~~
```

To fix, this patch suggests adding `__attribute__((format(printf, n, m)))` to those function declarations.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Under a configuration including `cppflags=-DUNIVERSAL_PARSER`, warnings listed below show in build time:

```
node.c:396:30: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  396 |     bug_report_func rb_bug = ast-&gt;node_buffer-&gt;config-&gt;bug;
      |                              ^~~
```

```
ruby_parser.c:655:21: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  655 |     .compile_warn = rb_compile_warn,
      |                     ^~~~~~~~~~~~~~~
ruby_parser.c:656:24: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  656 |     .compile_warning = rb_compile_warning,
      |                        ^~~~~~~~~~~~~~~~~~
ruby_parser.c:657:12: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  657 |     .bug = rb_bug,
      |            ^~~~~~
ruby_parser.c:658:14: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format]
  658 |     .fatal = rb_fatal,
      |              ^~~~~~~~
```

To fix, this patch suggests adding `__attribute__((format(printf, n, m)))` to those function declarations.
</pre>
</div>
</content>
</entry>
</feed>
