diff gen/runtime.cpp @ 197:bfcb657756f6 trunk

[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'. Fixed: string switch runtime support had wrong param types. Fixed: string switch on a temporary slice was broken.
author lindquist
date Mon, 12 May 2008 20:02:52 +0200
parents 2900754a6989
children e881c9b1c738
line wrap: on
line diff
--- a/gen/runtime.cpp	Mon May 12 19:10:41 2008 +0200
+++ b/gen/runtime.cpp	Mon May 12 20:02:52 2008 +0200
@@ -145,6 +145,14 @@
     return rt_ptr(llvm::StructType::get(t));
 }
 
+static const llvm::Type* rt_array2(const llvm::Type* elemty)
+{
+    std::vector<const llvm::Type*> t;
+    t.push_back(DtoSize_t());
+    t.push_back(rt_ptr(elemty));
+    return llvm::StructType::get(t);
+}
+
 static const llvm::Type* rt_dg1()
 {
     std::vector<const llvm::Type*> types;
@@ -705,7 +713,7 @@
     {
         std::string fname("_d_switch_string");
         std::vector<const llvm::Type*> types;
-        types.push_back(rt_array(stringTy));
+        types.push_back(rt_array(rt_array2(byteTy)));
         types.push_back(stringTy);
         const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
         new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
@@ -715,7 +723,7 @@
     {
         std::string fname("_d_switch_ustring");
         std::vector<const llvm::Type*> types;
-        types.push_back(rt_array(wstringTy));
+        types.push_back(rt_array(rt_array2(shortTy)));
         types.push_back(wstringTy);
         const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
         new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
@@ -725,7 +733,7 @@
     {
         std::string fname("_d_switch_dstring");
         std::vector<const llvm::Type*> types;
-        types.push_back(rt_array(dstringTy));
+        types.push_back(rt_array(rt_array2(intTy)));
         types.push_back(dstringTy);
         const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false);
         new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M);