diff options
author | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-05 02:13:45 +0000 |
---|---|---|
committer | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-05 02:13:45 +0000 |
commit | ce798d08de38a89852017bfefe44708b97121d74 (patch) | |
tree | f15bcecacdd4f2cd8a5b3890d77fa1c83f5440a6 /parse.y | |
parent | 6d497629b22f67bcaa4d074e0bee728808cfd4be (diff) |
Implement `RubyVM::AST.of` [Feature #14836]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -234,6 +234,7 @@ struct parser_params { ID cur_arg; rb_ast_t *ast; + int node_id; unsigned int command_start:1; unsigned int eofp: 1; @@ -339,6 +340,14 @@ static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, static NODE *nd_set_loc(NODE *nd, const YYLTYPE *loc); +static int +parser_get_node_id(struct parser_params *p) +{ + int node_id = p->node_id; + p->node_id++; + return node_id; +} + #ifndef RIPPER static inline void set_line_body(NODE *body, int line) @@ -8294,6 +8303,7 @@ node_newnode(struct parser_params *p, enum node_type type, VALUE a0, VALUE a1, V rb_node_init(n, type, a0, a1, a2); nd_set_loc(n, loc); + nd_set_node_id(n, parser_get_node_id(p)); return n; } @@ -10774,6 +10784,7 @@ parser_initialize(struct parser_params *p) p->command_start = TRUE; p->ruby_sourcefile_string = Qnil; p->lex.lpar_beg = -1; /* make lambda_beginning_p() == FALSE at first */ + p->node_id = 0; #ifdef RIPPER p->delayed = Qnil; p->result = Qnil; |