72 if( *nest_idx == 0 )
return 0;
73 cls = nest_buf[--(*nest_idx)];
82 mrbc_printf(
"Warning: Module nest exceeds upper limit.\n");
84 nest_buf[(*nest_idx)++] = cls;
104 if( *nest_idx == 0 )
return 0;
105 return nest_buf[--(*nest_idx)];
137 if( !cls )
return cls;
142#if defined(MRBC_DEBUG)
183 if( !cls )
return cls;
191#if defined(MRBC_DEBUG)
229 if( !cls )
return cls;
235#if defined(MRBC_DEBUG)
275 if( !cls )
return cls;
284#if defined(MRBC_DEBUG)
309 if( !method )
return;
314 if( method->
sym_id < 0 ) {
317 method->
func = cfunc;
398#if defined(MRBC_ALLOC_VMID)
425 while( cls != tcls ) {
427 if( ! cls )
return 0;
451 if( method->
sym_id == sym_id ) {
460 if( right == 0 )
goto NEXT;
463 while( left < right ) {
464 int mid = (left + right) / 2;
473 r_method->
type =
'm';
504 if(
sym_id < 0 )
return NULL;
507 if( obj == NULL )
return NULL;
539 mrbc_value *recv,
const char *method_name,
int n_params, ... )
551 "Method needs to be C function. '%s' for %s",
563 va_start(ap, n_params);
565 for( i = 1; i <= n_params; i++ ) {
574 method.
func(vm, regs, n_params);
577 for(; i >= 0; i-- ) {
626#define MRBC_DEFINE_BUILTIN_CLASS_TABLE
627#include "_autogen_builtin_class.h"
628#undef MRBC_DEFINE_BUILTIN_CLASS_TABLE
638 for(
int i = 0; i <
sizeof(MRBC_BuiltinClass)/
sizeof(
struct MRBC_BuiltinClass); i++ ) {
653 extern const uint8_t mrblib_bytecode[];
void * mrbc_raw_alloc_no_free(unsigned int size)
void mrbc_raw_free(void *ptr)
void mrbc_init_module_math(void)
mrbc_value mrbc_instance_new(struct VM *vm, mrbc_class *cls, int size)
mrbc_class * mrbc_get_class_by_name(const char *name)
void mrbc_init_class(void)
mrbc_class * mrbc_define_module_under(struct VM *vm, const mrbc_class *outer, const char *name)
void c_ineffect(struct VM *vm, mrbc_value v[], int argc)
int mrbc_obj_is_kind_of(const mrbc_value *obj, const mrbc_class *tcls)
void mrbc_define_method(struct VM *vm, mrbc_class *cls, const char *name, mrbc_func_t cfunc)
mrbc_value mrbc_instance_getiv(mrbc_value *obj, mrbc_sym sym_id)
mrbc_class * mrbc_traverse_class_tree(mrbc_class *cls, mrbc_class *nest_buf[], int *nest_idx)
void mrbc_instance_delete(mrbc_value *v)
mrbc_class * mrbc_define_module(struct VM *vm, const char *name)
int mrbc_run_mrblib(const void *bytecode)
void mrbc_instance_setiv(mrbc_value *obj, mrbc_sym sym_id, mrbc_value *v)
mrbc_method * mrbc_find_method(mrbc_method *r_method, mrbc_class *cls, mrbc_sym sym_id)
mrbc_value mrbc_send(struct VM *vm, mrbc_value *v, int argc, mrbc_value *recv, const char *method_name, int n_params,...)
mrbc_class * mrbc_define_class_under(struct VM *vm, const mrbc_class *outer, const char *name, mrbc_class *super)
mrbc_class *const mrbc_class_tbl[MRBC_TT_MAXVAL+1]
mrbc_class * mrbc_define_class(struct VM *vm, const char *name, mrbc_class *super)
mrbc_class * mrbc_traverse_class_tree_skip(mrbc_class *nest_buf[], int *nest_idx)
struct RInstance mrbc_instance
Instance object.
#define MRBC_TRAVERSE_NEST_LEVEL
struct RMethod mrbc_method
Method management structure.
static mrbc_class * find_class_by_object(const mrbc_value *obj)
struct RClass mrbc_class
Class object.
void mrbc_printf(const char *fstr,...)
void mrbc_raise(struct VM *vm, struct RClass *exc_cls, const char *msg)
void mrbc_print_vm_exception(const struct VM *vm)
void mrbc_raisef(struct VM *vm, struct RClass *exc_cls, const char *fstr,...)
mrbc_value * mrbc_get_class_const(const struct RClass *cls, mrbc_sym sym_id)
mrbc_value * mrbc_get_const(mrbc_sym sym_id)
int mrbc_set_class_const(const struct RClass *cls, mrbc_sym sym_id, mrbc_value *v)
int mrbc_set_const(mrbc_sym sym_id, mrbc_value *v)
int mrbc_kv_init_handle(struct VM *vm, mrbc_kv_handle *kvh, int size)
void mrbc_kv_delete_data(mrbc_kv_handle *kvh)
mrbc_value * mrbc_kv_get(mrbc_kv_handle *kvh, mrbc_sym sym_id)
int mrbc_kv_set(mrbc_kv_handle *kvh, mrbc_sym sym_id, mrbc_value *set_val)
int mrbc_load_mrb(struct VM *vm, const void *bytecode)
Include at once the necessary header files.
uint8_t num_builtin_method
num of built-in method.
unsigned int flag_module
is module?
mrbc_sym sym_id
class name's symbol ID
const mrbc_sym * method_symbols
built-in method sym-id table.
const mrbc_func_t * method_functions
built-in method function table.
struct RMethod * method_link
pointer to method link.
unsigned int flag_alias
is module alias?
struct RClass * super
pointer to super class.
struct RClass * aliased
aliased class or module.
unsigned int flag_builtin
is built-in class? (= 0)
mrbc_sym sym_id
class name's symbol ID
void(* destructor)(mrbc_value *)
specify a destructor if need.
unsigned int flag_module
is module?
struct RClass * cls
pointer to class of this object.
struct RKeyValueHandle ivar
instance variable.
struct RClass * cls
return value for mrbc_find_method.
mrbc_sym sym_id
function names symbol ID
uint8_t type
M:OP_DEF or OP_ALIAS, m:mrblib or define_method()
struct RMethod * next
link to next method.
uint8_t c_func
0:IREP, 1:C Func, 2:C Func (built-in)
mrbc_func_t func
to C function.
struct RInstance * instance
mrbc_sym mrbc_search_symid(const char *str)
mrbc_value mrbc_symbol_new(struct VM *vm, const char *str)
mrbc_sym mrbc_str_to_symid(const char *str)
const char * mrbc_symid_to_str(mrbc_sym sym_id)
void make_nested_symbol_s(char *buf, mrbc_sym id1, mrbc_sym id2)
static void mrbc_decref(mrbc_value *v)
#define MRBC_INIT_OBJECT_HEADER(p, t)
void(* mrbc_func_t)(struct VM *vm, struct RObject *v, int argc)
static void mrbc_incref(mrbc_value *v)
int16_t mrbc_sym
mruby/c symbol ID
@ MRBC_TT_OBJECT
General instance.
struct RObject mrbc_value
mrbc_vm * mrbc_vm_new(int regs_size)
void mrbc_vm_end(struct VM *vm)
void mrbc_vm_begin(struct VM *vm)
int mrbc_vm_run(struct VM *vm)
void mrbc_vm_close(struct VM *vm)
struct VM mrbc_vm
Virtual Machine.
Global configuration of mruby/c VM's.