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

yarv-diff:163

From: ko1 atdot.net
Date: 24 Dec 2005 11:50:13 -0000
Subject: [yarv-diff:163] r322 - trunk

Author: ko1
Date: 2005-12-24 20:50:12 +0900 (Sat, 24 Dec 2005)
New Revision: 322

Modified:
   trunk/ChangeLog
   trunk/compile.c
   trunk/compile.h
   trunk/eval_jump.h
   trunk/test.rb
Log:
	* compile.c, compile.h : fix ADD_CATCH_ENTRY and add LABEL#sp

	* eval_jump.h : fix catch to remove illegal error



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-12-24 00:52:40 UTC (rev 321)
+++ trunk/ChangeLog	2005-12-24 11:50:12 UTC (rev 322)
@@ -4,6 +4,13 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-12-24(Sat) 19:34:04 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* compile.c, compile.h : fix ADD_CATCH_ENTRY and add LABEL#sp
+
+	* eval_jump.h : fix catch to remove illegal error
+
+
 2005-12-24(Sat) 09:05:23 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* eval_method.h : change data structure for RClass#m_tbl

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2005-12-24 00:52:40 UTC (rev 321)
+++ trunk/compile.c	2005-12-24 11:50:12 UTC (rev 322)
@@ -42,15 +42,16 @@
 } LINK_ANCHOR;
 
 typedef struct iseq_label_data{
-  struct iseq_link_element link;
+  LINK_ELEMENT link;
   int label_no;
   int position;
   int sc_state;
   int set;
+  int sp;
 } LABEL;
 
 typedef struct iseq_insn_data{
-  struct iseq_link_element link;
+  LINK_ELEMENT link;
   int insn_id;
   int line_no;
   int operand_size;
@@ -83,6 +84,7 @@
 
 static int insn_data_length(INSN *insnobj);
 static int insn_data_line_no(INSN *insnobj);
+static int insn_sp_increase(INSN *insnobj);
 static int insn_ret_num(int insn);
 
 static void ADD_ELEM(LINK_ANCHOR *anchor, LINK_ELEMENT* elem);
@@ -232,8 +234,8 @@
       ADD_LABEL(list_anchor, iseq->compile_data->end_label);
 
       /* wide range catch handler must put at last */
-      ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, 0, 0, start);
-      ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, 0, end);
+      ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, 0, start);
+      ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, end);
     }
     else if(iseq->type == ISEQ_TYPE_TOP){
       set_localtbl(iseq, GET_THREAD()->top_local_tbl);
@@ -1215,18 +1217,19 @@
   LINK_ELEMENT *list;
   VALUE *generated_iseq;
   
-  int k, pos, stack_max = 0;
+  int k, pos, sp, stack_max = 0;
 
   GC_CHECK();
   
   /* set label position */
   list = FIRST_ELEMENT(anchor);
-  k = pos = 0;
+  k = pos = sp = 0;
   while(list){
     switch(list->type){
     case ISEQ_ELEMENT_INSN:{
       iobj = (INSN*)list;
       pos += insn_data_length(iobj);
+      sp  += insn_sp_increase(iobj);
       k+=1;
       break;
     }
@@ -1234,6 +1237,7 @@
       lobj = (LABEL*)list;
       lobj->position = pos;
       lobj->set      = Qtrue;
+      lobj->sp       = sp;
       break;
     }
     case ISEQ_ELEMENT_NONE:{
@@ -1383,13 +1387,18 @@
 }
 
 static int
-label_get_position(VALUE self)
+label_get_position(LABEL *lobj)
 {
-  LABEL *lobj = (LABEL *) self;
   return lobj->position;
 }
 
 static int
+label_get_sp(LABEL *lobj)
+{
+  return lobj->sp;
+}
+
+static int
 set_exception_table(yarv_iseq_t *iseq)
 {
   VALUE *tptr, *ptr;
@@ -1406,17 +1415,18 @@
     ptr   = RARRAY(tptr[i])->ptr;
     entry = &iseq->catch_table[i];
     entry->type  = ptr[0];
-    entry->start = label_get_position(ptr[1] & ~1);
-    entry->end   = label_get_position(ptr[2] & ~1);
+    entry->start = label_get_position((LABEL*)(ptr[1] & ~1));
+    entry->end   = label_get_position((LABEL*)(ptr[2] & ~1));
     entry->iseq  = ptr[3];
     
     if(entry->iseq != 0){
       iseq_add_mark_object(iseq, entry->iseq);
     }
     
-    entry->sp    = FIX2INT(ptr[4]);
-    if(ptr[5]){
-      entry->cont  = label_get_position(ptr[5] & ~1);
+    if(ptr[4]){
+      LABEL *lobj = (LABEL*)(ptr[4] & ~1);
+      entry->cont = label_get_position(lobj);
+      entry->sp   = label_get_sp(lobj);
     }
     else{
       entry->cont  = 0;
@@ -1430,7 +1440,11 @@
 /*
  * set optional argument table
  *   def foo(a, b=expr1, c=expr2)
- *   => 
+ *   =>
+ *    b:
+ *      expr1
+ *    c:
+ *      expr2
  */
 static int
 set_optargs_table(yarv_iseq_t *iseq)
@@ -1439,9 +1453,8 @@
 
   if(iseq->arg_opts != 0){
     for(i=0; i< iseq->arg_opts; i++){
-      // dp((VALUE)iseq->arg_opt_tbl[i]);
       iseq->arg_opt_tbl[i] =
-        label_get_position((VALUE)iseq->arg_opt_tbl[i]);
+        label_get_position((LABEL *)iseq->arg_opt_tbl[i]);
     }
   }
   return COMPILE_OK;
@@ -2273,7 +2286,7 @@
     ADD_INSN1(ret, nd_line(node), putobject, str);
     ADD_LABEL(ret, lend);
 
-    ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, lstart, lend, ensure, 0, lfinish);
+    ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, lstart, lend, ensure, lfinish);
     return 1;
     // rb_bug("unimplemented defined: %s", node_name(nd_type(node)));
   } /* end of default */
@@ -2672,11 +2685,11 @@
     ADD_LABEL(ret, break_label); /* braek */
     
     ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, redo_label, break_label,
-                    0, 0, break_label);
+                    0, break_label);
     ADD_CATCH_ENTRY(CATCH_TYPE_NEXT,  redo_label, break_label,
-                    0, 0, iseq->compile_data->start_label);
+                    0, iseq->compile_data->start_label);
     ADD_CATCH_ENTRY(CATCH_TYPE_REDO,  redo_label, break_label,
-                    0, 0, iseq->compile_data->redo_label);
+                    0, iseq->compile_data->redo_label);
     
     iseq->compile_data->start_label       = prev_start_label;
     iseq->compile_data->end_label         = prev_end_label;
