2019-12-09 02:20:35 -05:00
|
|
|
#ifndef BUILTIN_H_INCLUDED
|
|
|
|
#define BUILTIN_H_INCLUDED
|
|
|
|
|
2019-11-07 02:58:00 -05: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 08:43:42 -04:00
|
|
|
|
|
|
|
// for jit
|
2020-07-12 22:43:24 -04:00
|
|
|
void (*compiler)(FILE *, long, unsigned, bool);
|
2019-11-07 02:58:00 -05:00
|
|
|
};
|
|
|
|
|
2020-07-09 08:43:42 -04:00
|
|
|
#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\
|
2022-09-08 22:51:11 -04:00
|
|
|
.name = _i < 0 ? NULL : #_name, \
|
2019-12-13 03:26:12 -05:00
|
|
|
.func_ptr = (void *)_fname, \
|
|
|
|
.argc = _arity, \
|
2020-07-09 08:43:42 -04:00
|
|
|
.index = _i, \
|
|
|
|
.compiler = _compiler, \
|
2019-12-13 03:26:12 -05:00
|
|
|
}
|
2019-11-07 02:58:00 -05:00
|
|
|
|
2019-11-09 05:43:14 -05:00
|
|
|
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
|
2019-11-07 02:58:00 -05:00
|
|
|
|
2020-03-19 00:25:53 -04:00
|
|
|
#ifndef rb_execution_context_t
|
2019-11-07 02:58:00 -05:00
|
|
|
typedef struct rb_execution_context_struct rb_execution_context_t;
|
2020-03-19 00:25:53 -04:00
|
|
|
#define rb_execution_context_t rb_execution_context_t
|
2019-11-07 02:58:00 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The following code is generated by the following Ruby script:
|
|
|
|
|
2022-06-02 03:03:55 -04:00
|
|
|
typedef = proc {|i, args|
|
|
|
|
"typedef VALUE (*rb_builtin_arity#{i}_function_type)(rb_execution_context_t *ec, VALUE self#{args});"
|
|
|
|
}
|
|
|
|
puts typedef[0, ""]
|
|
|
|
(1..15).each {|i|
|
|
|
|
puts typedef[i, ",\n " + (0...i).map{"VALUE"}.join(", ")]
|
|
|
|
}
|
2019-11-07 02:58:00 -05:00
|
|
|
16.times{|i|
|
2022-06-02 03:03:55 -04:00
|
|
|
puts "static inline void rb_builtin_function_check_arity#{i}(rb_builtin_arity#{i}_function_type f){}"
|
2019-11-07 02:58:00 -05:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2022-06-02 03:03:55 -04:00
|
|
|
typedef VALUE (*rb_builtin_arity0_function_type)(rb_execution_context_t *ec, VALUE self);
|
|
|
|
typedef VALUE (*rb_builtin_arity1_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity2_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity3_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity4_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity5_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity6_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity7_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity8_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity9_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity10_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity11_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity12_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity13_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity14_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
typedef VALUE (*rb_builtin_arity15_function_type)(rb_execution_context_t *ec, VALUE self,
|
|
|
|
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
|
|
|
static inline void rb_builtin_function_check_arity0(rb_builtin_arity0_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity1(rb_builtin_arity1_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity2(rb_builtin_arity2_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity3(rb_builtin_arity3_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity4(rb_builtin_arity4_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity5(rb_builtin_arity5_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity6(rb_builtin_arity6_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity7(rb_builtin_arity7_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity8(rb_builtin_arity8_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity9(rb_builtin_arity9_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity10(rb_builtin_arity10_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity11(rb_builtin_arity11_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity12(rb_builtin_arity12_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity13(rb_builtin_arity13_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity14(rb_builtin_arity14_function_type f){}
|
|
|
|
static inline void rb_builtin_function_check_arity15(rb_builtin_arity15_function_type f){}
|
2019-11-07 02:58:00 -05:00
|
|
|
|
2021-11-14 20:18:20 -05:00
|
|
|
PUREFUNC(VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index));
|
2019-11-11 02:38:46 -05:00
|
|
|
VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
|
|
|
|
|
2019-11-13 11:48:08 -05:00
|
|
|
// __builtin_inline!
|
|
|
|
|
|
|
|
PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
|
|
|
|
|
2019-11-11 10:07:26 -05:00
|
|
|
static inline VALUE
|
2019-11-11 02:38:46 -05:00
|
|
|
rb_vm_lvar(rb_execution_context_t *ec, int index)
|
|
|
|
{
|
2021-04-29 08:31:05 -04:00
|
|
|
#if defined(VM_CORE_H_EC_DEFINED) && VM_CORE_H_EC_DEFINED
|
2019-11-11 02:38:46 -05:00
|
|
|
return ec->cfp->ep[index];
|
|
|
|
#else
|
|
|
|
return rb_vm_lvar_exposed(ec, index);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-11-07 02:58:00 -05: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 02:20:35 -05:00
|
|
|
|
|
|
|
#endif // BUILTIN_H_INCLUDED
|