summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authoryui-knk <[email protected]>2024-01-12 22:26:54 +0900
committerYuichiro Kaneko <[email protected]>2024-01-23 08:58:16 +0900
commitee7f63ebba542f87e6fa28709e67ace0fefcae90 (patch)
tree2e6e772d4317bdd3ecbeed81ded30de12c69bb34 /internal
parent706eea9d3c27b9785fc7f650ff9b5d6669908768 (diff)
Make lastline and nextline to be rb_parser_string
This commit changes `struct parser_params` lastline and nextline from `VALUE` (String object) to `rb_parser_string_t *` so that dependency on Ruby Object is reduced. `parser_string_buffer_t string_buffer` is added to `struct parser_params` to manage `rb_parser_string_t` pointers of each line. All allocated line strings are freed in `rb_ruby_parser_free`.
Diffstat (limited to 'internal')
-rw-r--r--internal/parse.h5
-rw-r--r--internal/ruby_parser.h4
2 files changed, 7 insertions, 2 deletions
diff --git a/internal/parse.h b/internal/parse.h
index bd6d295be1..3c6e48090e 100644
--- a/internal/parse.h
+++ b/internal/parse.h
@@ -29,7 +29,7 @@ typedef struct rb_strterm_literal_struct {
} rb_strterm_literal_t;
typedef struct rb_strterm_heredoc_struct {
- VALUE lastline; /* the string of line that contains `<<"END"` */
+ rb_parser_string_t *lastline; /* the string of line that contains `<<"END"` */
long offset; /* the column of END in `<<"END"` */
int sourceline; /* lineno of the line that contains `<<"END"` */
unsigned length; /* the length of END in `<<"END"` */
@@ -65,6 +65,7 @@ RUBY_SYMBOL_EXPORT_BEGIN
VALUE rb_ruby_parser_encoding(rb_parser_t *p);
int rb_ruby_parser_end_seen_p(rb_parser_t *p);
int rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag);
+rb_parser_string_t *rb_str_to_parser_string(rb_parser_t *p, VALUE str);
RUBY_SYMBOL_EXPORT_END
@@ -96,7 +97,7 @@ int rb_ruby_ripper_initialized_p(rb_parser_t *p);
void rb_ruby_ripper_parser_initialize(rb_parser_t *p);
long rb_ruby_ripper_column(rb_parser_t *p);
long rb_ruby_ripper_token_len(rb_parser_t *p);
-VALUE rb_ruby_ripper_lex_lastline(rb_parser_t *p);
+rb_parser_string_t *rb_ruby_ripper_lex_lastline(rb_parser_t *p);
VALUE rb_ruby_ripper_lex_state_name(struct parser_params *p, int state);
struct parser_params *rb_ruby_ripper_parser_allocate(void);
#endif
diff --git a/internal/ruby_parser.h b/internal/ruby_parser.h
index ddff2c364d..018a1865de 100644
--- a/internal/ruby_parser.h
+++ b/internal/ruby_parser.h
@@ -72,6 +72,10 @@ enum lex_state_e {
EXPR_NONE = 0
};
+RUBY_SYMBOL_EXPORT_BEGIN
+VALUE rb_str_new_parser_string(rb_parser_string_t *str);
+RUBY_SYMBOL_EXPORT_END
+
VALUE rb_node_sym_string_val(const NODE *);
VALUE rb_node_line_lineno_val(const NODE *);
VALUE rb_node_file_path_val(const NODE *);