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

yarv-diff:156

From: ko1 atdot.net
Date: 19 Dec 2005 16:08:17 -0000
Subject: [yarv-diff:156] r315 - in trunk: . win32 yarvtest

Author: ko1
Date: 2005-12-20 01:08:17 +0900 (Tue, 20 Dec 2005)
New Revision: 315

Modified:
   trunk/ChangeLog
   trunk/compile.c
   trunk/test.rb
   trunk/win32/Makefile.sub
   trunk/win32/configure.bat
   trunk/win32/mkexports.rb
   trunk/win32/setup.mak
   trunk/win32/win32.c
   trunk/yarvcore.h
   trunk/yarvtest/test_bin.rb
Log:
	* compile.c, yarvcore.h : support all defined?() syntax

	* compile.c : fix NODE_COLON2 

	* yarvtest/test_bin.rb : add or fix tests for above

	* win32/* : update all



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/ChangeLog	2005-12-19 16:08:17 UTC (rev 315)
@@ -4,6 +4,17 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-12-20(Tue) 01:03:34 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* compile.c, yarvcore.h : support all defined?() syntax
+
+	* compile.c : fix NODE_COLON2 
+
+	* yarvtest/test_bin.rb : add or fix tests for above
+
+	* win32/* : update all
+
+
 2005-12-17(Sat) 10:46:08 +0900  Minero Aoki  <aamine loveruby.net>
 
 	* vm_macro.def: fix printf type mismatch for LP64 system (again).
@@ -18,6 +29,7 @@
 	  for LP64 system.
 
 
+>>>>>>> .r314
 2005-12-14(Wed) 03:49:40 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* compile.c : change rescue/ensure iseq name

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/compile.c	2005-12-19 16:08:17 UTC (rev 315)
@@ -255,6 +255,9 @@
       iseq->rewind_frame_size = iseq->local_size + REWIND_DSIZE();
       COMPILE_POPED(list_anchor, "ensure", node);
     }
+    else if(iseq->type == ISEQ_TYPE_DEFINED_GUARD){
+      COMPILE(list_anchor, "defined guard", node);
+    }
     else if(node == 0){
       COMPILE(list_anchor, "nil", node);
     }
@@ -267,7 +270,6 @@
 
   if(iseq->type == ISEQ_TYPE_RESCUE ||
      iseq->type == ISEQ_TYPE_ENSURE){
-    
     ADD_INSN2(list_anchor, 0, getdynamic, I2F(1), I2F(0));
     ADD_INSN1(list_anchor, 0, throw, I2F(0) /* continue throw */);
   }
@@ -501,6 +503,17 @@
   return size;
 }
 
+static int
+LIST_SIZE_ZERO(LINK_ANCHOR *anchor)
+{
+  if(anchor->anchor.next == 0){
+    return 1;
+  }
+  else{
+    return 0;
+  }
+}
+
 /*
  * anc1: e1, e2, e3
  * anc2: e4, e5
@@ -2110,9 +2123,13 @@
     debugi("compile_colon2 - colon2", node->nd_mid);
     ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
     break;
+  case NODE_SELF:
+    /* optimize for "self::..." */
+    ADD_INSN(body, nd_line(node), pop);
+    ADD_INSN(body, nd_line(node), putself);
+    break;
   default:
     COMPILE(pref, "const colon2 prefix", node);
-    ADD_INSN (body, nd_line(node), pop);
     break;
   }
   return COMPILE_OK;
@@ -2123,7 +2140,7 @@
              LINK_ANCHOR *ret, NODE *node, LABEL *lfinish, VALUE needstr)
 {
   char *estr = 0;
-  
+
   switch(nd_type(node)){
 
   /* easy literals */
@@ -2143,7 +2160,7 @@
   case NODE_LIT:
     estr = "expression";
     break;
-    
+
   /* variables */
   case NODE_LVAR:
     estr = "local-variable";
@@ -2155,68 +2172,76 @@
   case NODE_IVAR:
     ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_IVAR), ID2SYM(node->nd_vid), needstr);
     return 1;
+
   case NODE_GVAR:
