[前][次][番号順一覧][スレッド一覧]

ruby-changes:2848

From: ko1@a...
Date: 20 Dec 2007 01:11:05 +0900
Subject: [ruby-changes:2848] nobu - Ruby:r14339 (trunk): * compile.c (iseq_compile_each): should handle upper level eval iseq

nobu	2007-12-20 01:10:54 +0900 (Thu, 20 Dec 2007)

  New Revision: 14339

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_eval.rb
    trunk/compile.c
    trunk/version.h

  Log:
    * compile.c (iseq_compile_each): should handle upper level eval iseq
      from break/next, and COMPILE_ERROR() breaks only one block.
      [ruby-dev:31372]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=14339&r2=14338
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.c?r1=14339&r2=14338
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14339&r2=14338
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_eval.rb?r1=14339&r2=14338

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14338)
+++ ChangeLog	(revision 14339)
@@ -1,3 +1,9 @@
+Thu Dec 20 01:10:52 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (iseq_compile_each): should handle upper level eval iseq
+	  from break/next, and COMPILE_ERROR() breaks only one block.
+	  [ruby-dev:31372]
+
 Thu Dec 20 00:07:36 2007  Masatoshi SEKI  <m_seki@m...>
 
 	* test/drb/drbtest.rb (test_07_public_private_protected_missing):
Index: bootstraptest/test_eval.rb
===================================================================
--- bootstraptest/test_eval.rb	(revision 14338)
+++ bootstraptest/test_eval.rb	(revision 14339)
@@ -189,7 +189,12 @@
   $ans
 }
 
-assert_match /Illegal break/, %q{
-  STDERR.reopen(STDOUT)
-  eval "0 rescue break"
-}, '[ruby-dev:31372]'
+%w[break next redo].each do |keyword|
+  assert_match %r"Can't escape from eval with #{keyword}\z", %{
+    begin
+      eval "0 rescue #{keyword}"
+    rescue SyntaxError => e
+      e.message
+    end
+  }, '[ruby-dev:31372]'
+end
Index: compile.c
===================================================================
--- compile.c	(revision 14338)
+++ compile.c	(revision 14339)
@@ -2942,11 +2942,12 @@
 		      INT2FIX(level | 0x02) /* TAG_BREAK */ );
 	}
 	else if (iseq->type == ISEQ_TYPE_EVAL) {
+	  break_in_eval:
 	    COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with break"));
 	}
 	else {
 	    rb_iseq_t *ip = iseq->parent_iseq;
-	    while (ip && ip->compile_data) {
+	    while (ip) {
 		level++;
 		if (ip->compile_data->redo_label != 0) {
 		    level = 0x8000;
@@ -2960,6 +2961,9 @@
 		    level <<= 16;
 		    goto break_by_insn;
 		}
+		else if (ip->type == ISEQ_TYPE_EVAL) {
+		    goto break_in_eval;
+		}
 		ip = ip->parent_iseq;
 	    }
 	    COMPILE_ERROR((ERROR_ARGS "Illegal break"));
@@ -2985,6 +2989,7 @@
 		      iseq->compile_data->end_label);
 	}
 	else if (iseq->type == ISEQ_TYPE_EVAL) {
+	  next_in_eval:
 	    COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with next"));
 	}
 	else {
@@ -3001,6 +3006,9 @@
 		    level |= 0x4000;
 		    break;
 		}
+		else if (ip->type == ISEQ_TYPE_EVAL) {
+		    goto next_in_eval;
+		}
 		ip = ip->parent_iseq;
 	    }
 	    if (ip != 0) {
@@ -3034,6 +3042,7 @@
 #endif
 	}
 	else if (iseq->type == ISEQ_TYPE_EVAL) {
+	  redo_in_eval:
 	    COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with redo"));
 	}
 	else if (iseq->compile_data->start_label) {
@@ -3059,7 +3068,7 @@
 		    break;
 		}
 		else if (ip->type == ISEQ_TYPE_EVAL) {
-		    COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with redo"));
+		    goto redo_in_eval;
 		}
 		ip = ip->parent_iseq;
 	    }
Index: version.h
===================================================================
--- version.h	(revision 14338)
+++ version.h	(revision 14339)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2007-12-19"
+#define RUBY_RELEASE_DATE "2007-12-20"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20071219
+#define RUBY_RELEASE_CODE 20071220
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2007
 #define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 19
+#define RUBY_RELEASE_DAY 20
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]