Ruby
2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
|
Go to the documentation of this file.
12 static VALUE rb_cNode;
20 node_gc_mark(
void *
ptr)
27 node_memsize(
const void *
ptr)
57 obj = rb_ast_node_alloc(rb_cNode);
87 return rb_ast_parse_str(
str);
97 return ast_parse_done(
ast);
103 return rb_ast_parse_file(
path);
118 return ast_parse_done(
ast);
135 rb_ast_parse_array(
VALUE array)
141 return ast_parse_done(
ast);
147 node_find(
VALUE self,
const int node_id)
156 ary = node_children(data->
ast, data->
node);
162 VALUE result = node_find(child, node_id);
163 if (
RTEST(result))
return result;
177 CONST_ID(script_lines,
"SCRIPT_LINES__");
194 iseq = vm_proc_iseq(body);
208 if (!
NIL_P(lines = script_lines(
path))) {
209 node = rb_ast_parse_array(lines);
218 return node_find(
node, node_id);
245 #define NEW_CHILD(ast, node) node ? ast_new_internal(ast, node) : Qnil
257 for (
i=0;
i<
n;
i++) {
272 }
while (
node->nd_next &&
300 if (!
id)
return Qnil;
315 return rb_ary_new_from_node_args(
ast, 3,
node->nd_cond,
node->nd_body,
node->nd_else);
317 return rb_ary_new_from_node_args(
ast, 3,
node->nd_cond,
node->nd_body,
node->nd_else);
319 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_body);
321 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_body);
323 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_body);
325 return rb_ary_new_from_node_args(
ast, 3,
node->nd_head,
node->nd_body,
node->nd_next);
327 return rb_ary_new_from_node_args(
ast, 3,
node->nd_head,
node->nd_body,
node->nd_next);
336 return rb_ary_new_from_node_args(
ast, 2,
node->nd_iter,
node->nd_body);
338 return rb_ary_new_from_node_args(
ast, 1,
node->nd_var);
345 return rb_ary_new_from_node_args(
ast, 1,
node->nd_stts);
347 return rb_ary_new_from_node_args(
ast, 0);
349 return rb_ary_new_from_node_args(
ast, 0);
351 return rb_ary_new_from_node_args(
ast, 1,
node->nd_body);
353 return rb_ary_new_from_node_args(
ast, 3,
node->nd_head,
node->nd_resq,
node->nd_else);
355 return rb_ary_new_from_node_args(
ast, 3,
node->nd_args,
node->nd_body,
node->nd_head);
357 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_ensr);
376 return rb_ary_new_from_node_args(
ast, 3,
node->nd_value,
node->nd_head,
node->nd_args);
437 return rb_ary_new_from_node_args(
ast, 1,
node->nd_args);
439 return rb_ary_new_from_node_args(
ast, 0);
446 return rb_ary_new_from_node_args(
ast, 0);
448 return rb_ary_new_from_node_args(
ast, 1,
node->nd_head);
450 return rb_ary_new_from_node_args(
ast, 1,
node->nd_head);
471 return rb_ary_new_from_node_args(
ast, 3,
node->nd_recv,
node->nd_value,
node->nd_args);
473 return rb_ary_new_from_node_args(
ast, 2,
node->nd_recv,
node->nd_value);
475 return rb_ary_new_from_node_args(
ast, 2,
node->nd_recv,
node->nd_value);
484 return rb_ary_new_from_node_args(
ast, 1,
node->nd_body);
497 return rb_ary_new_from_node_args(
ast, 1,
node->nd_body);
499 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_body);
501 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_body);
503 return rb_ary_new_from_node_args(
ast, 1,
node->nd_head);
505 return rb_ary_new_from_node_args(
ast, 2,
node->nd_head,
node->nd_body);
511 return rb_ary_new_from_node_args(
ast, 2,
node->nd_1st,
node->nd_2nd);
515 return rb_ary_new_from_node_args(
ast, 1,
node->nd_undef);
517 return rb_ary_new_from_node_args(
ast, 3,
node->nd_cpath,
node->nd_super,
node->nd_body);
519 return rb_ary_new_from_node_args(
ast, 2,
node->nd_cpath,
node->nd_body);
521 return rb_ary_new_from_node_args(
ast, 2,
node->nd_recv,
node->nd_body);
534 return rb_ary_new_from_node_args(
ast, 2,
node->nd_beg,
node->nd_end);
536 return rb_ary_new_from_node_args(
ast, 0);
538 return rb_ary_new_from_node_args(
ast, 0);
540 return rb_ary_new_from_node_args(
ast, 0);
542 return rb_ary_new_from_node_args(
ast, 0);
544 return rb_ary_new_from_node_args(
ast, 0);
546 return rb_ary_new_from_node_args(
ast, 1,
node->nd_head);
548 return rb_ary_new_from_node_args(
ast, 1,
node->nd_body);
552 return rb_ary_new_from_node_args(
ast, 1,
node->nd_body);
554 return rb_ary_new_from_node_args(
ast, 2,
node->nd_body,
node->nd_next);
556 return rb_ary_new_from_node_args(
ast, 2,
node->nd_body,
node->nd_next);
559 return rb_ary_new_from_node_args(
ast, 2,
node->nd_1st,
node->nd_2nd);
582 ID *tbl = node->nd_tbl;
583 int i,
size = tbl ? (
int)*tbl++ : 0;
625 return node_children(data->
ast, data->
node);
677 node_type_to_str(data->
node),
VALUE rb_ary_new_capa(long capa)
VALUE rb_parser_new(void)
const char * ruby_node_name(int node)
#define TypedData_Make_Struct(klass, type, data_type, sval)
VALUE rb_define_module_under(VALUE outer, const char *name)
#define NODE_SPECIAL_EXCESSIVE_COMMA
void rb_ast_dispose(rb_ast_t *ast)
#define RB_TYPE_P(obj, type)
rb_encoding * rb_enc_get(VALUE obj)
#define rb_enc_asciicompat(enc)
#define nd_last_lineno(n)
VALUE rb_const_get_at(VALUE, ID)
VALUE rb_iseq_path(const rb_iseq_t *iseq)
rb_iseq_location_t location
rb_ast_t * rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
rb_ast_t * rb_parser_compile_generic(VALUE vparser, VALUE(*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start)
#define NODE_SPECIAL_NO_REST_KEYWORD
VALUE rb_enc_from_encoding(rb_encoding *encoding)
#define RUBY_TYPED_DEFAULT_FREE
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_ary_entry(VALUE ary, long offset)
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
VALUE rb_obj_is_proc(VALUE)
VALUE rb_file_open_str(VALUE, const char *)
#define NEW_CHILD(ast, node)
size_t rb_ast_memsize(const rb_ast_t *ast)
VALUE rb_hash_lookup(VALUE hash, VALUE key)
VALUE rb_ary_push(VALUE ary, VALUE item)
#define RARRAY_AREF(a, i)
#define nd_first_column(n)
rb_ast_t * rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
int memcmp(const void *s1, const void *s2, size_t len)
#define CONST_ID(var, str)
VALUE rb_check_array_type(VALUE ary)
RUBY_EXTERN VALUE rb_cObject
#define nd_last_column(n)
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE rb_str_append(VALUE, VALUE)
void rb_bug(const char *fmt,...)
rb_encoding * rb_utf8_encoding(void)
#define NODE_NAMED_REST_P(node)
char str[HTML_ESCAPE_MAX_LEN+1]
#define nd_first_lineno(n)
#define RUBY_TYPED_FREE_IMMEDIATELY
VALUE rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main)
void rb_gc_mark(VALUE ptr)
VALUE rb_str_catf(VALUE str, const char *format,...)
VALUE rb_class_path(VALUE)
struct rb_iseq_constant_body * body
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
#define NODE_REQUIRED_KEYWORD_P(node)
int rb_const_defined_at(VALUE, ID)
#define DECIMAL_SIZE_OF_BITS(n)
const rb_iseq_t * rb_method_iseq(VALUE body)
void rb_undef_alloc_func(VALUE)
#define rb_strlen_lit(str)
VALUE type(ANYARGS)
ANYARGS-ed function type.