1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

rename variables

* vm.c (vm_collect_local_variables_in_heap): rename an argument.

* vm_eval.c (rb_f_local_variables): rename a local variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-05-07 02:00:28 +00:00
parent f83660163d
commit c60e282b30
2 changed files with 11 additions and 11 deletions

12
vm.c
View file

@ -516,24 +516,24 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp,
}
static int
collect_local_variables_in_iseq(rb_iseq_t *iseq, const VALUE ary)
collect_local_variables_in_iseq(rb_iseq_t *iseq, const VALUE vars)
{
int i;
if (!iseq) return 0;
for (i = 0; i < iseq->local_table_size; i++) {
ID lid = iseq->local_table[i];
if (rb_is_local_id(lid)) {
rb_ary_push(ary, ID2SYM(lid));
rb_ary_push(vars, ID2SYM(lid));
}
}
return 1;
}
static int
collect_local_variables_in_env(rb_env_t * env, const VALUE ary)
collect_local_variables_in_env(rb_env_t *env, const VALUE vars)
{
while (collect_local_variables_in_iseq(env->block.iseq, ary),
while (collect_local_variables_in_iseq(env->block.iseq, vars),
env->prev_envval) {
GetEnvPtr(env->prev_envval, env);
}
@ -541,12 +541,12 @@ collect_local_variables_in_env(rb_env_t * env, const VALUE ary)
}
static int
vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *ep, VALUE ary)
vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *ep, VALUE vars)
{
if (ENV_IN_HEAP_P(th, ep)) {
rb_env_t *env;
GetEnvPtr(ENV_VAL(ep), env);
collect_local_variables_in_env(env, ary);
collect_local_variables_in_env(env, vars);
return 1;
}
else {

View file

@ -18,7 +18,7 @@ static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *
static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr);
static VALUE vm_exec(rb_thread_t *th);
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE vars);
/* vm_backtrace.c */
VALUE rb_vm_backtrace_str_ary(rb_thread_t *th, int lev, int n);
@ -1886,7 +1886,7 @@ rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr)
static VALUE
rb_f_local_variables(void)
{
VALUE ary = rb_ary_new();
VALUE vars = rb_ary_new();
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp =
vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp));
@ -1900,7 +1900,7 @@ rb_f_local_variables(void)
const char *vname = rb_id2name(lid);
/* should skip temporary variable */
if (vname) {
rb_ary_push(ary, ID2SYM(lid));
rb_ary_push(vars, ID2SYM(lid));
}
}
}
@ -1909,7 +1909,7 @@ rb_f_local_variables(void)
/* block */
VALUE *ep = VM_CF_PREV_EP(cfp);
if (vm_collect_local_variables_in_heap(th, ep, ary)) {
if (vm_collect_local_variables_in_heap(th, ep, vars)) {
break;
}
else {
@ -1922,7 +1922,7 @@ rb_f_local_variables(void)
break;
}
}
return ary;
return vars;
}
/*