Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions | Variables
proc.c File Reference
`#include "eval_intern.h"`
`#include "internal.h"`
`#include "gc.h"`
`#include "vm_core.h"`
`#include "iseq.h"`

Go to the source code of this file.

## Data Structures
struct | METHOD
struct | cfunc_proc_t

## Macros
#define | PROC_NEW_REQUIRES_BLOCK 0
#define | NO_CLOBBERED(v) (*(volatile VALUE *)&(v))
#define | UPDATE_TYPED_REFERENCE(_type, _ref) *(_type*)&_ref = (_type)rb_gc_location((VALUE)_ref)
#define | UPDATE_REFERENCE(_ref) UPDATE_TYPED_REFERENCE(VALUE, _ref)
#define | attached id__attached__
#define | IS_METHOD_PROC_IFUNC(ifunc) ((ifunc)->func == bmcall)
#define | check_argc(argc) (argc)
#define | MSG(s) rb_fstring_lit("undefined method `%1$s' for"s" `%2$s'")

## Functions
const rb_cref_t * | rb_vm_cref_in_context (VALUE self, VALUE cbase)
VALUE | rb_proc_alloc (VALUE klass)
VALUE | rb_obj_is_proc (VALUE proc)
VALUE | rb_proc_lambda_p (VALUE procval)
VALUE | rb_binding_alloc (VALUE klass)
VALUE | rb_binding_new (void)
struct vm_ifunc * | rb_vm_ifunc_new (rb_block_call_func_t func, const void *data, int min_argc, int max_argc)
MJIT_FUNC_EXPORTED VALUE | rb_func_proc_new (rb_block_call_func_t func, VALUE val)
VALUE | rb_func_lambda_new (rb_block_call_func_t func, VALUE val, int min_argc, int max_argc)
VALUE | rb_block_proc (void)
VALUE | rb_block_lambda (void)
VALUE | rb_proc_call_kw (VALUE self, VALUE args, int kw_splat)
VALUE | rb_proc_call (VALUE self, VALUE args)
VALUE | rb_proc_call_with_block_kw (VALUE self, int argc, const VALUE *argv, VALUE passed_procval, int kw_splat)
VALUE | rb_proc_call_with_block (VALUE self, int argc, const VALUE *argv, VALUE passed_procval)
int | rb_proc_arity (VALUE self)
int | rb_block_arity (void)
int | rb_block_min_max_arity (int *max)
const rb_iseq_t * | rb_proc_get_iseq (VALUE self, int *is_proc)
MJIT_FUNC_EXPORTED VALUE | rb_iseq_location (const rb_iseq_t *iseq)
VALUE | rb_proc_location (VALUE self)
VALUE | rb_unnamed_parameters (int arity)
st_index_t | rb_hash_proc (st_index_t hash, VALUE prc)
MJIT_FUNC_EXPORTED VALUE | rb_sym_to_proc (VALUE sym)
VALUE | rb_block_to_s (VALUE self, const struct rb_block *block, const char *additional_info)
VALUE | rb_obj_is_method (VALUE m)
void | rb_method_name_error (VALUE klass, VALUE str)
VALUE | rb_obj_method (VALUE obj, VALUE vid)
VALUE | rb_obj_public_method (VALUE obj, VALUE vid)
VALUE | rb_obj_singleton_method (VALUE obj, VALUE vid)
VALUE | rb_method_call_kw (int argc, const VALUE *argv, VALUE method, int kw_splat)
VALUE | rb_method_call (int argc, const VALUE *argv, VALUE method)
VALUE | rb_method_call_with_block_kw (int argc, const VALUE *argv, VALUE method, VALUE passed_procval, int kw_splat)
VALUE | rb_method_call_with_block (int argc, const VALUE *argv, VALUE method, VALUE passed_procval)
int | rb_method_entry_arity (const rb_method_entry_t *me)
int | rb_mod_method_arity (VALUE mod, ID id)
int | rb_obj_method_arity (VALUE obj, ID id)
const rb_method_definition_t * | rb_method_def (VALUE method)
const rb_iseq_t * | rb_method_iseq (VALUE method)
VALUE | rb_method_entry_location (const rb_method_entry_t *me)
VALUE | rb_method_location (VALUE method)
VALUE | rb_proc_new (rb_block_call_func_t func, VALUE val)
rb_cref_t * | rb_vm_cref_new_toplevel (void)
void | Init_Proc (void)
void | Init_Binding (void)

## Variables
VALUE | rb_cUnboundMethod
VALUE | rb_cMethod
VALUE | rb_cBinding
VALUE | rb_cProc
const rb_data_type_t | ruby_binding_data_type

