2019-12-09 10:20:35 +03:00
|
|
|
#ifndef BUILTIN_H_INCLUDED
|
|
|
|
#define BUILTIN_H_INCLUDED
|
|
|
|
|
2019-11-07 10:58:00 +03:00
|
|
|
// invoke
|
|
|
|
|
|
|
|
struct rb_builtin_function {
|
|
|
|
// for invocation
|
|
|
|
const void * const func_ptr;
|
|
|
|
const int argc;
|
|
|
|
|
|
|
|
// for load
|
|
|
|
const int index;
|
|
|
|
const char * const name;
|
2020-07-09 15:43:42 +03:00
|
|
|
|
|
|
|
// for jit
|
2020-07-13 05:43:24 +03:00
|
|
|
void (*compiler)(FILE *, long, unsigned, bool);
|
2019-11-07 10:58:00 +03:00
|
|
|
};
|
|
|
|
|
2020-07-09 15:43:42 +03:00
|
|
|
#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\
|
2019-12-13 11:26:12 +03:00
|
|
|
.name = #_name, \
|
|
|
|
.func_ptr = (void *)_fname, \
|
|
|
|
.argc = _arity, \
|
2020-07-09 15:43:42 +03:00
|
|
|
.index = _i, \
|
|
|
|
.compiler = _compiler, \
|
2019-12-13 11:26:12 +03:00
|
|
|
}
|
2019-11-07 10:58:00 +03:00
|
|
|
|
2019-11-09 13:43:14 +03:00
|
|
|
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
|
2019-11-07 10:58:00 +03:00
|
|
|
|
2020-03-19 07:25:53 +03:00
|
|
|
#ifndef rb_execution_context_t
|
2019-11-07 10:58:00 +03:00
|
|
|
typedef struct rb_execution_context_struct rb_execution_context_t;
|
2020-03-19 07:25:53 +03:00
|
|
|
#define rb_execution_context_t rb_execution_context_t
|
2019-11-07 10:58:00 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The following code is generated by the following Ruby script:
|
|
|
|
|
|
|
|
16.times{|i|
|
|
|
|
args = (i > 0 ? ', ' : '') + (0...i).map{"VALUE"}.join(', ')
|
|
|
|
puts "static inline void rb_builtin_function_check_arity#{i}(VALUE (*f)(rb_execution_context_t *ec, VALUE self#{args})){}"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void rb_builtin_function_check_arity0(VALUE (*f)(rb_execution_context_t *ec, VALUE self)){}
|
|
|
|
static inline void rb_builtin_function_check_arity1(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE)){}
|
|
|
|
static inline void rb_builtin_function_check_arity2(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE)){}
|
|
|
|
static inline void rb_builtin_function_check_arity3(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE)){}
|
|
|
|
static inline void rb_builtin_function_check_arity4(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE)){}
|
|
|
|
static inline void rb_builtin_function_check_arity5(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE)){}
|
|
|
|
static inline void rb_builtin_function_check_arity6(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
|
|
|
|
static inline void rb_builtin_function_check_arity7(VALUE (*f)(rb_execution_context_t *ec, VALUE self, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
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)){}
|
|
|
|
|
2019-11-11 10:38:46 +03:00
|
|
|
VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
|
|
|
|
|
2019-11-13 19:48:08 +03:00
|
|
|
// __builtin_inline!
|
|
|
|
|
|
|
|
PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
|
|
|
|
|
2019-11-11 18:07:26 +03:00
|
|
|
static inline VALUE
|
2019-11-11 10:38:46 +03:00
|
|
|
rb_vm_lvar(rb_execution_context_t *ec, int index)
|
|
|
|
{
|
|
|
|
#if VM_CORE_H_EC_DEFINED
|
|
|
|
return ec->cfp->ep[index];
|
|
|
|
#else
|
|
|
|
return rb_vm_lvar_exposed(ec, index);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-11-07 10:58:00 +03:00
|
|
|
// dump/load
|
|
|
|
|
|
|
|
struct builtin_binary {
|
|
|
|
const char *feature; // feature name
|
|
|
|
const unsigned char *bin; // binary by ISeq#to_binary
|
|
|
|
size_t bin_size;
|
|
|
|
};
|
2019-12-09 10:20:35 +03:00
|
|
|
|
|
|
|
#endif // BUILTIN_H_INCLUDED
|