[macruby-changes] [2408] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 28 14:33:03 PDT 2009


Revision: 2408
          http://trac.macosforge.org/projects/ruby/changeset/2408
Author:   lsansonetti at apple.com
Date:     2009-08-28 14:33:00 -0700 (Fri, 28 Aug 2009)
Log Message:
-----------
fixed AOT compilation of empty regexs

Modified Paths:
--------------
    MacRuby/trunk/compiler.cpp
    MacRuby/trunk/re.c

Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp	2009-08-28 21:01:13 UTC (rev 2407)
+++ MacRuby/trunk/compiler.cpp	2009-08-28 21:33:00 UTC (rev 2408)
@@ -5121,17 +5121,23 @@
 		{
 		    struct RRegexp *re = (struct RRegexp *)val;
 
-		    GlobalVariable *rename_gvar =
-			compile_const_global_string(re->str, re->len);
+		    Instruction *re_str;
+		    if (re->len == 0) {
+			re_str = compile_const_pointer(NULL, NULL, false);	
+		    }
+		    else {
+			GlobalVariable *rename_gvar =
+			    compile_const_global_string(re->str, re->len);
 
-		    std::vector<Value *> idxs;
-		    idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
-		    idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
-		    Instruction *load = GetElementPtrInst::Create(rename_gvar,
-			    idxs.begin(), idxs.end(), "");
+			std::vector<Value *> idxs;
+			idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
+			idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
+			re_str = GetElementPtrInst::Create(rename_gvar,
+				idxs.begin(), idxs.end(), "");
+		    }
 
 		    std::vector<Value *> params;
-		    params.push_back(load);
+		    params.push_back(re_str);
 		    params.push_back(ConstantInt::get(Type::Int32Ty, re->len));
 		    params.push_back(ConstantInt::get(Type::Int32Ty,
 				re->ptr->options));
@@ -5143,7 +5149,7 @@
 
 		    list.insert(list.begin(), assign);
 		    list.insert(list.begin(), call);
-		    list.insert(list.begin(), load);
+		    list.insert(list.begin(), re_str);
 		}
 		break;
 

Modified: MacRuby/trunk/re.c
===================================================================
--- MacRuby/trunk/re.c	2009-08-28 21:01:13 UTC (rev 2407)
+++ MacRuby/trunk/re.c	2009-08-28 21:33:00 UTC (rev 2408)
@@ -2681,6 +2681,9 @@
 rb_reg_new(const char *s, long len, int options)
 {
 #if WITH_OBJC
+    if (s == NULL && len == 0) {
+	s = "";
+    }
     return rb_enc_reg_new(s, len, NULL, options);
 #else
     return rb_enc_reg_new(s, len, rb_ascii8bit_encoding(), options);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090828/05062b1c/attachment.html>


More information about the macruby-changes mailing list