Ruby: include/ruby/internal/intern/vm.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Typedefs | Functions
vm.h File Reference

Public APIs related to rb_cRubyVM. More...

`#include "ruby/internal/attr/noreturn.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Macros
#define | HAVE_RB_DEFINE_ALLOC_FUNC 1

## Typedefs
typedef VALUE(* | rb_alloc_func_t) (VALUE)

## Functions
int | rb_sourceline (void)
const char * | rb_sourcefile (void)
int | rb_frame_method_id_and_class (ID *idp, VALUE *klassp)
VALUE | rb_check_funcall (VALUE, ID, int, const VALUE *)
VALUE | rb_check_funcall_kw (VALUE, ID, int, const VALUE *, int)
void | rb_remove_method (VALUE, const char *)
void | rb_remove_method_id (VALUE, ID)
VALUE | rb_eval_cmd_kw (VALUE, VALUE, int)
VALUE | rb_apply (VALUE, ID, VALUE)
| Calls a method. More...
VALUE | rb_obj_instance_eval (int, const VALUE *, VALUE)
VALUE | rb_obj_instance_exec (int, const VALUE *, VALUE)
VALUE | rb_mod_module_eval (int, const VALUE *, VALUE)
VALUE | rb_mod_module_exec (int, const VALUE *, VALUE)
void | rb_define_alloc_func (VALUE, rb_alloc_func_t)
void | rb_undef_alloc_func (VALUE)
rb_alloc_func_t | rb_get_alloc_func (VALUE)
void | rb_clear_constant_cache (void)
void | rb_clear_method_cache_by_class (VALUE)
void | rb_alias (VALUE, ID, ID)
void | rb_attr (VALUE, ID, int, int, int)
int | rb_method_boundp (VALUE, ID, int)
int | rb_method_basic_definition_p (VALUE, ID)
int | rb_obj_respond_to (VALUE, ID, int)
int | rb_respond_to (VALUE, ID)
VALUE | rb_f_notimplement (int argc, const VALUE *argv, VALUE obj, VALUE marker)
void | rb_backtrace (void)
VALUE | rb_make_backtrace (void)

## Detailed Description

Public APIs related to rb_cRubyVM.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file vm.h.

## Macro Definition Documentation

## ◆ HAVE_RB_DEFINE_ALLOC_FUNC

#define HAVE_RB_DEFINE_ALLOC_FUNC 1

Definition at line 49 of file vm.h.

## Typedef Documentation

## ◆ rb_alloc_func_t

typedef VALUE(* rb_alloc_func_t) (VALUE)

Definition at line 50 of file vm.h.

## Function Documentation

## ◆ rb_alias()

void rb_alias | ( | VALUE | klass,
|  | ID | alias_name,
|  | ID | original_name
| ) |  |

Definition at line 1926 of file vm_method.c.

References rb_method_entry_struct::called_id, rb_method_entry_struct::def, rb_method_entry_struct::defined_class, METHOD_ENTRY_VISI, METHOD_VISI_UNDEF, NIL_P, NULL, rb_method_definition_struct::original_id, rb_method_entry_struct::owner, Qnil, rb_class_modify_check(), rb_cObject, rb_eTypeError, rb_method_entry_clone(), RB_OBJ_WRITE, rb_print_undef(), rb_raise(), rb_resolve_refined_method(), RCLASS_SUPER, T_MODULE, UNDEFINED_METHOD_ENTRY_P, UNDEFINED_REFINED_METHOD_P, VM_METHOD_TYPE_ALIAS, VM_METHOD_TYPE_REFINED, and VM_METHOD_TYPE_ZSUPER.

Referenced by Init_signal(), Init_strscan(), and rb_define_alias().

## ◆ rb_apply()

VALUE rb_apply | ( | VALUE | recv,
|  | ID | mid,
|  | VALUE | args
| ) |  |

Calls a method.

Parameters

  recv | receiver of the method
  mid | an ID that represents the name of the method
  args | an Array object which contains method arguments

Precondition
  args must refer an Array object.

Definition at line 1044 of file vm_eval.c.

References ALLOCA_N, argc, argv, CALL_FCALL, MEMCPY, OBJ_FREEZE, RARRAY_CONST_PTR, RARRAY_CONST_PTR_TRANSIENT, rb_ary_subseq, rb_funcallv, and RB_GC_GUARD.

## ◆ rb_attr()

void rb_attr | ( | VALUE | klass,
|  | ID | id,
|  | int | read,
|  | int | write,
|  | int | ex
| ) |  |

Definition at line 1508 of file vm_method.c.

References METHOD_VISI_PRIVATE, METHOD_VISI_PROTECTED, METHOD_VISI_PUBLIC, PRIsVALUE, rb_add_method(), rb_id2str, rb_id_attrset(), rb_intern_str, rb_sprintf(), rb_vm_cref_in_context(), rb_warning(), read(), VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_IVAR, and write().

Referenced by Init_Exception(), Init_ossl_asn1(), Init_ossl_ec(), Init_ossl_pkcs12(), Init_ossl_pkcs7(), Init_ossl_ssl(), Init_ossl_ts(), Init_ossl_x509ext(), Init_ossl_x509store(), and rb_define_attr().

## ◆ rb_backtrace()

void rb_backtrace | ( | void |  | ) |

Definition at line 1013 of file vm_backtrace.c.

## ◆ rb_check_funcall()

VALUE rb_check_funcall | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 619 of file vm_eval.c.

References argc, argv, rescue_funcall_args::mid, Qundef, RB_NO_KEYWORDS, and rescue_funcall_args::recv.

Referenced by rb_get_message(), rb_iseq_load_iseq(), rb_range_values(), and rb_time_zone_abbreviation().

## ◆ rb_check_funcall_kw()

VALUE rb_check_funcall_kw | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | int | kw_splat
| ) |  |

Definition at line 613 of file vm_eval.c.

References argc, argv, rescue_funcall_args::kw_splat, rescue_funcall_args::mid, Qundef, and rescue_funcall_args::recv.

## ◆ rb_clear_constant_cache()

void rb_clear_constant_cache | ( | void |  | ) |

Definition at line 127 of file vm_method.c.

References INC_GLOBAL_CONSTANT_STATE.

Referenced by rb_const_remove(), and rb_const_set().

## ◆ rb_clear_method_cache_by_class()

void rb_clear_method_cache_by_class | ( | VALUE |  | ) |

## ◆ rb_define_alloc_func()

void rb_define_alloc_func | ( | VALUE | ,
|  | rb_alloc_func_t |
| ) |  |

Referenced by Init_Array(), Init_Complex(), Init_Cont(), Init_date_core(), Init_dbm(), Init_Dir(), Init_Encoding(), Init_Exception(), Init_fiddle_closure(), Init_fiddle_function(), Init_fiddle_handle(), Init_fiddle_pinned(), Init_fiddle_pointer(), Init_File(), Init_GC(), Init_gdbm(), Init_generator(), Init_Hash(), Init_IO(), Init_monitor(), Init_ossl_bn(), Init_ossl_cipher(), Init_ossl_digest(), Init_ossl_ec(), Init_ossl_hmac(), Init_ossl_ns_spki(), Init_ossl_ocsp(), Init_ossl_pkcs12(), Init_ossl_pkcs7(), Init_ossl_pkey(), Init_ossl_ssl(), Init_ossl_ssl_session(), Init_ossl_ts(), Init_ossl_x509attr(), Init_ossl_x509cert(), Init_ossl_x509crl(), Init_ossl_x509ext(), Init_ossl_x509name(), Init_ossl_x509req(), Init_ossl_x509revoked(), Init_ossl_x509store(), Init_parser(), Init_psych_emitter(), Init_psych_parser(), Init_Rational(), Init_Regexp(), Init_String(), Init_stringio(), Init_strscan(), Init_Thread(), Init_Time(), Init_vm_backtrace(), Init_win32ole(), Init_win32ole_event(), Init_win32ole_method(), Init_win32ole_param(), Init_win32ole_record(), Init_win32ole_type(), Init_win32ole_typelib(), Init_win32ole_variant(), Init_zlib(), InitVM_console(), InitVM_digest(), InitVM_Enumerator(), InitVM_process(), InitVM_Random(), InitVM_transcode(), and rsock_init_addrinfo().

## ◆ rb_eval_cmd_kw()

VALUE rb_eval_cmd_kw | ( | VALUE | cmd,
|  | VALUE | arg,
|  | int | kw_splat
| ) |  |

Definition at line 1909 of file vm_eval.c.

References EC_EXEC_TAG, EC_JUMP_TAG, EC_POP_TAG, EC_PUSH_TAG, NULL, Qnil, RARRAY_CONST_PTR, rb_funcallv_kw(), rb_vm_top_self(), T_STRING, and TAG_NONE.

## ◆ rb_f_notimplement()

VALUE rb_f_notimplement | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | obj,
|  | VALUE | marker
| ) |  |

Definition at line 299 of file vm_method.c.

References Qnil, rb_notimplement(), and UNREACHABLE_RETURN.

Referenced by Init_ossl_ssl(), rb_add_method_cfunc(), and rb_method_definition_set().

## ◆ rb_frame_method_id_and_class()

int rb_frame_method_id_and_class | ( | ID * | idp,
|  | VALUE * | klassp
| ) |  |

Definition at line 2446 of file vm.c.

References rb_ec_frame_method_id_and_class().

## ◆ rb_get_alloc_func()

rb_alloc_func_t rb_get_alloc_func | ( | VALUE | klass | ) |

Definition at line 960 of file vm_method.c.

References RCLASS_EXT, RCLASS_SUPER, T_CLASS, and UNDEF_ALLOC_FUNC.

## ◆ rb_make_backtrace()

VALUE rb_make_backtrace | ( | void |  | ) |

Definition at line 1059 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, BACKTRACE_START, and rb_ec_backtrace_str_ary().

## ◆ rb_method_basic_definition_p()

int rb_method_basic_definition_p | ( | VALUE | klass,
|  | ID | id
| ) |  |

Definition at line 2439 of file vm_method.c.

References FALSE, METHOD_ENTRY_BASIC, rb_callable_method_entry(), and TRUE.

## ◆ rb_method_boundp()

int rb_method_boundp | ( | VALUE | klass,
|  | ID | id,
|  | int | ex
| ) |  |

Definition at line 1469 of file vm_method.c.

## ◆ rb_mod_module_eval()

VALUE rb_mod_module_eval | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | mod
| ) |  |

Definition at line 2164 of file vm_eval.c.

References argc, argv, mod, and RB_NO_KEYWORDS.

## ◆ rb_mod_module_exec()

VALUE rb_mod_module_exec | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | mod
| ) |  |

Definition at line 2198 of file vm_eval.c.

References argc, argv, mod, and RB_NO_KEYWORDS.

## ◆ rb_obj_instance_eval()

VALUE rb_obj_instance_eval | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | self
| ) |  |

Definition at line 2092 of file vm_eval.c.

References argc, argv, RB_NO_KEYWORDS, and rb_captured_block::self.

## ◆ rb_obj_instance_exec()

VALUE rb_obj_instance_exec | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | self
| ) |  |

Definition at line 2124 of file vm_eval.c.

References argc, argv, RB_NO_KEYWORDS, and rb_captured_block::self.

## ◆ rb_obj_respond_to()

int rb_obj_respond_to | ( | VALUE | obj,
|  | ID | id,
|  | int | priv
| ) |  |

Definition at line 2545 of file vm_method.c.

References rb_ec_obj_respond_to().

Referenced by rb_respond_to().

## ◆ rb_remove_method()

void rb_remove_method | ( | VALUE | klass,
|  | const char * | name
| ) |  |

Definition at line 1357 of file vm_method.c.

References name, and rb_intern().

## ◆ rb_remove_method_id()

void rb_remove_method_id | ( | VALUE | klass,
|  | ID | mid
| ) |  |

Definition at line 1351 of file vm_method.c.

## ◆ rb_respond_to()

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

Definition at line 2561 of file vm_method.c.

References FALSE, and rb_obj_respond_to().

Referenced by ossl_to_der_if_possible(), rb_econv_prepare_options(), rb_scheduler_close(), rb_scheduler_supports_io_read(), rb_scheduler_supports_io_write(), rb_scheduler_supports_process_wait(), and rb_str_equal().

## ◆ rb_sourcefile()

const char * rb_sourcefile | ( | void |  | ) |

Definition at line 1571 of file vm.c.

References rb_execution_context_struct::cfp, rb_control_frame_struct::iseq, rb_iseq_path(), rb_vm_get_ruby_level_next_cfp(), and RSTRING_PTR.

Referenced by rb_autoload_load().

## ◆ rb_sourceline()

int rb_sourceline | ( | void |  | ) |

Definition at line 1586 of file vm.c.

References rb_execution_context_struct::cfp, rb_vm_get_ruby_level_next_cfp(), and rb_vm_get_sourceline().

## ◆ rb_undef_alloc_func()

void rb_undef_alloc_func | ( | VALUE | klass | ) |

Definition at line 954 of file vm_method.c.

References rb_define_alloc_func(), and UNDEF_ALLOC_FUNC.

Referenced by Init_ast(), Init_bigdecimal(), Init_Binding(), Init_cparse(), Init_ISeq(), Init_Numeric(), Init_objspace(), Init_ossl_engine(), Init_Proc(), Init_Ractor(), Init_String(), Init_VM(), Init_vm_backtrace(), Init_vm_trace(), Init_zlib(), InitVM_Enumerator(), InitVM_process(), InitVM_Random(), InitVM_Struct(), rsock_init_sockifaddr(), and ruby_Init_Continuation_body().