Can dmd compile with my own runtime library?
Huang F Guan
gdxxhg at gmail.com
Thu Aug 23 10:17:16 PDT 2007
Frits van Bommel Wrote:
> > I'm not sure what exactly this is about, I've run in the the same
> > problems lately. I think it's some (static) initialization code for
> > TypeInfo, or at least that's what the mangled name suggests. Try to add
> > an implementation for init in the TypeInfo definition in object.d.
>
> It's not a function. As I think I mentioned in my other post[1], though
> perhaps not with so many words, this is part of what DMD emits when it
> encounters a class called TypeInfo_Aa (The name used for the result type
> of typeid(char[]).
>
I solved this problem by defining a function like below:
void _D11TypeInfo_Aa6__initZ()
{
while(1){}
}
But it is stupid to do such a thing.
Now my object.d can be linked well.
And I want to know how the classinfos get the information of the class, is it stored in a initialized data section?
I wrote this program with my object.d
class A{
private int a;
this()
{
a = 0x00111111;
}
~this()
{
a= 0x88111111;
}
}
class B : A
{
private int b;
this()
{
b = 0x00222222;
super();
}
int printok()
{
b = 0x00333333;
return b;
}
~this()
{
b = 0x88222222;
}
}
extern (C) int test()
{
B b = new B;
b.printok();
delete b;
return 2;
}
The result is
test(): passed
a.this(): passed
b.this(): passed
b.printok() : passed
b.~this(): not passed
a.~this(): not passed
I don't know why the two disconstructors are not passed everytime. When I check the deallocator of the classinfo of these two classes, they are all empty pointers.
This is my _d_delclass:
void _d_delclass(Object *p)
{
if (*p)
{
//debug (PRINTF) printf("_d_delclass(%p)\n", *p);
ClassInfo **pc = cast(ClassInfo **)*p;
if (*pc)
{
ClassInfo c = **pc;
if (c.deallocator) //====failed at here!!!!!!!!!
{
_d_callfinalizer(cast(void *)(*p));
fp_t fp = cast(fp_t)c.deallocator;
(*fp)(*p); // call deallocator
*p = null;
return;
}
}
free(cast(void*)(*p)); //passed.
*p = null;
}
}
More information about the Digitalmars-d
mailing list