Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
vm.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_VM_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_VM_H
26#include "ruby/internal/value.h"
27
29
30/* vm.c */
31
32
39int rb_sourceline(void);
40
49const char *rb_sourcefile(void);
50
62int rb_frame_method_id_and_class(ID *idp, VALUE *klassp);
63
64/* vm_eval.c */
65
77VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv);
78
96VALUE rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat);
97
112VALUE rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat);
113
125VALUE rb_apply(VALUE recv, ID mid, VALUE args);
126
144VALUE rb_obj_instance_eval(int argc, const VALUE *argv, VALUE recv);
145
169VALUE rb_obj_instance_exec(int argc, const VALUE *argv, VALUE recv);
170
181VALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod);
182
193VALUE rb_mod_module_exec(int argc, const VALUE *argv, VALUE mod);
194
195/* vm_method.c */
196
204#define HAVE_RB_DEFINE_ALLOC_FUNC 1
205
216typedef VALUE (*rb_alloc_func_t)(VALUE klass);
217
226
237void rb_undef_alloc_func(VALUE klass);
238
253
260
273void rb_alias(VALUE klass, ID dst, ID src);
274
293void rb_attr(VALUE klass, ID name, int need_reader, int need_writer, int honour_visibility);
294
307void rb_remove_method(VALUE klass, const char *name);
308
319void rb_remove_method_id(VALUE klass, ID mid);
320
338int rb_method_boundp(VALUE klass, ID id, int ex);
339
350int rb_method_basic_definition_p(VALUE klass, ID mid);
351
365int rb_obj_respond_to(VALUE obj, ID mid, int private_p);
366
376int rb_respond_to(VALUE obj, ID mid);
377
398VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker);
399#if !defined(RUBY_EXPORT) && defined(_WIN32)
400RUBY_EXTERN VALUE (*const rb_f_notimplement_)(int, const VALUE *, VALUE, VALUE marker);
401#define rb_f_notimplement (*rb_f_notimplement_)
402#endif
403
404/* vm_backtrace.c */
405
414void rb_backtrace(void);
415
427
429
430#endif /* RBIMPL_INTERN_VM_H */
Tweaking visibility of C variables/functions.
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
int rb_respond_to(VALUE obj, ID mid)
Queries if the object responds to the method.
Definition vm_method.c:2953
VALUE(* rb_alloc_func_t)(VALUE klass)
This is the type of functions that ruby calls when trying to allocate an object.
Definition vm.h:216
void rb_undef_alloc_func(VALUE klass)
Deletes the allocator function of a class.
Definition vm_method.c:1284
const char * rb_sourcefile(void)
Resembles __FILE__.
Definition vm.c:1873
void rb_alias(VALUE klass, ID dst, ID src)
Resembles alias.
Definition vm_method.c:2282
void rb_attr(VALUE klass, ID name, int need_reader, int need_writer, int honour_visibility)
This function resembles now-deprecated Module#attr.
Definition vm_method.c:1862
void rb_remove_method(VALUE klass, const char *name)
Removes a method.
Definition vm_method.c:1711
VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv)
Identical to rb_funcallv(), except it returns RUBY_Qundef instead of raising rb_eNoMethodError.
Definition vm_eval.c:668
int rb_frame_method_id_and_class(ID *idp, VALUE *klassp)
Resembles __method__.
Definition vm.c:2888
rb_alloc_func_t rb_get_alloc_func(VALUE klass)
Queries the allocator function of a class.
Definition vm_method.c:1290
void rb_clear_constant_cache_for_id(ID id)
Clears the inline constant caches associated with a particular ID.
Definition vm_method.c:138
VALUE rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Identical to rb_check_funcall(), except you can specify how to handle the last element of the given a...
Definition vm_eval.c:662
VALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod)
Identical to rb_obj_instance_eval(), except it evaluates within the context of module.
Definition vm_eval.c:2367
void rb_remove_method_id(VALUE klass, ID mid)
Identical to rb_remove_method(), except it accepts the method name as ID.
Definition vm_method.c:1705
VALUE rb_mod_module_exec(int argc, const VALUE *argv, VALUE mod)
Identical to rb_obj_instance_exec(), except it evaluates within the context of module.
Definition vm_eval.c:2401
void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func)
Sets the allocator function of a class.
VALUE rb_obj_instance_exec(int argc, const VALUE *argv, VALUE recv)
Executes the given block within the context of the receiver.
Definition vm_eval.c:2328
VALUE rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat)
This API is practically a variant of rb_proc_call_kw() now.
Definition vm_eval.c:2123
VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker)
Raises rb_eNotImpError.
Definition vm_method.c:474
VALUE rb_apply(VALUE recv, ID mid, VALUE args)
Identical to rb_funcallv(), except it takes Ruby's array instead of C's.
Definition vm_eval.c:1074
VALUE rb_make_backtrace(void)
Creates the good old fashioned array-of-strings style backtrace info.
int rb_method_boundp(VALUE klass, ID id, int ex)
Queries if the klass has this method.
Definition vm_method.c:1823
void rb_backtrace(void)
Prints the backtrace out to the standard error.
VALUE rb_obj_instance_eval(int argc, const VALUE *argv, VALUE recv)
Evaluates a string containing Ruby source code, or the given block, within the context of the receive...
Definition vm_eval.c:2298
int rb_sourceline(void)
Resembles __LINE__.
Definition vm.c:1887
int rb_obj_respond_to(VALUE obj, ID mid, int private_p)
Identical to rb_respond_to(), except it additionally takes the visibility parameter.
Definition vm_method.c:2937
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
Defines RBIMPL_ATTR_NORETURN.
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
Defines VALUE and ID.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40