[ruby/etc] bump up to 1.3.1
[ruby-80x24.org.git] / builtin.h
blob96339afdb558acd85308b26218657596d3fdb20e
1 #ifndef BUILTIN_H_INCLUDED
2 #define BUILTIN_H_INCLUDED
4 // invoke
6 struct rb_builtin_function {
7 // for invocation
8 const void * const func_ptr;
9 const int argc;
11 // for load
12 const int index;
13 const char * const name;
15 // for jit
16 void (*compiler)(FILE *, long, unsigned, bool);
19 #define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\
20 .name = #_name, \
21 .func_ptr = (void *)_fname, \
22 .argc = _arity, \
23 .index = _i, \
24 .compiler = _compiler, \
27 void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
29 #ifndef rb_execution_context_t
30 typedef struct rb_execution_context_struct rb_execution_context_t;
31 #define rb_execution_context_t rb_execution_context_t
32 #endif
34 /* The following code is generated by the following Ruby script:
36 16.times{|i|
37 args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
38 puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
42 static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
43 static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
44 static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
45 static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
46 static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
47 static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
48 static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
49 static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
50 static inline void rb_builtin_function_check_arity8(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
51 static 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)){}
52 static 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)){}
53 static 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)){}
54 static 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)){}
55 static 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)){}
56 static 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)){}
57 static 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)){}
59 PUREFUNC(VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index));
60 VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
62 // __builtin_inline!
64 PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
66 static inline VALUE
67 rb_vm_lvar(rb_execution_context_t *ec, int index)
69 #if defined(VM_CORE_H_EC_DEFINED) && VM_CORE_H_EC_DEFINED
70 return ec->cfp->ep[index];
71 #else
72 return rb_vm_lvar_exposed(ec, index);
73 #endif
76 // dump/load
78 struct builtin_binary {
79 const char *feature; // feature name
80 const unsigned char *bin; // binary by ISeq#to_binary
81 size_t bin_size;
84 #endif // BUILTIN_H_INCLUDED