* parse.y (parser_params): turn in_def and in_single into bit
  flags and reduce the size by 2-words.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-08-07 12:04:22 +00:00
Родитель ebdf35e1e4
Коммит 48baa71ec6
2 изменённых файлов: 23 добавлений и 19 удалений

Просмотреть файл

@ -1,4 +1,7 @@
Fri Aug 7 17:30:19 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Aug 7 21:04:19 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_params): turn in_def and in_single into bit
flags and reduce the size by 2-words.
* parse.y (parser_params): remove redundant prefixes. * parse.y (parser_params): remove redundant prefixes.

37
parse.y
Просмотреть файл

@ -250,8 +250,6 @@ struct parser_params {
} lex; } lex;
stack_type cond_stack; stack_type cond_stack;
stack_type cmdarg_stack; stack_type cmdarg_stack;
int in_single; /* counter */
int in_def; /* counter */
int tokidx; int tokidx;
int toksiz; int toksiz;
int tokline; int tokline;
@ -277,6 +275,8 @@ struct parser_params {
unsigned int in_defined: 1; unsigned int in_defined: 1;
unsigned int compile_for_eval: 1; unsigned int compile_for_eval: 1;
unsigned int in_kwarg: 1; unsigned int in_kwarg: 1;
unsigned int in_single: 1;
unsigned int in_def: 1;
#ifndef RIPPER #ifndef RIPPER
/* Ruby core only */ /* Ruby core only */
@ -2956,27 +2956,24 @@ primary : literal
} }
| k_class tLSHFT expr | k_class tLSHFT expr
{ {
$<num>$ = in_def; $<num>$ = (in_def << 1) | in_single;
in_def = 0; in_def = 0;
}
term
{
$<num>$ = in_single;
in_single = 0; in_single = 0;
local_push(0); local_push(0);
} }
term
bodystmt bodystmt
k_end k_end
{ {
/*%%%*/ /*%%%*/
$$ = NEW_SCLASS($3, $7); $$ = NEW_SCLASS($3, $6);
fixpos($$, $3); fixpos($$, $3);
/*% /*%
$$ = dispatch2(sclass, $3, $7); $$ = dispatch2(sclass, $3, $6);
%*/ %*/
local_pop(); local_pop();
in_def = $<num>4; in_def = ($<num>4 >> 1) & 1;
in_single = $<num>6; in_single = $<num>4 & 1;
} }
| k_module cpath | k_module cpath
{ {
@ -3001,30 +2998,34 @@ primary : literal
} }
| k_def fname | k_def fname
{ {
in_def++;
local_push(0); local_push(0);
$<id>$ = current_arg; $<id>$ = current_arg;
current_arg = 0; current_arg = 0;
} }
{
$<num>$ = in_def;
in_def = 1;
}
f_arglist f_arglist
bodystmt bodystmt
k_end k_end
{ {
/*%%%*/ /*%%%*/
NODE *body = remove_begin($5); NODE *body = remove_begin($6);
reduce_nodes(&body); reduce_nodes(&body);
$$ = NEW_DEFN($2, $4, body, METHOD_VISI_PRIVATE); $$ = NEW_DEFN($2, $5, body, METHOD_VISI_PRIVATE);
nd_set_line($$, $<num>1); nd_set_line($$, $<num>1);
/*% /*%
$$ = dispatch3(def, $2, $4, $5); $$ = dispatch3(def, $2, $5, $6);
%*/ %*/
local_pop(); local_pop();
in_def--; in_def = $<num>4 & 1;
current_arg = $<id>3; current_arg = $<id>3;
} }
| k_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname | k_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
{ {
in_single++; $<num>4 = in_single;
in_single = 1;
lex_state = EXPR_ENDFN; /* force for args */ lex_state = EXPR_ENDFN; /* force for args */
local_push(0); local_push(0);
$<id>$ = current_arg; $<id>$ = current_arg;
@ -3043,7 +3044,7 @@ primary : literal
$$ = dispatch5(defs, $2, $3, $5, $7, $8); $$ = dispatch5(defs, $2, $3, $5, $7, $8);
%*/ %*/
local_pop(); local_pop();
in_single--; in_single = $<num>4 & 1;
current_arg = $<id>6; current_arg = $<id>6;
} }
| keyword_break | keyword_break