Delete heredoc line mark references

This commit is contained in:
Nobuyoshi Nakada 2023-10-13 19:21:59 +09:00
parent 5fc9810bf3
commit a405b28e85
5 changed files with 12 additions and 0 deletions

8
node.c
View File

@ -93,6 +93,7 @@ rb_node_buffer_new(void)
#define Qtrue ast->node_buffer->config->qtrue
#define NIL_P ast->node_buffer->config->nil_p
#define rb_hash_aset ast->node_buffer->config->hash_aset
#define rb_hash_delete ast->node_buffer->config->hash_delete
#define RB_OBJ_WRITE(old, slot, young) ast->node_buffer->config->obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young))
#endif
@ -458,6 +459,13 @@ rb_ast_add_mark_object(rb_ast_t *ast, VALUE obj)
rb_hash_aset(ast->node_buffer->mark_hash, obj, Qtrue);
}
void
rb_ast_delete_mark_object(rb_ast_t *ast, VALUE obj)
{
if (NIL_P(ast->node_buffer->mark_hash)) return;
rb_hash_delete(ast->node_buffer->mark_hash, obj);
}
VALUE
rb_ast_tokens(rb_ast_t *ast)
{

1
node.h
View File

@ -67,6 +67,7 @@ void rb_ast_mark(rb_ast_t*);
void rb_ast_update_references(rb_ast_t*);
void rb_ast_free(rb_ast_t*);
void rb_ast_add_mark_object(rb_ast_t*, VALUE);
void rb_ast_delete_mark_object(rb_ast_t*, VALUE);
void rb_ast_set_tokens(rb_ast_t*, VALUE);
NODE *rb_ast_newnode(rb_ast_t*, enum node_type type, size_t size, size_t alignment);
void rb_ast_delete_node(rb_ast_t*, NODE *n);

View File

@ -8756,6 +8756,7 @@ heredoc_restore(struct parser_params *p, rb_strterm_heredoc_t *here)
if (p->eofp) p->lex.nextline = Qnil;
p->eofp = 0;
xfree(term);
rb_ast_delete_mark_object(p->ast, line);
}
static int

View File

@ -618,6 +618,7 @@ rb_parser_config_initialize(rb_parser_config_t *config)
config->hash_new = rb_hash_new;
config->hash_aset = rb_hash_aset;
config->hash_lookup = rb_hash_lookup;
config->hash_delete = rb_hash_delete;
config->ident_hash_new = rb_ident_hash_new;
config->int2fix = int2fix;

View File

@ -1230,6 +1230,7 @@ typedef struct rb_parser_config_struct {
VALUE (*hash_clear)(VALUE hash);
VALUE (*hash_new)(void);
VALUE (*hash_aset)(VALUE hash, VALUE key, VALUE val);
VALUE (*hash_delete)(VALUE hash, VALUE key);
VALUE (*hash_lookup)(VALUE hash, VALUE key);
VALUE (*ident_hash_new)(void);