-    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_GVAR), ((VALUE)node->nd_entry) | 1, needstr);
+    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_GVAR),
+              ((VALUE)node->nd_entry) | 1, needstr);
     return 1;
+
   case NODE_CVAR:
-    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CVAR), ID2SYM(node->nd_vid), needstr);
+    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CVAR),
+              ID2SYM(node->nd_vid), needstr);
     return 1;
 
   case NODE_CONST:
     ADD_INSN (ret, nd_line(node), putnil);
-    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CONST), ID2SYM(node->nd_vid), needstr);
+    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CONST),
+              ID2SYM(node->nd_vid), needstr);
     return 1;
   case NODE_COLON2:
     if(rb_is_const_id(node->nd_mid)){
       LABEL *lcont = NEW_LABEL(nd_line(node));
       defined_expr(self, iseq, ret, node->nd_head, lfinish, Qfalse);
-      
+
       ADD_INSNL(ret, nd_line(node), if, lcont);
       ADD_INSN (ret, nd_line(node), putnil);
       ADD_INSNL(ret, nd_line(node), jump, lfinish);
-      
+
       ADD_LABEL(ret, lcont);
       COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
-      ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CONST), ID2SYM(node->nd_mid), needstr);
+      ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CONST),
+                ID2SYM(node->nd_mid), needstr);
     }
     else{
       LABEL *lcont = NEW_LABEL(nd_line(node));
       defined_expr(self, iseq, ret, node->nd_head, lfinish, Qfalse);
-      
+
       ADD_INSNL(ret, nd_line(node), if, lcont);
       ADD_INSN (ret, nd_line(node), putnil);
       ADD_INSNL(ret, nd_line(node), jump, lfinish);
-      
+
       ADD_LABEL(ret, lcont);
       COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
-      ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_METHOD), ID2SYM(node->nd_mid), needstr);
+      ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_METHOD),
+                ID2SYM(node->nd_mid), needstr);
     }
     return 1;
   case NODE_COLON3:
     ADD_INSN1(ret, nd_line(node), putobject, rb_cObject);
-    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_CONST), ID2SYM(node->nd_mid), needstr);
+    ADD_INSN3(ret, nd_line(node), defined,
+              I2F(DEFINED_CONST), ID2SYM(node->nd_mid), needstr);
     return 1;
 
-
   /* method dispatch */
   case NODE_CALL:
   case NODE_VCALL:
   case NODE_FCALL:
     if(nd_type(node) == NODE_CALL){
       LABEL *lcont = NEW_LABEL(nd_line(node));
-      
+
       defined_expr(self, iseq, ret, node->nd_recv, lfinish, Qfalse);
       ADD_INSNL(ret, nd_line(node), if, lcont);
       ADD_INSN (ret, nd_line(node), putnil);
       ADD_INSNL(ret, nd_line(node), jump, lfinish);
-      
+
       ADD_LABEL(ret, lcont);
       COMPILE(ret, "defined/recv", node->nd_recv);
     }
     else{
       ADD_INSN(ret, nd_line(node), putself);
     }
-    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_METHOD), ID2SYM(node->nd_mid), needstr);
+    ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_METHOD),
+              ID2SYM(node->nd_mid), needstr);
     return 1;
 
   case NODE_YIELD:
@@ -2231,8 +2256,32 @@
     ADD_INSN3(ret, nd_line(node), defined, I2F(DEFINED_ZSUPER), 0, needstr);
     return 1;
 
