38 #define IS_METHOD_PROC_NODE(node) (nd_type(node) == NODE_IFUNC && (node)->nd_cfnc == bmcall)
371 rb_scan_args(argc, argv,
"12", &args[0], &args[2], &args[3]);
392 rb_warn(
"tried to create Proc object without a block");
397 "tried to create Proc object without a block");
401 procval = block->
proc;
404 if (
RBASIC(procval)->klass == klass) {
480 rb_warn(
"rb_f_lambda() is deprecated; use rb_block_proc() instead");
538 VALUE passed_procval;
547 blockptr = &passed_proc->
block;
556 #if SIZEOF_LONG > SIZEOF_INT
560 if (argc > INT_MAX || argc < 0) {
562 (
unsigned long)argc);
567 #define check_argc(argc) (argc)
591 if (!
NIL_P(pass_procval)) {
594 block = &pass_proc->
block;
689 #define get_proc_iseq rb_proc_get_iseq
699 if (is_proc) *is_proc = !proc->
is_lambda;
706 if (is_proc) *is_proc = 0;
717 if (!iseq)
return Qnil;
746 int n = (arity < 0) ? ~arity : arity;
824 const char *is_lambda;
828 is_lambda = proc->
is_lambda ?
" (lambda)" :
"";
831 int first_lineno = 0;
836 str =
rb_sprintf(
"#<%s:%p@%s:%d%s>", cname, (
void *)
self,
838 first_lineno, is_lambda);
883 ume->
next =
GET_VM()->unlinked_method_entry_list;
884 GET_VM()->unlinked_method_entry_list = ume;
891 return ptr ?
sizeof(
struct METHOD) : 0;
937 defined_class =
klass;
957 switch (flag & NOEX_MASK) {
976 while (rclass != klass &&
1096 data->
id = orig->
id;
1098 *data->
me = *orig->
me;
1157 defined_class =
RBASIC(defined_class)->klass;
1166 const char *s0 =
" class";
1172 switch (
TYPE(obj)) {
1353 "wrong argument type %s (expected Proc/Method)",
1365 "can't bind singleton method to a different class");
1369 "bind argument must be a subclass of %s",
1447 rb_warning(
"main.define_method in the wrapped load is effective only in wrapper module");
1483 *data->
me = *orig->
me;
1516 volatile int safe = -1;
1524 const int safe_level_to_run = 4 ;
1535 if (!
NIL_P(pass_procval)) {
1538 block = &pass_proc->
block;
1654 methclass = data->
rclass;
1659 "singleton method called for a different object");
1670 *bound->
me = *data->
me;
1698 if (!def)
return *max = 0;
1699 switch (def->
type) {
1727 case OPTIMIZED_METHOD_TYPE_SEND:
1738 rb_bug(
"rb_method_entry_min_max_arity: invalid method entry type (%d)", def->
type);
1746 return min == max ? min : -min-1;
1842 return data->
me->
def;
1848 switch (def->
type) {
1878 if (!me || !me->
def)
return Qnil;
1943 const char *sharp =
"#";
1957 else if (data->
recv == v) {
2154 if (!
NIL_P(passed_proc)) {
2155 rb_warn(
"given block not used");
2299 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
2301 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
2303 (
void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
2305 (
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 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_ary_new4(long n, const VALUE *elts)
VALUE rb_obj_public_method(VALUE obj, VALUE vid)
void rb_bug(const char *fmt,...)
static VALUE proc_to_proc(VALUE self)
VALUE rb_block_lambda(void)
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)
#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)
SSL_METHOD *(* func)(void)
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 *)
#define IS_METHOD_PROC_NODE(node)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
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)
VALUE rb_ary_new3(long n,...)
union rb_method_definition_struct::@112 body
void rb_method_name_error(VALUE klass, VALUE str)
static VALUE proc_clone(VALUE self)
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)
VALUE rb_str_append(VALUE, VALUE)
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)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
VALUE rb_binding_new(void)
VALUE rb_block_proc(void)
unsigned short first_lineno
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)
int rb_iseq_first_lineno(const rb_iseq_t *iseq)
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)
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 RUBY_MARK_ENTER(msg)
int rb_method_entry_arity(const rb_method_entry_t *me)
static VALUE rb_method_parameters(VALUE method)
enum rb_method_definition_struct::@112::method_optimized_type optimize_type
static VALUE rb_f_binding(VALUE self)
rb_method_entry_t * rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr)
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 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)
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_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE)
VALUE rb_class_inherited_p(VALUE, VALUE)
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)
const char * rb_class2name(VALUE)
static VALUE mlambda(VALUE method)
VALUE rb_mRubyVMFrozenCore
static void bm_mark(void *ptr)
VALUE rb_method_location(VALUE method)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
int rb_method_basic_definition_p(VALUE, ID)
VALUE rb_exc_new3(VALUE etype, VALUE str)
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)
RUBY_EXTERN VALUE rb_cObject
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
VALUE rb_ary_dup(VALUE ary)
rb_iseq_t * rb_method_get_iseq(VALUE body)
#define CLONESETUP(clone, obj)
static const rb_data_type_t binding_data_type
VALUE rb_ary_new2(long capa)
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
#define Check_TypedStruct(v, t)
#define rb_check_arity(argc, min, max)
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
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)