Ruby: node.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

node.h
Go to the documentation of this file.
1#ifndef RUBY_NODE_H
2#define RUBY_NODE_H 1
3/**********************************************************************
4
5 node.h -
6
7 $Author$
8 created at: Fri May 28 15:14:02 JST 1993
9
10 Copyright (C) 1993-2007 Yukihiro Matsumoto
11
12**********************************************************************/
13
14#if defined(__cplusplus)
15extern "C" {
16#if 0
17} /* satisfy cc-mode */
18#endif
19#endif
20
21 enum node_type {
22 NODE_SCOPE,
23 NODE_BLOCK,
24 NODE_IF,
25 NODE_UNLESS,
26 NODE_CASE,
27 NODE_CASE2,
28 NODE_CASE3,
29 NODE_WHEN,
30 NODE_IN,
31 NODE_WHILE,
32 NODE_UNTIL,
33 NODE_ITER,
34 NODE_FOR,
35 NODE_FOR_MASGN,
36 NODE_BREAK,
37 NODE_NEXT,
38 NODE_REDO,
39 NODE_RETRY,
40 NODE_BEGIN,
41 NODE_RESCUE,
42 NODE_RESBODY,
43 NODE_ENSURE,
44 NODE_AND,
45 NODE_OR,
46 NODE_MASGN,
47 NODE_LASGN,
48 NODE_DASGN,
49 NODE_DASGN_CURR,
50 NODE_GASGN,
51 NODE_IASGN,
52 NODE_CDECL,
53 NODE_CVASGN,
54 NODE_OP_ASGN1,
55 NODE_OP_ASGN2,
56 NODE_OP_ASGN_AND,
57 NODE_OP_ASGN_OR,
58 NODE_OP_CDECL,
59 NODE_CALL,
60 NODE_OPCALL,
61 NODE_FCALL,
62 NODE_VCALL,
63 NODE_QCALL,
64 NODE_SUPER,
65 NODE_ZSUPER,
66 NODE_LIST,
67 NODE_ZLIST,
68 NODE_VALUES,
69 NODE_HASH,
70 NODE_RETURN,
71 NODE_YIELD,
72 NODE_LVAR,
73 NODE_DVAR,
74 NODE_GVAR,
75 NODE_IVAR,
76 NODE_CONST,
77 NODE_CVAR,
78 NODE_NTH_REF,
79 NODE_BACK_REF,
80 NODE_MATCH,
81 NODE_MATCH2,
82 NODE_MATCH3,
83 NODE_LIT,
84 NODE_STR,
85 NODE_DSTR,
86 NODE_XSTR,
87 NODE_DXSTR,
88 NODE_EVSTR,
89 NODE_DREGX,
90 NODE_ONCE,
91 NODE_ARGS,
92 NODE_ARGS_AUX,
93 NODE_OPT_ARG,
94 NODE_KW_ARG,
95 NODE_POSTARG,
96 NODE_ARGSCAT,
97 NODE_ARGSPUSH,
98 NODE_SPLAT,
99 NODE_BLOCK_PASS,
100 NODE_DEFN,
101 NODE_DEFS,
102 NODE_ALIAS,
103 NODE_VALIAS,
104 NODE_UNDEF,
105 NODE_CLASS,
106 NODE_MODULE,
107 NODE_SCLASS,
108 NODE_COLON2,
109 NODE_COLON3,
110 NODE_DOT2,
111 NODE_DOT3,
112 NODE_FLIP2,
113 NODE_FLIP3,
114 NODE_SELF,
115 NODE_NIL,
116 NODE_TRUE,
117 NODE_FALSE,
118 NODE_ERRINFO,
119 NODE_DEFINED,
120 NODE_POSTEXE,
121 NODE_DSYM,
122 NODE_ATTRASGN,
123 NODE_LAMBDA,
124 NODE_ARYPTN,
125 NODE_HSHPTN,
126 NODE_FNDPTN,
127 NODE_LAST
128};
129
130 typedef struct rb_code_position_struct {
131 int lineno;
132 int column;
133} rb_code_position_t;
134
135 typedef struct rb_code_location_struct {
136 rb_code_position_t beg_pos;
137 rb_code_position_t end_pos;
138} rb_code_location_t;
139
140static inline rb_code_location_t
141code_loc_gen(const rb_code_location_t *loc1, const rb_code_location_t *loc2)
142{
143 rb_code_location_t loc;
144 loc.beg_pos = loc1->beg_pos;
145 loc.end_pos = loc2->end_pos;
146 return loc;
147}
148
149 typedef struct RNode {
150 VALUE flags;
151 union {
152 struct RNode *node;
153 ID id;
154 VALUE value;
155 ID *tbl;
156 } u1;
157 union {
158 struct RNode *node;
159 ID id;
160 long argc;
161 VALUE value;
162 } u2;
163 union {
164 struct RNode *node;
165 ID id;
166 long state;
167 struct rb_args_info *args;
168 struct rb_ary_pattern_info *apinfo;
169 struct rb_fnd_pattern_info *fpinfo;
170 VALUE value;
171 } u3;
172 rb_code_location_t nd_loc;
173 int node_id;
174} NODE;
175
176#define RNODE(obj) ((struct RNode *)(obj))
177
178/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
179/* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,
180 * 8..14: nd_type,
181 * 15..: nd_line
182 */
183#define NODE_FL_NEWLINE (((VALUE)1)<<7)
184
185#define NODE_TYPESHIFT 8
186#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
187
188#define nd_type(n) ((int) (((n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
189#define nd_set_type(n,t) \
190 rb_node_set_type(n, t)
191#define nd_init_type(n,t) \
192 (n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
193
194#define NODE_LSHIFT (NODE_TYPESHIFT+7)
195#define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
196#define nd_line(n) (int)(((SIGNED_VALUE)(n)->flags)>>NODE_LSHIFT)
197#define nd_set_line(n,l) \
198 (n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
199
200#define nd_first_column(n) ((int)((n)->nd_loc.beg_pos.column))
201#define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v))
202#define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno))
203#define nd_set_first_lineno(n, v) ((n)->nd_loc.beg_pos.lineno = (v))
204#define nd_first_loc(n) ((n)->nd_loc.beg_pos)
205#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v))
206
207#define nd_last_column(n) ((int)((n)->nd_loc.end_pos.column))
208#define nd_set_last_column(n, v) ((n)->nd_loc.end_pos.column = (v))
209#define nd_last_lineno(n) ((int)((n)->nd_loc.end_pos.lineno))
210#define nd_set_last_lineno(n, v) ((n)->nd_loc.end_pos.lineno = (v))
211#define nd_last_loc(n) ((n)->nd_loc.end_pos)
212#define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
213#define nd_node_id(n) ((n)->node_id)
214#define nd_set_node_id(n,id) ((n)->node_id = (id))
215
216#define nd_head u1.node
217#define nd_alen u2.argc
218#define nd_next u3.node
219
220#define nd_cond u1.node
221#define nd_body u2.node
222#define nd_else u3.node
223
224#define nd_resq u2.node
225#define nd_ensr u3.node
226
227#define nd_1st u1.node
228#define nd_2nd u2.node
229
230#define nd_stts u1.node
231
232#define nd_entry u3.id
233#define nd_vid u1.id
234#define nd_cflag u2.id
235#define nd_cval u3.value
236
237#define nd_oid u1.id
238#define nd_tbl u1.tbl
239
240#define nd_var u1.node
241#define nd_iter u3.node
242
243#define nd_value u2.node
244#define nd_aid u3.id
245
246#define nd_lit u1.value
247
248#define nd_rest u1.id
249#define nd_opt u1.node
250#define nd_pid u1.id
251#define nd_plen u2.argc
252
253#define nd_recv u1.node
254#define nd_mid u2.id
255#define nd_args u3.node
256#define nd_ainfo u3.args
257
258#define nd_defn u3.node
259
260#define nd_cpath u1.node
261#define nd_super u3.node
262
263#define nd_beg u1.node
264#define nd_end u2.node
265#define nd_state u3.state
266#define nd_rval u2.value
267
268#define nd_nth u2.argc
269
270#define nd_tag u1.id
271
272#define nd_alias u1.id
273#define nd_orig u2.id
274#define nd_undef u2.node
275
276#define nd_brace u2.argc
277
278#define nd_pconst u1.node
279#define nd_pkwargs u2.node
280#define nd_pkwrestarg u3.node
281
282#define nd_apinfo u3.apinfo
283
284#define nd_fpinfo u3.fpinfo
285
286#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
287#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
288
289#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
290#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
291#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc)
292#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
293#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
294#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
295#define NEW_CASE(h,b,loc) NEW_NODE(NODE_CASE,h,b,0,loc)
296#define NEW_CASE2(b,loc) NEW_NODE(NODE_CASE2,0,b,0,loc)
297#define NEW_CASE3(h,b,loc) NEW_NODE(NODE_CASE3,h,b,0,loc)
298#define NEW_WHEN(c,t,e,loc) NEW_NODE(NODE_WHEN,c,t,e,loc)
299#define NEW_IN(c,t,e,loc) NEW_NODE(NODE_IN,c,t,e,loc)
300#define NEW_WHILE(c,b,n,loc) NEW_NODE(NODE_WHILE,c,b,n,loc)
301#define NEW_UNTIL(c,b,n,loc) NEW_NODE(NODE_UNTIL,c,b,n,loc)
302#define NEW_FOR(i,b,loc) NEW_NODE(NODE_FOR,0,b,i,loc)
303#define NEW_FOR_MASGN(v,loc) NEW_NODE(NODE_FOR_MASGN,v,0,0,loc)
304#define NEW_ITER(a,b,loc) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,loc),0,loc)
305#define NEW_LAMBDA(a,b,loc) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,loc),0,loc)
306#define NEW_BREAK(s,loc) NEW_NODE(NODE_BREAK,s,0,0,loc)
307#define NEW_NEXT(s,loc) NEW_NODE(NODE_NEXT,s,0,0,loc)
308#define NEW_REDO(loc) NEW_NODE(NODE_REDO,0,0,0,loc)
309#define NEW_RETRY(loc) NEW_NODE(NODE_RETRY,0,0,0,loc)
310#define NEW_BEGIN(b,loc) NEW_NODE(NODE_BEGIN,0,b,0,loc)
311#define NEW_RESCUE(b,res,e,loc) NEW_NODE(NODE_RESCUE,b,res,e,loc)
312#define NEW_RESBODY(a,ex,n,loc) NEW_NODE(NODE_RESBODY,n,ex,a,loc)
313#define NEW_ENSURE(b,en,loc) NEW_NODE(NODE_ENSURE,b,0,en,loc)
314#define NEW_RETURN(s,loc) NEW_NODE(NODE_RETURN,s,0,0,loc)
315#define NEW_YIELD(a,loc) NEW_NODE(NODE_YIELD,a,0,0,loc)
316#define NEW_LIST(a,loc) NEW_NODE(NODE_LIST,a,1,0,loc)
317#define NEW_ZLIST(loc) NEW_NODE(NODE_ZLIST,0,0,0,loc)
318#define NEW_HASH(a,loc) NEW_NODE(NODE_HASH,a,0,0,loc)
319#define NEW_MASGN(l,r,loc) NEW_NODE(NODE_MASGN,l,0,r,loc)
320#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,v,loc)
321#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
322#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
323#define NEW_DASGN_CURR(v,val,loc) NEW_NODE(NODE_DASGN_CURR,v,val,0,loc)
324#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
325#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
326#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
327#define NEW_OP_ASGN1(p,id,a,loc) NEW_NODE(NODE_OP_ASGN1,p,id,a,loc)
328#define NEW_OP_ASGN2(r,t,i,o,val,loc) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
329#define NEW_OP_ASGN22(i,o,t,loc) NEW_NODE(NODE_OP_ASGN2,i,o,t,loc)
330#define NEW_OP_ASGN_OR(i,val,loc) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,loc)
331#define NEW_OP_ASGN_AND(i,val,loc) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,loc)
332#define NEW_OP_CDECL(v,op,val,loc) NEW_NODE(NODE_OP_CDECL,v,val,op,loc)
333#define NEW_GVAR(v,loc) NEW_NODE(NODE_GVAR,v,0,v,loc)
334#define NEW_LVAR(v,loc) NEW_NODE(NODE_LVAR,v,0,0,loc)
335#define NEW_DVAR(v,loc) NEW_NODE(NODE_DVAR,v,0,0,loc)
336#define NEW_IVAR(v,loc) NEW_NODE(NODE_IVAR,v,0,0,loc)
337#define NEW_CONST(v,loc) NEW_NODE(NODE_CONST,v,0,0,loc)
338#define NEW_CVAR(v,loc) NEW_NODE(NODE_CVAR,v,0,0,loc)
339#define NEW_NTH_REF(n,loc) NEW_NODE(NODE_NTH_REF,0,n,0,loc)
340#define NEW_BACK_REF(n,loc) NEW_NODE(NODE_BACK_REF,0,n,0,loc)
341#define NEW_MATCH(c,loc) NEW_NODE(NODE_MATCH,c,0,0,loc)
342#define NEW_MATCH2(n1,n2,loc) NEW_NODE(NODE_MATCH2,n1,n2,0,loc)
343#define NEW_MATCH3(r,n2,loc) NEW_NODE(NODE_MATCH3,r,n2,0,loc)
344#define NEW_LIT(l,loc) NEW_NODE(NODE_LIT,l,0,0,loc)
345#define NEW_STR(s,loc) NEW_NODE(NODE_STR,s,0,0,loc)
346#define NEW_DSTR(s,loc) NEW_NODE(NODE_DSTR,s,1,0,loc)
347#define NEW_XSTR(s,loc) NEW_NODE(NODE_XSTR,s,0,0,loc)
348#define NEW_DXSTR(s,loc) NEW_NODE(NODE_DXSTR,s,0,0,loc)
349#define NEW_DSYM(s,loc) NEW_NODE(NODE_DSYM,s,0,0,loc)
350#define NEW_EVSTR(n,loc) NEW_NODE(NODE_EVSTR,0,(n),0,loc)
351#define NEW_CALL(r,m,a,loc) NEW_NODE(NODE_CALL,r,m,a,loc)
352#define NEW_OPCALL(r,m,a,loc) NEW_NODE(NODE_OPCALL,r,m,a,loc)
353#define NEW_FCALL(m,a,loc) NEW_NODE(NODE_FCALL,0,m,a,loc)
354#define NEW_VCALL(m,loc) NEW_NODE(NODE_VCALL,0,m,0,loc)
355#define NEW_SUPER(a,loc) NEW_NODE(NODE_SUPER,0,0,a,loc)
356#define NEW_ZSUPER(loc) NEW_NODE(NODE_ZSUPER,0,0,0,loc)
357#define NEW_ARGS_AUX(r,b,loc) NEW_NODE(NODE_ARGS_AUX,r,b,0,loc)
358#define NEW_OPT_ARG(i,v,loc) NEW_NODE(NODE_OPT_ARG,i,v,0,loc)
359#define NEW_KW_ARG(i,v,loc) NEW_NODE(NODE_KW_ARG,i,v,0,loc)
360#define NEW_POSTARG(i,v,loc) NEW_NODE(NODE_POSTARG,i,v,0,loc)
361#define NEW_ARGSCAT(a,b,loc) NEW_NODE(NODE_ARGSCAT,a,b,0,loc)
362#define NEW_ARGSPUSH(a,b,loc) NEW_NODE(NODE_ARGSPUSH,a,b,0,loc)
363#define NEW_SPLAT(a,loc) NEW_NODE(NODE_SPLAT,a,0,0,loc)
364#define NEW_BLOCK_PASS(b,loc) NEW_NODE(NODE_BLOCK_PASS,0,b,0,loc)
365#define NEW_ALIAS(n,o,loc) NEW_NODE(NODE_ALIAS,n,o,0,loc)
366#define NEW_VALIAS(n,o,loc) NEW_NODE(NODE_VALIAS,n,o,0,loc)
367#define NEW_UNDEF(i,loc) NEW_NODE(NODE_UNDEF,0,i,0,loc)
368#define NEW_CLASS(n,b,s,loc) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,loc),(s),loc)
369#define NEW_SCLASS(r,b,loc) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,loc),0,loc)
370#define NEW_MODULE(n,b,loc) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,loc),0,loc)
371#define NEW_COLON2(c,i,loc) NEW_NODE(NODE_COLON2,c,i,0,loc)
372#define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc)
373#define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc)
374#define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc)
375#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,1,loc)
376#define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc)
377#define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc)
378#define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc)
379#define NEW_ERRINFO(loc) NEW_NODE(NODE_ERRINFO,0,0,0,loc)
380#define NEW_DEFINED(e,loc) NEW_NODE(NODE_DEFINED,e,0,0,loc)
381#define NEW_PREEXE(b,loc) NEW_SCOPE(b,loc)
382#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
383#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
384
385#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
386#define NODE_REQUIRED_KEYWORD_P(node) ((node)->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD)
387#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
388#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
389#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
390#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
391
392 VALUE rb_node_case_when_optimizable_literal(const NODE *const node);
393
394RUBY_SYMBOL_EXPORT_BEGIN
395
396 typedef struct node_buffer_struct node_buffer_t;
397/* T_IMEMO/ast */
398 typedef struct rb_ast_body_struct {
399 const NODE *root;
400 VALUE compile_option;
401 int line_count;
402} rb_ast_body_t;
403 typedef struct rb_ast_struct {
404 VALUE flags;
405 node_buffer_t *node_buffer;
406 rb_ast_body_t body;
407} rb_ast_t;
408 rb_ast_t *rb_ast_new(void);
409void rb_ast_mark(rb_ast_t*);
410void rb_ast_update_references(rb_ast_t*);
411void rb_ast_add_local_table(rb_ast_t*, ID *buf);
412void rb_ast_dispose(rb_ast_t*);
413void rb_ast_free(rb_ast_t*);
414size_t rb_ast_memsize(const rb_ast_t*);
415void rb_ast_add_mark_object(rb_ast_t*, VALUE);
416 NODE *rb_ast_newnode(rb_ast_t*, enum node_type type);
417void rb_ast_delete_node(rb_ast_t*, NODE *n);
418
419 VALUE rb_parser_new(void);
420 VALUE rb_parser_end_seen_p(VALUE);
421 VALUE rb_parser_encoding(VALUE);
422 VALUE rb_parser_set_yydebug(VALUE, VALUE);
423 VALUE rb_parser_dump_tree(const NODE *node, int comment);
424void rb_parser_set_options(VALUE, int, int, int, int);
425
426 rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
427 rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
428 rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
429 rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
430
431void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
432const char *ruby_node_name(int node);
433
434const struct kwtable *rb_reserved_word(const char *, unsigned int);
435
436 struct rb_args_info {
437 NODE *pre_init;
438 NODE *post_init;
439
440 int pre_args_num; /* count of mandatory pre-arguments */
441 int post_args_num; /* count of mandatory post-arguments */
442
443 ID first_post_arg;
444
445 ID rest_arg;
446 ID block_arg;
447
448 NODE *kw_args;
449 NODE *kw_rest_arg;
450
451 NODE *opt_args;
452 unsigned int no_kwarg: 1;
453 unsigned int ruby2_keywords: 1;
454
455 VALUE imemo;
456};
457
458 struct rb_ary_pattern_info {
459 NODE *pre_args;
460 NODE *rest_arg;
461 NODE *post_args;
462};
463
464 struct rb_fnd_pattern_info {
465 NODE *pre_rest_arg;
466 NODE *args;
467 NODE *post_rest_arg;
468};
469
470struct parser_params;
471void *rb_parser_malloc(struct parser_params *, size_t);
472void *rb_parser_realloc(struct parser_params *, void *, size_t);
473void *rb_parser_calloc(struct parser_params *, size_t, size_t);
474void rb_parser_free(struct parser_params *, void *);
475 PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
476void rb_ast_node_type_change(NODE *n, enum node_type type);
477
478RUBY_SYMBOL_EXPORT_END
479
480static inline VALUE
481rb_node_set_type(NODE *n, enum node_type t)
482{
483#if RUBY_DEBUG
484 rb_ast_node_type_change(n, t);
485#endif
486 return nd_init_type(n, t);
487}
488
489#if defined(__cplusplus)
490#if 0
491{ /* satisfy cc-mode */
492#endif
493} /* extern "C" { */
494#endif
495
496#endif /* RUBY_NODE_H */
PRINTF_ARGS
#define PRINTF_ARGS(decl, string_index, first_to_check)
Definition: attributes.h:112
buf
voidpf void * buf
Definition: ioapi.h:138
rb_reserved_word
#define rb_reserved_word(str, len)
Definition: lex.c:38
input
unsigned int input
Definition: nkf.c:4325
rb_code_location_t
struct rb_code_location_struct rb_code_location_t
rb_parser_encoding
VALUE rb_parser_encoding(VALUE)
Definition: ripper.c:20854
rb_ast_dispose
void rb_ast_dispose(rb_ast_t *)
Definition: node.c:1448
rb_parser_compile_file_path
rb_ast_t * rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line)
Definition: ripper.c:14029
rb_node_init
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
Definition: node.c:1139
rb_parser_dump_tree
VALUE rb_parser_dump_tree(const NODE *node, int comment)
Definition: node.c:1120
rb_ast_t
struct rb_ast_struct rb_ast_t
rb_parser_free
void rb_parser_free(struct parser_params *, void *)
Definition: ripper.c:20975
rb_ast_newnode
NODE * rb_ast_newnode(rb_ast_t *, enum node_type type)
Definition: node.c:1264
rb_parser_new
VALUE rb_parser_new(void)
Definition: ripper.c:20781
rb_parser_malloc
void * rb_parser_malloc(struct parser_params *, size_t)
Definition: ripper.c:20935
rb_parser_calloc
void * rb_parser_calloc(struct parser_params *, size_t, size_t)
Definition: ripper.c:20945
NODE
struct RNode NODE
rb_ast_new
rb_ast_t * rb_ast_new(void)
Definition: node.c:1299
rb_ast_free
void rb_ast_free(rb_ast_t *)
Definition: node.c:1413
node_type
node_type
Definition: node.h:21
NODE_OR
@ NODE_OR
Definition: node.h:45
NODE_LVAR
@ NODE_LVAR
Definition: node.h:72
NODE_FOR
@ NODE_FOR
Definition: node.h:34
NODE_OP_ASGN_OR
@ NODE_OP_ASGN_OR
Definition: node.h:57
NODE_SPLAT
@ NODE_SPLAT
Definition: node.h:98
NODE_DEFS
@ NODE_DEFS
Definition: node.h:101
NODE_REDO
@ NODE_REDO
Definition: node.h:38
NODE_IN
@ NODE_IN
Definition: node.h:30
NODE_MATCH
@ NODE_MATCH
Definition: node.h:80
NODE_MATCH2
@ NODE_MATCH2
Definition: node.h:81
NODE_STR
@ NODE_STR
Definition: node.h:84
NODE_DSYM
@ NODE_DSYM
Definition: node.h:121
NODE_DASGN_CURR
@ NODE_DASGN_CURR
Definition: node.h:49
NODE_LIST
@ NODE_LIST
Definition: node.h:66
NODE_CVAR
@ NODE_CVAR
Definition: node.h:77
NODE_NEXT
@ NODE_NEXT
Definition: node.h:37
NODE_MODULE
@ NODE_MODULE
Definition: node.h:106
NODE_ARGSCAT
@ NODE_ARGSCAT
Definition: node.h:96
NODE_DASGN
@ NODE_DASGN
Definition: node.h:48
NODE_LASGN
@ NODE_LASGN
Definition: node.h:47
NODE_AND
@ NODE_AND
Definition: node.h:44
NODE_MASGN
@ NODE_MASGN
Definition: node.h:46
NODE_CLASS
@ NODE_CLASS
Definition: node.h:105
NODE_CVASGN
@ NODE_CVASGN
Definition: node.h:53
NODE_CALL
@ NODE_CALL
Definition: node.h:59
NODE_OP_ASGN2
@ NODE_OP_ASGN2
Definition: node.h:55
NODE_FALSE
@ NODE_FALSE
Definition: node.h:117
NODE_FLIP2
@ NODE_FLIP2
Definition: node.h:112
NODE_EVSTR
@ NODE_EVSTR
Definition: node.h:88
NODE_DVAR
@ NODE_DVAR
Definition: node.h:73
NODE_ATTRASGN
@ NODE_ATTRASGN
Definition: node.h:122
NODE_BEGIN
@ NODE_BEGIN
Definition: node.h:40
NODE_UNTIL
@ NODE_UNTIL
Definition: node.h:32
NODE_FCALL
@ NODE_FCALL
Definition: node.h:61
NODE_MATCH3
@ NODE_MATCH3
Definition: node.h:82
NODE_LAST
@ NODE_LAST
Definition: node.h:127
NODE_SUPER
@ NODE_SUPER
Definition: node.h:64
NODE_CASE2
@ NODE_CASE2
Definition: node.h:27
NODE_DXSTR
@ NODE_DXSTR
Definition: node.h:87
NODE_IASGN
@ NODE_IASGN
Definition: node.h:51
NODE_GASGN
@ NODE_GASGN
Definition: node.h:50
NODE_OP_CDECL
@ NODE_OP_CDECL
Definition: node.h:58
NODE_RESCUE
@ NODE_RESCUE
Definition: node.h:41
NODE_SCOPE
@ NODE_SCOPE
Definition: node.h:22
NODE_SCLASS
@ NODE_SCLASS
Definition: node.h:107
NODE_HASH
@ NODE_HASH
Definition: node.h:69
NODE_YIELD
@ NODE_YIELD
Definition: node.h:71
NODE_LAMBDA
@ NODE_LAMBDA
Definition: node.h:123
NODE_CDECL
@ NODE_CDECL
Definition: node.h:52
NODE_OP_ASGN_AND
@ NODE_OP_ASGN_AND
Definition: node.h:56
NODE_BLOCK
@ NODE_BLOCK
Definition: node.h:23
NODE_TRUE
@ NODE_TRUE
Definition: node.h:116
NODE_ARGS_AUX
@ NODE_ARGS_AUX
Definition: node.h:92
NODE_CASE
@ NODE_CASE
Definition: node.h:26
NODE_ITER
@ NODE_ITER
Definition: node.h:33
NODE_RETRY
@ NODE_RETRY
Definition: node.h:39
NODE_DOT3
@ NODE_DOT3
Definition: node.h:111
NODE_RETURN
@ NODE_RETURN
Definition: node.h:70
NODE_BACK_REF
@ NODE_BACK_REF
Definition: node.h:79
NODE_QCALL
@ NODE_QCALL
Definition: node.h:63
NODE_ENSURE
@ NODE_ENSURE
Definition: node.h:43
NODE_SELF
@ NODE_SELF
Definition: node.h:114
NODE_DOT2
@ NODE_DOT2
Definition: node.h:110
NODE_OPT_ARG
@ NODE_OPT_ARG
Definition: node.h:93
NODE_FNDPTN
@ NODE_FNDPTN
Definition: node.h:126
NODE_LIT
@ NODE_LIT
Definition: node.h:83
NODE_UNDEF
@ NODE_UNDEF
Definition: node.h:104
NODE_FLIP3
@ NODE_FLIP3
Definition: node.h:113
NODE_POSTARG
@ NODE_POSTARG
Definition: node.h:95
NODE_NTH_REF
@ NODE_NTH_REF
Definition: node.h:78
NODE_VCALL
@ NODE_VCALL
Definition: node.h:62
NODE_KW_ARG
@ NODE_KW_ARG
Definition: node.h:94
NODE_DEFN
@ NODE_DEFN
Definition: node.h:100
NODE_GVAR
@ NODE_GVAR
Definition: node.h:74
NODE_ALIAS
@ NODE_ALIAS
Definition: node.h:102
NODE_COLON2
@ NODE_COLON2
Definition: node.h:108
NODE_POSTEXE
@ NODE_POSTEXE
Definition: node.h:120
NODE_IVAR
@ NODE_IVAR
Definition: node.h:75
NODE_ERRINFO
@ NODE_ERRINFO
Definition: node.h:118
NODE_BLOCK_PASS
@ NODE_BLOCK_PASS
Definition: node.h:99
NODE_ZSUPER
@ NODE_ZSUPER
Definition: node.h:65
NODE_DREGX
@ NODE_DREGX
Definition: node.h:89
NODE_DEFINED
@ NODE_DEFINED
Definition: node.h:119
NODE_ONCE
@ NODE_ONCE
Definition: node.h:90
NODE_IF
@ NODE_IF
Definition: node.h:24
NODE_HSHPTN
@ NODE_HSHPTN
Definition: node.h:125
NODE_ZLIST
@ NODE_ZLIST
Definition: node.h:67
NODE_ARYPTN
@ NODE_ARYPTN
Definition: node.h:124
NODE_XSTR
@ NODE_XSTR
Definition: node.h:86
NODE_BREAK
@ NODE_BREAK
Definition: node.h:36
NODE_UNLESS
@ NODE_UNLESS
Definition: node.h:25
NODE_VALIAS
@ NODE_VALIAS
Definition: node.h:103
NODE_WHEN
@ NODE_WHEN
Definition: node.h:29
NODE_CASE3
@ NODE_CASE3
Definition: node.h:28
NODE_COLON3
@ NODE_COLON3
Definition: node.h:109
NODE_CONST
@ NODE_CONST
Definition: node.h:76
NODE_NIL
@ NODE_NIL
Definition: node.h:115
NODE_VALUES
@ NODE_VALUES
Definition: node.h:68
NODE_RESBODY
@ NODE_RESBODY
Definition: node.h:42
NODE_DSTR
@ NODE_DSTR
Definition: node.h:85
NODE_FOR_MASGN
@ NODE_FOR_MASGN
Definition: node.h:35
NODE_WHILE
@ NODE_WHILE
Definition: node.h:31
NODE_ARGSPUSH
@ NODE_ARGSPUSH
Definition: node.h:97
NODE_OP_ASGN1
@ NODE_OP_ASGN1
Definition: node.h:54
NODE_OPCALL
@ NODE_OPCALL
Definition: node.h:60
NODE_ARGS
@ NODE_ARGS
Definition: node.h:91
rb_ast_body_t
struct rb_ast_body_struct rb_ast_body_t
rb_parser_end_seen_p
VALUE rb_parser_end_seen_p(VALUE)
Definition: ripper.c:20839
rb_parser_printf
void rb_parser_printf(struct parser_params *parser, const char *fmt,...)
Definition: ripper.c:20992
rb_code_position_t
struct rb_code_position_struct rb_code_position_t
rb_ast_add_mark_object
void rb_ast_add_mark_object(rb_ast_t *, VALUE)
Definition: node.c:1454
rb_ast_mark
void rb_ast_mark(rb_ast_t *)
Definition: node.c:1401
rb_ast_update_references
void rb_ast_update_references(rb_ast_t *)
Definition: node.c:1391
rb_parser_set_options
void rb_parser_set_options(VALUE, int, int, int, int)
Definition: ripper.c:20599
rb_ast_node_type_change
void rb_ast_node_type_change(NODE *n, enum node_type type)
Definition: node.c:1273
rb_node_case_when_optimizable_literal
VALUE rb_node_case_when_optimizable_literal(const NODE *const node)
Definition: compile.c:4480
rb_parser_set_yydebug
VALUE rb_parser_set_yydebug(VALUE, VALUE)
Definition: ripper.c:20886
ruby_node_name
const char * ruby_node_name(int node)
Definition: iseq.c:2593
rb_ast_add_local_table
void rb_ast_add_local_table(rb_ast_t *, ID *buf)
Definition: node.c:1283
rb_ast_memsize
size_t rb_ast_memsize(const rb_ast_t *)
Definition: node.c:1434
rb_parser_compile_generic
rb_ast_t * rb_parser_compile_generic(VALUE vparser, VALUE(*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line)
Definition: ripper.c:14049
rb_parser_compile_string
rb_ast_t * rb_parser_compile_string(VALUE, const char *, VALUE, int)
Definition: ripper.c:14008
nd_init_type
#define nd_init_type(n, t)
Definition: node.h:191
rb_parser_compile_string_path
rb_ast_t * rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line)
Definition: ripper.c:14014
rb_ast_delete_node
void rb_ast_delete_node(rb_ast_t *, NODE *n)
Definition: node.c:1291
rb_parser_realloc
void * rb_parser_realloc(struct parser_params *, void *, size_t)
Definition: ripper.c:20955
RNode
Definition: node.h:149
RNode::nd_loc
rb_code_location_t nd_loc
Definition: node.h:172
RNode::args
struct rb_args_info * args
Definition: node.h:167
RNode::node_id
int node_id
Definition: node.h:173
RNode::fpinfo
struct rb_fnd_pattern_info * fpinfo
Definition: node.h:169
RNode::flags
VALUE flags
Definition: node.h:150
RNode::apinfo
struct rb_ary_pattern_info * apinfo
Definition: node.h:168
RNode::u2
union RNode::@128 u2
RNode::argc
long argc
Definition: node.h:160
RNode::node
struct RNode * node
Definition: node.h:152
RNode::value
VALUE value
Definition: node.h:154
RNode::id
ID id
Definition: node.h:153
RNode::state
long state
Definition: node.h:166
RNode::tbl
ID * tbl
Definition: node.h:155
RNode::u1
union RNode::@127 u1
RNode::u3
union RNode::@129 u3
kwtable
Definition: lex.c:34
node_buffer_struct
Definition: node.c:1164
parser_params
Definition: ripper.c:317
rb_args_info
Definition: node.h:436
rb_args_info::block_arg
ID block_arg
Definition: node.h:446
rb_args_info::pre_init
NODE * pre_init
Definition: node.h:437
rb_args_info::post_args_num
int post_args_num
Definition: node.h:441
rb_args_info::first_post_arg
ID first_post_arg
Definition: node.h:443
rb_args_info::kw_args
NODE * kw_args
Definition: node.h:448
rb_args_info::ruby2_keywords
unsigned int ruby2_keywords
Definition: node.h:453
rb_args_info::imemo
VALUE imemo
Definition: node.h:455
rb_args_info::opt_args
NODE * opt_args
Definition: node.h:451
rb_args_info::rest_arg
ID rest_arg
Definition: node.h:445
rb_args_info::kw_rest_arg
NODE * kw_rest_arg
Definition: node.h:449
rb_args_info::post_init
NODE * post_init
Definition: node.h:438
rb_args_info::no_kwarg
unsigned int no_kwarg
Definition: node.h:452
rb_args_info::pre_args_num
int pre_args_num
Definition: node.h:440
rb_ary_pattern_info
Definition: node.h:458
rb_ary_pattern_info::rest_arg
NODE * rest_arg
Definition: node.h:460
rb_ary_pattern_info::post_args
NODE * post_args
Definition: node.h:461
rb_ary_pattern_info::pre_args
NODE * pre_args
Definition: node.h:459
rb_ast_body_struct
Definition: node.h:398
rb_ast_body_struct::root
const NODE * root
Definition: node.h:399
rb_ast_body_struct::compile_option
VALUE compile_option
Definition: node.h:400
rb_ast_body_struct::line_count
int line_count
Definition: node.h:401
rb_ast_struct
Definition: node.h:403
rb_ast_struct::body
rb_ast_body_t body
Definition: node.h:406
rb_ast_struct::node_buffer
node_buffer_t * node_buffer
Definition: node.h:405
rb_ast_struct::flags
VALUE flags
Definition: node.h:404
rb_code_location_struct
Definition: node.h:135
rb_code_location_struct::beg_pos
rb_code_position_t beg_pos
Definition: node.h:136
rb_code_location_struct::end_pos
rb_code_position_t end_pos
Definition: node.h:137
rb_code_position_struct
Definition: node.h:130
rb_code_position_struct::lineno
int lineno
Definition: node.h:131
rb_code_position_struct::column
int column
Definition: node.h:132
rb_fnd_pattern_info
Definition: node.h:464
rb_fnd_pattern_info::post_rest_arg
NODE * post_rest_arg
Definition: node.h:467
rb_fnd_pattern_info::args
NODE * args
Definition: node.h:466
rb_fnd_pattern_info::pre_rest_arg
NODE * pre_rest_arg
Definition: node.h:465
t
#define t
Definition: symbol.c:253
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39