63 method.
func(vm, v, argc);
64 for(
int i = 1; i <= argc; i++ ) {
90 if (!class_or_module) {
91 buf[0] =
'#'; buf[1] =
'<';
95 int bufsiz =
sizeof(buf) - (s - buf);
98 if (!class_or_module) {
212 if( !callinfo )
goto RETURN_FALSE;
218 if( !callinfo )
goto RETURN_FALSE;
257#if !defined(MRBC_NO_STDIO)
260 for(
int i = 1; i <= argc; i++ ) {
267 }
else if (argc == 1) {
273 for(
int i = 1; i <= argc; i++ ) {
286#if !defined(MRBC_NO_STDIO)
289 for(
int i = 1; i <= argc; i++ ) {
300#if !defined(MRBC_NO_STDIO)
304 for(
int i = 1; i <= argc; i++ ) {
381#if defined(MRBC_DEBUG)
418 method = method->
next;
421 if( !flag_inherit )
break;
446 for(
int i = 0; i < kvh->
n_stored; i++ ) {
455#if !defined(MRBC_ALLOC_LIBC)
506 char namebuf_auto[16];
509 int len = strlen(name);
511 if(
sizeof(namebuf_auto) < len ) {
512 namebuf = mrbc_alloc(vm, len);
514 namebuf = namebuf_auto;
517 memcpy( namebuf, name, len-1 );
518 namebuf[len-1] =
'\0';
523 if( namebuf != namebuf_auto ) mrbc_free(vm, namebuf);
532 for(
int i = 1; i <= argc; i++ ) {
551 for(
int i = 1; i <= argc; i++ ) {
563 int len = strlen(name);
564 char *namebuf = mrbc_alloc(vm, len+2);
566 memcpy(namebuf, name, len);
571 mrbc_free(vm, namebuf);
592 for(
int i = 1; i <= argc; i++ ) {
601 .sym_id =
module->sym_id,
604 .super = self->super,
606#if defined(MRBC_DEBUG)
608 .name = module->name,
635 if( !flag_inherit )
break;
655 static const int BUF_INC_STEP = 32;
663 int buflen = BUF_INC_STEP;
664 char *buf = mrbc_alloc(vm, buflen);
673 if( ret == 0 )
break;
674 if( ret < 0 )
goto INCREASE_BUFFER;
701 default: s =
"";
break;
769 buflen += BUF_INC_STEP;
770 buf = mrbc_realloc(vm, pf.
buf, buflen);
776 mrbc_realloc(vm, pf.
buf, buflen+1);
787#if !defined(MRBC_NO_STDIO)
790 c_object_sprintf(vm, v, argc);
1008#include "_autogen_class_object.h"
void mrbc_alloc_statistics(struct MRBC_ALLOC_STATISTICS *ret)
void * mrbc_raw_alloc_no_free(unsigned int size)
#define mrbc_symbol_value(n)
static void mrbc_set_tt(mrbc_value *p, mrbc_vtype type)
#define mrbc_float_value(vm, n)
struct RObject mrbc_value
Value object. Default version.
#define mrbc_integer_value(n)
int mrbc_array_push(mrbc_value *ary, mrbc_value *set_val)
mrbc_value mrbc_array_new(mrbc_vm *vm, int size)
mrbc_value mrbc_hash_new(mrbc_vm *vm, int size)
int mrbc_hash_set(mrbc_value *hash, mrbc_value *key, mrbc_value *val)
void mrbc_object_inspect(mrbc_vm *vm, mrbc_value v[], int argc)
static int set_sym_name_by_id(char *buf, int bufsiz, mrbc_sym sym_id)
void mrbc_instance_call_initialize(mrbc_vm *vm, mrbc_value v[], int argc)
mrbc_value mrbc_string_new(mrbc_vm *vm, const void *src, int len)
mrbc_value mrbc_string_new_alloc(mrbc_vm *vm, void *buf, int len)
static char * mrbc_string_cstr(const mrbc_value *v)
static mrbc_value mrbc_string_new_cstr(mrbc_vm *vm, const char *src)
static int mrbc_string_size(const mrbc_value *str)
mrbc_value mrbc_instance_new(struct VM *vm, mrbc_class *cls, int size)
mrbc_class * mrbc_find_method(mrbc_method *r_method, mrbc_class *cls, mrbc_sym sym_id)
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_setiv(mrbc_value *obj, mrbc_sym sym_id, mrbc_value *v)
mrbc_class * mrbc_traverse_class_tree_skip(mrbc_class *nest_buf[], int *nest_idx)
#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_p(const mrbc_value *v)
int mrbc_printf_float(mrbc_printf_t *pf, double value)
int mrbc_print_sub(const mrbc_value *v)
void mrbc_printf(const char *fstr,...)
int mrbc_printf_int(mrbc_printf_t *pf, mrbc_int_t value, unsigned int base)
int mrbc_printf_char(mrbc_printf_t *pf, int ch)
void mrbc_nprint(const char *str, int size)
int mrbc_printf_bstr(mrbc_printf_t *pf, const char *str, int len, int pad)
int mrbc_puts_sub(const mrbc_value *v)
void mrbc_snprintf(char *buf, int bufsiz, const char *fstr,...)
void mrbc_printf_replace_buffer(mrbc_printf_t *pf, char *buf, int size)
void mrbc_putchar(char c)
int mrbc_printf_bit(mrbc_printf_t *pf, mrbc_int_t value, int bit)
int mrbc_printf_main(mrbc_printf_t *pf)
static void mrbc_printf_end(mrbc_printf_t *pf)
static int mrbc_printf_len(mrbc_printf_t *pf)
struct RPrintf mrbc_printf_t
printf tiny (mruby/c) version data container.
static int mrbc_printf_str(mrbc_printf_t *pf, const char *str, int pad)
static void mrbc_printf_init(mrbc_printf_t *pf, char *buf, int size, const char *fstr)
void mrbc_raise(struct VM *vm, struct RClass *exc_cls, const char *msg)
mrbc_value mrbc_exception_new(struct VM *vm, struct RClass *exc_cls, const void *message, int len)
#define mrbc_israised(vm)
void mrbc_get_all_class_const(const mrbc_class *cls, mrbc_value *ret)
void mrbc_kv_dup(const mrbc_kv_handle *src, mrbc_kv_handle *dst)
struct RKeyValueHandle mrbc_kv_handle
Key-Value handle.
Include at once the necessary header files.
mrbc_sym method_id
called method ID.
uint8_t n_args
num of arguments.
mrbc_value * cur_regs
copy from mrbc_vm.
struct RClass * own_class
class that owns method.
uint8_t reg_offset
register offset after call.
const uint8_t * inst
pointer to instruction in RITE binary
Return value structure for mrbc_alloc_statistics function.
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.
mrbc_sym sym_id
class name's symbol ID
uint8_t num_builtin_method
num of built-in method.
unsigned int flag_nomethod
is built-in no method class? (= 0)
mrbc_sym method_id
raised method, if it is known.
struct RClass * cls
pointer to class of this object.
struct RKeyValueHandle ivar
instance variable.
uint16_t n_stored
num of stored.
mrbc_kv * data
pointer to allocated memory.
uint16_t data_size
data buffer size.
mrbc_sym sym_id
symbol ID as key.
struct RClass * cls
return value for mrbc_find_method.
mrbc_sym sym_id
function names symbol ID
struct IREP * irep
to IREP for ruby proc.
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 RException * exception
struct RInstance * instance
struct CALLINFO * callinfo_self
callinfo of self object. Valid when 'B'.
const mrbc_irep * cur_irep
IREP currently running.
mrbc_callinfo * callinfo_tail
Last point of CALLINFO link.
volatile int8_t flag_preemption
mrbc_value exception
Raised exception or nil.
const uint8_t * inst
Instruction pointer.
mrbc_value * cur_regs
Current register top.
mrbc_value mrbc_symbol_new(struct VM *vm, const char *str)
mrbc_sym mrbc_str_to_symid(const char *str)
void mrbc_separate_nested_symid(mrbc_sym sym_id, mrbc_sym *id1, mrbc_sym *id2)
const char * mrbc_symid_to_str(mrbc_sym sym_id)
static const char * mrbc_symbol_cstr(const mrbc_value *v)
static int mrbc_is_nested_symid(mrbc_sym sym_id)
int mrbc_compare(const mrbc_value *v1, const mrbc_value *v2)
int mrbc_strcpy(char *dest, int destsize, const char *src)
static void mrbc_decref(mrbc_value *v)
#define SET_BOOL_RETURN(n)
#define SET_INT_RETURN(n)
static void mrbc_decref_empty(mrbc_value *v)
#define MRBC_PTR_TO_UINT32(p)
static void mrbc_incref(mrbc_value *v)
int16_t mrbc_sym
mruby/c symbol ID
@ MRBC_TT_FALSE
FalseClass.
@ MRBC_TT_INTEGER
Integer.
@ MRBC_TT_EXCEPTION
Exception.
@ MRBC_TT_OBJECT
General instance.
#define SET_FALSE_RETURN()
mrbc_callinfo * mrbc_push_callinfo(mrbc_vm *vm, mrbc_sym method_id, int reg_offset, int n_args)
struct CALLINFO mrbc_callinfo
Call information.
static const char * mrbc_get_callee_name(const mrbc_vm *vm)
struct VM mrbc_vm
Virtual Machine.
static mrbc_sym mrbc_get_callee_symid(const mrbc_vm *vm)
Global configuration of mruby/c VM's.