summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-05 02:13:45 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-05 02:13:45 +0000
commitce798d08de38a89852017bfefe44708b97121d74 (patch)
treef15bcecacdd4f2cd8a5b3890d77fa1c83f5440a6 /parse.y
parent6d497629b22f67bcaa4d074e0bee728808cfd4be (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.y11
1 files changed, 11 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 8dcc25bfea..aed392822e 100644
--- a/parse.y
+++ b/parse.y
@@ -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;