Manage rb_strterm_t without imemo

This commit is contained in:
Nobuyoshi Nakada 2023-10-13 19:07:31 +09:00
parent cb06b6632a
commit a075c55d0c
7 changed files with 36 additions and 74 deletions

View file

@ -473,39 +473,12 @@ zalloc(size_t elemsiz)
return ruby_xcalloc(1, elemsiz);
}
static VALUE
new_strterm(VALUE v1, VALUE v2, VALUE v3, VALUE v0, int heredoc)
{
rb_strterm_t *imemo = (rb_strterm_t *)rb_imemo_new(imemo_parser_strterm, v1, v2, v3, v0);
if (heredoc) {
imemo->flags |= STRTERM_HEREDOC;
}
return (VALUE)imemo;
}
static int
strterm_is_heredoc(VALUE strterm)
{
return ((rb_strterm_t *)strterm)->flags & STRTERM_HEREDOC;
}
static void
gc_guard(VALUE obj)
{
RB_GC_GUARD(obj);
}
void
rb_strterm_mark(VALUE obj)
{
rb_strterm_t *strterm = (rb_strterm_t*)obj;
if (RBASIC(obj)->flags & STRTERM_HEREDOC) {
rb_strterm_heredoc_t *heredoc = &strterm->u.heredoc;
rb_gc_mark(heredoc->lastline);
}
}
static rb_imemo_tmpbuf_t *
tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
{
@ -564,8 +537,6 @@ rb_parser_config_initialize(rb_parser_config_t *config)
config->nonempty_memcpy = nonempty_memcpy;
config->xmalloc_mul_add = rb_xmalloc_mul_add;
config->new_strterm = new_strterm;
config->strterm_is_heredoc = strterm_is_heredoc;
config->tmpbuf_parser_heap = tmpbuf_parser_heap;
config->ast_new = ast_new;