Introduce NODE_FILE

`__FILE__` was managed by `NODE_STR` with `String` object.
This commit introduces `NODE_FILE` and `struct rb_parser_string` so that

1. `__FILE__` is detectable from AST Node
2. Reduce dependency ruby object
This commit is contained in:
yui-knk 2023-12-29 22:34:35 +09:00 committed by Yuichiro Kaneko
parent 91a0d1c437
commit 7a050638b1
12 changed files with 185 additions and 37 deletions

View file

@ -4,12 +4,6 @@
#include "rubyparser.h"
VALUE
rb_node_line_lineno_val(const NODE *node)
{
return INT2FIX(node->nd_loc.beg_pos.lineno);
}
#ifdef UNIVERSAL_PARSER
#include "internal.h"
@ -920,3 +914,16 @@ rb_parser_set_yydebug(VALUE vparser, VALUE flag)
return flag;
}
#endif
VALUE
rb_node_line_lineno_val(const NODE *node)
{
return INT2FIX(node->nd_loc.beg_pos.lineno);
}
VALUE
rb_node_file_path_val(const NODE *node)
{
rb_parser_string_t *str = RNODE_FILE(node)->path;
return rb_enc_str_new(str->ptr, str->len, str->enc);
}