Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
builtin.h
Go to the documentation of this file.
1#ifndef BUILTIN_H_INCLUDED
2#define BUILTIN_H_INCLUDED
3
4// invoke
5
7 // for invocation
8 const void * const func_ptr;
9 const int argc;
10
11 // for load
12 const int index;
13 const char * const name;
14};
15
16#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) { \
17 .name = #_name, \
18 .func_ptr = (void *)_fname, \
19 .argc = _arity, \
20 .index = _i \
21}
22
23void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
24
25#ifndef VM_CORE_H_EC_DEFINED
27#endif
28
29/* The following code is generated by the following Ruby script:
30
3116.times{|i|
32 args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
33 puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
34}
35*/
36
37static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
38static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
39static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
40static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
41static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
42static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
43static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
44static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
45static inline void rb_builtin_function_check_arity8(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
46static inline void rb_builtin_function_check_arity9(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
47static inline void rb_builtin_function_check_arity10(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
48static inline void rb_builtin_function_check_arity11(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
49static inline void rb_builtin_function_check_arity12(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
50static inline void rb_builtin_function_check_arity13(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
51static inline void rb_builtin_function_check_arity14(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
52static inline void rb_builtin_function_check_arity15(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
53
55
56// __builtin_inline!
57
58PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
59
60static inline VALUE
61rb_vm_lvar(rb_execution_context_t *ec, int index)
62{
63#if VM_CORE_H_EC_DEFINED
64 return ec->cfp->ep[index];
65#else
66 return rb_vm_lvar_exposed(ec, index);
67#endif
68}
69
70// dump/load
71
72struct builtin_binary {
73 const char *feature; // feature name
74 const unsigned char *bin; // binary by ISeq#to_binary
75 size_t bin_size;
76};
77
78#endif // BUILTIN_H_INCLUDED
PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index))
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
Definition: builtin.c:39
VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index)
unsigned long VALUE
Definition: ruby.h:102
#define f
const unsigned char * bin