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

Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)

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
23#include "ruby/internal/attr/nonnull.h"
24#include "ruby/internal/attr/noreturn.h"
25#include "ruby/internal/dllexport.h"
26#include "ruby/internal/value.h"
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
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
77 VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv);
78
96 VALUE rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat);
97
112 VALUE rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat);
113
125 VALUE rb_apply(VALUE recv, ID mid, VALUE args);
126
144 VALUE rb_obj_instance_eval(int argc, const VALUE *argv, VALUE recv);
145
169 VALUE rb_obj_instance_exec(int argc, const VALUE *argv, VALUE recv);
170
181 VALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod);
182
193 VALUE 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
216 typedef VALUE (*rb_alloc_func_t)(VALUE klass);
217
225 void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func);
226
238void rb_undef_alloc_func(VALUE klass);
239
253 rb_alloc_func_t rb_get_alloc_func(VALUE klass);
254
260void rb_clear_constant_cache_for_id(ID id);
261
274void rb_alias(VALUE klass, ID dst, ID src);
275
294void rb_attr(VALUE klass, ID name, int need_reader, int need_writer, int honour_visibility);
295
296 RBIMPL_ATTR_NONNULL(())
308void rb_remove_method(VALUE klass, const char *name);
309
320void rb_remove_method_id(VALUE klass, ID mid);
321
339int rb_method_boundp(VALUE klass, ID id, int ex);
340
351int rb_method_basic_definition_p(VALUE klass, ID mid);
352
366int rb_obj_respond_to(VALUE obj, ID mid, int private_p);
367
377int rb_respond_to(VALUE obj, ID mid);
378
379 RBIMPL_ATTR_NORETURN()
399 VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker);
400#if !defined(RUBY_EXPORT) && defined(_WIN32)
401 RUBY_EXTERN VALUE (*const rb_f_notimplement_)(int, const VALUE *, VALUE, VALUE marker);
402#define rb_f_notimplement (*rb_f_notimplement_)
403#endif
404
405/* vm_backtrace.c */
406
415void rb_backtrace(void);
416
427 VALUE rb_make_backtrace(void);
428
429 RBIMPL_SYMBOL_EXPORT_END()
430
431#endif /* RBIMPL_INTERN_VM_H */
dllexport.h
Tweaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_respond_to
int rb_respond_to(VALUE obj, ID mid)
Queries if the object responds to the method.
Definition vm_method.c:2937
rb_alloc_func_t
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
rb_undef_alloc_func
void rb_undef_alloc_func(VALUE klass)
Deletes the allocator function of a class.
Definition vm_method.c:1274
rb_sourcefile
const char * rb_sourcefile(void)
Resembles __FILE__.
Definition vm.c:1830
rb_alias
void rb_alias(VALUE klass, ID dst, ID src)
Resembles alias.
Definition vm_method.c:2272
rb_attr
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:1852
rb_remove_method
void rb_remove_method(VALUE klass, const char *name)
Removes a method.
Definition vm_method.c:1701
rb_check_funcall
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:687
rb_frame_method_id_and_class
int rb_frame_method_id_and_class(ID *idp, VALUE *klassp)
Resembles __method__.
Definition vm.c:2779
rb_get_alloc_func
rb_alloc_func_t rb_get_alloc_func(VALUE klass)
Queries the allocator function of a class.
Definition vm_method.c:1280
rb_clear_constant_cache_for_id
void rb_clear_constant_cache_for_id(ID id)
Clears the inline constant caches associated with a particular ID.
Definition vm_method.c:141
rb_check_funcall_kw
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:681
rb_mod_module_eval
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:2128
rb_remove_method_id
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:1695
rb_mod_module_exec
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:2162
rb_define_alloc_func
void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func)
Sets the allocator function of a class.
rb_obj_instance_exec
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:2089
rb_eval_cmd_kw
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:1884
rb_f_notimplement
VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker)
Raises rb_eNotImpError.
Definition vm_method.c:490
rb_apply
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:1096
rb_make_backtrace
VALUE rb_make_backtrace(void)
Creates the good old fashioned array-of-strings style backtrace info.
Definition vm_backtrace.c:1079
rb_method_boundp
int rb_method_boundp(VALUE klass, ID id, int ex)
Queries if the klass has this method.
Definition vm_method.c:1813
rb_backtrace
void rb_backtrace(void)
Prints the backtrace out to the standard error.
Definition vm_backtrace.c:1036
rb_obj_instance_eval
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:2059
rb_sourceline
int rb_sourceline(void)
Resembles __LINE__.
Definition vm.c:1844
rb_obj_respond_to
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:2921
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
noreturn.h
Defines RBIMPL_ATTR_NORETURN.
RBIMPL_ATTR_NORETURN
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
value.h
Defines VALUE and ID.
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40