Updated to dmdfe 2.051

This commit is contained in:
Alexey Prokhin
2011-01-05 18:21:40 +03:00
parent 8a4ee0ede5
commit c5e9784863
37 changed files with 1405 additions and 1157 deletions

View File

@@ -43,6 +43,8 @@ struct CppMangleState
static Array components;
int substitute(OutBuffer *buf, void *p);
int exist(void *p);
void store(void *p);
};
Array CppMangleState::components;
@@ -82,6 +84,23 @@ int CppMangleState::substitute(OutBuffer *buf, void *p)
return 0;
}
int CppMangleState::exist(void *p)
{
for (size_t i = 0; i < components.dim; i++)
{
if (p == components.data[i])
{
return 1;
}
}
return 0;
}
void CppMangleState::store(void *p)
{
components.push(p);
}
void source_name(OutBuffer *buf, Dsymbol *s)
{
char *name = s->ident->toChars();
@@ -203,9 +222,6 @@ void TypeBasic::toCppMangle(OutBuffer *buf, CppMangleState *cms)
* u <source-name> # vendor extended type
*/
if (isConst())
buf->writeByte('K');
switch (ty)
{
case Tvoid: c = 'v'; break;
@@ -234,12 +250,18 @@ void TypeBasic::toCppMangle(OutBuffer *buf, CppMangleState *cms)
default: assert(0);
}
if (p)
if (p || isConst())
{
if (cms->substitute(buf, this))
return;
buf->writeByte(p);
}
if (isConst())
buf->writeByte('K');
if (p)
buf->writeByte(p);
buf->writeByte(c);
}
@@ -266,19 +288,25 @@ void TypeAArray::toCppMangle(OutBuffer *buf, CppMangleState *cms)
void TypePointer::toCppMangle(OutBuffer *buf, CppMangleState *cms)
{
if (!cms->substitute(buf, this))
if (!cms->exist(this))
{ buf->writeByte('P');
next->toCppMangle(buf, cms);
cms->store(this);
}
else
cms->substitute(buf, this);
}
void TypeReference::toCppMangle(OutBuffer *buf, CppMangleState *cms)
{
if (!cms->substitute(buf, this))
if (!cms->exist(this))
{ buf->writeByte('R');
next->toCppMangle(buf, cms);
cms->store(this);
}
else
cms->substitute(buf, this);
}
@@ -325,15 +353,37 @@ void TypeDelegate::toCppMangle(OutBuffer *buf, CppMangleState *cms)
void TypeStruct::toCppMangle(OutBuffer *buf, CppMangleState *cms)
{
if (!cms->substitute(buf, sym))
cpp_mangle_name(buf, cms, sym);
if (!cms->exist(this))
{
if (isConst())
buf->writeByte('K');
if (!cms->substitute(buf, sym))
cpp_mangle_name(buf, cms, sym);
if (isConst())
cms->store(this);
}
else
cms->substitute(buf, this);
}
void TypeEnum::toCppMangle(OutBuffer *buf, CppMangleState *cms)
{
if (!cms->substitute(buf, sym))
cpp_mangle_name(buf, cms, sym);
if (!cms->exist(this))
{
if (isConst())
buf->writeByte('K');
if (!cms->substitute(buf, sym))
cpp_mangle_name(buf, cms, sym);
if (isConst())
cms->store(this);
}
else
cms->substitute(buf, this);
}
@@ -373,7 +423,14 @@ void Parameter::argsCppMangle(OutBuffer *buf, CppMangleState *cms, Parameters *a
{ // Mangle static arrays as pointers
t = t->pointerTo();
}
t->toCppMangle(buf, cms);
/* If it is a basic, enum or struct type,
* then don't mark it const
*/
if ((t->ty == Tenum || t->ty == Tstruct || t->isTypeBasic()) && t->isConst())
t->mutableOf()->toCppMangle(buf, cms);
else
t->toCppMangle(buf, cms);
n++;
}