[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:104

From: ko1 atdot.net
Date: 25 Sep 2005 10:36:26 -0000
Subject: [yarv-diff:104] r260 - in trunk: . benchmark rb

Author: ko1
Date: 2005-09-25 19:36:25 +0900 (Sun, 25 Sep 2005)
New Revision: 260

Added:
   trunk/benchmark/bm_vm2_send.rb
Modified:
   trunk/ChangeLog
   trunk/benchmark/bmx_temp.rb
   trunk/common.mk
   trunk/eval.c
   trunk/eval_intern.h
   trunk/eval_proc.c
   trunk/rb/mklog.rb
   trunk/test.rb
   trunk/vm.c
   trunk/yarv.h
   trunk/yarvcore.c
   trunk/yarvcore.h
Log:
	* benchmark/bm_vm2_send.rb : added

	* common.mk : add rule "bench-item"

	* eval_intern.h : add PASS_PASSED_BLOCK()

	* eval_proc.c : support some functions

	* rb/mklog.rb : added

	* vm.c : fix prototype style and coding style

	* yarv.h : add some prototypes of functions

	* yarvcore.c, yarvcore.h, eval.c : yarv_thread_t#ifuncnode -> passed_block,
	and add yarv_proc_t#safe_level



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/ChangeLog	2005-09-25 10:36:25 UTC (rev 260)
@@ -4,6 +4,26 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-09-25(Sun) 19:30:59 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* benchmark/bm_vm2_send.rb : added
+
+	* common.mk : add rule "bench-item"
+
+	* eval_intern.h : add PASS_PASSED_BLOCK()
+
+	* eval_proc.c : support some functions
+
+	* rb/mklog.rb : added
+
+	* vm.c : fix prototype style and coding style
+
+	* yarv.h : add some prototypes of functions
+
+	* yarvcore.c, yarvcore.h, eval.c : yarv_thread_t#ifuncnode -> passed_block,
+	and add yarv_proc_t#safe_level
+
+
 2005-09-25(Sun) 11:01:17 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* some files : import from ruby 1.9.0 (2005-09-25)

Added: trunk/benchmark/bm_vm2_send.rb
===================================================================
--- trunk/benchmark/bm_vm2_send.rb	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/benchmark/bm_vm2_send.rb	2005-09-25 10:36:25 UTC (rev 260)
@@ -0,0 +1,12 @@
+class C
+  def m
+  end
+end
+
+o = C.new
+
+i=0
+while i<6000000 # benchmark loop 2
+  i+=1
+  o.__send__ :m
+end

Modified: trunk/benchmark/bmx_temp.rb
===================================================================
--- trunk/benchmark/bmx_temp.rb	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/benchmark/bmx_temp.rb	2005-09-25 10:36:25 UTC (rev 260)
@@ -1,5 +1,14 @@
 i = 0
+def m
+end
+class C
+  def m
+    
+  end
+end
+
+o = C.new
 while i < 1000000
   i+=1
+  o.m
 end
-

Modified: trunk/common.mk
===================================================================
--- trunk/common.mk	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/common.mk	2005-09-25 10:36:25 UTC (rev 260)
@@ -430,9 +430,12 @@
 benchmark: all
 	$(BASERUBY) -I$(srcdir) $(srcdir)/benchmark/run_rite.rb $(OPT) $(ITEMS) --yarv-program=$(MINIRUBY) --ruby-program=$(BASERUBY)
 
-ITEM=bmx_temp
 tbench: all
-	$(BASERUBY) -I$(srcdir) $(srcdir)/benchmark/run_rite.rb $(ITEM) $(OPT) --yarv-program=$(MINIRUBY) --ruby-program=$(BASERUBY)
+	$(BASERUBY) -I$(srcdir) $(srcdir)/benchmark/run_rite.rb bmx $(OPT) --yarv-program=$(MINIRUBY) --ruby-program=$(BASERUBY)
+
+bench-item: all
+	$(BASERUBY) -I$(srcdir) $(srcdir)/benchmark/run_rite.rb bm_$(ITEM) $(OPT) --yarv-program=$(MINIRUBY) --ruby-program=$(BASERUBY)
+
 aotc:
 	$(RUBY) -I$(srcdir) -I. $(srcdir)/rb/aotcompile.rb $(INSNS2VMOPT)
 

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/eval.c	2005-09-25 10:36:25 UTC (rev 260)
@@ -23,14 +23,12 @@
 VALUE rb_cProc;
 VALUE rb_cBinding;
 
-VALUE proc_invoke _((VALUE,VALUE,VALUE,VALUE));
-VALUE rb_f_binding _((VALUE));
-void bm_mark _((void *));
+VALUE proc_invoke(VALUE,VALUE,VALUE,VALUE);
+VALUE rb_f_binding(VALUE);
 
-static VALUE proc_lambda _((void));
-VALUE rb_f_block_given_p _((void));
-static VALUE umethod_bind _((VALUE, VALUE));
-static VALUE rb_mod_define_method _((int, VALUE*, VALUE));
+VALUE rb_f_block_given_p(void);
+static VALUE umethod_bind(VALUE, VALUE);
+static VALUE rb_mod_define_method(int, VALUE*, VALUE);
 
 ID rb_frame_callee();
 static VALUE rb_frame_self();
@@ -1279,7 +1277,13 @@
   state = EXEC_TAG();
   if (state == 0) {
   iter_retry:
-    GET_THREAD()->ifuncnode = node;
+    {
+      yarv_thread_t *th = GET_THREAD();
+      yarv_block_t *blockptr = GET_BLOCK_PTR_IN_CFP(th->cfp);
+      blockptr->iseq = (void *)node;
+      blockptr->proc = 0;
+      th->passed_block = blockptr;
+    }
     retval = (*it_proc)(data1);
   }
   else if (state == TAG_BREAK /* TODO: more check */ ) {
@@ -1685,19 +1689,15 @@
  */
 
 static VALUE
-rb_f_send(argc, argv, recv)
-    int argc;
-    VALUE *argv;
-    VALUE recv;
+rb_f_send(int argc, VALUE *argv, VALUE recv)
 {
-    VALUE vid;
+  VALUE vid;
 
-    if (argc == 0) rb_raise(rb_eArgError, "no method name given");
+  if (argc == 0) rb_raise(rb_eArgError, "no method name given");
 
-    vid = *argv++; argc--;
-    vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
-
-    return vid;
+  vid = *argv++; argc--;
+  PASS_PASSED_BLOCK();
+  return rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
 }
 
 VALUE
@@ -1733,23 +1733,15 @@
 }
 
 VALUE
-rb_funcall2(recv, mid, argc, argv)
-    VALUE recv;
-    ID mid;
-    int argc;
-    const VALUE *argv;
+rb_funcall2(VALUE recv, ID mid, int argc, const VALUE *argv)
 {
-    return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
+  return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
 }
 
 VALUE
-rb_funcall3(recv, mid, argc, argv)
-    VALUE recv;
-    ID mid;
-    int argc;
-    const VALUE *argv;
+rb_funcall3(VALUE recv, ID mid, int argc, const VALUE *argv)
 {
-    return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
+  return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
 }
 
 VALUE

Modified: trunk/eval_intern.h
===================================================================
--- trunk/eval_intern.h	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/eval_intern.h	2005-09-25 10:36:25 UTC (rev 260)
@@ -5,9 +5,14 @@
 #define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp))
 #define SDR3() vm_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
 
+#define PASS_PASSED_BLOCK() \
+  (GET_THREAD()->passed_block = (yarv_block_t *)GET_THREAD()->cfp->lfp[0])
+
+
 #define UNSUPPORTED(func) \
 { \
-  volatile int *a = 0; \
+  int *a = 0; \
+  fprintf(stderr, "%s", "-- unsuppoted: " #func "\n"); \
   *a = 0; \
   rb_bug("unsuppoted: " #func); \
 }

Modified: trunk/eval_proc.c
===================================================================
--- trunk/eval_proc.c	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/eval_proc.c	2005-09-25 10:36:25 UTC (rev 260)
@@ -61,11 +61,7 @@
 rb_f_binding(self)
     VALUE self;
 {
-  VALUE bind;
-  // TODO
-  UNSUPPORTED(rb_f_binding);
-  // bind = Data_Make_Struct(rb_cBinding, struct BLOCK, blk_mark, blk_free, 0);
-  return bind;
+  return th_make_current_env_object(GET_THREAD());
 }
 
 /*
@@ -113,18 +109,20 @@
 }
 
 static int
-proc_get_safe_level(data)
-    VALUE data;
+proc_get_safe_level(VALUE data)
 {
-    return (RBASIC(data)->flags & PROC_TMASK) >> PROC_TSHIFT;
+  yarv_proc_t *proc;
+  GetProcVal(data, proc);
+  return proc->safe_level;
 }
 
 static void
-proc_set_safe_level(data)
-    VALUE data;
+proc_set_safe_level(VALUE data)
 {
-    if (!proc_safe_level_p(data)) return;
-    ruby_safe_level = proc_get_safe_level(data);
+  yarv_proc_t *proc;
+  
+  GetProcVal(data, proc);
+  UNSUPPORTED(proc_set_safe_level);
 }
 
 static VALUE
@@ -222,12 +220,13 @@
 }
 
 VALUE
-proc_invoke(proc, args, self, klass)
-    VALUE proc, args;		/* OK */
-    VALUE self, klass;
+proc_invoke(VALUE self, VALUE args, VALUE alt_self, VALUE alt_klass)
 {
-  UNSUPPORTED(proc_invoke);
-  return Qnil;
+  yarv_proc_t *proc;
+  GetProcVal(self, proc);
+  
+  /* ignore self and klass */
+  return th_invoke_proc(GET_THREAD(), proc, RARRAY(args)->len, RARRAY(args)->ptr);
 }
 
 /* CHECKME: are the argument checking semantics correct? */
@@ -435,42 +434,40 @@
 }
 
 static VALUE
-mnew(klass, obj, id, mklass)
-    VALUE klass, obj, mklass;
-    ID id;
+mnew(VALUE klass, VALUE obj, ID id, VALUE mklass)
 {
-    VALUE method;
-    NODE *body;
-    int noex;
-    struct METHOD *data;
-    VALUE rklass = klass;
-    ID oid = id;
+  VALUE method;
+  NODE *body;
+  int noex;
+  struct METHOD *data;
+  VALUE rklass = klass;
+  ID oid = id;
 
-  again:
-    if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
-	print_undef(rklass, oid);
-    }
+again:
+  if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
+    print_undef(rklass, oid);
+  }
 
-    if (nd_type(body) == NODE_ZSUPER) {
-	klass = RCLASS(klass)->super;
-	goto again;
-    }
+  if (nd_type(body) == NODE_ZSUPER) {
+    klass = RCLASS(klass)->super;
+    goto again;
+  }
 
-    while (rklass != klass &&
-	   (FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
-	rklass = RCLASS(rklass)->super;
-    }
-    if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass;
-    method = Data_Make_Struct(mklass, struct METHOD, bm_mark, -1, data);
-    data->klass = klass;
-    data->recv = obj;
-    data->id = id;
-    data->body = body;
-    data->rklass = rklass;
-    data->oid = oid;
-    OBJ_INFECT(method, klass);
+  while (rklass != klass &&
+         (FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
+    rklass = RCLASS(rklass)->super;
+  }
+  if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass;
+  method = Data_Make_Struct(mklass, struct METHOD, bm_mark, -1, data);
+  data->klass = klass;
+  data->recv = obj;
+  data->id = id;
+  data->body = body;
+  data->rklass = rklass;
+  data->oid = oid;
+  OBJ_INFECT(method, klass);
 
-    return method;
+  return method;
 }
 
 
@@ -689,33 +686,31 @@
  */
 
 VALUE
-rb_method_call(argc, argv, method)
-    int argc;
-    VALUE *argv;
-    VALUE method;
+rb_method_call(int argc, VALUE *argv, VALUE method)
 {
-    VALUE result = Qnil;	/* OK */
-    struct METHOD *data;
-    int state;
-    volatile int safe = -1;
+  VALUE result = Qnil;	/* OK */
+  struct METHOD *data;
+  int state;
+  volatile int safe = -1;
 
-    Data_Get_Struct(method, struct METHOD, data);
-    if (data->recv == Qundef) {
-	rb_raise(rb_eTypeError, "can't call unbound method; bind first");
-    }
-    PUSH_TAG(PROT_NONE);
-    if (OBJ_TAINTED(method)) {
-	safe = ruby_safe_level;
-	if (ruby_safe_level < 4) ruby_safe_level = 4;
-    }
-    if ((state = EXEC_TAG()) == 0) {
-	result = th_call0(GET_THREAD(),
-                          data->klass,data->recv,data->id,data->oid,argc,argv,data->body,0);
-    }
-    POP_TAG();
-    if (safe >= 0) ruby_safe_level = safe;
-    if (state) JUMP_TAG(state);
-    return result;
+  Data_Get_Struct(method, struct METHOD, data);
+  if (data->recv == Qundef) {
+    rb_raise(rb_eTypeError, "can't call unbound method; bind first");
+  }
+  PUSH_TAG(PROT_NONE);
+  if (OBJ_TAINTED(method)) {
+    safe = ruby_safe_level;
+    if (ruby_safe_level < 4) ruby_safe_level = 4;
+  }
+  if ((state = EXEC_TAG()) == 0) {
+    result = th_call0(GET_THREAD(),
+                      data->klass, data->recv, data->id, data->oid,
+                      argc, argv, data->body, 0);
+  }
+  POP_TAG();
+  if (safe >= 0) ruby_safe_level = safe;
+  if (state) JUMP_TAG(state);
+  return result;
 }
 
 /**********************************************************************
@@ -993,26 +988,22 @@
 }
 
 static VALUE
-mproc(method)
-    VALUE method;
+mproc(VALUE method)
 {
-  UNSUPPORTED(mproc);
-  return Qnil;
+  return rb_funcall(Qnil, rb_intern("proc"), 0);
 }
 
 static VALUE
-bmcall(args, method)
-    VALUE args, method;
+bmcall(VALUE args, VALUE method)
 {
-  UNSUPPORTED(bmcall);
-}
+  volatile VALUE a;
 
-VALUE
-rb_proc_new(func, val)
-    VALUE (*func)(ANYARGS);	/* VALUE yieldarg[, VALUE procarg] */
-    VALUE val;
-{
-  UNSUPPORTED(rb_proc_new);
+  if(CLASS_OF(args) != rb_cArray){
+    args = rb_ary_new3(1, args);
+  }
+  
+  a = args;
+  return rb_method_call(RARRAY(a)->len, RARRAY(a)->ptr, method);
 }
 
 /*
@@ -1026,7 +1017,16 @@
 method_proc(VALUE method)
 {
   VALUE proc;
-  UNSUPPORTED(method_proc);
+  /*
+   * class Method
+   *   def to_proc
+   *     proc{|*args|
+   *       self.call(*args)
+   *     }
+   *   end
+   * end
+   */
+  proc = rb_iterate((VALUE(*)(VALUE))mproc, 0, bmcall, method);
   return proc;
 }
 

Modified: trunk/rb/mklog.rb
===================================================================
--- trunk/rb/mklog.rb	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/rb/mklog.rb	2005-09-25 10:36:25 UTC (rev 260)
@@ -1,6 +1,6 @@
 files = []
 `svn diff`.each{|line|
-  if /\+\+\+ (.+)\t\(working copy\)/ =~ line
+  if /\+\+\+ (.+)\t\(.+\)/ =~ line
     files << $1
   end
   puts line

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/test.rb	2005-09-25 10:36:25 UTC (rev 260)
@@ -1,60 +1,8 @@
-p lambda{}
 
-__END__
-pr = proc{
-  p 1
-}
-
-pr.call
-
-__END__
-
-def proc &pr
-  pr
-end
-
-l = 0
-proc{
+def m
   i = 1
-  proc{
-    j = 2
-    p [l, i, j]
-  }.call
-}.call
-
-
-__END__
-def iter
-  a = [[]]
-  yield(*a)
+  binding
 end
 
-iter{|i, j|
-  p [i, j]
-}
+eval('p i', m)
 
-__END__
-def iter *args
-  p args
-  yield *args
-end
-
-iter([]){|i, j, *|
-  p [i, j]
-}
-__END__
-iter(1){|i, j, *|
-  p [i, j]
-}
-
-iter(1, 2){|i, j, *|
-  p [i, j]
-}
-
-iter(1, 2, 3){|i, j, *|
-  p [i, j]
-}
-
-iter(1, 2, 3, 4){|i, j, *|
-  p [i, j]
-}

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/vm.c	2005-09-25 10:36:25 UTC (rev 260)
@@ -62,14 +62,15 @@
 /*
  * prepare stack frame
  */
-static inline
-VALUE th_set_env(yarv_thread_t *th, yarv_iseq_t *iseq,
-                 VALUE magic, VALUE self, VALUE specval,
-                 VALUE *pc, VALUE *sp, VALUE *lfp,
-                 int local_size, int argc, const VALUE *argv){
+static inline VALUE
+th_set_env(yarv_thread_t *th, yarv_iseq_t *iseq,
+           VALUE magic, VALUE self, VALUE specval,
+           VALUE *pc, VALUE *sp, VALUE *lfp,
+           int local_size, int argc, const VALUE *argv)
+{
   VALUE *dfp;
   int i;
- 
+
   for(i=0; i<argc; i++){
     *sp = *argv;
     sp++; argv++;
@@ -79,7 +80,7 @@
     *sp = Qnil;
     sp++;
   }
-  
+
   *sp = GC_GUARDED_PTR(specval);
   dfp = sp;
   if(lfp == 0){
@@ -101,7 +102,9 @@
 
 EXTERN VALUE ruby_top_self;
 
-VALUE th_set_finish_env(yarv_thread_t *th){
+VALUE
+th_set_finish_env(yarv_thread_t *th)
+{
   th_set_env(th, 0,
              FRAME_MAGIC_FINISH, Qnil, 0,
              0, th->cfp->sp, 0,
@@ -111,7 +114,9 @@
 }
 
 
-VALUE thread_set_top_stack(VALUE self, VALUE iseqval){
+VALUE
+thread_set_top_stack(VALUE self, VALUE iseqval)
+{
   yarv_iseq_t *iseq;
   yarv_thread_t *th;
 
@@ -129,9 +134,10 @@
                     iseq->local_size, 0, 0);
 }
 
-static
-VALUE th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp,
-                         VALUE *envptr, VALUE *endptr){
+static VALUE
+th_make_env_object(yarv_thread_t *th, yarv_control_frame_t *cfp,
+                   VALUE *envptr, VALUE *endptr)
+{
   VALUE envval, penvval = 0;
   yarv_env_t *env;
   VALUE *nenvptr;
@@ -188,11 +194,17 @@
   return envval;
 }
 
-VALUE th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, yarv_block_t *block);
+VALUE
+th_make_current_env_object(yarv_thread_t *th)
+{
+  yarv_control_frame_t *cfp = th->cfp;
+  return th_make_env_object(th, cfp, cfp->dfp, cfp->lfp);
+}
 
-static
-VALUE th_make_proc_from_block(yarv_thread_t *th, yarv_control_frame_t *cfp,
-                              yarv_block_t *block){
+static VALUE
+th_make_proc_from_block(yarv_thread_t *th, yarv_control_frame_t *cfp,
+                        yarv_block_t *block)
+{
   VALUE procval;
   yarv_control_frame_t *bcfp;
   VALUE *bdfp; /* to gc mark */
@@ -208,7 +220,9 @@
   return procval;
 }
 
-VALUE th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, yarv_block_t *block){
+VALUE
+th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, yarv_block_t *block)
+{
   VALUE procval, envval;
   yarv_proc_t *proc;
 
@@ -222,7 +236,7 @@
     *cfp->lfp = GC_GUARDED_PTR(&p->block);
   }
 
-  envval = th_make_env_object(th, cfp, cfp->dfp, cfp->lfp);
+  envval = th_make_current_env_object(th);
 
   proc->block.self = block->self;
   proc->block.lfp  = block->lfp;
@@ -234,21 +248,20 @@
   return procval;
 }
 
-
-VALUE th_call0(yarv_thread_t *th, VALUE klass, VALUE recv,
-               VALUE id, ID oid, int argc, const VALUE *argv,
-               NODE *body, int nosuper){
+VALUE
+th_call0(yarv_thread_t *th, VALUE klass, VALUE recv,
+         VALUE id, ID oid, int argc, const VALUE *argv,
+         NODE *body, int nosuper)
+{
   VALUE val;
   yarv_block_t *blockptr = 0;
 
   //printf("id: %s\n", rb_id2name(id));
   //SDR2(th->cfp);
   
-  if(th->ifuncnode){
-    blockptr = GET_BLOCK_PTR_IN_CFP(th->cfp);
-    blockptr->iseq = (void *)th->ifuncnode;
-    blockptr->proc = 0;
-    th->ifuncnode = 0;
+  if(th->passed_block){
+    blockptr = th->passed_block;
+    th->passed_block = 0;
   }
   
   switch(nd_type(body)){
@@ -301,14 +314,18 @@
   return val;
 }
 
-VALUE thread_call0(VALUE self, VALUE klass, VALUE recv, VALUE id, ID oid,
-                   int argc, const VALUE *argv, NODE *body, int nosuper){
+VALUE
+thread_call0(VALUE self, VALUE klass, VALUE recv, VALUE id, ID oid,
+             int argc, const VALUE *argv, NODE *body, int nosuper)
+{
   yarv_thread_t *th;
   GetThreadVal(self, th);
   return th_call0(th, klass, recv, id, oid, argc, argv, body, nosuper);
 }
 
-VALUE th_call_super(yarv_thread_t *th, int argc, const VALUE *argv){
+VALUE
+th_call_super(yarv_thread_t *th, int argc, const VALUE *argv)
+{
   VALUE recv  = th->cfp->self;
   VALUE klass;
   ID id;
@@ -330,17 +347,19 @@
 }
 
 
-VALUE thread_call_super(VALUE self, int argc, const VALUE *argv){
+VALUE
+thread_call_super(VALUE self, int argc, const VALUE *argv)
+{
   yarv_thread_t *th;
   GetThreadVal(self, th);
   return th_call_super(th, argc, argv);
 }
 
 
-static inline
-VALUE thread_invoke_yield_cfunc(yarv_thread_t *th,
-                                yarv_block_t *block, int argc, VALUE *argv){
-
+static inline VALUE
+thread_invoke_yield_cfunc(yarv_thread_t *th,
+                          yarv_block_t *block, int argc, VALUE *argv)
+{
   NODE *ifunc = (NODE*)block->iseq;
   VALUE val;
   VALUE arg;
@@ -351,6 +370,9 @@
   else if(argc > 1){
     arg = rb_ary_new4(argc, argv);
   }
+  else{
+    arg = rb_ary_new();
+  }
 
   th_set_env(th, 0,
              FRAME_MAGIC_IFUNC, block->self, (VALUE)block->dfp,
@@ -408,8 +430,10 @@
 }
 
 
-VALUE thread_yield_light_prepare(VALUE self, int argc, VALUE *argv,
-                                 struct yarv_yield_data *data){
+VALUE
+thread_yield_light_prepare(VALUE self, int argc, VALUE *argv,
+                           struct yarv_yield_data *data)
+{
   yarv_thread_t *th;
   yarv_control_frame_t *cfp;
   yarv_block_t *block;
@@ -453,8 +477,10 @@
 }
 
 
-VALUE thread_yield_light_invoke(int argc, VALUE *argv,
-                                struct yarv_yield_data *data){
+VALUE
+thread_yield_light_invoke(int argc, VALUE *argv,
+                          struct yarv_yield_data *data)
+{
   VALUE val;
   yarv_thread_t *th = data->th;
   int i;
@@ -478,8 +504,9 @@
 }
 
 
-VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, int argc, VALUE *argv){
-  
+VALUE
+th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, int argc, VALUE *argv)
+{
   if(BUILTIN_TYPE(proc->block.iseq) == T_NODE){
     return thread_invoke_yield_cfunc(th, &proc->block, argc, argv);
   }
@@ -497,7 +524,9 @@
 }
 
 
-VALUE thread_invoke_proc_call(VALUE self, VALUE procval, int argc, VALUE *argv){
+VALUE
+thread_invoke_proc_call(VALUE self, VALUE procval, int argc, VALUE *argv)
+{
   yarv_thread_t *th;
   yarv_proc_t *proc;
   GetThreadVal(self, th);
@@ -506,8 +535,9 @@
   return th_invoke_proc(th, proc, argc, argv);
 }
 
-
-VALUE *th_svar(yarv_thread_t *th, int cnt){
+VALUE *
+th_svar(yarv_thread_t *th, int cnt)
+{
   yarv_control_frame_t *cfp = th->cfp;
   NODE *node;
 
@@ -539,17 +569,20 @@
 }
 
 
-VALUE *thread_svar(VALUE self, int cnt){
+VALUE *
+thread_svar(VALUE self, int cnt)
+{
   yarv_thread_t *th;
   GetThreadVal(self, th);
   return th_svar(th, cnt);
 }
 
-static
-VALUE th_backtrace_each(yarv_thread_t *th,
+static VALUE
+th_backtrace_each(yarv_thread_t *th,
                         yarv_control_frame_t *limit_cfp,
                         yarv_control_frame_t *cfp,
-                        char *file, int line_no, VALUE ary){
+                        char *file, int line_no, VALUE ary)
+{
   VALUE str = 0;
   char buf[BUFSIZE];
 
@@ -593,7 +626,9 @@
   return str;
 }
 
-VALUE th_backtrace(yarv_thread_t *th, int lev){
+VALUE
+th_backtrace(yarv_thread_t *th, int lev)
+{
   VALUE ary;
   yarv_control_frame_t *cfp = th->cfp;
   yarv_control_frame_t *top_of_cfp = (void *)(th->stack + th->stack_size);
@@ -617,7 +652,9 @@
   return ary;
 }
 
-VALUE thread_backtrace(VALUE self, int level){
+VALUE
+thread_backtrace(VALUE self, int level)
+{
   yarv_thread_t *th;
   GetThreadVal(self, th);
   return th_backtrace(th, level);
@@ -633,8 +670,10 @@
 
 
 EVALBODY_HELPER_FUNCTION
-VALUE eval_get_ev_const(yarv_thread_t *th,
-                        yarv_iseq_t *iseq, VALUE klass, ID id){
+VALUE
+eval_get_ev_const(yarv_thread_t *th,
+                  yarv_iseq_t *iseq, VALUE klass, ID id)
+{
   VALUE val;
   
   if(klass == Qnil){
@@ -675,9 +714,10 @@
   return val;
 }
 
-EVALBODY_HELPER_FUNCTION
-int eval_get_ev_defined(yarv_thread_t *th,
-                        yarv_iseq_t *iseq, VALUE klass, ID id){
+EVALBODY_HELPER_FUNCTION int
+eval_get_ev_defined(yarv_thread_t *th,
+                    yarv_iseq_t *iseq, VALUE klass, ID id)
+{
   VALUE val;
   if(klass == Qnil){
     VALUE cref;
@@ -710,8 +750,9 @@
 }
 
 
-EVALBODY_HELPER_FUNCTION
-NODE* eval_method_search(VALUE id, VALUE klass, IC ic){
+EVALBODY_HELPER_FUNCTION NODE*
+eval_method_search(VALUE id, VALUE klass, IC ic)
+{
   NODE *mn;
 
 //#undef  INLINE_METHOD_CACHE
@@ -1015,7 +1056,9 @@
  */
 
 
-VALUE th_eval_body(yarv_thread_t *th){
+VALUE
+th_eval_body(yarv_thread_t *th)
+{
   struct tag _tag;
   int state;
   VALUE result, err;
@@ -1221,7 +1264,9 @@
 }
 
 
-VALUE thread_eval(VALUE self){
+VALUE
+thread_eval(VALUE self)
+{
   yarv_thread_t *thobj;
   yarv_iseq_t *iseq;
   

Modified: trunk/yarv.h
===================================================================
--- trunk/yarv.h	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/yarv.h	2005-09-25 10:36:25 UTC (rev 260)
@@ -55,6 +55,10 @@
 
 VALUE yarvcore_eval_parsed(VALUE node, VALUE file);
 
+VALUE th_invoke_proc(yarv_thread_t *th, yarv_proc_t *proc, int argc, VALUE *argv);
+VALUE th_make_proc(yarv_thread_t *th, yarv_control_frame_t *cfp, yarv_block_t *block);
+VALUE th_make_current_env_object(yarv_thread_t *th);
+
 int yarv_block_given_p();
 
 #endif

Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/yarvcore.c	2005-09-25 10:36:25 UTC (rev 260)
@@ -195,12 +195,6 @@
   return th_svar(GET_THREAD(), cnt);
 }
 
-static int yarv_iterate(NODE *node){
-  yarv_thread_t *th = GET_THREAD();
-  th->ifuncnode = node;
-  return 0;
-}
-
 static VALUE compile_string(VALUE str, VALUE file, VALUE line){
   NODE *node;
   node = rb_compile_string(StringValueCStr(file), str, NUM2INT(line));
@@ -618,6 +612,10 @@
   return obj;
 }
 
+static VALUE env_eval(VALUE self, VALUE str){
+  
+  return ;
+}
 
 /***************/
 /* YarvProc    */

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2005-09-25 02:05:13 UTC (rev 259)
+++ trunk/yarvcore.h	2005-09-25 10:36:25 UTC (rev 260)
@@ -296,7 +296,7 @@
   int state;
   
   /* for rb_iterate */
-  NODE *ifuncnode;
+  yarv_block_t *passed_block;
 
   /* klass/module nest information stack */
   VALUE klass_nest_stack; /* Array */
@@ -343,6 +343,7 @@
   yarv_block_t block;
   VALUE envval;       /* for GC mark */
   VALUE blockprocval;
+  int safe_level;
 } yarv_proc_t;
 
 #define GetEnvVal(obj, iobj) \


--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]