-  default:
-    rb_bug("unimplemented defined: %s", node_name(nd_type(node)));
+  default:{
+    LABEL *lstart = NEW_LABEL(nd_line(node));
+    LABEL *lend   = NEW_LABEL(nd_line(node));
+    LABEL *ldefed = NEW_LABEL(nd_line(node));
+    VALUE str     = rb_str_new2("expression");
+    VALUE tmp;
+    VALUE ensure = NEW_CHILD_ISEQVAL(
+      NEW_NIL(),
+      rb_str_concat(rb_str_new2("defined guard in "), iseq->name),
+      ISEQ_TYPE_DEFINED_GUARD);
+
+    iseq_add_mark_object_compile_time(iseq, str);
+    
+    ADD_LABEL(ret, lstart);
+    COMPILE(ret, "defined expr (others)", node);
+    ADD_INSNL(ret, nd_line(node), if, ldefed);
+    ADD_INSN (ret, nd_line(node), putnil);
+    ADD_INSNL(ret, nd_line(node), jump, lend);
+    ADD_LABEL(ret, ldefed);
+    ADD_INSN1(ret, nd_line(node), putobject, str);
+    ADD_LABEL(ret, lend);
+
+    ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, lstart, lend, ensure, 0, lfinish);
+    return 1;
+    // rb_bug("unimplemented defined: %s", node_name(nd_type(node)));
+  } /* end of default */
   }
 
   if(estr != 0){
@@ -2262,7 +2311,7 @@
     int level = 1;
     yarv_iseq_t *ip = iseq;
     while(1){
-      if(ip->parent_iseq){
+      if(ip->local_iseq != ip){
         ip = ip->parent_iseq;
       }
       else{
@@ -3609,8 +3658,6 @@
 
     ADD_LABEL(ret, lstart);
     ADD_INSN2(ret, nd_line(node), getinlinecache, NEW_INLINE_CACHE_ENTRY(), lend);
-    /* ADD_INSN (ret, nd_line(node), pop); */
-    /* ADD_INSN (ret, nd_line(node), putnil); */ /* target class */
     ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_vid));
     ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
     ADD_LABEL(ret, lend);
@@ -3922,12 +3969,17 @@
       DECL_ANCHOR(body);
 
       compile_colon2(self, iseq, node, pref, body);
-      ADD_SEQ  (ret, pref);
-      ADD_LABEL(ret, lstart);
-      ADD_INSN2(ret, nd_line(node), getinlinecache, NEW_INLINE_CACHE_ENTRY(), lend);
-      ADD_SEQ  (ret, body);
-      ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
-      ADD_LABEL(ret, lend);
+      if(LIST_SIZE_ZERO(pref)){
+        ADD_LABEL(ret, lstart);
+        ADD_INSN2(ret, nd_line(node), getinlinecache, NEW_INLINE_CACHE_ENTRY(), lend);
+        ADD_SEQ  (ret, body);
+        ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
+        ADD_LABEL(ret, lend);
+      }
+      else{
+        ADD_SEQ  (ret, pref);
+        ADD_SEQ  (ret, body);
+      }
     }
     else{
       /* function call */

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/test.rb	2005-12-19 16:08:17 UTC (rev 315)
@@ -1,3 +1,7 @@
+a = defined?("...#{foo}...")
+
+__END__
+
 require 'pathname'
 __END__
 require 'test/unit'

Modified: trunk/win32/Makefile.sub
===================================================================
--- trunk/win32/Makefile.sub	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/win32/Makefile.sub	2005-12-19 16:08:17 UTC (rev 315)
@@ -6,6 +6,12 @@
 
 #### Start of system configuration section. ####
 
+!if defined(pathlist)
+PATH = $(pathlist:;=/bin;)$(PATH)
+INCLUDE = $(pathlist:;=/include;)
+LIB = $(pathlist:;=/lib;)
+!endif
+
 ## variables may be overridden by $(compile_dir)/Makefile
 !ifndef srcdir
 srcdir = ..
@@ -68,11 +74,8 @@
 DEBUGFLAGS = -Zi
 !endif
 !if !defined(OPTFLAGS)
-OPTFLAGS = -O2b2x
-!if $(MSC_VER) < 1300
-OPTFLAGS = $(OPTFLAGS)g-
+OPTFLAGS = -O2b2xg-
 !endif
-!endif
 !if !defined(OS)
 OS = mswin32
 !endif
@@ -120,7 +123,7 @@
 CXXFLAGS = $(CFLAGS)
 !endif
 !if !defined(LDFLAGS)
-LDFLAGS = -MD -link -incremental:no -debug -opt:ref -opt:icf
+LDFLAGS = -link -incremental:no -debug -opt:ref -opt:icf
 !endif
 !if !defined(XLDFLAGS)
 XLDFLAGS = -stack:$(STACK)
@@ -182,6 +185,10 @@
 
 !include $(srcdir)/common.mk
 
+$(MKFILES): $(srcdir)/win32/Makefile.sub $(srcdir)/win32/configure.bat $(srcdir)/win32/setup.mak
+	$(srcdir:/=\)\win32\configure.bat $(configure_args)
+	@echo $(MKFILES) should be updated, re-run $(MAKE).
+
 CONFIG_H = ./.config.h.time
 
 config: config.status
@@ -190,6 +197,9 @@
 
 $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub
 	@echo Creating config.h
+!if exist(config.h)
+	@copy config.h config.h.old > nul
+!endif
 	@$(srcdir:/=\)\win32\ifchange.bat config.h <<
 #define STDC_HEADERS 1
 #define HAVE_SYS_TYPES_H 1
@@ -218,6 +228,7 @@
 #define DEPRECATED(x) __declspec(deprecated) x
 #define NOINLINE(x) __declspec(noinline) x
 !endif
+#define RUBY_EXTERN extern __declspec(dllimport)
 #define HAVE_DECL_SYS_NERR 1
 #define HAVE_LIMITS_H 1
 #define HAVE_FCNTL_H 1
@@ -459,7 +470,7 @@
 		@$(RM) $(RUBY_INSTALL_NAME).res $(RUBYW_INSTALL_NAME).res $(RUBY_SO_NAME).res
 
 distclean-local::
-		@$(RM) ext\config.cache $(RBCONFIG:/=\)
+		@$(RM) ext\config.cache $(RBCONFIG:/=\) $(CONFIG_H:/=\)
 		@$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF)
 		@$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc
 

Modified: trunk/win32/configure.bat
===================================================================
--- trunk/win32/configure.bat	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/win32/configure.bat	2005-12-19 16:08:17 UTC (rev 315)
@@ -6,8 +6,10 @@
 echo> ~tmp~.mak ####
 echo>> ~tmp~.mak conf = %0
 echo>> ~tmp~.mak $(conf:\=/): nul
-echo>> ~tmp~.mak 	@del ~tmp~.mak
+echo>> ~tmp~.mak 	@del ~setup~.mak
 echo>> ~tmp~.mak 	@-$(MAKE) -l$(MAKEFLAGS) -f $( D)/setup.mak \
+if exist pathlist.tmp del pathlist.tmp
+echo>confargs.tmp #define CONFIGURE_ARGS \
 :loop
 if "%1" == "" goto :end
 if "%1" == "--prefix" goto :prefix
@@ -21,58 +23,75 @@
 if "%1" == "--enable-install-doc" goto :enable-rdoc
 if "%1" == "--disable-install-doc" goto :disable-rdoc
 if "%1" == "--extout" goto :extout
+if "%1" == "--path" goto :path
 if "%1" == "-h" goto :help
 if "%1" == "--help" goto :help
-  echo>> ~tmp~.mak 	"%1" \
+  echo>>confargs.tmp %1 \
   shift
 goto :loop
 :srcdir
   echo>> ~tmp~.mak 	"srcdir=%2" \
+  echo>>confargs.tmp --srcdir=%2 \
   shift
   shift
 goto :loop
 :prefix
   echo>> ~tmp~.mak 	"prefix=%2" \
+  echo>>confargs.tmp %1=%2 \
   shift
   shift
 goto :loop
 :suffix
   echo>> ~tmp~.mak 	"RUBY_SUFFIX=%2" \
+  echo>>confargs.tmp %1=%2 \
   shift
   shift
 goto :loop
 :installname
   echo>> ~tmp~.mak 	"RUBY_INSTALL_NAME=%2" \
+  echo>>confargs.tmp %1=%2 \
   shift
   shift
 goto :loop
 :soname
   echo>> ~tmp~.mak 	"RUBY_SO_NAME=%2" \
+  echo>>confargs.tmp %1=%2 \
   shift
   shift
 goto :loop
 :target
   echo>> ~tmp~.mak 	"%2" \
+  echo>>confargs.tmp --target=%2 \
   shift
   shift
 goto :loop
 :extstatic
   echo>> ~tmp~.mak 	"EXTSTATIC=static" \
+  echo>>confargs.tmp %1 \
   shift
 goto :loop
 :enable-rdoc
   echo>> ~tmp~.mak 	"RDOCTARGET=install-doc" \
+  echo>>confargs.tmp %1 \
   shift
 goto :loop
 :disable-rdoc
   echo>> ~tmp~.mak 	"RDOCTARGET=install-nodoc" \
+  echo>>confargs.tmp %1 \
   shift
 goto :loop
 :extout
   echo>> ~tmp~.mak 	"EXTOUT=%2" \
+  echo>>confargs.tmp %1=%2 \
   shift
   shift
 goto :loop
+:path
+  echo>>pathlist.tmp %2;\
+  echo>>confargs.tmp %1=%2 \
+  shift
+  shift
+goto :loop
 :help
   echo Configuration:
   echo   --help                  display this help
@@ -84,9 +103,26 @@
   echo Optional Package:
   echo   --with-static-linked-ext link external modules statically
   echo   --disable-install-doc   do not install rdoc indexes during install
+  del *.tmp
   del ~tmp~.mak
 goto :exit
 :end
 echo>> ~tmp~.mak 	WIN32DIR=$(@D)
-nmake -alf ~tmp~.mak
+echo.>>confargs.tmp
+echo>confargs.c #define $ $$ 
+type>>confargs.c confargs.tmp
+echo>>confargs.c configure_args = CONFIGURE_ARGS
+echo>>confargs.c #undef $
+if exist pathlist.tmp echo>>confargs.c #define PATH_LIST \
+if exist pathlist.tmp type>>confargs.c pathlist.tmp
+if exist pathlist.tmp echo.>>confargs.c
+if exist pathlist.tmp echo>>confargs.c pathlist = PATH_LIST
+cl -EP confargs.c > ~setup~.mak 2>nul
+if exist pathlist.tmp echo>>~setup~.mak PATH = $(pathlist:;=/bin;)$(PATH)
+if exist pathlist.tmp echo>>~setup~.mak INCLUDE = $(pathlist:;=/include;)
+if exist pathlist.tmp echo>>~setup~.mak LIB = $(pathlist:;=/lib;)
+type>>~setup~.mak ~tmp~.mak
+del *.tmp > nul
+del ~tmp~.mak > nul
+nmake -alf ~setup~.mak
 :exit

Modified: trunk/win32/mkexports.rb
===================================================================
--- trunk/win32/mkexports.rb	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/win32/mkexports.rb	2005-12-19 16:08:17 UTC (rev 315)
@@ -89,13 +89,13 @@
           case filetype
           when /OBJECT/, /LIBRARY/
             next if /^[[:xdigit:]]+ 0+ UNDEF / =~ l
-  next unless l.sub!(/.*\sExternal\s+\|\s+/, '')
+            next unless l.sub!(/.*\sExternal\s+\|\s+/, '')
             if noprefix or l.sub!(/^_/, '')
               next if /@.*@/ =~ l || /@[[:xdigit:]]{16}$/ =~ l
               l.sub!(/^/, '_') if /@\d+$/ =~ l
-  elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
-    next
-  end
+            elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
+              next
+            end
           when /DLL/
             next unless l.sub!(/^\s*\d+\s+[[:xdigit:]]+\s+[[:xdigit:]]+\s+/, '')
           else

Modified: trunk/win32/setup.mak
===================================================================
--- trunk/win32/setup.mak	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/win32/setup.mak	2005-12-19 16:08:17 UTC (rev 315)
@@ -139,7 +139,12 @@
 	@$(APPEND) $(CPU) = 6
 
 -epilogue-: nul
+!if exist(confargs.c)
+	@$(CPP) confargs.c | findstr /v /r ^^$$ >> $(MAKEFILE)
+	@del confargs.c
+!endif
 	@type << >>$(MAKEFILE)
+
 # OS = $(OS)
 # RUBY_INSTALL_NAME = ruby
 # RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)$$(MAJOR)$$(MINOR)
@@ -153,5 +158,4 @@
 
 $(BANG)include $$(srcdir)/win32/Makefile.sub
 <<
-	@$(srcdir:/=\)\win32\rm.bat config.h config.status
 	@echo type `$(MAKE)' to make ruby for $(OS).

Modified: trunk/win32/win32.c
===================================================================
--- trunk/win32/win32.c	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/win32/win32.c	2005-12-19 16:08:17 UTC (rev 315)
@@ -1921,7 +1921,7 @@
 
 	    for (d = 0; d < dst->fd_count; d++) {
 		if (dst->fd_array[d] == fd) break;
-		}
+	    }
 	    if (d == dst->fd_count && dst->fd_count < FD_SETSIZE) {
 		dst->fd_array[dst->fd_count++] = fd;
 	    }
@@ -1929,9 +1929,9 @@
 		&src->fd_array[s],
 		&src->fd_array[s+1], 
 		sizeof(src->fd_array[0]) * (--src->fd_count - s));
-		}
+	}
 	else s++;
-	    }
+    }
 
     return dst->fd_count;
 }
@@ -1966,7 +1966,7 @@
 	}
 	else {
 	    ret = (GetLastError() == ERROR_BROKEN_PIPE); /* pipe was closed */
-    }
+	}
     );
 
     return ret;
@@ -2026,11 +2026,11 @@
 	int trap_immediate = rb_trap_immediate;
 #endif	/* !USE_INTERRUPT_WINSOCK */
 	RUBY_CRITICAL(
-	r = select(nfds, rd, wr, ex, timeout);
-	if (r == SOCKET_ERROR) {
-	    errno = map_errno(WSAGetLastError());
-	    r = -1;
-	}
+	    r = select(nfds, rd, wr, ex, timeout);
+	    if (r == SOCKET_ERROR) {
+		errno = map_errno(WSAGetLastError());
+		r = -1;
+	    }
 	);
 #if !USE_INTERRUPT_WINSOCK
 	rb_trap_immediate = trap_immediate;
@@ -2058,7 +2058,7 @@
 
 int WSAAPI
 rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
-	      struct timeval *timeout)
+	       struct timeval *timeout)
 {
     int r;
     fd_set pipe_rd;
@@ -2114,43 +2114,43 @@
     ex = &trap;
 #endif /* USE_INTERRUPT_WINSOCK */
 
-	if (nonsock) {
-	    struct timeval rest;
-	    struct timeval wait;
-	    struct timeval zero;
-	    if (timeout) rest = *timeout;
-	    wait.tv_sec = 0; wait.tv_usec = 10 * 1000; // 10ms
-	    zero.tv_sec = 0; zero.tv_usec = 0;         //  0ms
-	    do {
-		// modifying {else,pipe,cons}_rd is safe because
-		// if they are modified, function returns immediately.
-		extract_fd(&else_rd, &pipe_rd, is_readable_pipe);
-		extract_fd(&else_rd, &cons_rd, is_readable_console);
+    if (nonsock) {
+	struct timeval rest;
+	struct timeval wait;
+	struct timeval zero;
+	if (timeout) rest = *timeout;
+	wait.tv_sec = 0; wait.tv_usec = 10 * 1000; // 10ms
+	zero.tv_sec = 0; zero.tv_usec = 0;         //  0ms
+	do {
+	    // modifying {else,pipe,cons}_rd is safe because
+	    // if they are modified, function returns immediately.
+	    extract_fd(&else_rd, &pipe_rd, is_readable_pipe);
+	    extract_fd(&else_rd, &cons_rd, is_readable_console);
 
-		if (else_rd.fd_count || else_wr.fd_count) {
-		    r = do_select(nfds, rd, wr, ex, &zero); // polling
-		    if (r < 0) break; // XXX: should I ignore error and return signaled handles?
-		    r += extract_fd(rd, &else_rd, NULL); // move all
-		    r += extract_fd(wr, &else_wr, NULL); // move all
-		    break;
-	}
-		else {
-		    fd_set orig_rd;
-		    fd_set orig_wr;
-		    fd_set orig_ex;
-		    if (rd) orig_rd = *rd;
-		    if (wr) orig_wr = *wr;
-		    if (ex) orig_ex = *ex;
-		    r = do_select(nfds, rd, wr, ex, &wait);
-		    if (r != 0) break; // signaled or error
-		    if (rd) *rd = orig_rd;
-		    if (wr) *wr = orig_wr;
-		    if (ex) *ex = orig_ex;
-		}
-	    } while (!timeout || subst(&rest, &wait));
-	}
-	else
-	    r = do_select(nfds, rd, wr, ex, timeout);
+	    if (else_rd.fd_count || else_wr.fd_count) {
+		r = do_select(nfds, rd, wr, ex, &zero); // polling
+		if (r < 0) break; // XXX: should I ignore error and return signaled handles?
+		r += extract_fd(rd, &else_rd, NULL); // move all
+		r += extract_fd(wr, &else_wr, NULL); // move all
+		break;
+	    }
+	    else {
+		fd_set orig_rd;
+		fd_set orig_wr;
+		fd_set orig_ex;
+		if (rd) orig_rd = *rd;
+		if (wr) orig_wr = *wr;
+		if (ex) orig_ex = *ex;
+		r = do_select(nfds, rd, wr, ex, &wait);
+		if (r != 0) break; // signaled or error
+		if (rd) *rd = orig_rd;
+		if (wr) *wr = orig_wr;
+		if (ex) *ex = orig_ex;
+	    }
+	} while (!timeout || subst(&rest, &wait));
+    }
+    else
+	r = do_select(nfds, rd, wr, ex, timeout);
 
 #if USE_INTERRUPT_WINSOCK
     RUBY_CRITICAL(ret = __WSAFDIsSet((SOCKET)interrupted_event, ex));
@@ -2362,8 +2362,8 @@
 #undef recvfrom
 
 int WSAAPI
-rb_w32_recvfrom(int s, char *buf, int len, int flags, 
-		struct sockaddr *from, int *fromlen)
+rb_w32_recvfrom(int s, char *buf, int len, int flags,
+		 struct sockaddr *from, int *fromlen)
 {
     int r;
     if (!NtSocketsInitialized) {

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/yarvcore.h	2005-12-19 16:08:17 UTC (rev 315)
@@ -138,6 +138,7 @@
 #define ISEQ_TYPE_RESCUE INT2FIX(5)
 #define ISEQ_TYPE_ENSURE INT2FIX(6)
 #define ISEQ_TYPE_EVAL   INT2FIX(7)
+#define ISEQ_TYPE_DEFINED_GUARD INT2FIX(8)
 
 #define CATCH_TYPE_RESCUE INT2FIX(1)
 #define CATCH_TYPE_ENSURE INT2FIX(2)

Modified: trunk/yarvtest/test_bin.rb
===================================================================
--- trunk/yarvtest/test_bin.rb	2005-12-17 01:47:55 UTC (rev 314)
+++ trunk/yarvtest/test_bin.rb	2005-12-19 16:08:17 UTC (rev 315)
@@ -118,14 +118,8 @@
   end
 
   def test_constant
-    ae %q(C = 1; C) do
-      remove_const :C
-    end
-
-    ae %q(C = 1; ::C) do
-      remove_const :C
-    end
-    
+    ae %q(C = 1; C)
+    ae %q(C = 1; $a = []; 2.times{$a << ::C}; $a)
     ae %q(
       class A
         class B
@@ -134,7 +128,9 @@
           end
         end
       end
-      A::B::C::Const
+      (1..2).map{
+        A::B::C::Const
+      }
     ) do
       remove_const :A
     end
@@ -144,7 +140,9 @@
         class B
           Const = 1
           class C
-            Const
+            (1..2).map{
+              Const
+            }
           end
         end
       end
@@ -157,7 +155,9 @@
         Const = 1
         class B
           class C
-            Const
+            (1..2).map{
+              Const
+            }
           end
         end
       end
@@ -170,7 +170,9 @@
       class A
         class B
           class C
-            Const
+            (1..2).map{
+              Const
+            }
           end
         end
       end
@@ -216,6 +218,23 @@
     } do
       remove_const :A
     end
+    
+    ae %q{
+      class C
+        Const = 1
+        (1..3).map{
+          self::Const
+        }
+      end
+    }
+    ae %q{
+      class C
+        Const = 1
+        (1..3).map{
+          eval('self')::Const
+        }
+      end
+    }
   end
   
   def test_gvar


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

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