## Macro Definition Documentation

## ◆ attached

#define attached id__attached__

Definition at line 50 of file proc.c.

## ◆ check_argc

#define check_argc | ( |  | argc | ) | (argc)

Definition at line 944 of file proc.c.

## ◆ IS_METHOD_PROC_IFUNC

#define IS_METHOD_PROC_IFUNC | ( |  | ifunc | ) | ((ifunc)->func == bmcall)

Definition at line 54 of file proc.c.

## ◆ MSG

#define MSG | ( |  | s | ) | rb_fstring_lit("undefined method `%1$s' for"s" `%2$s'")

## ◆ NO_CLOBBERED

#define NO_CLOBBERED | ( |  | v | ) | (*(volatile VALUE *)&(v))

Definition at line 23 of file proc.c.

## ◆ PROC_NEW_REQUIRES_BLOCK

#define PROC_NEW_REQUIRES_BLOCK 0

Definition at line 20 of file proc.c.

## ◆ UPDATE_REFERENCE

#define UPDATE_REFERENCE | ( |  | _ref | ) | UPDATE_TYPED_REFERENCE(VALUE, _ref)

Definition at line 29 of file proc.c.

## ◆ UPDATE_TYPED_REFERENCE

#define UPDATE_TYPED_REFERENCE | ( |  | _type,
|  |  | _ref
| ) |  | *(_type*)&_ref = (_type)rb_gc_location((VALUE)_ref)

Definition at line 28 of file proc.c.

## Function Documentation

## ◆ Init_Binding()

void Init_Binding | ( | void |  | ) |

Definition at line 4045 of file proc.c.

References CLASS_OF, rb_cBinding, rb_cObject, rb_define_class(), rb_define_method(), rb_undef_alloc_func(), and rb_undef_method().

## ◆ Init_Proc()

void Init_Proc | ( | void |  | ) |

Definition at line 3895 of file proc.c.

References rb_cObject, rb_cProc, rb_define_class(), rb_define_singleton_method(), and rb_undef_alloc_func().

## ◆ rb_binding_alloc()

VALUE rb_binding_alloc | ( | VALUE | klass | ) |

Definition at line 331 of file proc.c.

References klass, obj, ruby_binding_data_type, and TypedData_Make_Struct.

## ◆ rb_binding_new()

VALUE rb_binding_new | ( | void |  | ) |

Definition at line 364 of file proc.c.

References rb_execution_context_struct::cfp, GET_EC, and rb_vm_make_binding().

## ◆ rb_block_arity()

int rb_block_arity | ( | void |  | ) |

Definition at line 1144 of file proc.c.

## ◆ rb_block_lambda()

VALUE rb_block_lambda | ( | void |  | ) |

Definition at line 856 of file proc.c.

## ◆ rb_block_min_max_arity()

int rb_block_min_max_arity | ( | int * | max | ) |

Definition at line 1178 of file proc.c.

## ◆ rb_block_proc()

VALUE rb_block_proc | ( | void |  | ) |

Definition at line 837 of file proc.c.

Referenced by rb_f_trace_var(), rb_method_call(), and rb_method_call_kw().

## ◆ rb_block_to_s()

VALUE rb_block_to_s | ( | VALUE | self,
|  | const struct rb_block * | block,
|  | const char * | additional_info
| ) |  |

Definition at line 1360 of file proc.c.

References PRIsVALUE, rb_obj_class(), rb_sprintf(), and str.

## ◆ rb_func_lambda_new()

VALUE rb_func_lambda_new | ( | rb_block_call_func_t | func,
|  | VALUE | val,
|  | int | min_argc,
|  | int | max_argc
| ) |  |

Definition at line 735 of file proc.c.

References vm_ifunc::func, max_argc, min_argc, and rb_vm_ifunc_new().

## ◆ rb_func_proc_new()

MJIT_FUNC_EXPORTED VALUE rb_func_proc_new | ( | rb_block_call_func_t | func,
|  | VALUE | val
| ) |  |

Definition at line 728 of file proc.c.

## ◆ rb_hash_proc()

st_index_t rb_hash_proc | ( | st_index_t | hash,
|  | VALUE | prc
| ) |  |

Definition at line 1302 of file proc.c.

## ◆ rb_iseq_location()

MJIT_FUNC_EXPORTED VALUE rb_iseq_location | ( | const rb_iseq_t * | iseq | ) |

Definition at line 1242 of file proc.c.

## ◆ rb_method_call()

VALUE rb_method_call | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | method
| ) |  |

Definition at line 2261 of file proc.c.

References argc, argv, Qnil, rb_block_given_p(), rb_block_proc(), and rb_method_call_with_block().

