On 24.01.2012 14:04, Daniel Murphy wrote:
I'm modifying the compiler so it will link directly.  I've got static
and non-virtual struct and class members working so far.  It's here if
you're interested - some is working but it's not very polished.

https://github.com/yebblies/dmd/compare/master...cpplinking

It is somewhat complicated by the fact I'm testing it with the c++
codebase I'm most unfamiliar with - the d compiler.


I was thinking about making something similar some time ago to integrate compiler functionality in D programs: instead of trying to translate dmd, just replace the memory allocations with the D-GC and otherwise link directly to the C++ code.

I figured out some issues and made two tiny changes. Maybe your changes cover these, but in case they might help:

diff --git a/src/tocsym.c b/src/tocsym.c
index 1d614a1..4d47d18 100644
--- a/src/tocsym.c
+++ b/src/tocsym.c
@@ -356,7 +356,7 @@ Symbol *FuncDeclaration::toSymbol()
             func_t *f = s->Sfunc;
             if (isVirtual())
                 f->Fflags |= Fvirtual;
-            else if (isMember2())
+            else if ((storage_class & STCstatic) && isMember2())
                 f->Fflags |= Fstatic;
             f->Fstartline.Slinnum = loc.linnum;
             f->Fstartline.Sfilename = (char *)loc.filename;
@@ -406,12 +406,16 @@ Symbol *FuncDeclaration::toSymbol()
 #endif
                     s->Sflags |= SFLpublic;
                     Dsymbol *parent = toParent();
-                    ClassDeclaration *cd = parent->isClassDeclaration();
-                    if (cd)
+ if (ClassDeclaration *cd = parent->isClassDeclaration())
                     {
                         ::type *tc = cd->type->toCtype();
                         s->Sscope = tc->Tnext->Ttag;
                     }
+ else if (StructDeclaration *sd = parent->isStructDeclaration())
+                    {
+                        ::type *tc = sd->type->toCtype();
+                        s->Sscope = tc->Ttag;
+                    }
                     break;
                 }
                 default:

I also noticed that calling a virtual function of a derived extern(C++) interface uses a wrong offset into the virtual function table, but did not try to fix it yet.

Rainer
_______________________________________________
dmd-internals mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-internals

Reply via email to