Ruby  3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
Data Structures | Macros | Functions | Variables
proc.c File Reference

(b76ad15ed0da636161de0243c547ee1e6fc95681)

#include "eval_intern.h"
#include "gc.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/error.h"
#include "internal/eval.h"
#include "internal/object.h"
#include "internal/proc.h"
#include "internal/symbol.h"
#include "method.h"
#include "iseq.h"
#include "vm_core.h"
Include dependency graph for proc.c:

Go to the source code of this file.

Data Structures

struct  METHOD
 
struct  cfunc_proc_t
 

Macros

#define NO_CLOBBERED(v)   (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_trb_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_ifuncrb_vm_ifunc_new (rb_block_call_func_t func, const void *data, int min_argc, int max_argc)
 
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_pair_yield_optimizable (void)
 
int rb_block_arity (void)
 
int rb_block_min_max_arity (int *max)
 
const rb_iseq_trb_proc_get_iseq (VALUE self, int *is_proc)
 
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)
 
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)
 
VALUE rb_callable_receiver (VALUE callable)
 
const rb_method_definition_trb_method_def (VALUE method)
 
const rb_iseq_trb_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)
 
VALUE rb_find_defined_class_by_owner (VALUE current_class, VALUE target_owner)
 
rb_cref_trb_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 54 of file proc.c.

◆ check_argc

#define check_argc (   argc)    (argc)

Definition at line 972 of file proc.c.

◆ IS_METHOD_PROC_IFUNC

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

Definition at line 58 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)    (v)

Definition at line 28 of file proc.c.

◆ UPDATE_REFERENCE

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

Definition at line 32 of file proc.c.

◆ UPDATE_TYPED_REFERENCE

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

Definition at line 31 of file proc.c.

Function Documentation

◆ Init_Binding()

void Init_Binding ( void  )

◆ Init_Proc()

void Init_Proc ( void  )

◆ rb_binding_alloc()

VALUE rb_binding_alloc ( VALUE  klass)

Definition at line 344 of file proc.c.

References ruby_binding_data_type, and TypedData_Make_Struct.

◆ rb_binding_new()

VALUE rb_binding_new ( void  )

Definition at line 377 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 1197 of file proc.c.

◆ rb_block_lambda()

VALUE rb_block_lambda ( void  )

Definition at line 855 of file proc.c.

◆ rb_block_min_max_arity()

int rb_block_min_max_arity ( int *  max)

Definition at line 1230 of file proc.c.

◆ rb_block_pair_yield_optimizable()

int rb_block_pair_yield_optimizable ( void  )

Definition at line 1162 of file proc.c.

◆ rb_block_proc()

VALUE rb_block_proc ( void  )

Definition at line 836 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 1495 of file proc.c.

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

◆ rb_callable_receiver()

VALUE rb_callable_receiver ( VALUE  callable)

Definition at line 2801 of file proc.c.

References rb_obj_is_proc().

◆ rb_find_defined_class_by_owner()

VALUE rb_find_defined_class_by_owner ( VALUE  current_class,
VALUE  target_owner 
)

Definition at line 3078 of file vm_insnhelper.c.

◆ 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 755 of file proc.c.

References vm_ifunc::func, and rb_vm_ifunc_new().

◆ rb_func_proc_new()

VALUE rb_func_proc_new ( rb_block_call_func_t  func,
VALUE  val 
)

Definition at line 748 of file proc.c.

◆ rb_hash_proc()

st_index_t rb_hash_proc ( st_index_t  hash,
VALUE  prc 
)

Definition at line 1437 of file proc.c.

◆ rb_iseq_location()

VALUE rb_iseq_location ( const rb_iseq_t iseq)

Definition at line 1377 of file proc.c.

◆ rb_method_call()

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

Definition at line 2404 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 2397 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 2440 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 2427 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 2816 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 2698 of file proc.c.

◆ rb_method_entry_location()

VALUE rb_method_entry_location ( const rb_method_entry_t me)

Definition at line 2883 of file proc.c.

References METHOD::me, and Qnil.

◆ rb_method_iseq()

const rb_iseq_t* rb_method_iseq ( VALUE  method)

Definition at line 2849 of file proc.c.

◆ rb_method_location()

VALUE rb_method_location ( VALUE  method)

Definition at line 2898 of file proc.c.

◆ rb_method_name_error()

void rb_method_name_error ( VALUE  klass,
VALUE  str 
)

Definition at line 1915 of file proc.c.

