changeset 728:635f91212b78

Change _d_newclass into _d_allocclass. Add initialization to ClassInfo.create.
author Christian Kamm <kamm incasoftware de>
date Sun, 26 Oct 2008 14:12:03 +0100
parents eea28bfa8416
children 50d01791859c
files gen/classes.cpp gen/runtime.cpp runtime/internal/genobj.d runtime/internal/lifetime.d runtime/internal/mars.h
diffstat 5 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gen/classes.cpp	Sun Oct 26 14:11:14 2008 +0100
+++ b/gen/classes.cpp	Sun Oct 26 14:12:03 2008 +0100
@@ -812,7 +812,7 @@
     // default allocator
     else
     {
-        llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass");
+        llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_allocclass");
         mem = gIR->CreateCallOrInvoke(fn, tc->sym->ir.irStruct->classInfo, ".newclass_gc_alloc")->get();
         mem = DtoBitCast(mem, DtoType(tc), ".newclass_gc");
     }
--- a/gen/runtime.cpp	Sun Oct 26 14:11:14 2008 +0100
+++ b/gen/runtime.cpp	Sun Oct 26 14:12:03 2008 +0100
@@ -257,9 +257,9 @@
         llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M);
     }
 
-    // Object _d_newclass(ClassInfo ci)
+    // Object _d_allocclass(ClassInfo ci)
     {
-        std::string fname("_d_newclass");
+        std::string fname("_d_allocclass");
         std::vector<const LLType*> types;
         types.push_back(classInfoTy);
         const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
--- a/runtime/internal/genobj.d	Sun Oct 26 14:11:14 2008 +0100
+++ b/runtime/internal/genobj.d	Sun Oct 26 14:12:03 2008 +0100
@@ -48,7 +48,7 @@
     debug(PRINTF) import tango.stdc.stdio; // : printf;
 
     extern (C) void onOutOfMemoryError();
-    extern (C) Object _d_newclass(ClassInfo ci);
+    extern (C) Object _d_allocclass(ClassInfo ci);
 }
 
 // NOTE: For some reason, this declaration method doesn't work
@@ -188,7 +188,11 @@
     {
         if (flags & 8 && !defaultConstructor)
             return null;
-        Object o = _d_newclass(this);
+
+        Object o = _d_allocclass(this);
+        // initialize it
+        (cast(byte*) o)[0 .. init.length] = init[];
+
         if (flags & 8 && defaultConstructor)
         {
             defaultConstructor(o);
--- a/runtime/internal/lifetime.d	Sun Oct 26 14:11:14 2008 +0100
+++ b/runtime/internal/lifetime.d	Sun Oct 26 14:12:03 2008 +0100
@@ -88,11 +88,11 @@
 /**
  *
  */
-extern (C) Object _d_newclass(ClassInfo ci)
+extern (C) Object _d_allocclass(ClassInfo ci)
 {
     void* p;
 
-    debug(PRINTF2) printf("_d_newclass(ci = %p, %s)\n", ci, cast(char *)ci.name.ptr);
+    debug(PRINTF2) printf("_d_allocclass(ci = %p, %s)\n", ci, cast(char *)ci.name.ptr);
     /+
     if (ci.flags & 1) // if COM object
     {   /* COM objects are not garbage collected, they are reference counted
--- a/runtime/internal/mars.h	Sun Oct 26 14:11:14 2008 +0100
+++ b/runtime/internal/mars.h	Sun Oct 26 14:12:03 2008 +0100
@@ -94,7 +94,7 @@
 int _d_isbaseof(ClassInfo *b, ClassInfo *c);
 Object *_d_dynamic_cast(Object *o, ClassInfo *ci);
 
-Object * _d_newclass(ClassInfo *ci);
+Object * _d_allocclass(ClassInfo *ci);
 void _d_delclass(Object **p);
 
 void _d_OutOfMemory();