## ◆ rb_method_call_kw()

VALUE rb_method_call_kw | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | method,
|  | int | kw_splat
| ) |  |

Definition at line 2254 of file proc.c.

References argc, argv, Qnil, rb_block_given_p(), rb_block_proc(), and rb_method_call_with_block_kw().

## ◆ rb_method_call_with_block()

VALUE rb_method_call_with_block | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | method,
|  | VALUE | passed_procval
| ) |  |

Definition at line 2297 of file proc.c.

References argc, argv, rb_method_call_with_block_kw(), and RB_NO_KEYWORDS.

Referenced by rb_method_call().

## ◆ rb_method_call_with_block_kw()

VALUE rb_method_call_with_block_kw | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | method,
|  | VALUE | passed_procval,
|  | int | kw_splat
| ) |  |

Definition at line 2284 of file proc.c.

References GET_EC, and TypedData_Get_Struct.

Referenced by rb_method_call_kw(), and rb_method_call_with_block().

## ◆ rb_method_def()

const rb_method_definition_t* rb_method_def | ( | VALUE | method | ) |

Definition at line 2646 of file proc.c.

References TypedData_Get_Struct.

## ◆ rb_method_entry_arity()

int rb_method_entry_arity | ( | const rb_method_entry_t * | me | ) |

Definition at line 2543 of file proc.c.

## ◆ rb_method_entry_location()

VALUE rb_method_entry_location | ( | const rb_method_entry_t * | me | ) |

Definition at line 2713 of file proc.c.

References me, and Qnil.

## ◆ rb_method_iseq()

const rb_iseq_t* rb_method_iseq | ( | VALUE | method | ) |

Definition at line 2679 of file proc.c.

## ◆ rb_method_location()

VALUE rb_method_location | ( | VALUE | method | ) |

Definition at line 2728 of file proc.c.

## ◆ rb_method_name_error()

void rb_method_name_error | ( | VALUE | klass,
|  | VALUE | str
| ) |  |

Definition at line 1778 of file proc.c.

References attached, BUILTIN_TYPE, FL_SINGLETON, FL_TEST, klass, MSG, obj, rb_ivar_get(), rb_name_err_raise_str, RB_TYPE_P, str, T_CLASS, and T_MODULE.

## ◆ rb_mod_method_arity()

int rb_mod_method_arity | ( | VALUE | mod,
|  | ID | id
| ) |  |

Definition at line 2632 of file proc.c.

References me.

Referenced by rb_obj_method_arity().

## ◆ rb_obj_is_method()

VALUE rb_obj_is_method | ( | VALUE | m | ) |

Definition at line 1459 of file proc.c.

References rb_typeddata_is_kind_of().

## ◆ rb_obj_is_proc()

VALUE rb_obj_is_proc | ( | VALUE | proc | ) |

Definition at line 152 of file proc.c.

References rb_typeddata_is_kind_of().

## ◆ rb_obj_method()

VALUE rb_obj_method | ( | VALUE | obj,
|  | VALUE | vid
| ) |  |

Definition at line 1861 of file proc.c.

## ◆ rb_obj_method_arity()

int rb_obj_method_arity | ( | VALUE | obj,
|  | ID | id
| ) |  |

Definition at line 2640 of file proc.c.

References CLASS_OF, obj, and rb_mod_method_arity().

## ◆ rb_obj_public_method()

VALUE rb_obj_public_method | ( | VALUE | obj,
|  | VALUE | vid
| ) |  |

Definition at line 1874 of file proc.c.

## ◆ rb_obj_singleton_method()

VALUE rb_obj_singleton_method | ( | VALUE | obj,
|  | VALUE | vid
| ) |  |

Definition at line 1904 of file proc.c.

References klass, me, NIL_P, obj, rb_check_id(), rb_name_err_raise, rb_singleton_class_get(), and RCLASS_ORIGIN.

## ◆ rb_proc_alloc()

VALUE rb_proc_alloc | ( | VALUE | klass | ) |

Definition at line 145 of file proc.c.

References klass, and TypedData_Make_Struct.

## ◆ rb_proc_arity()

int rb_proc_arity | ( | VALUE | self | ) |

Definition at line 1112 of file proc.c.

## ◆ rb_proc_call()

VALUE rb_proc_call | ( | VALUE | self,
|  | VALUE | args
| ) |  |

Definition at line 966 of file proc.c.

References check_argc, GET_EC, GetProcPtr, RARRAY_CONST_PTR, RARRAY_LEN, RB_GC_GUARD, RB_NO_KEYWORDS, rb_vm_invoke_proc(), and VM_BLOCK_HANDLER_NONE.