@@ -2716,7 +2729,7 @@
     ADD_LABEL(ret, retry_end_l);
     iseq->compile_data->current_block = prevblock;
 
-    ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, 0, retry_label);
+    ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, retry_label);
     break;
   }
   case NODE_BREAK:{
@@ -2861,8 +2874,8 @@
     }
     
     /* resgister catch entry */
-    ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, 0, lcont);
-    ADD_CATCH_ENTRY(CATCH_TYPE_RETRY,  lend, lcont, 0, 0, lstart);
+    ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lcont);
+    ADD_CATCH_ENTRY(CATCH_TYPE_RETRY,  lend, lcont, 0, lstart);
     break;
   }
   case NODE_RESBODY:{
@@ -2934,7 +2947,7 @@
 
     erange = iseq->compile_data->ensure_node_stack->erange;
     while(erange){
-      ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, erange->begin, erange->end, ensure, 0, lcont);
+      ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, erange->begin, erange->end, ensure, lcont);
       erange = erange->next;
     }
     iseq->compile_data->ensure_node_stack = enl.prev;
@@ -3847,7 +3860,7 @@
     ADD_LABEL(ret, retry_end_l);
     
     iseq->compile_data->current_block = prevblock;
-    ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, 0, retry_label);
+    ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, retry_label);
     break;
   }
   case NODE_DEFN:{
@@ -4287,6 +4300,12 @@
 }
 
 static int
+insn_sp_increase(INSN *insn)
+{
+  return 0;
+}
+
+static int
 insn_data_line_no(INSN *insnobj)
 {
   return insn_len(insnobj->line_no);

Modified: trunk/compile.h
===================================================================
--- trunk/compile.h	2005-12-24 00:52:40 UTC (rev 321)
+++ trunk/compile.h	2005-12-24 11:50:12 UTC (rev 322)
@@ -147,13 +147,12 @@
 #define ADD_LABEL(seq, label) \
   ADD_ELEM(seq, (LINK_ELEMENT *)label)
 
-#define ADD_CATCH_ENTRY(type, ls, le, iseqv, sp, lc) \
+#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc) \
   (tmp = rb_ary_new(),                               \
    rb_ary_push(tmp, type),                           \
    rb_ary_push(tmp, (VALUE) ls | 1),                 \
    rb_ary_push(tmp, (VALUE) le | 1),                 \
    rb_ary_push(tmp, iseqv),                          \
-   rb_ary_push(tmp, I2F(sp)),                        \
    rb_ary_push(tmp, (VALUE) lc | 1),                 \
    rb_ary_push(iseq->catch_table_ary, tmp))
 

Modified: trunk/eval_jump.h
===================================================================
--- trunk/eval_jump.h	2005-12-24 00:52:40 UTC (rev 321)
+++ trunk/eval_jump.h	2005-12-24 11:50:12 UTC (rev 322)
@@ -33,11 +33,6 @@
       tt->retval = value;
       break;
     }
-    if (tt->tag == PROT_THREAD) {
-      rb_raise(rb_eThreadError, "uncaught throw `%s' in thread %p",
-               rb_id2name(SYM2ID(tag)),
-               rb_vm_curr_thread());
-    }
     tt = tt->prev;
   }
   if (!tt) {

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-12-24 00:52:40 UTC (rev 321)
+++ trunk/test.rb	2005-12-24 11:50:12 UTC (rev 322)
@@ -1,5 +1,12 @@
 
+catch(:foo){
+  Thread.new{
+    throw :foo
+  }.join
+}
 
+
+__END__
 require 'test/unit'
 __END__
 module M


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

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