Skip to content

Commit

Permalink
Rename vast to ast_value
Browse files Browse the repository at this point in the history
There is an English word "vast".
This commit changes the name to be more clear name to avoid confusion.
  • Loading branch information
yui-knk committed May 2, 2024
1 parent a3726c0 commit 51a1f7a
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 239 deletions.
286 changes: 143 additions & 143 deletions ast.c

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,11 +1479,11 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
VALUE name, const rb_iseq_t *parent, enum rb_iseq_type type, int line_no)
{
rb_iseq_t *ret_iseq;
VALUE vast = rb_ruby_ast_new(node);
VALUE ast_value = rb_ruby_ast_new(node);

debugs("[new_child_iseq]> ---------------------------------------\n");
int isolated_depth = ISEQ_COMPILE_DATA(iseq)->isolated_depth;
ret_iseq = rb_iseq_new_with_opt(vast, name,
ret_iseq = rb_iseq_new_with_opt(ast_value, name,
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
line_no, parent,
isolated_depth ? isolated_depth + 1 : 0,
Expand Down Expand Up @@ -8771,10 +8771,10 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
scope_node.nd_body = mandatory_node(iseq, node);
scope_node.nd_args = &args_node;

VALUE vast = rb_ruby_ast_new(RNODE(&scope_node));
VALUE ast_value = rb_ruby_ast_new(RNODE(&scope_node));

ISEQ_BODY(iseq)->mandatory_only_iseq =
rb_iseq_new_with_opt(vast, rb_iseq_base_label(iseq),
rb_iseq_new_with_opt(ast_value, rb_iseq_base_label(iseq),
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
nd_line(line_node), NULL, 0,
ISEQ_TYPE_METHOD, ISEQ_COMPILE_DATA(iseq)->option,
Expand Down
2 changes: 1 addition & 1 deletion internal/ruby_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ enum lex_state_e {
};

VALUE rb_ruby_ast_new(const NODE *const root);
rb_ast_t *rb_ruby_ast_data_get(VALUE vast);
rb_ast_t *rb_ruby_ast_data_get(VALUE ast_value);

#endif /* INTERNAL_RUBY_PARSE_H */
46 changes: 23 additions & 23 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,18 +839,18 @@ make_compile_option_value(rb_compile_option_t *option)
}

rb_iseq_t *
rb_iseq_new(const VALUE vast, VALUE name, VALUE path, VALUE realpath,
rb_iseq_new(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath,
const rb_iseq_t *parent, enum rb_iseq_type type)
{
return rb_iseq_new_with_opt(vast, name, path, realpath, 0, parent,
return rb_iseq_new_with_opt(ast_value, name, path, realpath, 0, parent,
0, type, &COMPILE_OPTION_DEFAULT,
Qnil);
}

static int
ast_line_count(const VALUE vast)
ast_line_count(const VALUE ast_value)
{
rb_ast_t *ast = rb_ruby_ast_data_get(vast);
rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
return ast->body.line_count;
}

Expand Down Expand Up @@ -880,11 +880,11 @@ iseq_new_setup_coverage(VALUE path, int line_count)
}

rb_iseq_t *
rb_iseq_new_top(const VALUE vast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
rb_iseq_new_top(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
{
iseq_new_setup_coverage(path, ast_line_count(vast));
iseq_new_setup_coverage(path, ast_line_count(ast_value));

return rb_iseq_new_with_opt(vast, name, path, realpath, 0, parent, 0,
return rb_iseq_new_with_opt(ast_value, name, path, realpath, 0, parent, 0,
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT,
Qnil);
}
Expand All @@ -902,11 +902,11 @@ pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, c
}

rb_iseq_t *
rb_iseq_new_main(const VALUE vast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
rb_iseq_new_main(const VALUE ast_value, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
{
iseq_new_setup_coverage(path, ast_line_count(vast));
iseq_new_setup_coverage(path, ast_line_count(ast_value));

return rb_iseq_new_with_opt(vast, rb_fstring_lit("<main>"),
return rb_iseq_new_with_opt(ast_value, rb_fstring_lit("<main>"),
path, realpath, 0,
parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE,
Qnil);
Expand All @@ -927,16 +927,16 @@ pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_ise
}

rb_iseq_t *
rb_iseq_new_eval(const VALUE vast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth)
rb_iseq_new_eval(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth)
{
if (rb_get_coverage_mode() & COVERAGE_TARGET_EVAL) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
iseq_setup_coverage(coverages, path, ast_line_count(vast) + first_lineno - 1);
iseq_setup_coverage(coverages, path, ast_line_count(ast_value) + first_lineno - 1);
}
}

return rb_iseq_new_with_opt(vast, name, path, realpath, first_lineno,
return rb_iseq_new_with_opt(ast_value, name, path, realpath, first_lineno,
parent, isolated_depth, ISEQ_TYPE_EVAL, &COMPILE_OPTION_DEFAULT,
Qnil);
}
Expand Down Expand Up @@ -971,12 +971,12 @@ iseq_translate(rb_iseq_t *iseq)
}

rb_iseq_t *
rb_iseq_new_with_opt(const VALUE vast, VALUE name, VALUE path, VALUE realpath,
rb_iseq_new_with_opt(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath,
int first_lineno, const rb_iseq_t *parent, int isolated_depth,
enum rb_iseq_type type, const rb_compile_option_t *option,
VALUE script_lines)
{
rb_ast_t *ast = rb_ruby_ast_data_get(vast);
rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
rb_ast_body_t *body = ast ? &ast->body : NULL;
const NODE *node = body ? body->root : 0;
/* TODO: argument check */
Expand Down Expand Up @@ -1217,7 +1217,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
#endif
VALUE (*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
int ln;
VALUE INITIALIZED vast;
VALUE INITIALIZED ast_value;
rb_ast_t *ast;
VALUE name = rb_fstring_lit("<compiled>");

Expand All @@ -1239,17 +1239,17 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
rb_parser_set_context(parser, outer_scope, FALSE);
if (ruby_vm_keep_script_lines) rb_parser_set_script_lines(parser);
RB_GC_GUARD(outer_scope_v);
vast = (*parse)(parser, file, src, ln);
ast_value = (*parse)(parser, file, src, ln);
}

ast = rb_ruby_ast_data_get(vast);
ast = rb_ruby_ast_data_get(ast_value);

if (!ast || !ast->body.root) {
rb_ast_dispose(ast);
rb_exc_raise(GET_EC()->errinfo);
}
else {
iseq = rb_iseq_new_with_opt(vast, name, file, realpath, ln,
iseq = rb_iseq_new_with_opt(ast_value, name, file, realpath, ln,
NULL, 0, ISEQ_TYPE_TOP, &option,
Qnil);
rb_ast_dispose(ast);
Expand Down Expand Up @@ -1624,7 +1624,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
VALUE file, opt = Qnil;
VALUE parser, f, exc = Qnil, ret;
rb_ast_t *ast;
VALUE vast;
VALUE ast_value;
rb_compile_option_t option;
int i;

Expand All @@ -1643,8 +1643,8 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)

parser = rb_parser_new();
rb_parser_set_context(parser, NULL, FALSE);
vast = rb_parser_load_file(parser, file);
ast = rb_ruby_ast_data_get(vast);
ast_value = rb_parser_load_file(parser, file);
ast = rb_ruby_ast_data_get(ast_value);
if (!ast->body.root) exc = GET_EC()->errinfo;

rb_io_close(f);
Expand All @@ -1655,7 +1655,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)

make_compile_option(&option, opt);

ret = iseqw_new(rb_iseq_new_with_opt(vast, rb_fstring_lit("<main>"),
ret = iseqw_new(rb_iseq_new_with_opt(ast_value, rb_fstring_lit("<main>"),
file,
rb_realpath_internal(Qnil, file, 1),
1, NULL, 0, ISEQ_TYPE_TOP, &option,
Expand Down
8 changes: 4 additions & 4 deletions load.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,13 @@ load_iseq_eval(rb_execution_context_t *ec, VALUE fname)
}
else {
rb_ast_t *ast;
VALUE vast;
VALUE ast_value;
VALUE parser = rb_parser_new();
rb_parser_set_context(parser, NULL, FALSE);
vast = rb_parser_load_file(parser, fname);
ast = rb_ruby_ast_data_get(vast);
ast_value = rb_parser_load_file(parser, fname);
ast = rb_ruby_ast_data_get(ast_value);

iseq = rb_iseq_new_top(vast, rb_fstring_lit("<top (required)>"),
iseq = rb_iseq_new_top(ast_value, rb_fstring_lit("<top (required)>"),
fname, realpath_internal_cached(realpath_map, fname), NULL);
rb_ast_dispose(ast);
}
Expand Down
10 changes: 5 additions & 5 deletions mini_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
static struct st_table *loaded_builtin_table;
#endif

VALUE rb_builtin_vast(const char *feature_name, VALUE *name_str);
VALUE rb_builtin_ast_value(const char *feature_name, VALUE *name_str);

static const rb_iseq_t *
builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *table)
{
VALUE name_str = 0;
rb_ast_t *ast;
VALUE vast = rb_builtin_vast(feature_name, &name_str);
VALUE ast_value = rb_builtin_ast_value(feature_name, &name_str);
rb_vm_t *vm = GET_VM();

if (NIL_P(vast)) {
if (NIL_P(ast_value)) {
rb_fatal("builtin_iseq_load: can not find %s; "
"probably miniprelude.c is out of date",
feature_name);
Expand All @@ -40,8 +40,8 @@ builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *ta
.coverage_enabled = FALSE,
.debug_level = 0,
};
ast = rb_ruby_ast_data_get(vast);
const rb_iseq_t *iseq = rb_iseq_new_with_opt(vast, name_str, name_str, Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization, Qnil);
ast = rb_ruby_ast_data_get(ast_value);
const rb_iseq_t *iseq = rb_iseq_new_with_opt(ast_value, name_str, name_str, Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization, Qnil);
GET_VM()->builtin_function_table = NULL;

rb_ast_dispose(ast);
Expand Down
30 changes: 15 additions & 15 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ static VALUE
process_script(ruby_cmdline_options_t *opt)
{
rb_ast_t *ast;
VALUE vast;
VALUE ast_value;
VALUE parser = rb_parser_new();
const unsigned int dump = opt->dump;

Expand All @@ -2080,22 +2080,22 @@ process_script(ruby_cmdline_options_t *opt)
ruby_set_script_name(progname);
rb_parser_set_options(parser, opt->do_print, opt->do_loop,
opt->do_line, opt->do_split);
vast = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
ast_value = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
}
else {
VALUE f;
int xflag = opt->xflag;
f = open_load_file(opt->script_name, &xflag);
opt->xflag = xflag != 0;
rb_parser_set_context(parser, 0, f == rb_stdin);
vast = load_file(parser, opt->script_name, f, 1, opt);
ast_value = load_file(parser, opt->script_name, f, 1, opt);
}
ast = rb_ruby_ast_data_get(vast);
ast = rb_ruby_ast_data_get(ast_value);
if (!ast->body.root) {
rb_ast_dispose(ast);
return Qnil;
}
return vast;
return ast_value;
}

/**
Expand Down Expand Up @@ -2239,7 +2239,7 @@ process_options_global_setup(const ruby_cmdline_options_t *opt, const rb_iseq_t
static VALUE
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
{
VALUE vast = Qnil;
VALUE ast_value = Qnil;
struct {
rb_ast_t *ast;
pm_parse_result_t prism;
Expand Down Expand Up @@ -2474,8 +2474,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
}

if (!(*rb_ruby_prism_ptr())) {
vast = process_script(opt);
if (!(result.ast = rb_ruby_ast_data_get(vast))) return Qfalse;
ast_value = process_script(opt);
if (!(result.ast = rb_ruby_ast_data_get(ast_value))) return Qfalse;
}
else {
prism_script(opt, &result.prism);
Expand Down Expand Up @@ -2557,7 +2557,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
}
else {
rb_ast_t *ast = result.ast;
iseq = rb_iseq_new_main(vast, opt->script_name, path, parent, optimize);
iseq = rb_iseq_new_main(ast_value, opt->script_name, path, parent, optimize);
rb_ast_dispose(ast);
}
}
Expand Down Expand Up @@ -2608,7 +2608,7 @@ load_file_internal(VALUE argp_v)
ruby_cmdline_options_t *opt = argp->opt;
VALUE f = argp->f;
int line_start = 1;
VALUE vast = Qnil;
VALUE ast_value = Qnil;
rb_encoding *enc;
ID set_encoding;

Expand Down Expand Up @@ -2709,7 +2709,7 @@ load_file_internal(VALUE argp_v)
return rb_parser_compile_string_path(parser, orig_fname, f, line_start);
}
rb_funcall(f, set_encoding, 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
vast = rb_parser_compile_file_path(parser, orig_fname, f, line_start);
ast_value = rb_parser_compile_file_path(parser, orig_fname, f, line_start);
rb_funcall(f, set_encoding, 1, rb_parser_encoding(parser));
if (script && rb_parser_end_seen_p(parser)) {
/*
Expand All @@ -2727,7 +2727,7 @@ load_file_internal(VALUE argp_v)
rb_define_global_const("DATA", f);
argp->f = Qnil;
}
return vast;
return ast_value;
}

/* disabling O_NONBLOCK, and returns 0 on success, otherwise errno */
Expand Down Expand Up @@ -2859,9 +2859,9 @@ rb_load_file(const char *fname)
void *
rb_load_file_str(VALUE fname_v)
{
VALUE vast;
vast = rb_parser_load_file(rb_parser_new(), fname_v);
return (void *)rb_ruby_ast_data_get(vast);
VALUE ast_value;
ast_value = rb_parser_load_file(rb_parser_new(), fname_v);
return (void *)rb_ruby_ast_data_get(ast_value);
}

VALUE
Expand Down
Loading

0 comments on commit 51a1f7a

Please sign in to comment.