diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-13 09:10:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-13 09:10:40 +0000 |
commit | 2a754a733045da9965e88d1f31e650ea6b3f2b6c (patch) | |
tree | 4efdda77eca0999f3a35a2ec20002432af2e265b | |
parent | 787b98e365e597e1ba8e9ec9b53fecb7f03688eb (diff) | |
download | ruby-2a754a733045da9965e88d1f31e650ea6b3f2b6c.tar.gz |
proc.c: make lambda directly
* vm.c (rb_vm_make_proc_lambda): similar to rb_vm_make_proc() with
is_lambda argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | proc.c | 13 | ||||
-rw-r--r-- | vm.c | 8 | ||||
-rw-r--r-- | vm_core.h | 1 |
4 files changed, 15 insertions, 12 deletions
@@ -1,3 +1,8 @@ +Thu Nov 13 18:10:38 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm.c (rb_vm_make_proc_lambda): similar to rb_vm_make_proc() with + is_lambda argument. + Thu Nov 13 12:11:18 2014 NAKAMURA Usaku <usa@ruby-lang.org> * rb_w32_fstat{,i64}: speed up. adjuting timestamps in this function @@ -566,10 +566,7 @@ proc_new(VALUE klass, int is_lambda) rb_control_frame_t *cfp = th->cfp; rb_block_t *block; - if ((block = rb_vm_control_frame_block_ptr(cfp)) != 0) { - /* block found */ - } - else { + if (!(block = rb_vm_control_frame_block_ptr(cfp))) { cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); if ((block = rb_vm_control_frame_block_ptr(cfp)) != 0) { @@ -596,13 +593,7 @@ proc_new(VALUE klass, int is_lambda) } } - procval = rb_vm_make_proc(th, block, klass); - - if (is_lambda) { - rb_proc_t *proc; - GetProcPtr(procval, proc); - proc->is_lambda = TRUE; - } + procval = rb_vm_make_proc_lambda(th, block, klass, is_lambda); return procval; } @@ -663,6 +663,12 @@ rb_proc_alloc(VALUE klass, const rb_block_t *block, VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass) { + return rb_vm_make_proc_lambda(th, block, klass, 0); +} + +VALUE +rb_vm_make_proc_lambda(rb_thread_t *th, const rb_block_t *block, VALUE klass, int8_t is_lambda) +{ VALUE procval, envval, blockprocval = 0; rb_control_frame_t *cfp = RUBY_VM_GET_CFP_FROM_BLOCK_PTR(block); @@ -677,7 +683,7 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass) } procval = rb_proc_alloc(klass, block, envval, blockprocval, - (int8_t)th->safe_level, 0, 0); + (int8_t)th->safe_level, 0, is_lambda); if (VMDEBUG) { if (th->stack < block->ep && block->ep < th->stack + th->stack_size) { @@ -944,6 +944,7 @@ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp); VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, const rb_block_t *blockptr); +VALUE rb_vm_make_proc_lambda(rb_thread_t *th, const rb_block_t *block, VALUE klass, int8_t is_lambda); VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass); VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp); VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp); |