mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
insns.def (invokesuper): remove a dummy receiever flag hack for ZSUPER
This is just a refactoring. The receiver of "invokesuper" was a boolean to represent if it is ZSUPER or not. This was used in vm_search_super_method to prohibit ZSUPER call in define_method. (It is currently prohibited because of the limitation of the implementation.) This change removes the hack by introducing an explicit flag, VM_CALL_SUPER, to signal the information. Now, the implementation of "invokesuper" is consistent with "send" instruction. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f945ea86d8
commit
2138f24c70
5 changed files with 9 additions and 8 deletions
|
@ -6624,11 +6624,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
|
|||
}
|
||||
}
|
||||
|
||||
/* dummy receiver */
|
||||
ADD_INSN1(ret, line, putobject, type == NODE_ZSUPER ? Qfalse : Qtrue);
|
||||
ADD_INSN(ret, line, putself);
|
||||
ADD_SEQ(ret, args);
|
||||
ADD_INSN3(ret, line, invokesuper,
|
||||
new_callinfo(iseq, 0, argc, flag | VM_CALL_SUPER | VM_CALL_FCALL, keywords, parent_block != NULL),
|
||||
new_callinfo(iseq, 0, argc, flag | VM_CALL_SUPER | (type == NODE_ZSUPER ? VM_CALL_ZSUPER : 0) | VM_CALL_FCALL, keywords, parent_block != NULL),
|
||||
Qnil, /* CALL_CACHE */
|
||||
parent_block);
|
||||
|
||||
|
|
|
@ -716,7 +716,8 @@ send
|
|||
struct rb_calling_info calling;
|
||||
|
||||
vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, FALSE);
|
||||
vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
|
||||
calling.recv = TOPN(calling.argc = ci->orig_argc);
|
||||
vm_search_method(ci, cc, calling.recv);
|
||||
CALL_METHOD(&calling, ci, cc);
|
||||
}
|
||||
|
||||
|
@ -783,10 +784,9 @@ invokesuper
|
|||
// attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));
|
||||
{
|
||||
struct rb_calling_info calling;
|
||||
calling.argc = ci->orig_argc;
|
||||
|
||||
vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, TRUE);
|
||||
calling.recv = GET_SELF();
|
||||
calling.recv = TOPN(calling.argc = ci->orig_argc);
|
||||
vm_search_super_method(ec, GET_CFP(), &calling, ci, cc);
|
||||
CALL_METHOD(&calling, ci, cc);
|
||||
}
|
||||
|
|
1
iseq.c
1
iseq.c
|
@ -1775,6 +1775,7 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
|
|||
CALL_FLAG(BLOCKISEQ);
|
||||
CALL_FLAG(TAILCALL);
|
||||
CALL_FLAG(SUPER);
|
||||
CALL_FLAG(ZSUPER);
|
||||
CALL_FLAG(KWARG);
|
||||
CALL_FLAG(KW_SPLAT);
|
||||
CALL_FLAG(OPT_SEND); /* maybe not reachable */
|
||||
|
|
|
@ -1018,6 +1018,7 @@ enum vm_call_flag_bits {
|
|||
VM_CALL_KW_SPLAT_bit, /* m(**opts) */
|
||||
VM_CALL_TAILCALL_bit, /* located at tail position */
|
||||
VM_CALL_SUPER_bit, /* super */
|
||||
VM_CALL_ZSUPER_bit, /* zsuper */
|
||||
VM_CALL_OPT_SEND_bit, /* internal flag */
|
||||
VM_CALL__END
|
||||
};
|
||||
|
@ -1032,6 +1033,7 @@ enum vm_call_flag_bits {
|
|||
#define VM_CALL_KW_SPLAT (0x01 << VM_CALL_KW_SPLAT_bit)
|
||||
#define VM_CALL_TAILCALL (0x01 << VM_CALL_TAILCALL_bit)
|
||||
#define VM_CALL_SUPER (0x01 << VM_CALL_SUPER_bit)
|
||||
#define VM_CALL_ZSUPER (0x01 << VM_CALL_ZSUPER_bit)
|
||||
#define VM_CALL_OPT_SEND (0x01 << VM_CALL_OPT_SEND_bit)
|
||||
|
||||
enum vm_special_object_type {
|
||||
|
|
|
@ -2473,7 +2473,6 @@ vm_search_super_method(const rb_execution_context_t *ec, rb_control_frame_t *reg
|
|||
struct rb_calling_info *calling, struct rb_call_info *ci, struct rb_call_cache *cc)
|
||||
{
|
||||
VALUE current_defined_class, klass;
|
||||
VALUE sigval = TOPN(calling->argc);
|
||||
const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(reg_cfp);
|
||||
|
||||
if (!me) {
|
||||
|
@ -2499,7 +2498,7 @@ vm_search_super_method(const rb_execution_context_t *ec, rb_control_frame_t *reg
|
|||
rb_obj_class(calling->recv), m);
|
||||
}
|
||||
|
||||
if (me->def->type == VM_METHOD_TYPE_BMETHOD && !sigval) {
|
||||
if (me->def->type == VM_METHOD_TYPE_BMETHOD && (ci->flag & VM_CALL_ZSUPER)) {
|
||||
rb_raise(rb_eRuntimeError,
|
||||
"implicit argument passing of super from method defined"
|
||||
" by define_method() is not supported."
|
||||
|
|
Loading…
Reference in a new issue