* node.h (ast_t): renamed to rb_ast_t
.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ad8bc4493d
commit
85fcaf025d
2
gc.c
2
gc.c
@ -434,7 +434,7 @@ typedef struct RVALUE {
|
|||||||
const rb_iseq_t iseq;
|
const rb_iseq_t iseq;
|
||||||
rb_env_t env;
|
rb_env_t env;
|
||||||
struct rb_imemo_alloc_struct alloc;
|
struct rb_imemo_alloc_struct alloc;
|
||||||
ast_t ast;
|
rb_ast_t ast;
|
||||||
} imemo;
|
} imemo;
|
||||||
struct {
|
struct {
|
||||||
struct RBasic basic;
|
struct RBasic basic;
|
||||||
|
6
iseq.c
6
iseq.c
@ -641,9 +641,9 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
|
|||||||
#else
|
#else
|
||||||
# define INITIALIZED /* volatile */
|
# define INITIALIZED /* volatile */
|
||||||
#endif
|
#endif
|
||||||
ast_t *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
|
rb_ast_t *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
|
||||||
int ln;
|
int ln;
|
||||||
ast_t *INITIALIZED ast;
|
rb_ast_t *INITIALIZED ast;
|
||||||
|
|
||||||
/* safe results first */
|
/* safe results first */
|
||||||
make_compile_option(&option, opt);
|
make_compile_option(&option, opt);
|
||||||
@ -854,7 +854,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||||||
{
|
{
|
||||||
VALUE file, line = INT2FIX(1), opt = Qnil;
|
VALUE file, line = INT2FIX(1), opt = Qnil;
|
||||||
VALUE parser, f, exc = Qnil, ret;
|
VALUE parser, f, exc = Qnil, ret;
|
||||||
ast_t *ast;
|
rb_ast_t *ast;
|
||||||
rb_compile_option_t option;
|
rb_compile_option_t option;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
4
load.c
4
load.c
@ -602,7 +602,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||||||
EC_PUSH_TAG(th->ec);
|
EC_PUSH_TAG(th->ec);
|
||||||
state = EXEC_TAG();
|
state = EXEC_TAG();
|
||||||
if (state == TAG_NONE) {
|
if (state == TAG_NONE) {
|
||||||
ast_t *ast;
|
rb_ast_t *ast;
|
||||||
const rb_iseq_t *iseq;
|
const rb_iseq_t *iseq;
|
||||||
|
|
||||||
if ((iseq = rb_iseq_load_iseq(fname)) != NULL) {
|
if ((iseq = rb_iseq_load_iseq(fname)) != NULL) {
|
||||||
@ -611,7 +611,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||||||
else {
|
else {
|
||||||
VALUE parser = rb_parser_new();
|
VALUE parser = rb_parser_new();
|
||||||
rb_parser_set_context(parser, NULL, FALSE);
|
rb_parser_set_context(parser, NULL, FALSE);
|
||||||
ast = (ast_t *)rb_parser_load_file(parser, fname);
|
ast = (rb_ast_t *)rb_parser_load_file(parser, fname);
|
||||||
iseq = rb_iseq_new_top(ast->root, rb_fstring_cstr("<top (required)>"),
|
iseq = rb_iseq_new_top(ast->root, rb_fstring_cstr("<top (required)>"),
|
||||||
fname, rb_realpath_internal(Qnil, fname, 1), NULL);
|
fname, rb_realpath_internal(Qnil, fname, 1), NULL);
|
||||||
rb_ast_dispose(ast);
|
rb_ast_dispose(ast);
|
||||||
|
18
node.c
18
node.c
@ -1248,7 +1248,7 @@ rb_node_buffer_free(node_buffer_t *nb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NODE *
|
NODE *
|
||||||
rb_ast_newnode(ast_t *ast)
|
rb_ast_newnode(rb_ast_t *ast)
|
||||||
{
|
{
|
||||||
node_buffer_t *nb = ast->node_buffer;
|
node_buffer_t *nb = ast->node_buffer;
|
||||||
if (nb->idx >= nb->len) {
|
if (nb->idx >= nb->len) {
|
||||||
@ -1264,27 +1264,27 @@ rb_ast_newnode(ast_t *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ast_delete_node(ast_t *ast, NODE *n)
|
rb_ast_delete_node(rb_ast_t *ast, NODE *n)
|
||||||
{
|
{
|
||||||
(void)ast;
|
(void)ast;
|
||||||
(void)n;
|
(void)n;
|
||||||
/* should we implement freelist? */
|
/* should we implement freelist? */
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t *
|
rb_ast_t *
|
||||||
rb_ast_new(void)
|
rb_ast_new(void)
|
||||||
{
|
{
|
||||||
return (ast_t *)rb_imemo_new(imemo_ast, 0, (VALUE)rb_node_buffer_new(), rb_ary_tmp_new(0), 0);
|
return (rb_ast_t *)rb_imemo_new(imemo_ast, 0, (VALUE)rb_node_buffer_new(), rb_ary_tmp_new(0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ast_mark(ast_t *ast)
|
rb_ast_mark(rb_ast_t *ast)
|
||||||
{
|
{
|
||||||
if (ast->node_buffer) rb_gc_mark(ast->mark_ary);
|
if (ast->node_buffer) rb_gc_mark(ast->mark_ary);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ast_free(ast_t *ast)
|
rb_ast_free(rb_ast_t *ast)
|
||||||
{
|
{
|
||||||
if (ast->node_buffer) rb_node_buffer_free(ast->node_buffer);
|
if (ast->node_buffer) rb_node_buffer_free(ast->node_buffer);
|
||||||
ast->node_buffer = 0;
|
ast->node_buffer = 0;
|
||||||
@ -1293,20 +1293,20 @@ rb_ast_free(ast_t *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ast_dispose(ast_t *ast)
|
rb_ast_dispose(rb_ast_t *ast)
|
||||||
{
|
{
|
||||||
rb_ast_free(ast);
|
rb_ast_free(ast);
|
||||||
rb_gc_writebarrier_remember((VALUE)ast);
|
rb_gc_writebarrier_remember((VALUE)ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ast_add_mark_object(ast_t *ast, VALUE obj)
|
rb_ast_add_mark_object(rb_ast_t *ast, VALUE obj)
|
||||||
{
|
{
|
||||||
rb_ary_push(ast->mark_ary, obj);
|
rb_ary_push(ast->mark_ary, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_ast_delete_mark_object(ast_t *ast, VALUE obj)
|
rb_ast_delete_mark_object(rb_ast_t *ast, VALUE obj)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
for (i = 0; i < RARRAY_LEN(ast->mark_ary); i++) {
|
for (i = 0; i < RARRAY_LEN(ast->mark_ary); i++) {
|
||||||
|
36
node.h
36
node.h
@ -441,21 +441,21 @@ RUBY_SYMBOL_EXPORT_BEGIN
|
|||||||
|
|
||||||
typedef struct node_buffer_struct node_buffer_t;
|
typedef struct node_buffer_struct node_buffer_t;
|
||||||
/* T_IMEMO/ast */
|
/* T_IMEMO/ast */
|
||||||
typedef struct ast_struct {
|
typedef struct rb_ast_struct {
|
||||||
VALUE flags;
|
VALUE flags;
|
||||||
VALUE reserved1;
|
VALUE reserved1;
|
||||||
NODE *root;
|
NODE *root;
|
||||||
node_buffer_t *node_buffer;
|
node_buffer_t *node_buffer;
|
||||||
VALUE mark_ary;
|
VALUE mark_ary;
|
||||||
} ast_t;
|
} rb_ast_t;
|
||||||
ast_t *rb_ast_new();
|
rb_ast_t *rb_ast_new();
|
||||||
void rb_ast_mark(ast_t*);
|
void rb_ast_mark(rb_ast_t*);
|
||||||
void rb_ast_dispose(ast_t*);
|
void rb_ast_dispose(rb_ast_t*);
|
||||||
void rb_ast_free(ast_t*);
|
void rb_ast_free(rb_ast_t*);
|
||||||
void rb_ast_add_mark_object(ast_t*, VALUE);
|
void rb_ast_add_mark_object(rb_ast_t*, VALUE);
|
||||||
void rb_ast_delete_mark_object(ast_t*, VALUE);
|
void rb_ast_delete_mark_object(rb_ast_t*, VALUE);
|
||||||
NODE *rb_ast_newnode(ast_t*);
|
NODE *rb_ast_newnode(rb_ast_t*);
|
||||||
void rb_ast_delete_node(ast_t*, NODE *n);
|
void rb_ast_delete_node(rb_ast_t*, NODE *n);
|
||||||
|
|
||||||
VALUE rb_parser_new(void);
|
VALUE rb_parser_new(void);
|
||||||
VALUE rb_parser_end_seen_p(VALUE);
|
VALUE rb_parser_end_seen_p(VALUE);
|
||||||
@ -465,15 +465,15 @@ VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
|||||||
VALUE rb_parser_dump_tree(NODE *node, int comment);
|
VALUE rb_parser_dump_tree(NODE *node, int comment);
|
||||||
void rb_parser_set_options(VALUE, int, int, int, int);
|
void rb_parser_set_options(VALUE, int, int, int, int);
|
||||||
|
|
||||||
ast_t *rb_parser_compile_cstr(VALUE, const char*, const char*, int, int);
|
rb_ast_t *rb_parser_compile_cstr(VALUE, const char*, const char*, int, int);
|
||||||
ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
|
rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
|
||||||
ast_t *rb_parser_compile_file(VALUE, const char*, VALUE, int);
|
rb_ast_t *rb_parser_compile_file(VALUE, const char*, VALUE, int);
|
||||||
ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
|
rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
|
||||||
ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
|
rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
|
||||||
|
|
||||||
ast_t *rb_compile_cstr(const char*, const char*, int, int);
|
rb_ast_t *rb_compile_cstr(const char*, const char*, int, int);
|
||||||
ast_t *rb_compile_string(const char*, VALUE, int);
|
rb_ast_t *rb_compile_string(const char*, VALUE, int);
|
||||||
ast_t *rb_compile_file(const char*, VALUE, int);
|
rb_ast_t *rb_compile_file(const char*, VALUE, int);
|
||||||
|
|
||||||
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
|
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
|
||||||
NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
|
NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
|
||||||
|
24
parse.y
24
parse.y
@ -239,7 +239,7 @@ struct parser_params {
|
|||||||
unsigned int do_chomp: 1;
|
unsigned int do_chomp: 1;
|
||||||
unsigned int do_split: 1;
|
unsigned int do_split: 1;
|
||||||
|
|
||||||
ast_t *ast;
|
rb_ast_t *ast;
|
||||||
NODE *eval_tree_begin;
|
NODE *eval_tree_begin;
|
||||||
NODE *eval_tree;
|
NODE *eval_tree;
|
||||||
VALUE error_buffer;
|
VALUE error_buffer;
|
||||||
@ -5589,11 +5589,11 @@ lex_getline(struct parser_params *parser)
|
|||||||
static const rb_data_type_t parser_data_type;
|
static const rb_data_type_t parser_data_type;
|
||||||
|
|
||||||
#ifndef RIPPER
|
#ifndef RIPPER
|
||||||
static ast_t*
|
static rb_ast_t*
|
||||||
parser_compile_string(VALUE vparser, VALUE fname, VALUE s, int line)
|
parser_compile_string(VALUE vparser, VALUE fname, VALUE s, int line)
|
||||||
{
|
{
|
||||||
struct parser_params *parser;
|
struct parser_params *parser;
|
||||||
ast_t *ast;
|
rb_ast_t *ast;
|
||||||
|
|
||||||
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
|
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
|
||||||
parser->ast = ast = rb_ast_new();
|
parser->ast = ast = rb_ast_new();
|
||||||
@ -5610,34 +5610,34 @@ parser_compile_string(VALUE vparser, VALUE fname, VALUE s, int line)
|
|||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_compile_string(const char *f, VALUE s, int line)
|
rb_compile_string(const char *f, VALUE s, int line)
|
||||||
{
|
{
|
||||||
must_be_ascii_compatible(s);
|
must_be_ascii_compatible(s);
|
||||||
return parser_compile_string(rb_parser_new(), rb_filesystem_str_new_cstr(f), s, line);
|
return parser_compile_string(rb_parser_new(), rb_filesystem_str_new_cstr(f), s, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_parser_compile_string(VALUE vparser, const char *f, VALUE s, int line)
|
rb_parser_compile_string(VALUE vparser, const char *f, VALUE s, int line)
|
||||||
{
|
{
|
||||||
return rb_parser_compile_string_path(vparser, rb_filesystem_str_new_cstr(f), s, line);
|
return rb_parser_compile_string_path(vparser, rb_filesystem_str_new_cstr(f), s, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
|
rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
|
||||||
{
|
{
|
||||||
must_be_ascii_compatible(s);
|
must_be_ascii_compatible(s);
|
||||||
return parser_compile_string(vparser, f, s, line);
|
return parser_compile_string(vparser, f, s, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_compile_cstr(const char *f, const char *s, int len, int line)
|
rb_compile_cstr(const char *f, const char *s, int len, int line)
|
||||||
{
|
{
|
||||||
VALUE str = rb_str_new(s, len);
|
VALUE str = rb_str_new(s, len);
|
||||||
return parser_compile_string(rb_parser_new(), rb_filesystem_str_new_cstr(f), str, line);
|
return parser_compile_string(rb_parser_new(), rb_filesystem_str_new_cstr(f), str, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_parser_compile_cstr(VALUE vparser, const char *f, const char *s, int len, int line)
|
rb_parser_compile_cstr(VALUE vparser, const char *f, const char *s, int len, int line)
|
||||||
{
|
{
|
||||||
VALUE str = rb_str_new(s, len);
|
VALUE str = rb_str_new(s, len);
|
||||||
@ -5652,7 +5652,7 @@ lex_io_gets(struct parser_params *parser, VALUE io)
|
|||||||
return rb_io_gets_internal(io);
|
return rb_io_gets_internal(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_compile_file(const char *f, VALUE file, int start)
|
rb_compile_file(const char *f, VALUE file, int start)
|
||||||
{
|
{
|
||||||
VALUE vparser = rb_parser_new();
|
VALUE vparser = rb_parser_new();
|
||||||
@ -5660,17 +5660,17 @@ rb_compile_file(const char *f, VALUE file, int start)
|
|||||||
return rb_parser_compile_file(vparser, f, file, start);
|
return rb_parser_compile_file(vparser, f, file, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_parser_compile_file(VALUE vparser, const char *f, VALUE file, int start)
|
rb_parser_compile_file(VALUE vparser, const char *f, VALUE file, int start)
|
||||||
{
|
{
|
||||||
return rb_parser_compile_file_path(vparser, rb_filesystem_str_new_cstr(f), file, start);
|
return rb_parser_compile_file_path(vparser, rb_filesystem_str_new_cstr(f), file, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_t*
|
rb_ast_t*
|
||||||
rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
|
rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
|
||||||
{
|
{
|
||||||
struct parser_params *parser;
|
struct parser_params *parser;
|
||||||
ast_t *ast;
|
rb_ast_t *ast;
|
||||||
|
|
||||||
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
|
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, parser);
|
||||||
parser->ast = ast = rb_ast_new();
|
parser->ast = ast = rb_ast_new();
|
||||||
|
10
ruby.c
10
ruby.c
@ -177,7 +177,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
|
|||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ast_t *load_file(VALUE parser, VALUE fname, VALUE f, int script,
|
static rb_ast_t *load_file(VALUE parser, VALUE fname, VALUE f, int script,
|
||||||
ruby_cmdline_options_t *opt);
|
ruby_cmdline_options_t *opt);
|
||||||
static VALUE open_load_file(VALUE fname_v, int *xflag);
|
static VALUE open_load_file(VALUE fname_v, int *xflag);
|
||||||
static void forbid_setid(const char *, const ruby_cmdline_options_t *);
|
static void forbid_setid(const char *, const ruby_cmdline_options_t *);
|
||||||
@ -1461,7 +1461,7 @@ rb_f_chomp(int argc, VALUE *argv)
|
|||||||
static VALUE
|
static VALUE
|
||||||
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||||
{
|
{
|
||||||
ast_t *ast = 0;
|
rb_ast_t *ast = 0;
|
||||||
VALUE parser;
|
VALUE parser;
|
||||||
VALUE script_name;
|
VALUE script_name;
|
||||||
const rb_iseq_t *iseq;
|
const rb_iseq_t *iseq;
|
||||||
@ -1797,7 +1797,7 @@ load_file_internal(VALUE argp_v)
|
|||||||
ruby_cmdline_options_t *opt = argp->opt;
|
ruby_cmdline_options_t *opt = argp->opt;
|
||||||
VALUE f = argp->f;
|
VALUE f = argp->f;
|
||||||
int line_start = 1;
|
int line_start = 1;
|
||||||
ast_t *ast = 0;
|
rb_ast_t *ast = 0;
|
||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
ID set_encoding;
|
ID set_encoding;
|
||||||
|
|
||||||
@ -2011,7 +2011,7 @@ restore_load_file(VALUE arg)
|
|||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ast_t *
|
static rb_ast_t *
|
||||||
load_file(VALUE parser, VALUE fname, VALUE f, int script, ruby_cmdline_options_t *opt)
|
load_file(VALUE parser, VALUE fname, VALUE f, int script, ruby_cmdline_options_t *opt)
|
||||||
{
|
{
|
||||||
struct load_file_arg arg;
|
struct load_file_arg arg;
|
||||||
@ -2020,7 +2020,7 @@ load_file(VALUE parser, VALUE fname, VALUE f, int script, ruby_cmdline_options_t
|
|||||||
arg.script = script;
|
arg.script = script;
|
||||||
arg.opt = opt;
|
arg.opt = opt;
|
||||||
arg.f = f;
|
arg.f = f;
|
||||||
return (ast_t *)rb_ensure(load_file_internal, (VALUE)&arg,
|
return (rb_ast_t *)rb_ensure(load_file_internal, (VALUE)&arg,
|
||||||
restore_load_file, (VALUE)&arg);
|
restore_load_file, (VALUE)&arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ prelude_eval(VALUE code, VALUE name, int line)
|
|||||||
FALSE, /* int debug_frozen_string_literal; */
|
FALSE, /* int debug_frozen_string_literal; */
|
||||||
};
|
};
|
||||||
|
|
||||||
ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
|
rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
|
||||||
if (!ast->root) {
|
if (!ast->root) {
|
||||||
rb_ast_dispose(ast);
|
rb_ast_dispose(ast);
|
||||||
rb_exc_raise(rb_errinfo());
|
rb_exc_raise(rb_errinfo());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user