References attached, BUILTIN_TYPE, FL_SINGLETON, FL_TEST, METHOD::klass, Qundef, rb_ivar_get(), T_CLASS, and T_MODULE.

◆ rb_mod_method_arity()

int rb_mod_method_arity ( VALUE  mod,
ID  id 
)

Definition at line 2787 of file proc.c.

References METHOD::me.

Referenced by rb_obj_method_arity().

◆ rb_obj_is_method()

VALUE rb_obj_is_method ( VALUE  m)

Definition at line 1594 of file proc.c.

References rb_typeddata_is_kind_of(), and RBOOL.

◆ rb_obj_is_proc()

VALUE rb_obj_is_proc ( VALUE  proc)

Definition at line 170 of file proc.c.

References rb_typeddata_is_kind_of(), and RBOOL.

Referenced by rb_callable_receiver().

◆ rb_obj_method()

VALUE rb_obj_method ( VALUE  obj,
VALUE  vid 
)

Definition at line 1998 of file proc.c.

◆ rb_obj_method_arity()

int rb_obj_method_arity ( VALUE  obj,
ID  id 
)

Definition at line 2795 of file proc.c.

References CLASS_OF, and rb_mod_method_arity().

◆ rb_obj_public_method()

VALUE rb_obj_public_method ( VALUE  obj,
VALUE  vid 
)

Definition at line 2011 of file proc.c.

◆ rb_obj_singleton_method()

VALUE rb_obj_singleton_method ( VALUE  obj,
VALUE  vid 
)

Definition at line 2041 of file proc.c.

References METHOD::klass, NIL_P, rb_check_id(), rb_singleton_class_get(), and RCLASS_ORIGIN.

◆ rb_proc_alloc()

VALUE rb_proc_alloc ( VALUE  klass)

Definition at line 163 of file proc.c.

References TypedData_Make_Struct.

◆ rb_proc_arity()

int rb_proc_arity ( VALUE  self)

Definition at line 1130 of file proc.c.

◆ rb_proc_call()

VALUE rb_proc_call ( VALUE  self,
VALUE  args 
)

◆ rb_proc_call_kw()

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

◆ rb_proc_call_with_block()

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

Definition at line 1023 of file proc.c.

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

◆ 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 1011 of file proc.c.

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

Referenced by rb_proc_call_with_block().

◆ rb_proc_get_iseq()

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

Definition at line 1246 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 288 of file proc.c.

References GetProcPtr, rb_proc_t::is_lambda, and RBOOL.

◆ rb_proc_location()

VALUE rb_proc_location ( VALUE  self)

Definition at line 1391 of file proc.c.

◆ rb_proc_new()

VALUE rb_proc_new ( rb_block_call_func_t  func,
VALUE  val 
)

Definition at line 3152 of file proc.c.

References ruby::backward::cxxanyargs::rb_block_call(), and rb_mRubyVMFrozenCore.

◆ rb_sym_to_proc()

VALUE rb_sym_to_proc ( VALUE  sym)

◆ rb_unnamed_parameters()

VALUE rb_unnamed_parameters ( int  arity)

Definition at line 1397 of file proc.c.

References CONST_ID, ID2SYM, 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 1642 of file vm.c.

◆ rb_vm_cref_new_toplevel()

rb_cref_t* rb_vm_cref_new_toplevel ( void  )

Definition at line 310 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 
)

Variable Documentation

◆ rb_cBinding

VALUE rb_cBinding

Definition at line 46 of file proc.c.

Referenced by Init_Binding().

◆ rb_cMethod

VALUE rb_cMethod

Definition at line 45 of file proc.c.

◆ rb_cProc

VALUE rb_cProc

Definition at line 47 of file proc.c.

Referenced by Init_Proc().

◆ rb_cUnboundMethod

VALUE rb_cUnboundMethod

Definition at line 44 of file proc.c.

◆ ruby_binding_data_type

const rb_data_type_t ruby_binding_data_type
Initial value:
= {
"binding",
{
binding_mark,
binding_free,
binding_memsize,
binding_compact,
},
}

Definition at line 332 of file proc.c.

Referenced by rb_binding_alloc().

RUBY_TYPED_WB_PROTECTED
@ RUBY_TYPED_WB_PROTECTED
Definition: rtypeddata.h:64
RUBY_TYPED_FREE_IMMEDIATELY
@ RUBY_TYPED_FREE_IMMEDIATELY
Definition: rtypeddata.h:62