36 #define attached id__attached__
40 #define IS_METHOD_PROC_NODE(node) (nd_type(node) == NODE_IFUNC && (node)->nd_cfnc == bmcall)
375 rb_scan_args(argc, argv,
"12", &args[0], &args[2], &args[3]);
554 rb_warn(
"tried to create Proc object without a block");
559 "tried to create Proc object without a block");
563 procval = block->
proc;
566 if (
RBASIC(procval)->klass == klass) {
653 rb_warn(
"rb_f_lambda() is deprecated; use rb_block_proc() instead");
711 VALUE passed_procval;
720 blockptr = &passed_proc->
block;
729 #if SIZEOF_LONG > SIZEOF_INT
733 if (argc > INT_MAX || argc < 0) {
735 (
unsigned long)argc);
740 #define check_argc(argc) (argc)
763 if (!
NIL_P(pass_procval)) {
766 block = &pass_proc->
block;
857 block = &proc->
block;
881 proc_value = block->
proc;
891 #define get_proc_iseq rb_proc_get_iseq
901 if (is_proc) *is_proc = !proc->
is_lambda;
908 if (is_proc) *is_proc = 0;
919 if (!iseq)
return Qnil;
948 int n = (arity < 0) ? ~arity : arity;
1026 const char *is_lambda;
1030 is_lambda = proc->
is_lambda ?
" (lambda)" :
"";
1033 int first_lineno = 0;
1084 ume->
next =
GET_VM()->unlinked_method_entry_list;
1085 GET_VM()->unlinked_method_entry_list = ume;
1092 return ptr ?
sizeof(
struct METHOD) : 0;
1135 defined_class =
klass;
1147 switch (flag & NOEX_MASK) {
1167 while (rclass != klass &&
1213 return mnew_from_me(me, defined_class, klass, obj,
id, mclass, scope);
1315 data->
id = orig->
id;
1317 *data->
me = *orig->
me;
1401 const char *s0 =
" class";
1407 switch (
TYPE(obj)) {
1621 if (cref && cref->nd_clss == mod) {
1622 noex = (
int)cref->nd_visi;
1635 "wrong argument type %s (expected Proc/Method)",
1647 "can't bind singleton method to a different class");
1651 "bind argument must be a subclass of % "PRIsVALUE,
1734 rb_warning(
"main.define_method in the wrapped load is effective only in wrapper module");
1770 *data->
me = *orig->
me;
1803 volatile int safe = -1;
1811 const int safe_level_to_run = 4 ;
1822 if (!
NIL_P(pass_procval)) {
1825 block = &pass_proc->
block;
1941 methclass = data->
rclass;
1946 "singleton method called for a different object");
1957 *bound->
me = *data->
me;
1985 if (!def)
return *max = 0;
1986 switch (def->
type) {
2014 case OPTIMIZED_METHOD_TYPE_SEND:
2026 rb_bug(
"rb_method_entry_min_max_arity: invalid method entry type (%d)", def->
type);
2034 return min == max ? min : -min-1;
2130 return data->
me->
def;
2136 switch (def->
type) {
2166 if (!me || !me->
def)
return Qnil;
2231 const char *sharp =
"#";
2247 else if (data->
recv == v) {
2261 if (data->
rclass != mklass) {
2458 if (!
NIL_P(passed_proc)) {
2459 rb_warn(
"given block not used");
2602 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
2604 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
2606 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
2608 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
const rb_block_t * passed_block
#define RB_TYPE_P(obj, type)
struct unlinked_method_entry_list_entry * next
static void bm_free(void *ptr)
static VALUE method_name(VALUE obj)
static VALUE bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val)
static int method_min_max_arity(VALUE, int *max)
static VALUE rb_obj_define_method(int argc, VALUE *argv, VALUE obj)
#define UNDEFINED_METHOD_ENTRY_P(me)
static size_t binding_memsize(const void *ptr)
int register char * block
VALUE rb_proc_alloc(VALUE klass)
static VALUE method_arity_m(VALUE method)
VALUE rb_obj_public_method(VALUE obj, VALUE vid)
rb_funcall2(argv[0], id_yield, argc-1, argv+1)
void rb_bug(const char *fmt,...)
static VALUE proc_to_proc(VALUE self)
VALUE rb_block_lambda(void)
#define RB_OBJ_WRITE(a, slot, b)
static rb_method_entry_t * original_method_entry(VALUE mod, ID id)
static VALUE proc_hash(VALUE self)
RUBY_EXTERN VALUE rb_cModule
#define RUBY_VM_IFUNC_P(ptr)
static const rb_data_type_t proc_data_type
VALUE rb_ary_freeze(VALUE ary)
static VALUE bind_eval(int argc, VALUE *argv, VALUE bindval)
static VALUE umethod_bind(VALUE method, VALUE recv)
const char * rb_obj_classname(VALUE)
static VALUE method_proc(VALUE method)
VALUE rb_proc_location(VALUE self)
static VALUE method_original_name(VALUE obj)
#define UNLIMITED_ARGUMENTS
static int max(int a, int b)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
VALUE rb_str_buf_append(VALUE, VALUE)
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
static VALUE method_def_location(rb_method_definition_t *def)
#define GetProcPtr(obj, ptr)
#define RUBY_VM_NORMAL_ISEQ_P(ptr)
rb_funcall(memo->yielder, id_lshift, 1, rb_assoc_new(memo->prev_value, memo->prev_elts))
SSL_METHOD *(* func)(void)
VALUE rb_block_clear_env_self(VALUE proc)
union rb_method_definition_struct::@149 body
static int rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
static void proc_mark(void *ptr)
VALUE rb_mod_method_location(VALUE mod, ID id)
rb_method_entry_t * rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class_ptr)
static rb_iseq_t * method_get_iseq(rb_method_definition_t *def)
RUBY_EXTERN VALUE rb_cBinding
VALUE rb_iv_get(VALUE, const char *)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static VALUE localjump_reason(VALUE exc)
VALUE rb_obj_freeze(VALUE)
struct unlinked_method_entry_list_entry * ume
VALUE rb_ary_push(VALUE ary, VALUE item)
static int rb_proc_min_max_arity(VALUE self, int *max)
static VALUE method_clone(VALUE self)
VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass)
VALUE rb_str_buf_cat2(VALUE, const char *)
VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE)
#define IS_METHOD_PROC_NODE(node)
VALUE rb_iseq_first_lineno(VALUE iseqval)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_proc_new(VALUE(*)(ANYARGS), VALUE)
VALUE rb_proc_lambda_p(VALUE)
#define RUBY_MARK_LEAVE(msg)
VALUE rb_class_name(VALUE)
static VALUE iseq_location(rb_iseq_t *iseq)
static VALUE unnamed_parameters(int arity)
void rb_method_name_error(VALUE klass, VALUE str)
static VALUE proc_clone(VALUE self)
#define GetEnvPtr(obj, ptr)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, const rb_block_t *blockptr)
static VALUE method_inspect(VALUE method)
ID rb_check_id(volatile VALUE *namep)
Returns ID for the given name if it is interned already, or 0.
static VALUE rb_proc_s_new(int argc, VALUE *argv, VALUE klass)
VALUE rb_iterate(VALUE(*)(VALUE), VALUE, VALUE(*)(ANYARGS), VALUE)
void rb_undef_method(VALUE klass, const char *name)
static VALUE proc_dup(VALUE self)
static size_t bm_memsize(const void *ptr)
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2)
VALUE rb_method_call_with_block(int, VALUE *, VALUE, VALUE)
VALUE rb_ivar_get(VALUE, ID)
void rb_mark_method_entry(const rb_method_entry_t *me)
void rb_name_error_str(VALUE str, const char *fmt,...)
VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc, const VALUE *argv, const rb_method_entry_t *me, VALUE defined_class)
static VALUE method_hash(VALUE method)
void rb_name_error(ID id, const char *fmt,...)
st_index_t rb_hash_start(st_index_t)
static VALUE method_eq(VALUE method, VALUE other)
static int method_arity(VALUE)
enum rb_method_definition_struct::@149::method_optimized_type optimize_type
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
VALUE rb_binding_new(void)
VALUE rb_block_proc(void)
static int rb_block_min_max_arity(rb_block_t *block, int *max)
unsigned short first_lineno
#define rb_intern_str(string)
static VALUE rb_mod_instance_method(VALUE mod, VALUE vid)
#define TypedData_Get_Struct(obj, type, data_type, sval)
int rb_block_given_p(void)
VALUE rb_class_search_ancestor(VALUE klass, VALUE super)
static VALUE proc_curry(int argc, VALUE *argv, VALUE self)
RUBY_EXTERN VALUE rb_mKernel
#define GetBindingPtr(obj, ptr)
int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
#define RARRAY_CONST_PTR(a)
#define RARRAY_AREF(a, i)
RUBY_EXTERN VALUE rb_cMethod
VALUE rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp)
int argc
argument information
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_method_call(int, VALUE *, VALUE)
static VALUE proc_arity(VALUE self)
void rb_ary_store(VALUE ary, long idx, VALUE val)
static VALUE rb_proc_parameters(VALUE self)
#define RBASIC_CLASS(obj)
#define RUBY_MARK_ENTER(msg)
int rb_method_entry_arity(const rb_method_entry_t *me)
const rb_data_type_t ruby_binding_data_type
static VALUE rb_method_parameters(VALUE method)
static VALUE rb_f_binding(VALUE self)
rb_method_entry_t * rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr)
VALUE * rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
static VALUE rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
static VALUE mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
static VALUE bmcall(VALUE, VALUE, int, VALUE *, VALUE)
VALUE rb_sprintf(const char *format,...)
static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
VALUE rb_include_class_new(VALUE module, VALUE super)
#define RUBY_TYPED_FREE_IMMEDIATELY
static VALUE * get_local_variable_ptr(VALUE envval, ID lid)
rb_method_entry_t * rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex)
#define CONST_ID(var, str)
static void binding_free(void *ptr)
VALUE rb_class_inherited_p(VALUE, VALUE)
int rb_is_local_id(ID id)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static VALUE rb_mod_public_instance_method(VALUE mod, VALUE vid)
static int min(int a, int b)
rb_iseq_t * rb_proc_get_iseq(VALUE proc, int *is_proc)
VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp)
RUBY_EXTERN VALUE rb_cUnboundMethod
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me)
static VALUE proc_binding(VALUE self)
static VALUE binding_dup(VALUE self)
int rb_mod_method_arity(VALUE, ID)
void rb_set_safe_level_force(int)
void rb_undef_alloc_func(VALUE)
rb_iseq_location_t location
static VALUE method_owner(VALUE obj)
static VALUE method_receiver(VALUE obj)
VALUE rb_obj_method(VALUE, VALUE)
VALUE rb_obj_is_method(VALUE)
static VALUE proc_new(VALUE klass, int is_lambda)
static VALUE make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
VALUE rb_obj_is_proc(VALUE)
static VALUE mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
VALUE rb_method_entry_location(rb_method_entry_t *me)
int rb_obj_method_arity(VALUE, ID)
rb_method_entry_t * rb_method_entry_at(VALUE obj, ID id)
static VALUE mlambda(VALUE method)
VALUE rb_mRubyVMFrozenCore
int rb_is_local_name(VALUE name)
static void bm_mark(void *ptr)
static VALUE bind_local_variable_defined_p(VALUE bindval, VALUE sym)
VALUE rb_method_location(VALUE method)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
int rb_method_basic_definition_p(VALUE, ID)
VALUE rb_ary_plus(VALUE x, VALUE y)
VALUE rb_proc_call(VALUE, VALUE)
rb_method_definition_t * def
#define RUBY_FREE_LEAVE(msg)
#define RUBY_FREE_ENTER(msg)
#define TypedData_Make_Struct(klass, type, data_type, sval)
VALUE rb_str_catf(VALUE str, const char *format,...)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_singleton_class_get(VALUE obj)
Returns the singleton class of obj, or nil if obj is not a singleton object.
VALUE rb_obj_singleton_method(VALUE obj, VALUE vid)
static VALUE proc_call(int argc, VALUE *argv, VALUE procval)
#define RUBY_MARK_UNLESS_NULL(ptr)
rb_block_t * rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp)
struct iseq_line_info_entry * line_info_table
#define RBASIC_SET_CLASS(obj, cls)
VALUE rb_ary_dup(VALUE ary)
rb_iseq_t * rb_method_get_iseq(VALUE body)
#define CLONESETUP(clone, obj)
static VALUE binding_clone(VALUE self)
VALUE rb_f_eval(int argc, VALUE *argv, VALUE self)
static VALUE proc_to_s(VALUE self)
RUBY_EXTERN VALUE rb_cProc
const char * rb_id2name(ID id)
static const rb_data_type_t method_data_type
static ID check_local_id(VALUE bindval, volatile VALUE *pname)
#define Check_TypedStruct(v, t)
static VALUE bind_local_variable_get(VALUE bindval, VALUE sym)
NODE * rb_vm_cref_in_context(VALUE self)
void rb_warning(const char *fmt,...)
static VALUE localjump_xvalue(VALUE exc)
rb_method_entry_t * rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex)
void rb_print_undef(VALUE klass, ID id, int scope)
static rb_method_definition_t * method_get_def(VALUE method)
static void proc_free(void *ptr)
static VALUE top_define_method(int argc, VALUE *argv, VALUE obj)
static void binding_mark(void *ptr)
st_index_t rb_hash_proc(st_index_t hash, VALUE proc)
void rb_obj_call_init(VALUE obj, int argc, VALUE *argv)
static rb_thread_t * GET_THREAD(void)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static size_t proc_memsize(const void *ptr)
static int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
void rb_warn(const char *fmt,...)
VALUE rb_binding_alloc(VALUE klass)
static VALUE mproc(VALUE method)
VALUE rb_obj_method_location(VALUE obj, ID id)
#define rb_hash_uint(h, i)
static VALUE method_unbind(VALUE obj)