63 method.
func(vm, v, argc);
64 for(
int i = 1; i <= argc; i++ ) {
84static void c_object_new(
struct VM *vm,
mrbc_value v[],
int argc)
94static void c_object_not(
struct VM *vm,
mrbc_value v[],
int argc)
103static void c_object_neq(
struct VM *vm,
mrbc_value v[],
int argc)
113static void c_object_compare(
struct VM *vm,
mrbc_value v[],
int argc)
123static void c_object_equal2(
struct VM *vm,
mrbc_value v[],
int argc)
133static void c_object_equal3(
struct VM *vm,
mrbc_value v[],
int argc)
150static void c_object_class(
struct VM *vm,
mrbc_value v[],
int argc)
161static void c_object_dup(
struct VM *vm,
mrbc_value v[],
int argc)
181static void c_object_block_given(
struct VM *vm,
mrbc_value v[],
int argc)
184 if( !callinfo )
goto RETURN_FALSE;
190 if( !callinfo )
goto RETURN_FALSE;
206static void c_object_kind_of(
struct VM *vm,
mrbc_value v[],
int argc)
220static void c_object_nil(
struct VM *vm,
mrbc_value v[],
int argc)
229#if !defined(MRBC_NO_STDIO)
230static void c_object_p(
struct VM *vm,
mrbc_value v[],
int argc)
232 for(
int i = 1; i <= argc; i++ ) {
238 }
else if (argc == 1) {
243 if( value.
array == NULL ) {
246 for (
int i = 1; i <= argc; i++ ) {
261#if !defined(MRBC_NO_STDIO)
262static void c_object_print(
struct VM *vm,
mrbc_value v[],
int argc)
264 for(
int i = 1; i <= argc; i++ ) {
275#if !defined(MRBC_NO_STDIO)
276static void c_object_puts(
struct VM *vm,
mrbc_value v[],
int argc)
279 for(
int i = 1; i <= argc; i++ ) {
300static void c_object_raise(
struct VM *vm,
mrbc_value v[],
int argc)
356#if defined(MRBC_DEBUG)
360static void c_object_object_id(
struct VM *vm,
mrbc_value v[],
int argc)
372static void c_object_instance_methods(
struct VM *vm,
mrbc_value v[],
int argc)
392 method = method->
next;
395 if( !flag_inherit )
break;
413static void c_object_instance_variables(
struct VM *vm,
mrbc_value v[],
int argc)
424 for(
int i = 0; i < kvh->
n_stored; i++ ) {
433#if !defined(MRBC_ALLOC_LIBC)
437static void c_object_memory_statistics(
struct VM *vm,
mrbc_value v[],
int argc)
470static void c_object_getiv(
struct VM *vm,
mrbc_value v[],
int argc)
482static void c_object_setiv(
struct VM *vm,
mrbc_value v[],
int argc)
484 static const int NAMEBUFSIZ = 16;
485 char namebuf_auto[NAMEBUFSIZ];
488 int len = strlen(name);
490 if( NAMEBUFSIZ < len ) {
491 namebuf = mrbc_alloc(vm, len);
492 if( !namebuf )
return;
494 namebuf = namebuf_auto;
497 memcpy( namebuf, name, len-1 );
498 namebuf[len-1] =
'\0';
503 if( NAMEBUFSIZ < len ) mrbc_free(vm, namebuf);
510static void c_object_attr_reader(
struct VM *vm,
mrbc_value v[],
int argc)
512 for(
int i = 1; i <= argc; i++ ) {
529static void c_object_attr_accessor(
struct VM *vm,
mrbc_value v[],
int argc)
531 for(
int i = 1; i <= argc; i++ ) {
543 int len = strlen(name);
544 char *namebuf = mrbc_alloc(vm, len+2);
545 if( !namebuf )
return;
546 memcpy(namebuf, name, len);
551 mrbc_free(vm, namebuf);
559static void c_object_include(
struct VM *vm,
mrbc_value v[],
int argc)
572 for(
int i = 1; i <= argc; i++ ) {
582 .sym_id =
module->sym_id,
585 .super = self->super,
587#if defined(MRBC_DEBUG)
588 .name = module->name,
614 if( !flag_inherit )
break;
630static void c_object_sprintf(
struct VM *vm,
mrbc_value v[],
int argc)
632 static const int BUF_INC_STEP = 32;
640 int buflen = BUF_INC_STEP;
641 char *buf = mrbc_alloc(vm, buflen);
642 if( !buf ) {
return; }
652 if( ret == 0 )
break;
653 if( ret < 0 )
goto INCREASE_BUFFER;
680 default: s =
"";
break;
748 buflen += BUF_INC_STEP;
749 buf = mrbc_realloc(vm, pf.
buf, buflen);
750 if( !buf ) {
return; }
756 mrbc_realloc(vm, pf.
buf, buflen+1);
767#if !defined(MRBC_NO_STDIO)
768static void c_object_printf(
struct VM *vm,
mrbc_value v[],
int argc)
770 c_object_sprintf(vm, v, argc);
780static void c_object_to_s(
struct VM *vm,
mrbc_value v[],
int argc)
787 if (!class_or_module) {
788 buf[0] =
'#'; buf[1] =
'<';
792 int bufsiz =
sizeof(buf) - (s - buf);
795 if (!class_or_module) {
862static void c_nil_to_i(
struct VM *vm,
mrbc_value v[],
int argc)
871static void c_nil_to_a(
struct VM *vm,
mrbc_value v[],
int argc)
880static void c_nil_to_h(
struct VM *vm,
mrbc_value v[],
int argc)
890static void c_nil_to_f(
struct VM *vm,
mrbc_value v[],
int argc)
901static void c_nil_inspect(
struct VM *vm,
mrbc_value v[],
int argc)
910static void c_nil_to_s(
struct VM *vm,
mrbc_value v[],
int argc)
943static void c_true_to_s(
struct VM *vm,
mrbc_value v[],
int argc)
968static void c_false_to_s(
struct VM *vm,
mrbc_value v[],
int argc)
985#include "_autogen_class_object.h"
void mrbc_alloc_statistics(struct MRBC_ALLOC_STATISTICS *ret)
void * mrbc_raw_alloc_no_free(unsigned int size)
int mrbc_array_push(mrbc_value *ary, mrbc_value *set_val)
mrbc_value mrbc_array_new(struct VM *vm, int size)
int mrbc_hash_set(mrbc_value *hash, mrbc_value *key, mrbc_value *val)
mrbc_value mrbc_hash_new(struct VM *vm, int size)
void mrbc_instance_call_initialize(struct VM *vm, mrbc_value v[], int argc)
static int set_sym_name_by_id(char *buf, int bufsiz, mrbc_sym sym_id)
mrbc_value mrbc_string_new(struct VM *vm, const void *src, int len)
mrbc_value mrbc_string_new_alloc(struct VM *vm, void *buf, int len)
static char * mrbc_string_cstr(const mrbc_value *v)
static mrbc_value mrbc_string_new_cstr(struct 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)
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_method * mrbc_find_method(mrbc_method *r_method, mrbc_class *cls, mrbc_sym sym_id)
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 struct RClass *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_class * own_class
class that owns method.
mrbc_value * cur_regs
copy from mrbc_vm.
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.
uint16_t n_stored
num of stored.
mrbc_value * data
pointer to allocated memory.
struct RMethod * method_link
pointer to method link.
struct RClass * super
pointer to super class.
mrbc_sym sym_id
class name's symbol ID
uint8_t num_builtin_method
num of built-in method.
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
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)
#define mrbc_symbol_value(n)
static void mrbc_incref(mrbc_value *v)
int16_t mrbc_sym
mruby/c symbol ID
#define mrbc_float_value(vm, n)
@ MRBC_TT_FALSE
FalseClass.
@ MRBC_TT_INTEGER
Integer.
@ MRBC_TT_EXCEPTION
Exception.
@ MRBC_TT_OBJECT
General instance.
struct RObject mrbc_value
#define SET_FALSE_RETURN()
#define mrbc_integer_value(n)
mrbc_callinfo * mrbc_push_callinfo(struct VM *vm, mrbc_sym method_id, int reg_offset, int n_args)
mrbc_sym mrbc_get_callee_symid(struct VM *vm)
const char * mrbc_get_callee_name(struct VM *vm)
struct CALLINFO mrbc_callinfo
Call information.
Global configuration of mruby/c VM's.