diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-06 14:28:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-06 14:28:48 +0000 |
commit | d750b62d66d812c3c946ce74be60e5b2c890d474 (patch) | |
tree | 397bb815a9d27e7af21126cf74ffc7dc85848ef7 /parse.y | |
parent | 8a57bb7b4a42c7676a63efa17c86c2a9678f9ed2 (diff) |
parse.y: remove duplicated names
* parse.y (local_tbl_gen): remove local variables duplicated with
arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 31 |
1 files changed, 13 insertions, 18 deletions
@@ -9715,30 +9715,25 @@ local_pop_gen(struct parser_params *parser) #ifndef RIPPER static ID* -vtable_tblcpy(ID *buf, const struct vtable *src) -{ - int i, cnt = vtable_size(src); - - if (cnt > 0) { - buf[0] = cnt; - for (i = 0; i < cnt; i++) { - buf[i] = src->tbl[i]; - } - return buf; - } - return 0; -} - -static ID* local_tbl_gen(struct parser_params *parser) { - int cnt = vtable_size(lvtbl->args) + vtable_size(lvtbl->vars); + int cnt_args = vtable_size(lvtbl->args); + int cnt_vars = vtable_size(lvtbl->vars); + int cnt = cnt_args + cnt_vars; + int i, j; ID *buf; if (cnt <= 0) return 0; buf = ALLOC_N(ID, cnt + 1); - vtable_tblcpy(buf+1, lvtbl->args); - vtable_tblcpy(buf+vtable_size(lvtbl->args)+1, lvtbl->vars); + MEMCPY(buf+1, lvtbl->args->tbl, ID, cnt_args); + /* remove IDs duplicated to warn shadowing */ + for (i = 0, j = cnt_args+1; i < cnt_vars; ++i) { + ID id = lvtbl->vars->tbl[i]; + if (!vtable_included(lvtbl->args, id)) { + buf[j++] = id; + } + } + if (--j < cnt) REALLOC_N(buf, ID, (cnt = j) + 1); buf[0] = cnt; return buf; } |