Created
February 9, 2020 09:10
-
-
Save miura1729/c61b0a09fdcb8eb01158bc04542ee436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mruby.h> | |
#include <mruby/value.h> | |
#include <mruby/array.h> | |
#include <mruby/throw.h> | |
#include <mruby/proc.h> | |
#include <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#undef mrb_int | |
typedef mrb_float mrb_float2; | |
#define mrb_float_value2(n) ({\ | |
mrb_value rc; \ | |
rc.f = n; \ | |
rc; \ | |
}) | |
typedef void *gproc; | |
struct gctab { | |
int size; | |
int csize; | |
int osize; | |
struct gctab *prev; | |
mrb_value **complex; | |
mrb_value **object; | |
void *caller_alloc; | |
mrb_value *single[0]; | |
}; | |
void mrb_mark_local(mrb_state *mrb) | |
{ | |
struct gctab *curtab = (struct gctab *)mrb->ud; | |
while (curtab) { | |
for (int i = curtab->size; i--;) { | |
mrb_gc_mark(mrb, mrb_basic_ptr(*curtab->single[i])); | |
} | |
for (int i = curtab->osize; i--;) { | |
mrb_gc_mark(mrb, mrb_basic_ptr(*curtab->object[i])); | |
} | |
for (int i = curtab->csize; i--;) { | |
mrb_value *cptr = curtab->complex[i]; | |
for (int j = 0; cptr[j].value.ttt != MRB_TT_FREE; j++) { | |
mrb_gc_mark(mrb, mrb_basic_ptr(cptr[j])); | |
} | |
} | |
curtab = curtab->prev; | |
} | |
} | |
struct env2 { | |
mrb_value *v132; | |
mrb_int v151; | |
struct env1 *prev; | |
}; | |
struct env6 { | |
struct env5 *prev; | |
}; | |
struct env3 { | |
struct env2 *prev; | |
}; | |
struct cls0_6 { | |
}; | |
struct cls2_6 { | |
}; | |
struct cls3_6 { | |
}; | |
struct cls4_6 { | |
}; | |
static mrb_value main_Object_0(mrb_state *, mrb_value self,struct gctab *); | |
static mrb_value foo__Object__1(mrb_state *, mrb_value self,struct gctab *); | |
struct proc3 { | |
int id; | |
void *code[2]; | |
struct env2 *env; | |
mrb_value self; | |
}; | |
static mrb_value each__Array__5(mrb_state *, mrb_value self, gproc v1734,struct gctab *); | |
static mrb_int p3_Object_0_4(mrb_state *, gproc cgproc, mrb_value v161, struct gctab *); | |
int main(int argc, char **argv) | |
{ | |
mrb_state *mrb = mrb_open(); | |
struct mrb_jmpbuf c_jmp; | |
MRB_TRY(&c_jmp) { | |
mrb->jmp = &c_jmp; | |
main_Object_0(mrb, mrb_top_self(mrb), NULL); | |
} | |
MRB_CATCH(&c_jmp) { | |
mrb_p(mrb, mrb_obj_value(mrb->exc)); | |
return 1; | |
} | |
MRB_END_EXC(&c_jmp); | |
return 0; | |
} | |
static mrb_value main_Object_0(mrb_state *mrb, mrb_value self, struct gctab *prevgctab) { | |
mrb_value v13; | |
struct gctab *gctab = prevgctab; | |
L0:; | |
v13 = foo__Object__1(mrb, self, gctab); | |
return v13; | |
} | |
static mrb_value foo__Object__1(mrb_state *mrb, mrb_value self, struct gctab *prevgctab) { | |
struct env2 env; | |
struct REnv *venv = NULL; | |
char *v133 = "ab"; | |
char *v138; | |
mrb_float2 v144; | |
mrb_sym v150; | |
mrb_int v151; | |
mrb_value v153; | |
char *v154 = "abc"; | |
mrb_value v156; | |
mrb_value v184; | |
mrb_value v188; | |
int ai = mrb_gc_arena_save(mrb); | |
struct gctab *gctab = (struct gctab *)alloca(sizeof(struct gctab) + 0 * sizeof(mrb_value *)); | |
gctab->prev = prevgctab; | |
gctab->complex = alloca(sizeof(mrb_value *) * 1); | |
gctab->object = NULL; | |
gctab->size = 0; | |
gctab->csize = 0; | |
gctab->osize = 0; | |
L5:; | |
mrb_value v132[6] = { | |
}; | |
v132[0].value.ttt = MRB_TT_FREE; | |
v132[1].value.ttt = MRB_TT_FREE; | |
v132[2].value.ttt = MRB_TT_FREE; | |
v132[3].value.ttt = MRB_TT_FREE; | |
v132[4].value.ttt = MRB_TT_FREE; | |
v132[5].value.ttt = MRB_TT_FREE; | |
gctab->complex[0] = v132; | |
gctab->csize = 1; | |
env.v132 = v132; | |
v132[0] = (mrb_str_new_cstr(mrb, "ab")); | |
v138 = "ab"; | |
v132[1] = (mrb_float_value2(3)); | |
v144 = 3; | |
v132[2] = (mrb_symbol_value(mrb_intern_lit(mrb, "b"))); | |
v150 = mrb_intern_lit(mrb, "b"); | |
v151 = 3; | |
env.v151 = v151; | |
{ | |
mrb_value tmpele[] = { | |
}; | |
mrb->ud = (void *)gctab; | |
v153 = mrb_ary_new_from_values(mrb, 0, tmpele); | |
ARY_SET_LEN(mrb_ary_ptr(v153), 0); | |
} | |
{ | |
mrb_value tmpele[] = { | |
(mrb_symbol_value(mrb_intern_lit(mrb, "a"))), v153, (mrb_str_new_cstr(mrb, "abc")), (mrb_fixnum_value(1)) | |
}; | |
mrb->ud = (void *)gctab; | |
v156 = mrb_ary_new_from_values(mrb, 4, tmpele); | |
ARY_SET_LEN(mrb_ary_ptr(v156), 4); | |
} | |
struct proc3 v157; | |
v157.id = 3; | |
v157.self = self; | |
v157.env = &env; | |
v184 = each__Array__5(mrb, v156, ((gproc)&v157), gctab); | |
v151 = env.v151; | |
v188 = v132[0]; | |
mrb_gc_arena_restore(mrb, ai); | |
return v188; | |
mrb_gc_arena_restore(mrb, ai); | |
} | |
static mrb_value each__Array__5(mrb_state *mrb, mrb_value self, gproc v1734, struct gctab *prevgctab) { | |
struct env6 env; | |
struct REnv *venv = NULL; | |
gproc v1795; | |
mrb_int v1796; | |
mrb_int v1804; | |
mrb_value v1787; | |
mrb_int v1789; | |
struct gctab *gctab = prevgctab; | |
L110:; | |
L111:; | |
L113:; | |
v1795 = v1734; | |
v1796 = 0; | |
L115:; | |
v1804 = ARY_LEN(mrb_ary_ptr(self)); | |
if ((v1796 < v1804)) goto L114; else goto L116; | |
L114:; | |
v1787 = mrb_ary_ref(mrb, self, v1796); | |
v1789 = (p3_Object_0_4(mrb, v1795, v1787, gctab)); | |
v1795 = v1795; | |
v1796 = (v1796 + 1); | |
goto L115; | |
L116:; | |
return self; | |
} | |
static mrb_int p3_Object_0_4(mrb_state *mrb, gproc cgproc, mrb_value v161, struct gctab *prevgctab) { | |
struct proc3 *proc = (struct proc3 *)cgproc; | |
mrb_value self = proc->self; | |
struct env3 env; | |
struct REnv *venv = NULL; | |
mrb_value *v176; | |
mrb_int v177; | |
mrb_value v180; | |
mrb_int v181; | |
mrb_int v182; | |
mrb_int v151; | |
struct gctab *gctab = prevgctab; | |
env.prev = proc->env; | |
L6:; | |
v176 = proc->env->v132; | |
v177 = proc->env->v151; | |
v176[v177] = v161; | |
v180 = v161; | |
v181 = proc->env->v151; | |
v182 = (v181 + 1); | |
proc->env->v151 = v182; | |
return v182; | |
} | |
/* | |
Class Object | |
Instance variables | |
methodes | |
foo (Object e=false, NilClass e=false) -> String e=false|Symbol(:a)|Array<> e=true|Fixnum e=false | |
Class Array | |
Instance variables | |
methodes | |
each (Array<[:undef] => Symbol(:a)|[:undef] => Array<> e=true|[:undef] => String e=false|[:undef] => Fixnum e=false|0 => Symbol(:a)|1 => Array<> e=true|2 => String e=false|3 => Fixnum e=false> e=false, (Object e=false, Symbol(:a), NilClass e=false) -> Fixnum e=false pos =true | |
(Object e=false, Symbol(:a)|Array<> e=true|String e=false|Fixnum e=false, NilClass e=false) -> Fixnum e=false pos =true ) -> Array<[:undef] => Symbol(:a)|[:undef] => Array<> e=true|[:undef] => String e=false|[:undef] => Fixnum e=false|0 => Symbol(:a)|1 => Array<> e=true|2 => String e=false|3 => Fixnum e=false> e=true | |
each (Array<[:undef] => Symbol(:a)|[:undef] => Array<> e=true|[:undef] => String e=false|[:undef] => Fixnum e=false|0 => Symbol(:a)|1 => Array<> e=true|2 => String e=false|3 => Fixnum e=false> e=true, (Object e=false, Symbol(:a), NilClass e=false) -> Fixnum e=false pos =true | |
(Object e=false, Symbol(:a)|Array<> e=true|String e=false|Fixnum e=false, NilClass e=false) -> Fixnum e=false pos =true ) -> Array<[:undef] => Symbol(:a)|[:undef] => Array<> e=true|[:undef] => String e=false|[:undef] => Fixnum e=false|0 => Symbol(:a)|1 => Array<> e=true|2 => String e=false|3 => Fixnum e=false> e=true | |
Class String | |
Instance variables | |
methodes | |
Class Float | |
Instance variables | |
methodes | |
Class Symbol | |
Instance variables | |
methodes | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment