Skip to content

Commit

Permalink
Merge pull request #4659 from ibuclaw/cxx_mangle
Browse files Browse the repository at this point in the history
Fix some bad coding conventions of cppmangle.c
  • Loading branch information
WalterBright committed May 17, 2015
2 parents 448ff39 + d8119c8 commit ae0c87f
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions src/cppmangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ class CppMangleVisitor : public Visitor
void visit(TypeVector *t)
{
is_top_level = false;
if (substitute(t)) return;
if (substitute(t))
return;
store(t);
if (t->isImmutable() || t->isShared())
{
Expand Down Expand Up @@ -707,7 +708,8 @@ class CppMangleVisitor : public Visitor
void visit(TypePointer *t)
{
is_top_level = false;
if (substitute(t)) return;
if (substitute(t))
return;
if (t->isImmutable() || t->isShared())
{
visit((Type *)t);
Expand All @@ -722,7 +724,8 @@ class CppMangleVisitor : public Visitor
void visit(TypeReference *t)
{
is_top_level = false;
if (substitute(t)) return;
if (substitute(t))
return;
buf.writeByte('R');
t->next->accept(this);
store(t);
Expand Down Expand Up @@ -753,7 +756,8 @@ class CppMangleVisitor : public Visitor
TypeFunctions for non-static member functions, and non-static
member functions of different classes.
*/
if (substitute(t)) return;
if (substitute(t))
return;
buf.writeByte('F');
if (t->linkage == LINKc)
buf.writeByte('Y');
Expand Down Expand Up @@ -809,7 +813,8 @@ class CppMangleVisitor : public Visitor

is_top_level = false;

if (substitute(t)) return;
if (substitute(t))
return;
if (t->isImmutable() || t->isShared())
{
visit((Type *)t);
Expand All @@ -834,7 +839,8 @@ class CppMangleVisitor : public Visitor
void visit(TypeEnum *t)
{
is_top_level = false;
if (substitute(t)) return;
if (substitute(t))
return;

if (t->isConst())
buf.writeByte('K');
Expand All @@ -855,7 +861,8 @@ class CppMangleVisitor : public Visitor

void visit(TypeClass *t)
{
if (substitute(t)) return;
if (substitute(t))
return;
if (t->isImmutable() || t->isShared())
{
visit((Type *)t);
Expand Down Expand Up @@ -960,7 +967,8 @@ class VisualCPPMangler : public Visitor

if (type->isConst() && ((flags & IS_NOT_TOP_TYPE) || (flags & IS_DMC)))
{
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
}

if ((type->ty == Tbool) && checkTypeSaved(type))// try to replace long name with number
Expand Down Expand Up @@ -1008,7 +1016,8 @@ class VisualCPPMangler : public Visitor
void visit(TypeVector *type)
{
//printf("visit(TypeVector); is_not_top_type = %d\n", (int)(flags & IS_NOT_TOP_TYPE));
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
buf.writestring("T__m128@@"); // may be better as __m128i or __m128d?
flags &= ~IS_NOT_TOP_TYPE;
flags &= ~IGNORE_CONST;
Expand All @@ -1018,7 +1027,8 @@ class VisualCPPMangler : public Visitor
{
// This method can be called only for static variable type mangling.
//printf("visit(TypeSArray); is_not_top_type = %d\n", (int)(flags & IS_NOT_TOP_TYPE));
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
// first dimension always mangled as const pointer
if (flags & IS_DMC)
buf.writeByte('Q');
Expand Down Expand Up @@ -1114,7 +1124,8 @@ class VisualCPPMangler : public Visitor
void visit(TypeReference *type)
{
//printf("visit(TypeReference); type = %s\n", type->toChars());
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;

if (type->isImmutable() || type->isShared())
{
Expand Down Expand Up @@ -1144,7 +1155,8 @@ class VisualCPPMangler : public Visitor

if ((flags & IS_DMC))
{
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
}
else
{
Expand Down Expand Up @@ -1177,15 +1189,17 @@ class VisualCPPMangler : public Visitor

if (type->isConst() && ((flags & IS_NOT_TOP_TYPE) || (flags & IS_DMC)))
{
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
}

mangleModifier(type);
buf.writeByte(c);
}
else
{
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
//printf("visit(TypeStruct); is_not_top_type = %d\n", (int)(flags & IS_NOT_TOP_TYPE));
mangleModifier(type);
if (type->sym->isUnionDeclaration())
Expand All @@ -1201,7 +1215,8 @@ class VisualCPPMangler : public Visitor
void visit(TypeEnum *type)
{
//printf("visit(TypeEnum); is_not_top_type = %d\n", (int)(flags & IS_NOT_TOP_TYPE));
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
mangleModifier(type);
buf.writeByte('W');

Expand Down Expand Up @@ -1247,7 +1262,8 @@ class VisualCPPMangler : public Visitor
void visit(TypeClass *type)
{
//printf("visit(TypeClass); is_not_top_type = %d\n", (int)(flags & IS_NOT_TOP_TYPE));
if (checkTypeSaved(type)) return;
if (checkTypeSaved(type))
return;
if (flags & IS_NOT_TOP_TYPE)
mangleModifier(type);

Expand Down Expand Up @@ -1600,7 +1616,8 @@ class VisualCPPMangler : public Visitor
}
else
{
if (checkAndSaveIdent(name)) return;
if (checkAndSaveIdent(name))
return;
}
}
buf.writestring(name);
Expand Down Expand Up @@ -1711,8 +1728,10 @@ class VisualCPPMangler : public Visitor

bool checkTypeSaved(Type *type)
{
if (flags & IS_NOT_TOP_TYPE) return false;
if (flags & MANGLE_RETURN_TYPE) return false;
if (flags & IS_NOT_TOP_TYPE)
return false;
if (flags & MANGLE_RETURN_TYPE)
return false;
for (size_t i = 0; i < VC_SAVED_TYPE_CNT; i++)
{
if (!saved_types[i]) // no saved same type
Expand All @@ -1733,7 +1752,8 @@ class VisualCPPMangler : public Visitor

void mangleModifier(Type *type)
{
if (flags & IGNORE_CONST) return;
if (flags & IGNORE_CONST)
return;
if (type->isImmutable() || type->isShared())
{
visit((Type*)type);
Expand Down

0 comments on commit ae0c87f

Please sign in to comment.