Referenced by rb_call_end_proc().

## ◆ rb_proc_call_kw()

VALUE rb_proc_call_kw | ( | VALUE | self,
|  | VALUE | args,
|  | int | kw_splat
| ) |  |

Definition at line 948 of file proc.c.

References argc, argv, check_argc, GET_EC, GetProcPtr, RARRAY_CONST_PTR, RARRAY_LEN, rb_adjust_argv_kw_splat(), rb_free_tmp_buffer(), RB_GC_GUARD, rb_vm_invoke_proc(), v, and VM_BLOCK_HANDLER_NONE.

## ◆ rb_proc_call_with_block()

VALUE rb_proc_call_with_block | ( | VALUE | self,
|  | int | argc,
|  | const VALUE * | argv,
|  | VALUE | passed_procval
| ) |  |

Definition at line 1000 of file proc.c.

References argc, argv, GET_EC, GetProcPtr, RB_NO_KEYWORDS, and rb_vm_invoke_proc().

## ◆ rb_proc_call_with_block_kw()

VALUE rb_proc_call_with_block_kw | ( | VALUE | self,
|  | int | argc,
|  | const VALUE * | argv,
|  | VALUE | passed_procval,
|  | int | kw_splat
| ) |  |

Definition at line 986 of file proc.c.

References argc, argv, GET_EC, GetProcPtr, rb_adjust_argv_kw_splat(), rb_vm_invoke_proc(), and v.

## ◆ rb_proc_get_iseq()

const rb_iseq_t* rb_proc_get_iseq | ( | VALUE | self,
|  | int * | is_proc
| ) |  |

Definition at line 1194 of file proc.c.

References GetProcPtr, and rb_block::proc.

Referenced by rb_resolve_me_location().

## ◆ rb_proc_lambda_p()

VALUE rb_proc_lambda_p | ( | VALUE | procval | ) |

Definition at line 275 of file proc.c.

References GetProcPtr, rb_proc_t::is_lambda, Qfalse, and Qtrue.

## ◆ rb_proc_location()

VALUE rb_proc_location | ( | VALUE | self | ) |

Definition at line 1256 of file proc.c.

## ◆ rb_proc_new()

VALUE rb_proc_new | ( | rb_block_call_func_t | func,
|  | VALUE | val
| ) |  |

Definition at line 2979 of file proc.c.

References ruby::backward::cxxanyargs::rb_iterate().

## ◆ rb_sym_to_proc()

MJIT_FUNC_EXPORTED VALUE rb_sym_to_proc | ( | VALUE | sym | ) |

Definition at line 1312 of file proc.c.

References id, index, Qfalse, Qnil, RARRAY_AREF, rb_ary_store(), rb_ary_tmp_new(), rb_gc_register_mark_object(), sym, and SYM2ID.

## ◆ rb_unnamed_parameters()

VALUE rb_unnamed_parameters | ( | int | arity | ) |

Definition at line 1262 of file proc.c.

References CONST_ID, ID2SYM, n, OBJ_FREEZE, rb_ary_new2, rb_ary_new3, rb_ary_push(), and rb_ary_store().

## ◆ rb_vm_cref_in_context()

const rb_cref_t* rb_vm_cref_in_context | ( | VALUE | self,
|  | VALUE | cbase
| ) |  |

Definition at line 1400 of file vm.c.

## ◆ rb_vm_cref_new_toplevel()

rb_cref_t* rb_vm_cref_new_toplevel | ( | void |  | ) |

Definition at line 298 of file vm.c.

## ◆ rb_vm_ifunc_new()

struct vm_ifunc* rb_vm_ifunc_new | ( | rb_block_call_func_t | func,
|  | const void * | data,
|  | int | min_argc,
|  | int | max_argc
| ) |  |

Definition at line 699 of file proc.c.

References vm_ifunc::argc, CHAR_BIT, IFUNC_NEW, max_argc, min_argc, rb_eRangeError, rb_raise(), SIZEOF_INT, SIZEOF_VALUE, and UNLIMITED_ARGUMENTS.

Referenced by rb_func_lambda_new(), and rb_lambda_call().

## Variable Documentation

## ◆ ruby_binding_data_type

const rb_data_type_t ruby_binding_data_type

Initial value:
= {
"binding",
{
binding_mark,
binding_free,
binding_memsize,
binding_compact,
},
0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
}

Definition at line 319 of file proc.c.

Referenced by rb_binding_alloc().

RUBY_TYPED_FREE_IMMEDIATELY
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1207
RUBY_TYPED_WB_PROTECTED
#define RUBY_TYPED_WB_PROTECTED
Definition: ruby.h:1208