Permalink
Browse files

Merge pull request #7735 from wilzbach/LINK

Automatically convert LINKXXX to LINK + use final switch
merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>
  • Loading branch information...
2 parents c68ae00 + 984ebcb commit 9fc9250c997a843c5946731a0bd44f1f5e399f01 @dlang-bot dlang-bot committed Jan 18, 2018
View
@@ -484,7 +484,7 @@ struct ASTBase
super(id);
storage_class = STC.undefined_;
protection = Prot(Prot.Kind.undefined);
- linkage = LINKdefault;
+ linkage = LINK.default_;
}
override final inout(Declaration) isDeclaration() inout
@@ -6277,24 +6277,23 @@ struct ASTBase
extern (C++) static const(char)* linkageToChars(LINK linkage)
{
- switch (linkage)
+ final switch (linkage)
{
- case LINKdefault:
+ case LINK.default_:
+ case LINK.system:
return null;
- case LINKd:
+ case LINK.d:
return "D";
- case LINKc:
+ case LINK.c:
return "C";
- case LINKcpp:
+ case LINK.cpp:
return "C++";
- case LINKwindows:
+ case LINK.windows:
return "Windows";
- case LINKpascal:
+ case LINK.pascal:
return "Pascal";
- case LINKobjc:
+ case LINK.objc:
return "Objective-C";
- default:
- assert(0);
}
}
View
@@ -439,7 +439,7 @@ extern (C++) final class LinkDeclaration : AttribDeclaration
{
super(decl);
//printf("LinkDeclaration(linkage = %d, decl = %p)\n", p, decl);
- linkage = (p == LINKsystem) ? Target.systemLinkage() : p;
+ linkage = (p == LINK.system) ? Target.systemLinkage() : p;
}
static LinkDeclaration create(LINK p, Dsymbols* decl)
@@ -491,7 +491,7 @@ extern (C++) final class CPPMangleDeclaration : AttribDeclaration
override Scope* newScope(Scope* sc)
{
- return createNewScope(sc, sc.stc, LINKcpp, cppmangle, sc.protection, sc.explicitProtection,
+ return createNewScope(sc, sc.stc, LINK.cpp, cppmangle, sc.protection, sc.explicitProtection,
sc.aligndecl, sc.inlining);
}
View
@@ -74,7 +74,7 @@ enum
TYifunc = 0x2E, // interrupt func
TYptr = 0x33, // generic pointer type
TYmfunc = 0x37, // NT C++ member func
- TYjfunc = 0x38, // LINKd D function
+ TYjfunc = 0x38, // LINK.d D function
TYhfunc = 0x39, // C function with hidden parameter
TYnref = 0x3A, // near reference
View
@@ -242,7 +242,7 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
auto fparams = new Parameters();
fparams.push(new Parameter(STC.nodtor, sd.type, Id.p, null));
- auto tf = new TypeFunction(fparams, sd.handleType(), 0, LINKd, stc | STC.ref_);
+ auto tf = new TypeFunction(fparams, sd.handleType(), 0, LINK.d, stc | STC.ref_);
auto fop = new FuncDeclaration(declLoc, Loc(), Id.assign, stc, tf);
fop.storage_class |= STC.inference;
fop.generated = true;
@@ -316,7 +316,7 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
uint errors = global.startGagging(); // Do not report errors, even if the template opAssign fbody makes it.
Scope* sc2 = sc.push();
sc2.stc = 0;
- sc2.linkage = LINKd;
+ sc2.linkage = LINK.d;
fop.dsymbolSemantic(sc2);
fop.semantic2(sc2);
// https://issues.dlang.org/show_bug.cgi?id=15044
@@ -487,7 +487,7 @@ extern (C++) FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)
*/
auto parameters = new Parameters();
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, null, null));
- tfeqptr = new TypeFunction(parameters, Type.tbool, 0, LINKd);
+ tfeqptr = new TypeFunction(parameters, Type.tbool, 0, LINK.d);
tfeqptr.mod = MODFlags.const_;
tfeqptr = cast(TypeFunction)tfeqptr.typeSemantic(Loc(), &scx);
}
@@ -513,7 +513,7 @@ extern (C++) FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)
auto parameters = new Parameters();
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.p, null));
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.q, null));
- auto tf = new TypeFunction(parameters, Type.tbool, 0, LINKd);
+ auto tf = new TypeFunction(parameters, Type.tbool, 0, LINK.d);
Identifier id = Id.xopEquals;
auto fop = new FuncDeclaration(declLoc, Loc(), id, STC.static_, tf);
fop.generated = true;
@@ -524,7 +524,7 @@ extern (C++) FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc)
uint errors = global.startGagging(); // Do not report errors
Scope* sc2 = sc.push();
sc2.stc = 0;
- sc2.linkage = LINKd;
+ sc2.linkage = LINK.d;
fop.dsymbolSemantic(sc2);
fop.semantic2(sc2);
sc2.pop();
@@ -557,7 +557,7 @@ extern (C++) FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
*/
auto parameters = new Parameters();
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, null, null));
- tfcmpptr = new TypeFunction(parameters, Type.tint32, 0, LINKd);
+ tfcmpptr = new TypeFunction(parameters, Type.tint32, 0, LINK.d);
tfcmpptr.mod = MODFlags.const_;
tfcmpptr = cast(TypeFunction)tfcmpptr.typeSemantic(Loc(), &scx);
}
@@ -633,7 +633,7 @@ extern (C++) FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
auto parameters = new Parameters();
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.p, null));
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.q, null));
- auto tf = new TypeFunction(parameters, Type.tint32, 0, LINKd);
+ auto tf = new TypeFunction(parameters, Type.tint32, 0, LINK.d);
Identifier id = Id.xopCmp;
auto fop = new FuncDeclaration(declLoc, Loc(), id, STC.static_, tf);
fop.generated = true;
@@ -644,7 +644,7 @@ extern (C++) FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc)
uint errors = global.startGagging(); // Do not report errors
Scope* sc2 = sc.push();
sc2.stc = 0;
- sc2.linkage = LINKd;
+ sc2.linkage = LINK.d;
fop.dsymbolSemantic(sc2);
fop.semantic2(sc2);
sc2.pop();
@@ -721,7 +721,7 @@ extern (C++) FuncDeclaration buildXtoHash(StructDeclaration sd, Scope* sc)
static __gshared TypeFunction tftohash;
if (!tftohash)
{
- tftohash = new TypeFunction(null, Type.thash_t, 0, LINKd);
+ tftohash = new TypeFunction(null, Type.thash_t, 0, LINK.d);
tftohash.mod = MODFlags.const_;
tftohash = cast(TypeFunction)tftohash.merge();
}
@@ -740,7 +740,7 @@ extern (C++) FuncDeclaration buildXtoHash(StructDeclaration sd, Scope* sc)
Loc loc = Loc(); // internal code should have no loc to prevent coverage
auto parameters = new Parameters();
parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.p, null));
- auto tf = new TypeFunction(parameters, Type.thash_t, 0, LINKd, STC.nothrow_ | STC.trusted);
+ auto tf = new TypeFunction(parameters, Type.thash_t, 0, LINK.d, STC.nothrow_ | STC.trusted);
Identifier id = Id.xtoHash;
auto fop = new FuncDeclaration(declLoc, Loc(), id, STC.static_, tf);
fop.generated = true;
@@ -758,7 +758,7 @@ extern (C++) FuncDeclaration buildXtoHash(StructDeclaration sd, Scope* sc)
fop.fbody = new CompileStatement(loc, new StringExp(loc, cast(char*)code));
Scope* sc2 = sc.push();
sc2.stc = 0;
- sc2.linkage = LINKd;
+ sc2.linkage = LINK.d;
fop.dsymbolSemantic(sc2);
fop.semantic2(sc2);
sc2.pop();
View
@@ -169,7 +169,7 @@ extern (C++) final class StaticForeach : RootObject
*/
private extern(D) Expression wrapAndCall(Loc loc, Statement s)
{
- auto tf = new TypeFunction(new Parameters(), null, 0, LINK.def, 0);
+ auto tf = new TypeFunction(new Parameters(), null, 0, LINK.default_, 0);
auto fd = new FuncLiteralDeclaration(loc, loc, tf, TOKreserved, null);
fd.fbody = s;
auto fe = new FuncExp(loc, fd);
View
@@ -49,7 +49,7 @@ const(char)* toCppMangleItanium(Dsymbol s)
{
//printf("toCppMangleItanium(%s)\n", s.toChars());
OutBuffer buf;
- Target.prefixName(&buf, LINKcpp);
+ Target.prefixName(&buf, LINK.cpp);
scope CppMangleVisitor v = new CppMangleVisitor(&buf, s.loc);
v.mangleOf(s);
return buf.extractString();
@@ -223,7 +223,7 @@ private final class CppMangleVisitor : Visitor
{
bool is_nested = d.toParent() &&
!d.toParent().isModule() &&
- (cast(TypeFunction)d.isFuncDeclaration().type).linkage == LINKcpp;
+ (cast(TypeFunction)d.isFuncDeclaration().type).linkage == LINK.cpp;
if (is_nested)
buf.writeByte('X');
buf.writeByte('L');
@@ -591,7 +591,7 @@ private final class CppMangleVisitor : Visitor
else
{
Dsymbol p = d.toParent();
- if (p && !p.isModule() && tf.linkage == LINKcpp)
+ if (p && !p.isModule() && tf.linkage == LINK.cpp)
{
/* <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
* ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
@@ -625,7 +625,7 @@ private final class CppMangleVisitor : Visitor
}
}
- if (tf.linkage == LINKcpp) //Template args accept extern "C" symbols with special mangling
+ if (tf.linkage == LINK.cpp) //Template args accept extern "C" symbols with special mangling
{
assert(tf.ty == Tfunction);
mangleFunctionParameters(tf.parameters, tf.varargs);
@@ -644,7 +644,7 @@ private final class CppMangleVisitor : Visitor
else if (fparam.storageClass & STC.lazy_)
{
// Mangle as delegate
- Type td = new TypeFunction(null, t, 0, LINKd);
+ Type td = new TypeFunction(null, t, 0, LINK.d);
td = new TypeDelegate(td);
t = merge(t);
}
@@ -950,7 +950,7 @@ public:
if (substitute(t))
return;
buf.writeByte('F');
- if (t.linkage == LINKc)
+ if (t.linkage == LINK.c)
buf.writeByte('Y');
Type tn = t.next;
if (t.isref)
View
@@ -973,24 +973,27 @@ private:
}
else
{
- switch (type.linkage)
+ final switch (type.linkage)
{
- case LINKc:
+ case LINK.c:
tmp.buf.writeByte('A');
break;
- case LINKcpp:
+ case LINK.cpp:
if (needthis && type.varargs != 1)
tmp.buf.writeByte('E'); // thiscall
else
tmp.buf.writeByte('A'); // cdecl
break;
- case LINKwindows:
+ case LINK.windows:
tmp.buf.writeByte('G'); // stdcall
break;
- case LINKpascal:
+ case LINK.pascal:
tmp.buf.writeByte('C');
break;
- default:
+ case LINK.d:
+ case LINK.default_:
+ case LINK.system:
+ case LINK.objc:
tmp.visit(cast(Type)type);
break;
}
@@ -1038,7 +1041,7 @@ private:
else if (p.storageClass & STC.lazy_)
{
// Mangle as delegate
- Type td = new TypeFunction(null, t, 0, LINKd);
+ Type td = new TypeFunction(null, t, 0, LINK.d);
td = new TypeDelegate(td);
t = merge(t);
}
View
@@ -894,7 +894,7 @@ extern (C++) MATCH implicitConvTo(Expression e, Type t)
*/
size_t nparams = Parameter.dim(tf.parameters);
- size_t j = (tf.linkage == LINKd && tf.varargs == 1); // if TypeInfoArray was prepended
+ size_t j = (tf.linkage == LINK.d && tf.varargs == 1); // if TypeInfoArray was prepended
if (e.e1.op == TOKdotvar)
{
/* Treat 'this' as just another function argument
@@ -1197,7 +1197,7 @@ extern (C++) MATCH implicitConvTo(Expression e, Type t)
Expressions* args = (fd == e.allocator) ? e.newargs : e.arguments;
size_t nparams = Parameter.dim(tf.parameters);
- size_t j = (tf.linkage == LINKd && tf.varargs == 1); // if TypeInfoArray was prepended
+ size_t j = (tf.linkage == LINK.d && tf.varargs == 1); // if TypeInfoArray was prepended
for (size_t i = j; i < e.arguments.dim; ++i)
{
Expression earg = (*args)[i];
View
@@ -1022,11 +1022,11 @@ extern (C++) final class InterfaceDeclaration : ClassDeclaration
{
auto sc2 = super.newScope(sc);
if (com)
- sc2.linkage = LINKwindows;
+ sc2.linkage = LINK.windows;
else if (classKind == ClassKind.cpp)
- sc2.linkage = LINKcpp;
+ sc2.linkage = LINK.cpp;
else if (classKind == ClassKind.objc)
- sc2.linkage = LINKobjc;
+ sc2.linkage = LINK.objc;
return sc2;
}
View
@@ -280,7 +280,7 @@ extern (C++) abstract class Declaration : Dsymbol
super(id);
storage_class = STC.undefined_;
protection = Prot(Prot.Kind.undefined);
- linkage = LINKdefault;
+ linkage = LINK.default_;
}
override const(char)* kind() const
@@ -1658,7 +1658,7 @@ extern (C++) class TypeInfoDeclaration : VarDeclaration
this.tinfo = tinfo;
storage_class = STC.static_ | STC.gshared;
protection = Prot(Prot.Kind.public_);
- linkage = LINKc;
+ linkage = LINK.c;
alignment = Target.ptrsize;
}
View
@@ -44,7 +44,7 @@ extern (C++) Expression toDelegate(Expression e, Type t, Scope* sc)
{
//printf("Expression::toDelegate(t = %s) %s\n", t.toChars(), e.toChars());
Loc loc = e.loc;
- auto tf = new TypeFunction(null, t, 0, LINKd);
+ auto tf = new TypeFunction(null, t, 0, LINK.d);
if (t.hasWild())
tf.mod = MODFlags.wild;
auto fld = new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, null);
Oops, something went wrong.

0 comments on commit 9fc9250

Please sign in to comment.