Rename Prot struct, protection member, prot() to visibility/vis

The way we approach attributes such as `public`, `private`, etc...
was overhauled as part of DMD v2.071.0 (2016-04-05).
Those changes kicked off a long transition period, which is now over,
changing the idea of such attributes being "protection attributes"
to them being visibility (notably fixing issues with `private`
symbols in different modules conflicting).

However, internal compiler structures were never changed to reflect
this meaning, and the name `protection` and its abbreviation `prot`
are still everywhere. This can be misleading for new and seasoned
contributors alike.

This commit mass-rename usages of "protection" & co to "visibility".
As "vis" is not quite an obvious abbreviation, "visible" was used
for the method name.

This finishes the rename started in 34ef34d652,
however a few items are left on this list:
- Adding a `getVisibility` alias for the `getProtection` trait;
- Adding a `visibility` alias in the DDOC output;
- Some files rename in the test suite;
This commit is contained in:
Geod24 2020-12-29 14:24:10 +09:00 committed by The Dlang Bot
parent 9695ab56c3
commit 04897a70d5
46 changed files with 404 additions and 401 deletions

View file

@ -51,8 +51,8 @@ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember)
if (!symbolIsVisible(sc, smember) && (!(sc.flags & SCOPE.onlysafeaccess) || sc.func.setUnsafe()))
{
ad.error(loc, "member `%s` is not accessible%s", smember.toChars(), (sc.flags & SCOPE.onlysafeaccess) ? " from `@safe` code".ptr : "".ptr);
//printf("smember = %s %s, prot = %d, semanticRun = %d\n",
// smember.kind(), smember.toPrettyChars(), smember.prot(), smember.semanticRun);
//printf("smember = %s %s, vis = %d, semanticRun = %d\n",
// smember.kind(), smember.toPrettyChars(), smember.visible() smember.semanticRun);
return true;
}
return false;
@ -70,14 +70,14 @@ private bool hasPackageAccess(Module mod, Dsymbol s)
{
static if (LOG)
{
printf("hasPackageAccess(s = '%s', mod = '%s', s.protection.pkg = '%s')\n", s.toChars(), mod.toChars(), s.prot().pkg ? s.prot().pkg.toChars() : "NULL");
printf("hasPackageAccess(s = '%s', mod = '%s', s.visibility.pkg = '%s')\n", s.toChars(), mod.toChars(), s.visible().pkg ? s.visible().pkg.toChars() : "NULL");
}
Package pkg = null;
if (s.prot().pkg)
pkg = s.prot().pkg;
if (s.visible().pkg)
pkg = s.visible().pkg;
else
{
// no explicit package for protection, inferring most qualified one
// no explicit package for visibility, inferring most qualified one
for (; s; s = s.parent)
{
if (auto m = s.isModule())
@ -227,7 +227,7 @@ bool checkAccess(Scope* sc, Package p)
return false;
for (; sc; sc = sc.enclosing)
{
if (sc.scopesym && sc.scopesym.isPackageAccessible(p, Prot(Prot.Kind.private_)))
if (sc.scopesym && sc.scopesym.isPackageAccessible(p, Visibility(Visibility.Kind.private_)))
return false;
}
@ -244,16 +244,16 @@ bool checkAccess(Scope* sc, Package p)
*/
bool symbolIsVisible(Module mod, Dsymbol s)
{
// should sort overloads by ascending protection instead of iterating here
// should sort overloads by ascending visibility instead of iterating here
s = mostVisibleOverload(s);
final switch (s.prot().kind)
final switch (s.visible().kind)
{
case Prot.Kind.undefined: return true;
case Prot.Kind.none: return false; // no access
case Prot.Kind.private_: return s.getAccessModule() == mod;
case Prot.Kind.package_: return s.getAccessModule() == mod || hasPackageAccess(mod, s);
case Prot.Kind.protected_: return s.getAccessModule() == mod;
case Prot.Kind.public_, Prot.Kind.export_: return true;
case Visibility.Kind.undefined: return true;
case Visibility.Kind.none: return false; // no access
case Visibility.Kind.private_: return s.getAccessModule() == mod;
case Visibility.Kind.package_: return s.getAccessModule() == mod || hasPackageAccess(mod, s);
case Visibility.Kind.protected_: return s.getAccessModule() == mod;
case Visibility.Kind.public_, Visibility.Kind.export_: return true;
}
}
@ -291,21 +291,21 @@ bool symbolIsVisible(Scope *sc, Dsymbol s)
*/
bool checkSymbolAccess(Scope *sc, Dsymbol s)
{
final switch (s.prot().kind)
final switch (s.visible().kind)
{
case Prot.Kind.undefined: return true;
case Prot.Kind.none: return false; // no access
case Prot.Kind.private_: return sc._module == s.getAccessModule();
case Prot.Kind.package_: return sc._module == s.getAccessModule() || hasPackageAccess(sc._module, s);
case Prot.Kind.protected_: return hasProtectedAccess(sc, s);
case Prot.Kind.public_, Prot.Kind.export_: return true;
case Visibility.Kind.undefined: return true;
case Visibility.Kind.none: return false; // no access
case Visibility.Kind.private_: return sc._module == s.getAccessModule();
case Visibility.Kind.package_: return sc._module == s.getAccessModule() || hasPackageAccess(sc._module, s);
case Visibility.Kind.protected_: return hasProtectedAccess(sc, s);
case Visibility.Kind.public_, Visibility.Kind.export_: return true;
}
}
/**
* Use the most visible overload to check visibility. Later perform an access
* check on the resolved overload. This function is similar to overloadApply,
* but doesn't recurse nor resolve aliases because protection/visibility is an
* but doesn't recurse nor resolve aliases because visibility is an
* attribute of the alias not the aliasee.
*/
public Dsymbol mostVisibleOverload(Dsymbol s, Module mod = null)
@ -378,23 +378,23 @@ public Dsymbol mostVisibleOverload(Dsymbol s, Module mod = null)
break;
/**
* Return the "effective" protection attribute of a symbol when accessed in a module.
* The effective protection attribute is the same as the regular protection attribute,
* Return the "effective" visibility attribute of a symbol when accessed in a module.
* The effective visibility attribute is the same as the regular visibility attribute,
* except package() is "private" if the module is outside the package;
* otherwise, "public".
*/
static Prot protectionSeenFromModule(Dsymbol d, Module mod = null)
static Visibility visibilitySeenFromModule(Dsymbol d, Module mod = null)
{
Prot prot = d.prot();
if (mod && prot.kind == Prot.Kind.package_)
Visibility vis = d.visible();
if (mod && vis.kind == Visibility.Kind.package_)
{
return hasPackageAccess(mod, d) ? Prot(Prot.Kind.public_) : Prot(Prot.Kind.private_);
return hasPackageAccess(mod, d) ? Visibility(Visibility.Kind.public_) : Visibility(Visibility.Kind.private_);
}
return prot;
return vis;
}
if (next &&
protectionSeenFromModule(mostVisible, mod).isMoreRestrictiveThan(protectionSeenFromModule(next, mod)))
visibilitySeenFromModule(mostVisible, mod).isMoreRestrictiveThan(visibilitySeenFromModule(next, mod)))
mostVisible = next;
}
return mostVisible;

View file

@ -125,14 +125,15 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
Expression getRTInfo; /// pointer to GC info generated by object.RTInfo(this)
Prot protection; /// visibility
///
Visibility visibility;
bool noDefaultCtor; /// no default construction
Sizeok sizeok = Sizeok.none; /// set when structsize contains valid data
final extern (D) this(const ref Loc loc, Identifier id)
{
super(loc, id);
protection = Prot(Prot.Kind.public_);
visibility = Visibility(Visibility.Kind.public_);
}
/***************************************
@ -145,8 +146,8 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
sc2.stc &= STCFlowThruAggregate;
sc2.parent = this;
sc2.inunion = isUnionDeclaration();
sc2.protection = Prot(Prot.Kind.public_);
sc2.explicitProtection = 0;
sc2.visibility = Visibility(Visibility.Kind.public_);
sc2.explicitVisibility = 0;
sc2.aligndecl = null;
sc2.userAttribDecl = null;
sc2.namespace = null;
@ -723,7 +724,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
// Emulate vthis.dsymbolSemantic()
vthis.storage_class |= STC.field;
vthis.parent = this;
vthis.protection = Prot(Prot.Kind.public_);
vthis.visibility = Visibility(Visibility.Kind.public_);
vthis.alignment = t.alignment();
vthis.semanticRun = PASS.semanticdone;
@ -767,7 +768,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
// Emulate vthis2.dsymbolSemantic()
vthis2.storage_class |= STC.field;
vthis2.parent = this;
vthis2.protection = Prot(Prot.Kind.public_);
vthis2.visibility = Visibility(Visibility.Kind.public_);
vthis2.alignment = t.alignment();
vthis2.semanticRun = PASS.semanticdone;
@ -777,7 +778,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
override final bool isExport() const
{
return protection.kind == Prot.Kind.export_;
return visibility.kind == Visibility.Kind.export_;
}
/*******************************************
@ -822,9 +823,9 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
return s;
}
override final Prot prot() pure nothrow @nogc @safe
override final Visibility visible() pure nothrow @nogc @safe
{
return protection;
return visibility;
}
// 'this' type

View file

@ -112,7 +112,7 @@ public:
Expression *getRTInfo; // pointer to GC info generated by object.RTInfo(this)
Prot protection;
Visibility visibility;
bool noDefaultCtor; // no default construction
Sizeok sizeok; // set when structsize contains valid data
@ -131,7 +131,7 @@ public:
bool isExport() const;
Dsymbol *searchCtor();
Prot prot();
Visibility visible();
// 'this' type
Type *handleType() { return type; }

View file

@ -552,7 +552,7 @@ struct ASTBase
extern (C++) abstract class Declaration : Dsymbol
{
StorageClass storage_class;
Prot protection;
Visibility visibility;
LINK linkage;
Type type;
short inuse;
@ -562,7 +562,7 @@ struct ASTBase
{
super(id);
storage_class = STC.undefined_;
protection = Prot(Prot.Kind.undefined);
visibility = Visibility(Visibility.Kind.undefined);
linkage = LINK.default_;
}
@ -598,7 +598,7 @@ struct ASTBase
Identifier id;
Identifier aliasId;
int isstatic;
Prot protection;
Visibility visibility;
Identifiers names;
Identifiers aliases;
@ -611,7 +611,7 @@ struct ASTBase
this.id = id;
this.aliasId = aliasId;
this.isstatic = isstatic;
this.protection = Prot(Prot.Kind.private_);
this.visibility = Visibility(Visibility.Kind.private_);
if (aliasId)
{
@ -1057,7 +1057,7 @@ struct ASTBase
{
Type type;
Type memtype;
Prot protection;
Visibility visibility;
extern (D) this(const ref Loc loc, Identifier id, Type memtype)
{
@ -1065,7 +1065,7 @@ struct ASTBase
this.loc = loc;
type = new TypeEnum(this);
this.memtype = memtype;
protection = Prot(Prot.Kind.undefined);
visibility = Visibility(Visibility.Kind.undefined);
}
override void accept(Visitor v)
@ -1076,7 +1076,7 @@ struct ASTBase
extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
{
Prot protection;
Visibility visibility;
Sizeok sizeok;
Type type;
@ -1084,7 +1084,7 @@ struct ASTBase
{
super(id);
this.loc = loc;
protection = Prot(Prot.Kind.public_);
visibility = Visibility(Visibility.Kind.public_);
sizeok = Sizeok.none;
}
@ -1107,7 +1107,7 @@ struct ASTBase
bool literal;
bool ismixin;
bool isstatic;
Prot protection;
Visibility visibility;
Dsymbol onemember;
extern (D) this(const ref Loc loc, Identifier id, TemplateParameters* parameters, Expression constraint, Dsymbols* decldefs, bool ismixin = false, bool literal = false)
@ -1120,7 +1120,7 @@ struct ASTBase
this.literal = literal;
this.ismixin = ismixin;
this.isstatic = true;
this.protection = Prot(Prot.Kind.undefined);
this.visibility = Visibility(Visibility.Kind.undefined);
if (members && ident)
{
@ -1398,21 +1398,21 @@ struct ASTBase
extern (C++) final class VisibilityDeclaration : AttribDeclaration
{
Prot protection;
Visibility visibility;
Identifiers* pkg_identifiers;
extern (D) this(const ref Loc loc, Prot p, Dsymbols* decl)
extern (D) this(const ref Loc loc, Visibility v, Dsymbols* decl)
{
super(decl);
this.loc = loc;
this.protection = p;
this.visibility = v;
}
extern (D) this(const ref Loc loc, Identifiers* pkg_identifiers, Dsymbols* decl)
{
super(decl);
this.loc = loc;
this.protection.kind = Prot.Kind.package_;
this.protection.pkg = null;
this.visibility.kind = Visibility.Kind.package_;
this.visibility.pkg = null;
this.pkg_identifiers = pkg_identifiers;
}
@ -6600,7 +6600,7 @@ struct ASTBase
}
}
struct Prot
struct Visibility
{
enum Kind : ubyte
{
@ -6651,23 +6651,23 @@ struct ASTBase
}
static const(char)* protectionToChars(Prot.Kind kind)
static const(char)* visibilityToChars(Visibility.Kind kind)
{
final switch (kind)
{
case Prot.Kind.undefined:
case Visibility.Kind.undefined:
return null;
case Prot.Kind.none:
case Visibility.Kind.none:
return "none";
case Prot.Kind.private_:
case Visibility.Kind.private_:
return "private";
case Prot.Kind.package_:
case Visibility.Kind.package_:
return "package";
case Prot.Kind.protected_:
case Visibility.Kind.protected_:
return "protected";
case Prot.Kind.public_:
case Visibility.Kind.public_:
return "public";
case Prot.Kind.export_:
case Visibility.Kind.export_:
return "export";
}
}

View file

@ -76,11 +76,11 @@ struct ASTCodegen
alias STC = dmd.declaration.STC;
alias Dsymbol = dmd.dsymbol.Dsymbol;
alias Dsymbols = dmd.dsymbol.Dsymbols;
alias Prot = dmd.dsymbol.Prot;
alias Visibility = dmd.dsymbol.Visibility;
alias stcToBuffer = dmd.hdrgen.stcToBuffer;
alias linkageToChars = dmd.hdrgen.linkageToChars;
alias protectionToChars = dmd.hdrgen.protectionToChars;
alias visibilityToChars = dmd.hdrgen.visibilityToChars;
alias isType = dmd.dtemplate.isType;
alias isExpression = dmd.dtemplate.isExpression;

View file

@ -36,7 +36,7 @@ import dmd.expression;
import dmd.expressionsem;
import dmd.func;
import dmd.globals;
import dmd.hdrgen : protectionToBuffer;
import dmd.hdrgen : visibilityToBuffer;
import dmd.id;
import dmd.identifier;
import dmd.mtype;
@ -81,15 +81,15 @@ extern (C++) abstract class AttribDeclaration : Dsymbol
* the scope after it used.
*/
extern (D) static Scope* createNewScope(Scope* sc, StorageClass stc, LINK linkage,
CPPMANGLE cppmangle, Prot protection, int explicitProtection,
CPPMANGLE cppmangle, Visibility visibility, int explicitVisibility,
AlignDeclaration aligndecl, PragmaDeclaration inlining)
{
Scope* sc2 = sc;
if (stc != sc.stc ||
linkage != sc.linkage ||
cppmangle != sc.cppmangle ||
!protection.isSubsetOf(sc.protection) ||
explicitProtection != sc.explicitProtection ||
!visibility.isSubsetOf(sc.visibility) ||
explicitVisibility != sc.explicitVisibility ||
aligndecl !is sc.aligndecl ||
inlining != sc.inlining)
{
@ -98,8 +98,8 @@ extern (C++) abstract class AttribDeclaration : Dsymbol
sc2.stc = stc;
sc2.linkage = linkage;
sc2.cppmangle = cppmangle;
sc2.protection = protection;
sc2.explicitProtection = explicitProtection;
sc2.visibility = visibility;
sc2.explicitVisibility = explicitVisibility;
sc2.aligndecl = aligndecl;
sc2.inlining = inlining;
}
@ -256,7 +256,7 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration
scstc |= stc;
//printf("scstc = x%llx\n", scstc);
return createNewScope(sc, scstc, sc.linkage, sc.cppmangle,
sc.protection, sc.explicitProtection, sc.aligndecl, sc.inlining);
sc.visibility, sc.explicitVisibility, sc.aligndecl, sc.inlining);
}
override final bool oneMember(Dsymbol* ps, Identifier ident)
@ -413,7 +413,7 @@ extern (C++) final class LinkDeclaration : AttribDeclaration
override Scope* newScope(Scope* sc)
{
return createNewScope(sc, sc.stc, this.linkage, sc.cppmangle, sc.protection, sc.explicitProtection,
return createNewScope(sc, sc.stc, this.linkage, sc.cppmangle, sc.visibility, sc.explicitVisibility,
sc.aligndecl, sc.inlining);
}
@ -460,7 +460,7 @@ extern (C++) final class CPPMangleDeclaration : AttribDeclaration
override Scope* newScope(Scope* sc)
{
return createNewScope(sc, sc.stc, LINK.cpp, cppmangle, sc.protection, sc.explicitProtection,
return createNewScope(sc, sc.stc, LINK.cpp, cppmangle, sc.visibility, sc.explicitVisibility,
sc.aligndecl, sc.inlining);
}
@ -576,24 +576,24 @@ extern (C++) final class CPPNamespaceDeclaration : AttribDeclaration
/***********************************************************
* Visibility declaration for Dsymbols, e.g. `public int i;`
*
* `<protection> <decl...>` or
* `<visibility> <decl...>` or
* `package(<pkg_identifiers>) <decl...>` if `pkg_identifiers !is null`
*/
extern (C++) final class VisibilityDeclaration : AttribDeclaration
{
Prot protection; /// the visibility
Visibility visibility; /// the visibility
Identifiers* pkg_identifiers; /// identifiers for `package(foo.bar)` or null
/**
* Params:
* loc = source location of attribute token
* protection = protection attribute data
* decl = declarations which are affected by this protection attribute
* visibility = visibility attribute data
* decl = declarations which are affected by this visibility attribute
*/
extern (D) this(const ref Loc loc, Prot protection, Dsymbols* decl)
extern (D) this(const ref Loc loc, Visibility visibility, Dsymbols* decl)
{
super(loc, null, decl);
this.protection = protection;
this.visibility = visibility;
//printf("decl = %p\n", decl);
}
@ -601,35 +601,36 @@ extern (C++) final class VisibilityDeclaration : AttribDeclaration
* Params:
* loc = source location of attribute token
* pkg_identifiers = list of identifiers for a qualified package name
* decl = declarations which are affected by this protection attribute
* decl = declarations which are affected by this visibility attribute
*/
extern (D) this(const ref Loc loc, Identifiers* pkg_identifiers, Dsymbols* decl)
{
super(loc, null, decl);
this.protection.kind = Prot.Kind.package_;
this.visibility.kind = Visibility.Kind.package_;
this.pkg_identifiers = pkg_identifiers;
if (pkg_identifiers !is null && pkg_identifiers.dim > 0)
{
Dsymbol tmp;
Package.resolve(pkg_identifiers, &tmp, null);
protection.pkg = tmp ? tmp.isPackage() : null;
visibility.pkg = tmp ? tmp.isPackage() : null;
}
}
override VisibilityDeclaration syntaxCopy(Dsymbol s)
{
assert(!s);
if (protection.kind == Prot.Kind.package_)
if (visibility.kind == Visibility.Kind.package_)
return new VisibilityDeclaration(this.loc, pkg_identifiers, Dsymbol.arraySyntaxCopy(decl));
else
return new VisibilityDeclaration(this.loc, protection, Dsymbol.arraySyntaxCopy(decl));
return new VisibilityDeclaration(this.loc, visibility, Dsymbol.arraySyntaxCopy(decl));
}
override Scope* newScope(Scope* sc)
{
if (pkg_identifiers)
dsymbolSemantic(this, sc);
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, this.protection, 1, sc.aligndecl, sc.inlining);
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, this.visibility, 1, sc.aligndecl, sc.inlining);
}
override void addMember(Scope* sc, ScopeDsymbol sds)
@ -638,24 +639,24 @@ extern (C++) final class VisibilityDeclaration : AttribDeclaration
{
Dsymbol tmp;
Package.resolve(pkg_identifiers, &tmp, null);
protection.pkg = tmp ? tmp.isPackage() : null;
visibility.pkg = tmp ? tmp.isPackage() : null;
pkg_identifiers = null;
}
if (protection.kind == Prot.Kind.package_ && protection.pkg && sc._module)
if (visibility.kind == Visibility.Kind.package_ && visibility.pkg && sc._module)
{
Module m = sc._module;
// While isAncestorPackageOf does an equality check, the fix for issue 17441 adds a check to see if
// each package's .isModule() properites are equal.
//
// Properties generated from `package(foo)` i.e. protection.pkg have .isModule() == null.
// Properties generated from `package(foo)` i.e. visibility.pkg have .isModule() == null.
// This breaks package declarations of the package in question if they are declared in
// the same package.d file, which _do_ have a module associated with them, and hence a non-null
// isModule()
if (!m.isPackage() || !protection.pkg.ident.equals(m.isPackage().ident))
if (!m.isPackage() || !visibility.pkg.ident.equals(m.isPackage().ident))
{
Package pkg = m.parent ? m.parent.isPackage() : null;
if (!pkg || !protection.pkg.isAncestorPackageOf(pkg))
if (!pkg || !visibility.pkg.isAncestorPackageOf(pkg))
error("does not bind to one of ancestor packages of module `%s`", m.toPrettyChars(true));
}
}
@ -664,14 +665,14 @@ extern (C++) final class VisibilityDeclaration : AttribDeclaration
override const(char)* kind() const
{
return "protection attribute";
return "visibility attribute";
}
override const(char)* toPrettyChars(bool)
{
assert(protection.kind > Prot.Kind.undefined);
assert(visibility.kind > Visibility.Kind.undefined);
OutBuffer buf;
protectionToBuffer(&buf, protection);
visibilityToBuffer(&buf, visibility);
return buf.extractChars();
}
@ -719,7 +720,7 @@ extern (C++) final class AlignDeclaration : AttribDeclaration
override Scope* newScope(Scope* sc)
{
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, sc.protection, sc.explicitProtection, this, sc.inlining);
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, sc.visibility, sc.explicitVisibility, this, sc.inlining);
}
override void accept(Visitor v)
@ -878,7 +879,7 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
{
// We keep track of this pragma inside scopes,
// then it's evaluated on demand in function semantic
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, sc.protection, sc.explicitProtection, sc.aligndecl, this);
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, sc.visibility, sc.explicitVisibility, sc.aligndecl, this);
}
if (ident == Id.printf || ident == Id.scanf)
{

View file

@ -106,7 +106,7 @@ public:
class VisibilityDeclaration : public AttribDeclaration
{
public:
Prot protection;
Visibility visibility;
Identifiers* pkg_identifiers;
VisibilityDeclaration *syntaxCopy(Dsymbol *s);

View file

@ -1191,12 +1191,12 @@ enum
SFLtmp = 0x400000, // symbol is a generated temporary
SFLthunk = 0x40000, // symbol is temporary for thunk
// Possible values for protection bits
// Possible values for visibility bits
SFLprivate = 0x60,
SFLprotected = 0x40,
SFLpublic = 0x20,
SFLnone = 0x00,
SFLpmask = 0x60, // mask for the protection bits
SFLpmask = 0x60, // mask for the visibility bits
SFLvtbl = 0x2000, // VEC_VTBL_LIST: Symbol is a vtable or vbtable

View file

@ -74,7 +74,7 @@ extern (C) void TOOFFSET(void* p, targ_size_t value)
extern __gshared char* ftdbname;
// Convert from SFL protections to CV4 protections
// Convert from SFL visibilities to CV4 protections
uint SFLtoATTR(uint sfl) { return 4 - ((sfl & SFLpmask) >> 5); }
__gshared

View file

@ -587,7 +587,7 @@ private int cpp_cvidx(tym_t ty)
}
/******************************
* Turn protection into 0..2
* Turn visibility into 0..2
*/
private int cpp_protection(Symbol *s)
@ -1496,10 +1496,10 @@ version (SCPPorMARS)
{
if (isclassmember(s))
{ // Member function
int protection;
int visibility;
int ftype;
protection = cpp_protection(s);
visibility = cpp_protection(s);
if (s.Sfunc.Fthunk && !(s.Sfunc.Fflags & Finstance))
ftype = 3;
else
@ -1509,7 +1509,7 @@ version (SCPPorMARS)
case 0: ftype = 0; break;
default: assert(0);
}
CHAR('A' + farfunc + protection * 8 + ftype * 2);
CHAR('A' + farfunc + visibility * 8 + ftype * 2);
switch (ftype)
{ case 0: cpp_member_function_type(s); break;
case 1: cpp_static_member_function_type(s); break;

View file

@ -502,12 +502,12 @@ extern(D):
//d.toChars(), d.isVirtualMethod(), d.isVirtual(), cast(int)d.vtblIndex, d.interfaceVirtual);
if ((d.isVirtual() && (d.vtblIndex != -1 || d.interfaceVirtual || d.overrideInterface())) || (d.isDtorDeclaration() && d.parent.isClassDeclaration() && !d.isFinal()))
{
switch (d.protection.kind)
switch (d.visibility.kind)
{
case Prot.Kind.private_:
case Visibility.Kind.private_:
buf.writeByte('E');
break;
case Prot.Kind.protected_:
case Visibility.Kind.protected_:
buf.writeByte('M');
break;
default:
@ -517,12 +517,12 @@ extern(D):
}
else
{
switch (d.protection.kind)
switch (d.visibility.kind)
{
case Prot.Kind.private_:
case Visibility.Kind.private_:
buf.writeByte('A');
break;
case Prot.Kind.protected_:
case Visibility.Kind.protected_:
buf.writeByte('I');
break;
default:
@ -544,12 +544,12 @@ extern(D):
else if (d.isMember2()) // static function
{
// <flags> ::= <virtual/protection flag> <calling convention flag>
switch (d.protection.kind)
switch (d.visibility.kind)
{
case Prot.Kind.private_:
case Visibility.Kind.private_:
buf.writeByte('C');
break;
case Prot.Kind.protected_:
case Visibility.Kind.protected_:
buf.writeByte('K');
break;
default:
@ -590,12 +590,12 @@ extern(D):
}
else
{
switch (d.protection.kind)
switch (d.visibility.kind)
{
case Prot.Kind.private_:
case Visibility.Kind.private_:
buf.writeByte('0');
break;
case Prot.Kind.protected_:
case Visibility.Kind.protected_:
buf.writeByte('1');
break;
default:

View file

@ -528,7 +528,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
continue;
else if (s == this) // happens if s is nested in this and derives from this
s = null;
else if (!(flags & IgnoreSymbolVisibility) && !(s.prot().kind == Prot.Kind.protected_) && !symbolIsVisible(this, s))
else if (!(flags & IgnoreSymbolVisibility) && !(s.visible().kind == Visibility.Kind.protected_) && !symbolIsVisible(this, s))
s = null;
else
break;

View file

@ -292,7 +292,7 @@ extern (C++) abstract class Declaration : Dsymbol
Type type;
Type originalType; // before semantic analysis
StorageClass storage_class = STC.undefined_;
Prot protection;
Visibility visibility;
LINK linkage = LINK.default_;
short inuse; // used to detect cycles
@ -306,13 +306,13 @@ extern (C++) abstract class Declaration : Dsymbol
final extern (D) this(Identifier ident)
{
super(ident);
protection = Prot(Prot.Kind.undefined);
visibility = Visibility(Visibility.Kind.undefined);
}
final extern (D) this(const ref Loc loc, Identifier ident)
{
super(loc, ident);
protection = Prot(Prot.Kind.undefined);
visibility = Visibility(Visibility.Kind.undefined);
}
override const(char)* kind() const
@ -568,9 +568,9 @@ extern (C++) abstract class Declaration : Dsymbol
return (storage_class & STC.future) != 0;
}
override final Prot prot() pure nothrow @nogc @safe
override final Visibility visible() pure nothrow @nogc @safe
{
return protection;
return visibility;
}
override final inout(Declaration) isDeclaration() inout
@ -790,7 +790,7 @@ extern (C++) final class AliasDeclaration : Declaration
if (auto fd = sa.isFuncDeclaration())
{
auto fa = new FuncAliasDeclaration(ident, fd);
fa.protection = protection;
fa.visibility = visibility;
fa.parent = parent;
aliassym = fa;
return aliassym.overloadInsert(s);
@ -798,7 +798,7 @@ extern (C++) final class AliasDeclaration : Declaration
if (auto td = sa.isTemplateDeclaration())
{
auto od = new OverDeclaration(ident, td);
od.protection = protection;
od.visibility = visibility;
od.parent = parent;
aliassym = od;
return aliassym.overloadInsert(s);
@ -808,7 +808,7 @@ extern (C++) final class AliasDeclaration : Declaration
if (sa.ident != ident || sa.parent != parent)
{
od = new OverDeclaration(ident, od);
od.protection = protection;
od.visibility = visibility;
od.parent = parent;
aliassym = od;
}
@ -819,7 +819,7 @@ extern (C++) final class AliasDeclaration : Declaration
if (sa.ident != ident || sa.parent != parent)
{
os = new OverloadSet(ident, os);
// TODO: protection is lost here b/c OverloadSets have no protection attribute
// TODO: visibility is lost here b/c OverloadSets have no visibility attribute
// Might no be a practical issue, b/c the code below fails to resolve the overload anyhow.
// ----
// module os1;
@ -834,7 +834,7 @@ extern (C++) final class AliasDeclaration : Declaration
// import os1, os2;
// void test() { merged(123); } // should only look at os2.merged
//
// os.protection = protection;
// os.visibility = visibility;
os.parent = parent;
aliassym = os;
}
@ -1262,12 +1262,12 @@ extern (C++) class VarDeclaration : Declaration
override final bool isExport() const
{
return protection.kind == Prot.Kind.export_;
return visibility.kind == Visibility.Kind.export_;
}
override final bool isImportedSymbol() const
{
if (protection.kind == Prot.Kind.export_ && !_init && (storage_class & STC.static_ || parent.isModule()))
if (visibility.kind == Visibility.Kind.export_ && !_init && (storage_class & STC.static_ || parent.isModule()))
return true;
return false;
}
@ -1695,7 +1695,7 @@ extern (C++) class TypeInfoDeclaration : VarDeclaration
super(Loc.initial, Type.dtypeinfo.type, tinfo.getTypeInfoIdent(), null);
this.tinfo = tinfo;
storage_class = STC.static_ | STC.gshared;
protection = Prot(Prot.Kind.public_);
visibility = Visibility(Visibility.Kind.public_);
linkage = LINK.c;
alignment = target.ptrsize;
}

View file

@ -98,7 +98,7 @@ public:
Type *type;
Type *originalType; // before semantic analysis
StorageClass storage_class;
Prot protection;
Visibility visibility;
LINK linkage;
short inuse; // used to detect cycles
uint8_t adFlags;
@ -135,7 +135,7 @@ public:
bool isFuture() const { return (storage_class & STCfuture) != 0; }
Prot prot();
Visibility visible();
Declaration *isDeclaration() { return this; }
void accept(Visitor *v) { v->visit(this); }

View file

@ -50,7 +50,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
Type type; // the TypeEnum
Type memtype; // type of the members
Prot protection;
Visibility visibility;
Expression maxval;
Expression minval;
Expression defaultval; // default initializer
@ -64,7 +64,7 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
//printf("EnumDeclaration() %s\n", toChars());
type = new TypeEnum(this);
this.memtype = memtype;
protection = Prot(Prot.Kind.undefined);
visibility = Visibility(Visibility.Kind.undefined);
}
override EnumDeclaration syntaxCopy(Dsymbol s)
@ -161,9 +161,9 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
return isdeprecated;
}
override Prot prot() pure nothrow @nogc @safe
override Visibility visible() pure nothrow @nogc @safe
{
return protection;
return visibility;
}
/******************************

View file

@ -34,7 +34,7 @@ extern (C++) final class Import : Dsymbol
Identifier id; // module Identifier
Identifier aliasId;
int isstatic; // !=0 if static import
Prot protection;
Visibility visibility;
// Pairs of alias=name to bind into current namespace
Identifiers names;
@ -88,7 +88,7 @@ extern (C++) final class Import : Dsymbol
this.id = id;
this.aliasId = aliasId;
this.isstatic = isstatic;
this.protection = Prot.Kind.private_; // default to private
this.visibility = Visibility.Kind.private_; // default to private
}
extern (D) void addAlias(Identifier name, Identifier _alias)
@ -106,9 +106,9 @@ extern (C++) final class Import : Dsymbol
return isstatic ? "static import" : "import";
}
override Prot prot() pure nothrow @nogc @safe
override Visibility visible() pure nothrow @nogc @safe
{
return protection;
return visibility;
}
// copy only syntax trees
@ -233,10 +233,10 @@ extern (C++) final class Import : Dsymbol
isstatic = true;
mod.importAll(null);
mod.checkImportDeprecation(loc, sc);
if (sc.explicitProtection)
protection = sc.protection;
if (sc.explicitVisibility)
visibility = sc.visibility;
if (!isstatic && !aliasId && !names.dim)
sc.scopesym.importScope(mod, protection);
sc.scopesym.importScope(mod, visibility);
// Enable access to pkgs/mod as soon as posible, because compiler
// can traverse them before the import gets semantic (Issue: 21501)
if (!aliasId && !names.dim)
@ -256,7 +256,7 @@ extern (C++) final class Import : Dsymbol
{
// import a.b.c.d;
auto p = pkg; // a
scopesym.addAccessiblePackage(p, protection);
scopesym.addAccessiblePackage(p, visibility);
foreach (id; (*packages)[1 .. packages.dim]) // [b, c]
{
p = cast(Package) p.symtab.lookup(id);
@ -266,10 +266,10 @@ extern (C++) final class Import : Dsymbol
// Package in the path conflicts with a module name
if (p is null)
break;
scopesym.addAccessiblePackage(p, protection);
scopesym.addAccessiblePackage(p, visibility);
}
}
scopesym.addAccessiblePackage(mod, protection); // d
scopesym.addAccessiblePackage(mod, visibility); // d
}
override Dsymbol toAlias()
@ -315,7 +315,7 @@ extern (C++) final class Import : Dsymbol
importAll(sc);
sc = sc.push(mod);
sc.protection = protection;
sc.visibility = visibility;
foreach (ad; aliasdecls)
ad.setScope(sc);
sc = sc.pop();

View file

@ -1287,7 +1287,7 @@ extern (C++) final class Module : Package
return s;
}
override bool isPackageAccessible(Package p, Prot protection, int flags = 0)
override bool isPackageAccessible(Package p, Visibility visibility, int flags = 0)
{
if (insearch) // don't follow import cycles
return false;
@ -1295,8 +1295,8 @@ extern (C++) final class Module : Package
scope (exit)
insearch = false;
if (flags & IgnorePrivateImports)
protection = Prot(Prot.Kind.public_); // only consider public imports
return super.isPackageAccessible(p, protection);
visibility = Visibility(Visibility.Kind.public_); // only consider public imports
return super.isPackageAccessible(p, visibility);
}
override Dsymbol symtabInsert(Dsymbol s)

View file

@ -917,25 +917,25 @@ private void emitMemberComments(ScopeDsymbol sds, ref OutBuffer buf, Scope* sc)
buf.writestring(")");
}
private void emitProtection(ref OutBuffer buf, Import i)
private void emitVisibility(ref OutBuffer buf, Import i)
{
// imports are private by default, which is different from other declarations
// so they should explicitly show their protection
emitProtection(buf, i.protection);
// so they should explicitly show their visibility
emitVisibility(buf, i.visibility);
}
private void emitProtection(ref OutBuffer buf, Declaration d)
private void emitVisibility(ref OutBuffer buf, Declaration d)
{
auto prot = d.protection;
if (prot.kind != Prot.Kind.undefined && prot.kind != Prot.Kind.public_)
auto vis = d.visibility;
if (vis.kind != Visibility.Kind.undefined && vis.kind != Visibility.Kind.public_)
{
emitProtection(buf, prot);
emitVisibility(buf, vis);
}
}
private void emitProtection(ref OutBuffer buf, Prot prot)
private void emitVisibility(ref OutBuffer buf, Visibility vis)
{
protectionToBuffer(&buf, prot);
visibilityToBuffer(&buf, vis);
buf.writeByte(' ');
}
@ -1052,7 +1052,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
override void visit(Import imp)
{
if (imp.prot().kind != Prot.Kind.public_ && sc.protection.kind != Prot.Kind.export_)
if (imp.visible().kind != Visibility.Kind.public_ && sc.visibility.kind != Visibility.Kind.export_)
return;
if (imp.comment)
@ -1084,7 +1084,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
return;
}
}
if (d.protection.kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_)
if (d.visibility.kind == Visibility.Kind.private_ || sc.visibility.kind == Visibility.Kind.private_)
return;
}
if (!com)
@ -1105,7 +1105,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
}
else
{
if (ad.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_)
if (ad.visible().kind == Visibility.Kind.private_ || sc.visibility.kind == Visibility.Kind.private_)
return;
if (!ad.comment)
return;
@ -1118,7 +1118,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
override void visit(TemplateDeclaration td)
{
//printf("TemplateDeclaration::emitComment() '%s', kind = %s\n", td.toChars(), td.kind());
if (td.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_)
if (td.visible().kind == Visibility.Kind.private_ || sc.visibility.kind == Visibility.Kind.private_)
return;
if (!td.comment)
return;
@ -1132,7 +1132,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
override void visit(EnumDeclaration ed)
{
if (ed.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_)
if (ed.visible().kind == Visibility.Kind.private_ || sc.visibility.kind == Visibility.Kind.private_)
return;
if (ed.isAnonymous() && ed.members)
{
@ -1153,7 +1153,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
override void visit(EnumMember em)
{
//printf("EnumMember::emitComment(%p '%s'), comment = '%s'\n", em, em.toChars(), em.comment);
if (em.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_)
if (em.visible().kind == Visibility.Kind.private_ || sc.visibility.kind == Visibility.Kind.private_)
return;
if (!em.comment)
return;
@ -1189,7 +1189,7 @@ private void emitComment(Dsymbol s, ref OutBuffer buf, Scope* sc)
{
Scope* scx = sc;
sc = sc.copy();
sc.protection = pd.protection;
sc.visibility = pd.visibility;
visit(cast(AttribDeclaration)pd);
scx.lastdc = sc.lastdc;
sc = sc.pop();
@ -1252,7 +1252,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
buf.writestring("deprecated ");
if (Declaration d = s.isDeclaration())
{
emitProtection(*buf, d);
emitVisibility(*buf, d);
if (d.isStatic())
buf.writestring("static ");
else if (d.isFinal())
@ -1292,7 +1292,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
{
HdrGenState hgs;
hgs.ddoc = true;
emitProtection(*buf, i);
emitVisibility(*buf, i);
.toCBuffer(i, buf, &hgs);
}
@ -1361,7 +1361,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
return;
if (ad.isDeprecated())
buf.writestring("deprecated ");
emitProtection(*buf, ad);
emitVisibility(*buf, ad);
buf.printf("alias %s = ", ad.toChars());
if (Dsymbol s = ad.aliassym) // ident alias
{
@ -1436,7 +1436,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
return;
version (none)
{
emitProtection(buf, ad);
emitVisibility(buf, ad);
}
buf.printf("%s %s", ad.kind(), ad.toChars());
buf.writestring(";\n");
@ -1449,7 +1449,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
return;
version (none)
{
emitProtection(buf, sd);
emitVisibility(buf, sd);
}
if (TemplateDeclaration td = getEponymousParent(sd))
{
@ -1469,7 +1469,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
return;
version (none)
{
emitProtection(*buf, cd);
emitVisibility(*buf, cd);
}
if (TemplateDeclaration td = getEponymousParent(cd))
{
@ -1907,7 +1907,7 @@ struct DocComment
s = td;
for (UnitTestDeclaration utd = s.ddocUnittest; utd; utd = utd.ddocUnittest)
{
if (utd.protection.kind == Prot.Kind.private_ || !utd.comment || !utd.fbody)
if (utd.visibility.kind == Visibility.Kind.private_ || !utd.comment || !utd.fbody)
continue;
// Strip whitespaces to avoid showing empty summary
const(char)* c = utd.comment;

View file

@ -122,9 +122,9 @@ struct Scope
/// inlining strategy for functions
PragmaDeclaration inlining;
/// protection for class members
Prot protection = Prot(Prot.Kind.public_);
int explicitProtection; /// set if in an explicit protection attribute
/// visibility for class members
Visibility visibility = Visibility(Visibility.Kind.public_);
int explicitVisibility; /// set if in an explicit visibility attribute
StorageClass stc; /// storage class
@ -555,7 +555,7 @@ struct Scope
if (scopesym != s.parent)
{
++cost; // got to the symbol through an import
if (s.prot().kind == Prot.Kind.private_)
if (s.visible().kind == Visibility.Kind.private_)
return null;
}
return s;

View file

@ -121,7 +121,7 @@ struct Ungag
}
}
struct Prot
struct Visibility
{
///
enum Kind : ubyte
@ -138,7 +138,7 @@ struct Prot
Kind kind;
Package pkg;
extern (D) this(Prot.Kind kind) pure nothrow @nogc @safe
extern (D) this(Visibility.Kind kind) pure nothrow @nogc @safe
{
this.kind = kind;
}
@ -149,19 +149,19 @@ struct Prot
* Checks if `this` is superset of `other` restrictions.
* For example, "protected" is more restrictive than "public".
*/
bool isMoreRestrictiveThan(const Prot other) const
bool isMoreRestrictiveThan(const Visibility other) const
{
return this.kind < other.kind;
}
/**
* Checks if `this` is absolutely identical protection attribute to `other`
* Checks if `this` is absolutely identical visibility attribute to `other`
*/
bool opEquals(ref const Prot other) const
bool opEquals(ref const Visibility other) const
{
if (this.kind == other.kind)
{
if (this.kind == Prot.Kind.package_)
if (this.kind == Visibility.Kind.package_)
return this.pkg == other.pkg;
return true;
}
@ -172,17 +172,17 @@ struct Prot
* Checks if parent defines different access restrictions than this one.
*
* Params:
* parent = protection attribute for scope that hosts this one
* parent = visibility attribute for scope that hosts this one
*
* Returns:
* 'true' if parent is already more restrictive than this one and thus
* no differentiation is needed.
*/
bool isSubsetOf(ref const Prot parent) const
bool isSubsetOf(ref const Visibility parent) const
{
if (this.kind != parent.kind)
return false;
if (this.kind == Prot.Kind.package_)
if (this.kind == Visibility.Kind.package_)
{
if (!this.pkg)
return true;
@ -1037,9 +1037,9 @@ extern (C++) class Dsymbol : ASTNode
/*************************************
*/
Prot prot() pure nothrow @nogc @safe
Visibility visible() pure nothrow @nogc @safe
{
return Prot(Prot.Kind.public_);
return Visibility(Visibility.Kind.public_);
}
/**************************************
@ -1275,7 +1275,7 @@ extern (C++) class ScopeDsymbol : Dsymbol
private:
/// symbols whose members have been imported, i.e. imported modules and template mixins
Dsymbols* importedScopes;
Prot.Kind* prots; // array of Prot.Kind, one for each import
Visibility.Kind* visibilities; // array of Visibility.Kind, one for each import
import dmd.root.bitarray;
BitArray accessiblePackages, privateAccessiblePackages;// whitelists of accessible (imported) packages
@ -1338,11 +1338,11 @@ public:
for (size_t i = 0; i < importedScopes.dim; i++)
{
// If private import, don't search it
if ((flags & IgnorePrivateImports) && prots[i] == Prot.Kind.private_)
if ((flags & IgnorePrivateImports) && visibilities[i] == Visibility.Kind.private_)
continue;
int sflags = flags & (IgnoreErrors | IgnoreAmbiguous); // remember these in recursive searches
Dsymbol ss = (*importedScopes)[i];
//printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss.toChars(), prots[i], ss.isModule(), ss.isImport());
//printf("\tscanning import '%s', visibilities = %d, isModule = %p, isImport = %p\n", ss.toChars(), visibilities[i], ss.isModule(), ss.isImport());
if (ss.isModule())
{
@ -1378,7 +1378,7 @@ public:
* alias is deprecated or less accessible, prefer
* the other.
*/
if (s.isDeprecated() || s.prot().isMoreRestrictiveThan(s2.prot()) && s2.prot().kind != Prot.Kind.none)
if (s.isDeprecated() || s.visible().isMoreRestrictiveThan(s2.visible()) && s2.visible().kind != Visibility.Kind.none)
s = s2;
}
else
@ -1491,7 +1491,7 @@ public:
Dsymbol s2 = os.a[j];
if (s.toAlias() == s2.toAlias())
{
if (s2.isDeprecated() || (s2.prot().isMoreRestrictiveThan(s.prot()) && s.prot().kind != Prot.Kind.none))
if (s2.isDeprecated() || (s2.visible().isMoreRestrictiveThan(s.visible()) && s.visible().kind != Visibility.Kind.none))
{
os.a[j] = s;
}
@ -1504,9 +1504,9 @@ public:
return os;
}
void importScope(Dsymbol s, Prot protection)
void importScope(Dsymbol s, Visibility visibility)
{
//printf("%s.ScopeDsymbol::importScope(%s, %d)\n", toChars(), s.toChars(), protection);
//printf("%s.ScopeDsymbol::importScope(%s, %d)\n", toChars(), s.toChars(), visibility);
// No circular or redundant import's
if (s != this)
{
@ -1519,36 +1519,36 @@ public:
Dsymbol ss = (*importedScopes)[i];
if (ss == s) // if already imported
{
if (protection.kind > prots[i])
prots[i] = protection.kind; // upgrade access
if (visibility.kind > visibilities[i])
visibilities[i] = visibility.kind; // upgrade access
return;
}
}
}
importedScopes.push(s);
prots = cast(Prot.Kind*)mem.xrealloc(prots, importedScopes.dim * (prots[0]).sizeof);
prots[importedScopes.dim - 1] = protection.kind;
visibilities = cast(Visibility.Kind*)mem.xrealloc(visibilities, importedScopes.dim * (visibilities[0]).sizeof);
visibilities[importedScopes.dim - 1] = visibility.kind;
}
}
extern (D) final void addAccessiblePackage(Package p, Prot protection)
extern (D) final void addAccessiblePackage(Package p, Visibility visibility)
{
auto pary = protection.kind == Prot.Kind.private_ ? &privateAccessiblePackages : &accessiblePackages;
auto pary = visibility.kind == Visibility.Kind.private_ ? &privateAccessiblePackages : &accessiblePackages;
if (pary.length <= p.tag)
pary.length = p.tag + 1;
(*pary)[p.tag] = true;
}
bool isPackageAccessible(Package p, Prot protection, int flags = 0)
bool isPackageAccessible(Package p, Visibility visibility, int flags = 0)
{
if (p.tag < accessiblePackages.length && accessiblePackages[p.tag] ||
protection.kind == Prot.Kind.private_ && p.tag < privateAccessiblePackages.length && privateAccessiblePackages[p.tag])
visibility.kind == Visibility.Kind.private_ && p.tag < privateAccessiblePackages.length && privateAccessiblePackages[p.tag])
return true;
foreach (i, ss; importedScopes ? (*importedScopes)[] : null)
{
// only search visible scopes && imported modules should ignore private imports
if (protection.kind <= prots[i] &&
ss.isScopeDsymbol.isPackageAccessible(p, protection, IgnorePrivateImports))
if (visibility.kind <= visibilities[i] &&
ss.isScopeDsymbol.isPackageAccessible(p, visibility, IgnorePrivateImports))
return true;
}
return false;
@ -2101,9 +2101,9 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol
return forward.symtabLookup(s,id);
}
override void importScope(Dsymbol s, Prot protection)
override void importScope(Dsymbol s, Visibility visibility)
{
forward.importScope(s, protection);
forward.importScope(s, visibility);
}
override const(char)* kind()const{ return "local scope"; }

View file

@ -89,7 +89,7 @@ void dsymbolSemantic(Dsymbol *dsym, Scope *sc);
void semantic2(Dsymbol *dsym, Scope *sc);
void semantic3(Dsymbol *dsym, Scope* sc);
struct Prot
struct Visibility
{
enum Kind
{
@ -104,8 +104,8 @@ struct Prot
Kind kind;
Package *pkg;
bool isMoreRestrictiveThan(const Prot other) const;
bool isSubsetOf(const Prot& other) const;
bool isMoreRestrictiveThan(const Visibility other) const;
bool isSubsetOf(const Visibility& other) const;
};
/* State of symbol in winding its way through the passes of the compiler
@ -213,7 +213,7 @@ public:
ClassDeclaration *isClassMember(); // isMember() is a ClassDeclaration?
virtual Type *getType(); // is this a type?
virtual bool needThis(); // need a 'this' pointer?
virtual Prot prot();
virtual Visibility visible();
virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees
virtual bool oneMember(Dsymbol **ps, Identifier *ident);
virtual void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion);
@ -293,15 +293,15 @@ public:
private:
Dsymbols *importedScopes; // imported Dsymbol's
Prot::Kind *prots; // array of PROTKIND, one for each import
Visibility::Kind *visibilities; // array of `Visibility.Kind`, one for each import
BitArray accessiblePackages, privateAccessiblePackages;
public:
ScopeDsymbol *syntaxCopy(Dsymbol *s);
Dsymbol *search(const Loc &loc, Identifier *ident, int flags = SearchLocalsOnly);
virtual void importScope(Dsymbol *s, Prot protection);
virtual bool isPackageAccessible(Package *p, Prot protection, int flags = 0);
virtual void importScope(Dsymbol *s, Visibility visibility);
virtual bool isPackageAccessible(Package *p, Visibility visibility, int flags = 0);
bool isforwardRef();
static void multiplyDefined(const Loc &loc, Dsymbol *s1, Dsymbol *s2);
const char *kind() const;
@ -364,7 +364,7 @@ public:
Dsymbol *symtabInsert(Dsymbol *s);
Dsymbol *symtabLookup(Dsymbol *s, Identifier *id);
void importScope(Dsymbol *s, Prot protection);
void importScope(Dsymbol *s, Visibility visibility);
const char *kind() const;
ForwardingScopeDsymbol *isForwardingScopeDsymbol() { return this; }

View file

@ -745,7 +745,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
assert(dsym.semanticRun <= PASS.semantic);
dsym.storage_class |= sc.stc & STC.deprecated_;
dsym.protection = sc.protection;
dsym.visibility = sc.visibility;
dsym.userAttribDecl = sc.userAttribDecl;
if (!sc.func && dsym.inNonRoot())
@ -871,7 +871,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
dsym.linkage = sc.linkage;
dsym.parent = sc.parent;
//printf("this = %p, parent = %p, '%s'\n", dsym, dsym.parent, dsym.parent.toChars());
dsym.protection = sc.protection;
dsym.visibility = sc.visibility;
/* If scope's alignment is the default, use the type's alignment,
* otherwise the scope overrrides.
@ -1628,8 +1628,8 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (!importer.aimports.contains(imp.mod))
importer.aimports.push(imp.mod);
if (sc.explicitProtection)
imp.protection = sc.protection;
if (sc.explicitVisibility)
imp.visibility = sc.visibility;
if (!imp.aliasId && !imp.names.dim) // neither a selective nor a renamed import
{
@ -1644,7 +1644,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (!imp.isstatic)
{
scopesym.importScope(imp.mod, imp.protection);
scopesym.importScope(imp.mod, imp.visibility);
}
imp.addPackageAccess(scopesym);
@ -1662,7 +1662,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
}
sc = sc.push(imp.mod);
sc.protection = imp.protection;
sc.visibility = imp.visibility;
for (size_t i = 0; i < imp.aliasdecls.dim; i++)
{
AliasDeclaration ad = imp.aliasdecls[i];
@ -1722,9 +1722,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
ob.writestring(" (");
escapePath(ob, imod.srcfile.toChars());
ob.writestring(") : ");
// use protection instead of sc.protection because it couldn't be
// use visibility instead of sc.visibility because it couldn't be
// resolved yet, see the comment above
protectionToBuffer(ob, imp.protection);
visibilityToBuffer(ob, imp.visibility);
ob.writeByte(' ');
if (imp.isstatic)
{
@ -2319,7 +2319,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
ed.parent = sc.parent;
ed.type = ed.type.typeSemantic(ed.loc, sc);
ed.protection = sc.protection;
ed.visibility = sc.visibility;
if (sc.stc & STC.deprecated_)
ed.isdeprecated = true;
ed.userAttribDecl = sc.userAttribDecl;
@ -2498,7 +2498,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
em.semanticRun = PASS.semantic;
em.protection = em.ed.isAnonymous() ? em.ed.protection : Prot(Prot.Kind.public_);
em.visibility = em.ed.isAnonymous() ? em.ed.visibility : Visibility(Visibility.Kind.public_);
em.linkage = LINK.d;
em.storage_class |= STC.manifest;
@ -2744,7 +2744,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
tempdecl.semanticRun = PASS.semantic;
tempdecl.parent = sc.parent;
tempdecl.protection = sc.protection;
tempdecl.visibility = sc.visibility;
tempdecl.cppnamespace = sc.namespace;
tempdecl.isstatic = tempdecl.toParent().isModule() || (tempdecl._scope.stc & STC.static_);
tempdecl.deprecated_ = !!(sc.stc & STC.deprecated_);
@ -2993,7 +2993,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
ScopeDsymbol sds = sce.scopesym;
if (sds)
{
sds.importScope(tm, Prot(Prot.Kind.public_));
sds.importScope(tm, Visibility(Visibility.Kind.public_));
break;
}
}
@ -3281,7 +3281,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (auto pragmadecl = sc.inlining)
funcdecl.inlining = pragmadecl.evalPragmaInline(sc);
funcdecl.protection = sc.protection;
funcdecl.visibility = sc.visibility;
funcdecl.userAttribDecl = sc.userAttribDecl;
UserAttributeDeclaration.checkGNUABITag(funcdecl, funcdecl.linkage);
@ -3473,8 +3473,8 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
const(char)* sfunc;
if (funcdecl.isStatic())
sfunc = "static";
else if (funcdecl.protection.kind == Prot.Kind.private_ || funcdecl.protection.kind == Prot.Kind.package_)
sfunc = protectionToChars(funcdecl.protection.kind);
else if (funcdecl.visibility.kind == Visibility.Kind.private_ || funcdecl.visibility.kind == Visibility.Kind.package_)
sfunc = visibilityToChars(funcdecl.visibility.kind);
else
sfunc = "final";
funcdecl.error("`%s` functions cannot be `abstract`", sfunc);
@ -3482,9 +3482,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (funcdecl.isOverride() && !funcdecl.isVirtual() && !funcdecl.isFuncLiteralDeclaration())
{
Prot.Kind kind = funcdecl.prot().kind;
if ((kind == Prot.Kind.private_ || kind == Prot.Kind.package_) && funcdecl.isMember())
funcdecl.error("`%s` method is not virtual and cannot override", protectionToChars(kind));
Visibility.Kind kind = funcdecl.visible().kind;
if ((kind == Visibility.Kind.private_ || kind == Visibility.Kind.package_) && funcdecl.isMember())
funcdecl.error("`%s` method is not virtual and cannot override", visibilityToChars(kind));
else
funcdecl.error("cannot override a non-virtual function");
}
@ -3662,7 +3662,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (f2)
{
f2 = f2.overloadExactMatch(funcdecl.type);
if (f2 && f2.isFinalFunc() && f2.prot().kind != Prot.Kind.private_)
if (f2 && f2.isFinalFunc() && f2.visible().kind != Visibility.Kind.private_)
funcdecl.error("cannot override `final` function `%s`", f2.toPrettyChars());
}
}
@ -4007,7 +4007,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (f2)
{
f2 = f2.overloadExactMatch(funcdecl.type);
if (f2 && f2.isFinalFunc() && f2.prot().kind != Prot.Kind.private_)
if (f2 && f2.isFinalFunc() && f2.visible().kind != Visibility.Kind.private_)
funcdecl.error("cannot override `final` function `%s.%s`", b.sym.toChars(), f2.toPrettyChars());
}
}
@ -4544,7 +4544,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
utd._scope = null;
}
utd.protection = sc.protection;
utd.visibility = sc.visibility;
utd.parent = sc.parent;
Dsymbol p = utd.parent.pastMixin();
@ -4718,7 +4718,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (sd.semanticRun == PASS.init)
{
sd.protection = sc.protection;
sd.visibility = sc.visibility;
sd.alignment = sc.alignment();
@ -4932,7 +4932,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (cldec.semanticRun == PASS.init)
{
cldec.protection = sc.protection;
cldec.visibility = sc.visibility;
cldec.storage_class |= sc.stc;
if (cldec.storage_class & STC.auto_)
@ -5512,10 +5512,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
foreach (vd; cldec.fields)
{
if (!vd.isThisDeclaration() &&
!vd.prot().isMoreRestrictiveThan(Prot(Prot.Kind.public_)))
!vd.visible().isMoreRestrictiveThan(Visibility(Visibility.Kind.public_)))
{
vd.error("Field members of a `synchronized` class cannot be `%s`",
protectionToChars(vd.prot().kind));
visibilityToChars(vd.visible().kind));
}
}
}
@ -5584,7 +5584,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (idec.semanticRun == PASS.init)
{
idec.protection = sc.protection;
idec.visibility = sc.visibility;
idec.storage_class |= sc.stc;
idec.userAttribDecl = sc.userAttribDecl;
@ -6173,7 +6173,7 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, Expressions*
// Declare each template parameter as an alias for the argument type
Scope* paramscope = _scope.push();
paramscope.stc = 0;
paramscope.protection = Prot(Prot.Kind.public_); // https://issues.dlang.org/show_bug.cgi?id=14169
paramscope.visibility = Visibility(Visibility.Kind.public_); // https://issues.dlang.org/show_bug.cgi?id=14169
// template parameters should be public
tempinst.declareParameters(paramscope);
paramscope.pop();
@ -6490,7 +6490,7 @@ void aliasSeqInstanceSemantic(TemplateInstance tempinst, Scope* sc, TemplateDecl
//printf("[%s] aliasSeqInstance.dsymbolSemantic('%s')\n", tempinst.loc.toChars(), tempinst.toChars());
Scope* paramscope = sc.push();
paramscope.stc = 0;
paramscope.protection = Prot(Prot.Kind.public_);
paramscope.visibility = Visibility(Visibility.Kind.public_);
TemplateTupleParameter ttp = (*tempdecl.parameters)[0].isTemplateTupleParameter();
Tuple va = tempinst.tdtypes[0].isTuple();
@ -6515,7 +6515,7 @@ void aliasInstanceSemantic(TemplateInstance tempinst, Scope* sc, TemplateDeclara
//printf("[%s] aliasInstance.dsymbolSemantic('%s')\n", tempinst.loc.toChars(), tempinst.toChars());
Scope* paramscope = sc.push();
paramscope.stc = 0;
paramscope.protection = Prot(Prot.Kind.public_);
paramscope.visibility = Visibility(Visibility.Kind.public_);
TemplateTypeParameter ttp = (*tempdecl.parameters)[0].isTemplateTypeParameter();
Type ta = tempinst.tdtypes[0].isType();
@ -6538,7 +6538,7 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc)
// as DsymbolSemanticVisitor::visit(AliasDeclaration), in case we're called first.
// see https://issues.dlang.org/show_bug.cgi?id=21001
ds.storage_class |= sc.stc & STC.deprecated_;
ds.protection = sc.protection;
ds.visibility = sc.visibility;
ds.userAttribDecl = sc.userAttribDecl;
// TypeTraits needs to know if it's located in an AliasDeclaration
@ -6831,7 +6831,7 @@ private void aliasAssignSemantic(AliasAssign ds, Scope* sc)
aliassym.aliassym = s;
aliassym.storage_class |= sc.stc & STC.deprecated_;
aliassym.protection = sc.protection;
aliassym.visibility = sc.visibility;
aliassym.userAttribDecl = sc.userAttribDecl;
}
else // it's a type alias

View file

@ -561,7 +561,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
bool isTrivialAliasSeq; /// matches pattern `template AliasSeq(T...) { alias AliasSeq = T; }`
bool isTrivialAlias; /// matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
bool deprecated_; /// this template declaration is deprecated
Prot protection;
Visibility visibility;
int inuse; /// for recursive expansion detection
// threaded list of previous instantiation attempts on stack
@ -599,7 +599,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
this.literal = literal;
this.ismixin = ismixin;
this.isstatic = true;
this.protection = Prot(Prot.Kind.undefined);
this.visibility = Visibility(Visibility.Kind.undefined);
// Compute in advance for Ddoc's use
// https://issues.dlang.org/show_bug.cgi?id=11153: ident could be NULL if parsing fails.
@ -772,9 +772,9 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
return buf.extractChars();
}
override Prot prot() pure nothrow @nogc @safe
override Visibility visible() pure nothrow @nogc @safe
{
return protection;
return visibility;
}
/****************************
@ -2756,7 +2756,7 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc,
if (tf.equals(m.lastf.type) &&
fd.storage_class == m.lastf.storage_class &&
fd.parent == m.lastf.parent &&
fd.protection == m.lastf.protection &&
fd.visibility == m.lastf.visibility &&
fd.linkage == m.lastf.linkage)
{
if (fd.fbody && !m.lastf.fbody)

View file

@ -257,7 +257,8 @@ public:
LINK linkage = LINK.d;
bool forwardedAA;
AST.Type* origType;
AST.Prot.Kind currentProt; /// Last written protection level
/// Last written visibility level
AST.Visibility.Kind currentVisibility;
AST.STC storageClass; /// Currently applicable storage classes
int ignoredCounter; /// How many symbols were ignored
@ -345,39 +346,39 @@ public:
}
/// Writes the corresponding access specifier if necessary
private void writeProtection(const AST.Prot.Kind kind)
private void writeProtection(const AST.Visibility.Kind kind)
{
// Don't write protection for global declarations
// Don't write visibility for global declarations
if (!adparent)
return;
string token;
switch(kind) with(AST.Prot.Kind)
switch(kind) with(AST.Visibility.Kind)
{
case none, private_:
if (this.currentProt == AST.Prot.Kind.private_)
if (this.currentVisibility == AST.Visibility.Kind.private_)
return;
this.currentProt = AST.Prot.Kind.private_;
this.currentVisibility = AST.Visibility.Kind.private_;
token = "private:";
break;
case package_, protected_:
if (this.currentProt == AST.Prot.Kind.protected_)
if (this.currentVisibility == AST.Visibility.Kind.protected_)
return;
this.currentProt = AST.Prot.Kind.protected_;
this.currentVisibility = AST.Visibility.Kind.protected_;
token = "protected:";
break;
case undefined, public_, export_:
if (this.currentProt == AST.Prot.Kind.public_)
if (this.currentVisibility == AST.Visibility.Kind.public_)
return;
this.currentProt = AST.Prot.Kind.public_;
this.currentVisibility = AST.Visibility.Kind.public_;
token = "public:";
break;
default:
printf("Unexpected protection: %d!\n", kind);
printf("Unexpected visibility: %d!\n", kind);
assert(0);
}
@ -419,7 +420,7 @@ public:
foreach (s; *decl)
{
if (adparent || s.prot().kind >= AST.Prot.Kind.public_)
if (adparent || s.visible().kind >= AST.Visibility.Kind.public_)
s.accept(this);
}
}
@ -467,7 +468,7 @@ public:
}
foreach (s; *m.members)
{
if (s.prot().kind < AST.Prot.Kind.public_)
if (s.visible().kind < AST.Visibility.Kind.public_)
continue;
s.accept(this);
}
@ -497,7 +498,7 @@ public:
if (fd.isVirtual() && fd.introducing)
{
// Hide placeholders because they are not ABI compatible
writeProtection(AST.Prot.Kind.private_);
writeProtection(AST.Visibility.Kind.private_);
__gshared int counter; // Ensure unique names in all cases
buf.printf("virtual void __vtable_slot_%u();", counter++);
@ -510,13 +511,13 @@ public:
ignored("function %s because it is extern", fd.toPrettyChars());
return;
}
if (fd.protection.kind == AST.Prot.Kind.none || fd.protection.kind == AST.Prot.Kind.private_)
if (fd.visibility.kind == AST.Visibility.Kind.none || fd.visibility.kind == AST.Visibility.Kind.private_)
{
ignored("function %s because it is private", fd.toPrettyChars());
return;
}
writeProtection(fd.protection.kind);
writeProtection(fd.visibility.kind);
if (tf && tf.linkage == LINK.c)
buf.writestring("extern \"C\" ");
@ -552,7 +553,7 @@ public:
}
if (adparent && fd.isDisabled && global.params.cplusplus < CppStdRevision.cpp11)
writeProtection(AST.Prot.Kind.private_);
writeProtection(AST.Visibility.Kind.private_);
funcToBuffer(tf, fd);
// FIXME: How to determine if fd is const without tf?
if (adparent && tf && (tf.isConst() || tf.isImmutable()))
@ -576,7 +577,7 @@ public:
buf.writestring(" = delete");
buf.writestringln(";");
if (adparent && fd.isDisabled && global.params.cplusplus < CppStdRevision.cpp11)
writeProtection(AST.Prot.Kind.public_);
writeProtection(AST.Visibility.Kind.public_);
if (!adparent)
buf.writenl();
@ -629,12 +630,12 @@ public:
AST.Type type = vd.type;
EnumKind kind = getEnumKind(type);
if (vd.protection.kind == AST.Prot.Kind.none || vd.protection.kind == AST.Prot.Kind.private_) {
ignored("enum `%s` because it is `%s`.", vd.toPrettyChars(), AST.protectionToChars(vd.protection.kind));
if (vd.visibility.kind == AST.Visibility.Kind.none || vd.visibility.kind == AST.Visibility.Kind.private_) {
ignored("enum `%s` because it is `%s`.", vd.toPrettyChars(), AST.visibilityToChars(vd.visibility.kind));
return;
}
writeProtection(vd.protection.kind);
writeProtection(vd.visibility.kind);
final switch (kind)
{
@ -676,7 +677,7 @@ public:
ignored("variable %s because of linkage", vd.toPrettyChars());
return;
}
writeProtection(vd.protection.kind);
writeProtection(vd.visibility.kind);
typeToBuffer(vd.type, vd.ident);
buf.writestringln(";");
return;
@ -695,7 +696,7 @@ public:
ignored("variable %s because of thread-local storage", vd.toPrettyChars());
return;
}
writeProtection(vd.protection.kind);
writeProtection(vd.visibility.kind);
if (vd.linkage == LINK.c)
buf.writestring("extern \"C\" ");
else if (!adparent)
@ -709,7 +710,7 @@ public:
if (adparent && vd.type && vd.type.deco)
{
writeProtection(vd.protection.kind);
writeProtection(vd.visibility.kind);
typeToBuffer(vd.type, vd.ident);
buf.writestringln(";");
@ -746,7 +747,7 @@ public:
printf("[AST.AliasDeclaration enter] %s\n", ad.toChars());
scope(exit) printf("[AST.AliasDeclaration exit] %s\n", ad.toChars());
}
writeProtection(ad.protection.kind);
writeProtection(ad.visibility.kind);
if (auto t = ad.type)
{
@ -900,7 +901,7 @@ public:
pushAlignToBuffer(sd.alignment);
writeProtection(sd.protection.kind);
writeProtection(sd.visibility.kind);
const structAsClass = sd.cppmangle == CPPMANGLE.asClass;
if (sd.isUnionDeclaration())
@ -919,9 +920,9 @@ public:
buf.writenl();
buf.writestring("{");
const protStash = this.currentProt;
this.currentProt = structAsClass ? AST.Prot.Kind.private_ : AST.Prot.Kind.public_;
scope (exit) this.currentProt = protStash;
const protStash = this.currentVisibility;
this.currentVisibility = structAsClass ? AST.Visibility.Kind.private_ : AST.Visibility.Kind.public_;
scope (exit) this.currentVisibility = protStash;
buf.level++;
buf.writenl();
@ -935,7 +936,7 @@ public:
// Generate default ctor
if (!sd.noDefaultCtor && !sd.isUnionDeclaration())
{
writeProtection(AST.Prot.Kind.public_);
writeProtection(AST.Visibility.Kind.public_);
buf.printf("%s()", sd.ident.toChars());
size_t varCount;
bool first = true;
@ -1096,7 +1097,7 @@ public:
return;
}
writeProtection(cd.protection.kind);
writeProtection(cd.visibility.kind);
const classAsStruct = cd.cppmangle == CPPMANGLE.asStruct;
buf.writestring(classAsStruct ? "struct " : "class ");
@ -1137,9 +1138,9 @@ public:
buf.writenl();
buf.writestringln("{");
const protStash = this.currentProt;
this.currentProt = classAsStruct ? AST.Prot.Kind.public_ : AST.Prot.Kind.private_;
scope (exit) this.currentProt = protStash;
const protStash = this.currentVisibility;
this.currentVisibility = classAsStruct ? AST.Visibility.Kind.public_ : AST.Visibility.Kind.private_;
scope (exit) this.currentVisibility = protStash;
auto save = adparent;
adparent = cd;
@ -1219,7 +1220,7 @@ public:
bool manifestConstants = !isOpaque && (!type || (isAnonymous && kind == EnumKind.Other));
assert(!manifestConstants || isAnonymous);
writeProtection(ed.protection.kind);
writeProtection(ed.visibility.kind);
// write the enum header
if (!manifestConstants)

View file

@ -30,7 +30,7 @@ public:
*/
Type *type; // the TypeEnum
Type *memtype; // type of the members
Prot protection;
Visibility visibility;
Expression *maxval;
Expression *minval;
@ -48,7 +48,7 @@ public:
const char *kind() const;
Dsymbol *search(const Loc &loc, Identifier *ident, int flags = SearchLocalsOnly);
bool isDeprecated() const; // is Dsymbol deprecated?
Prot prot();
Visibility visible();
Expression *getMaxMinValue(const Loc &loc, Identifier *id);
bool isSpecial() const;
Expression *getDefaultValue(const Loc &loc);

View file

@ -3966,7 +3966,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
decl.inuse--;
}
/* Fix for 1161 doesn't work because it causes protection
/* Fix for 1161 doesn't work because it causes visibility
* problems when instantiating imported templates passing private
* variables as alias template parameters.
*/
@ -4018,7 +4018,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
sc = sc.push(); // just create new scope
sc.flags &= ~SCOPE.ctfe; // temporary stop CTFE
sc.protection = Prot(Prot.Kind.public_); // https://issues.dlang.org/show_bug.cgi?id=12506
sc.visibility = Visibility(Visibility.Kind.public_); // https://issues.dlang.org/show_bug.cgi?id=12506
/* fd.treq might be incomplete type,
* so should not semantic it.

View file

@ -85,7 +85,7 @@ class AggregateDeclaration;
class LabelDsymbol;
class ClassDeclaration;
class Type;
struct Prot;
struct Visibility;
class Package;
class EnumMember;
class TemplateDeclaration;
@ -857,7 +857,7 @@ public:
ClassDeclaration* isClassMember();
virtual Type* getType();
virtual bool needThis();
virtual Prot prot();
virtual Visibility visible();
virtual Dsymbol* syntaxCopy(Dsymbol* s);
virtual bool oneMember(Dsymbol** ps, Identifier* ident);
virtual void setFieldOffset(AggregateDeclaration* ad, uint32_t* poffset, bool isunion);
@ -946,14 +946,14 @@ public:
uint32_t endlinnum;
private:
Array<Dsymbol* >* importedScopes;
Kind* prots;
Kind* visibilities;
BitArray accessiblePackages;
BitArray privateAccessiblePackages;
public:
ScopeDsymbol* syntaxCopy(Dsymbol* s);
Dsymbol* search(const Loc& loc, Identifier* ident, int32_t flags = 8);
virtual void importScope(Dsymbol* s, Prot protection);
virtual bool isPackageAccessible(Package* p, Prot protection, int32_t flags = 0);
virtual void importScope(Dsymbol* s, Visibility visibility);
virtual bool isPackageAccessible(Package* p, Visibility visibility, int32_t flags = 0);
bool isforwardRef();
static void multiplyDefined(const Loc& loc, Dsymbol* s1, Dsymbol* s2);
const char* kind() const;
@ -966,14 +966,14 @@ public:
~ScopeDsymbol();
};
struct Prot
struct Visibility
{
Kind kind;
Package* pkg;
bool isMoreRestrictiveThan(const Prot other) const;
bool opEquals(const Prot& other) const;
bool isSubsetOf(const Prot& parent) const;
Prot() :
bool isMoreRestrictiveThan(const Visibility other) const;
bool opEquals(const Visibility& other) const;
bool isSubsetOf(const Visibility& parent) const;
Visibility() :
pkg()
{
}
@ -1850,7 +1850,7 @@ public:
DtorDeclaration* tidtor;
FuncDeclaration* fieldDtor;
Expression* getRTInfo;
Prot protection;
Visibility visibility;
bool noDefaultCtor;
Sizeok sizeok;
virtual Scope* newScope(Scope* sc);
@ -1867,7 +1867,7 @@ public:
bool isNested() const;
bool isExport() const;
Dsymbol* searchCtor();
Prot prot();
Visibility visible();
Type* handleType();
Symbol* stag;
Symbol* sinit;
@ -2032,7 +2032,7 @@ public:
class VisibilityDeclaration final : public AttribDeclaration
{
public:
Prot protection;
Visibility visibility;
Array<Identifier* >* pkg_identifiers;
VisibilityDeclaration* syntaxCopy(Dsymbol* s);
Scope* newScope(Scope* sc);
@ -2551,7 +2551,7 @@ public:
Type* type;
Type* originalType;
StorageClass storage_class;
Prot protection;
Visibility visibility;
LINK linkage;
int16_t inuse;
uint8_t adFlags;
@ -2587,7 +2587,7 @@ public:
bool isOut() const;
bool isRef() const;
bool isFuture() const;
Prot prot();
Visibility visible();
Declaration* isDeclaration();
void accept(Visitor* v);
};
@ -2855,7 +2855,7 @@ class EnumDeclaration final : public ScopeDsymbol
public:
Type* type;
Type* memtype;
Prot protection;
Visibility visibility;
Expression* maxval;
Expression* minval;
Expression* defaultval;
@ -2870,7 +2870,7 @@ public:
const char* kind() const;
Dsymbol* search(const Loc& loc, Identifier* ident, int32_t flags = 8);
bool isDeprecated() const;
Prot prot();
Visibility visible();
Expression* getMaxMinValue(const Loc& loc, Identifier* id);
bool isSpecial() const;
Expression* getDefaultValue(const Loc& loc);
@ -2903,14 +2903,14 @@ public:
Identifier* id;
Identifier* aliasId;
int32_t isstatic;
Prot protection;
Visibility visibility;
Array<Identifier* > names;
Array<Identifier* > aliases;
Module* mod;
Package* pkg;
Array<AliasDeclaration* > aliasdecls;
const char* kind() const;
Prot prot();
Visibility visible();
Import* syntaxCopy(Dsymbol* s);
bool load(Scope* sc);
void importAll(Scope* sc);
@ -3032,7 +3032,7 @@ public:
int32_t needModuleInfo();
void checkImportDeprecation(const Loc& loc, Scope* sc);
Dsymbol* search(const Loc& loc, Identifier* ident, int32_t flags = 8);
bool isPackageAccessible(Package* p, Prot protection, int32_t flags = 0);
bool isPackageAccessible(Package* p, Visibility visibility, int32_t flags = 0);
Dsymbol* symtabInsert(Dsymbol* s);
void deleteObjFile();
static void runDeferredSemantic();
@ -3213,7 +3213,7 @@ public:
ScopeDsymbol* forward;
Dsymbol* symtabInsert(Dsymbol* s);
Dsymbol* symtabLookup(Dsymbol* s, Identifier* id);
void importScope(Dsymbol* s, Prot protection);
void importScope(Dsymbol* s, Visibility visibility);
const char* kind() const;
ForwardingScopeDsymbol* isForwardingScopeDsymbol();
~ForwardingScopeDsymbol();
@ -3292,7 +3292,7 @@ public:
bool isTrivialAliasSeq;
bool isTrivialAlias;
bool deprecated_;
Prot protection;
Visibility visibility;
int32_t inuse;
TemplatePrevious* previous;
private:
@ -3307,7 +3307,7 @@ public:
const char* toChars() const;
const char* toCharsNoConstraints() const;
const char* toCharsMaybeConstraints(bool includeConstraints) const;
Prot prot();
Visibility visible();
const char* getConstraintEvalError(const char*& tip);
Scope* scopeForTemplateParameters(TemplateInstance* ti, Scope* sc);
MATCH leastAsSpecialized(Scope* sc, TemplateDeclaration* td2, Array<Expression* >* fargs);
@ -3518,7 +3518,7 @@ public:
LINK linkage;
bool forwardedAA;
Type** origType;
Kind currentProt;
Kind currentVisibility;
STC storageClass;
int32_t ignoredCounter;
bool hasReal;

View file

@ -1228,14 +1228,14 @@ extern (C++) class FuncDeclaration : Declaration
override final bool isExport() const
{
return protection.kind == Prot.Kind.export_;
return visibility.kind == Visibility.Kind.export_;
}
override final bool isImportedSymbol() const
{
//printf("isImportedSymbol()\n");
//printf("protection = %d\n", protection);
return (protection.kind == Prot.Kind.export_) && !fbody;
//printf("protection = %d\n", visibility);
return (visibility.kind == Visibility.Kind.export_) && !fbody;
}
override final bool isCodeseg() const pure nothrow @nogc @safe
@ -1717,10 +1717,10 @@ extern (C++) class FuncDeclaration : Declaration
version (none)
{
printf("FuncDeclaration::isVirtual(%s)\n", toChars());
printf("isMember:%p isStatic:%d private:%d ctor:%d !Dlinkage:%d\n", isMember(), isStatic(), protection == Prot.Kind.private_, isCtorDeclaration(), linkage != LINK.d);
printf("result is %d\n", isMember() && !(isStatic() || protection == Prot.Kind.private_ || protection == Prot.Kind.package_) && p.isClassDeclaration() && !(p.isInterfaceDeclaration() && isFinalFunc()));
printf("isMember:%p isStatic:%d private:%d ctor:%d !Dlinkage:%d\n", isMember(), isStatic(), visibility == Visibility.Kind.private_, isCtorDeclaration(), linkage != LINK.d);
printf("result is %d\n", isMember() && !(isStatic() || visibility == Visibility.Kind.private_ || visibility == Visibility.Kind.package_) && p.isClassDeclaration() && !(p.isInterfaceDeclaration() && isFinalFunc()));
}
return !(isStatic() || protection.kind == Prot.Kind.private_ || protection.kind == Prot.Kind.package_) && !(p.isInterfaceDeclaration() && isFinalFunc());
return !(isStatic() || visibility.kind == Visibility.Kind.private_ || visibility.kind == Visibility.Kind.package_) && !(p.isInterfaceDeclaration() && isFinalFunc());
}
final bool isFinalFunc() const
@ -1749,14 +1749,14 @@ extern (C++) class FuncDeclaration : Declaration
{
auto ad = isThis();
ClassDeclaration cd = ad ? ad.isClassDeclaration() : null;
return (ad && !(cd && cd.isCPPclass()) && global.params.useInvariants == CHECKENABLE.on && (protection.kind == Prot.Kind.protected_ || protection.kind == Prot.Kind.public_ || protection.kind == Prot.Kind.export_) && !naked);
return (ad && !(cd && cd.isCPPclass()) && global.params.useInvariants == CHECKENABLE.on && (visibility.kind == Visibility.Kind.protected_ || visibility.kind == Visibility.Kind.public_ || visibility.kind == Visibility.Kind.export_) && !naked);
}
bool addPostInvariant()
{
auto ad = isThis();
ClassDeclaration cd = ad ? ad.isClassDeclaration() : null;
return (ad && !(cd && cd.isCPPclass()) && ad.inv && global.params.useInvariants == CHECKENABLE.on && (protection.kind == Prot.Kind.protected_ || protection.kind == Prot.Kind.public_ || protection.kind == Prot.Kind.export_) && !naked);
return (ad && !(cd && cd.isCPPclass()) && ad.inv && global.params.useInvariants == CHECKENABLE.on && (visibility.kind == Visibility.Kind.protected_ || visibility.kind == Visibility.Kind.public_ || visibility.kind == Visibility.Kind.export_) && !naked);
}
override const(char)* kind() const
@ -2540,7 +2540,7 @@ extern (C++) class FuncDeclaration : Declaration
{
tf = new TypeFunction(ParameterList(fparams), treturn, LINK.c, stc);
fd = new FuncDeclaration(Loc.initial, Loc.initial, id, STC.static_, tf);
fd.protection = Prot(Prot.Kind.public_);
fd.visibility = Visibility(Visibility.Kind.public_);
fd.linkage = LINK.c;
st.insert(fd);

View file

@ -974,7 +974,7 @@ public:
override void visit(VisibilityDeclaration d)
{
protectionToBuffer(buf, d.protection);
visibilityToBuffer(buf, d.visibility);
buf.writeByte(' ');
AttribDeclaration ad = cast(AttribDeclaration)d;
if (ad.decl.dim == 1 && (*ad.decl)[0].isVisibilityDeclaration)
@ -2867,13 +2867,13 @@ string linkageToString(LINK linkage) pure nothrow
}
}
void protectionToBuffer(OutBuffer* buf, Prot prot)
void visibilityToBuffer(OutBuffer* buf, Visibility vis)
{
buf.writestring(protectionToString(prot.kind));
if (prot.kind == Prot.Kind.package_ && prot.pkg)
buf.writestring(visibilityToString(vis.kind));
if (vis.kind == Visibility.Kind.package_ && vis.pkg)
{
buf.writeByte('(');
buf.writestring(prot.pkg.toPrettyChars(true));
buf.writestring(vis.pkg.toPrettyChars(true));
buf.writeByte(')');
}
}
@ -2882,30 +2882,30 @@ void protectionToBuffer(OutBuffer* buf, Prot prot)
* Returns:
* a human readable representation of `kind`
*/
const(char)* protectionToChars(Prot.Kind kind)
const(char)* visibilityToChars(Visibility.Kind kind)
{
// Null terminated because we return a literal
return protectionToString(kind).ptr;
return visibilityToString(kind).ptr;
}
/// Ditto
extern (D) string protectionToString(Prot.Kind kind) nothrow pure
extern (D) string visibilityToString(Visibility.Kind kind) nothrow pure
{
final switch (kind)
{
case Prot.Kind.undefined:
case Visibility.Kind.undefined:
return null;
case Prot.Kind.none:
case Visibility.Kind.none:
return "none";
case Prot.Kind.private_:
case Visibility.Kind.private_:
return "private";
case Prot.Kind.package_:
case Visibility.Kind.package_:
return "package";
case Prot.Kind.protected_:
case Visibility.Kind.protected_:
return "protected";
case Prot.Kind.public_:
case Visibility.Kind.public_:
return "public";
case Prot.Kind.export_:
case Visibility.Kind.export_:
return "export";
}
}

View file

@ -27,7 +27,7 @@ public:
Identifier *id; // module Identifier
Identifier *aliasId;
int isstatic; // !=0 if static import
Prot protection;
Visibility visibility;
// Pairs of alias=name to bind into current namespace
Identifiers names;
@ -39,7 +39,7 @@ public:
AliasDeclarations aliasdecls; // corresponding AliasDeclarations for alias=name pairs
const char *kind() const;
Prot prot();
Visibility visible();
Import *syntaxCopy(Dsymbol *s); // copy only syntax trees
void load(Scope *sc);
void importAll(Scope *sc);

View file

@ -432,7 +432,7 @@ public:
property("kind", s.kind.toDString);
}
// TODO: How about package(names)?
property("protection", protectionToString(s.prot().kind));
property("protection", visibilityToString(s.visible().kind));
if (EnumMember em = s.isEnumMember())
{
if (em.origValue)
@ -523,8 +523,8 @@ public:
property("kind", s.kind.toDString);
property("comment", s.comment.toDString);
property("line", "char", s.loc);
if (s.prot().kind != Prot.Kind.public_)
property("protection", protectionToString(s.prot().kind));
if (s.visible().kind != Visibility.Kind.public_)
property("protection", visibilityToString(s.visible().kind));
if (s.aliasId)
property("alias", s.aliasId.toString());
bool hasRenamed = false;

View file

@ -125,7 +125,7 @@ public:
void importAll(Scope *sc);
int needModuleInfo();
Dsymbol *search(const Loc &loc, Identifier *ident, int flags = SearchLocalsOnly);
bool isPackageAccessible(Package *p, Prot protection, int flags = 0);
bool isPackageAccessible(Package *p, Visibility visibility, int flags = 0);
Dsymbol *symtabInsert(Dsymbol *s);
void deleteObjFile();
static void runDeferredSemantic();

View file

@ -96,7 +96,7 @@ extern (C++) final class Nspace : ScopeDsymbol
ScopeDsymbol sds2 = sce.scopesym;
if (sds2)
{
sds2.importScope(this, Prot(Prot.Kind.public_));
sds2.importScope(this, Visibility(Visibility.Kind.public_));
break;
}
}

View file

@ -596,8 +596,8 @@ extern(C++) private final class Supported : Objc
// because the Objective-C runtime always use dynamic dispatch.
// * static member functions are kept virtual too, as they represent
// methods of the metaclass.
with (fd.protection)
return !(kind == Prot.Kind.private_ || kind == Prot.Kind.package_);
with (fd.visibility)
return !(kind == Visibility.Kind.private_ || kind == Visibility.Kind.package_);
}
override void setAsOptional(FuncDeclaration fd, Scope* sc) const

View file

@ -203,7 +203,7 @@ private struct PrefixAttributes(AST)
StorageClass storageClass;
AST.Expression depmsg;
LINK link;
AST.Prot protection;
AST.Visibility visibility;
bool setAlignment;
AST.Expression ealign;
AST.Expressions* udas;
@ -494,7 +494,7 @@ final class Parser(AST) : Lexer
pAttrs = &attrs;
pAttrs.comment = token.blockComment.ptr;
}
AST.Prot.Kind prot;
AST.Visibility.Kind prot;
StorageClass stc;
AST.Condition condition;
@ -1005,41 +1005,41 @@ final class Parser(AST) : Lexer
}
case TOK.private_:
prot = AST.Prot.Kind.private_;
prot = AST.Visibility.Kind.private_;
goto Lprot;
case TOK.package_:
prot = AST.Prot.Kind.package_;
prot = AST.Visibility.Kind.package_;
goto Lprot;
case TOK.protected_:
prot = AST.Prot.Kind.protected_;
prot = AST.Visibility.Kind.protected_;
goto Lprot;
case TOK.public_:
prot = AST.Prot.Kind.public_;
prot = AST.Visibility.Kind.public_;
goto Lprot;
case TOK.export_:
prot = AST.Prot.Kind.export_;
prot = AST.Visibility.Kind.export_;
goto Lprot;
Lprot:
{
if (pAttrs.protection.kind != AST.Prot.Kind.undefined)
if (pAttrs.visibility.kind != AST.Visibility.Kind.undefined)
{
if (pAttrs.protection.kind != prot)
error("conflicting protection attribute `%s` and `%s`", AST.protectionToChars(pAttrs.protection.kind), AST.protectionToChars(prot));
if (pAttrs.visibility.kind != prot)
error("conflicting visibility attribute `%s` and `%s`", AST.visibilityToChars(pAttrs.visibility.kind), AST.visibilityToChars(prot));
else
error("redundant protection attribute `%s`", AST.protectionToChars(prot));
error("redundant visibility attribute `%s`", AST.visibilityToChars(prot));
}
pAttrs.protection.kind = prot;
pAttrs.visibility.kind = prot;
nextToken();
// optional qualified package identifier to bind
// protection to
// visibility to
AST.Identifiers* pkg_prot_idents = null;
if (pAttrs.protection.kind == AST.Prot.Kind.package_ && token.value == TOK.leftParentheses)
if (pAttrs.visibility.kind == AST.Visibility.Kind.package_ && token.value == TOK.leftParentheses)
{
pkg_prot_idents = parseQualifiedIdentifier("protection package");
if (pkg_prot_idents)
@ -1055,14 +1055,14 @@ final class Parser(AST) : Lexer
const attrloc = token.loc;
a = parseBlock(pLastDecl, pAttrs);
if (pAttrs.protection.kind != AST.Prot.Kind.undefined)
if (pAttrs.visibility.kind != AST.Visibility.Kind.undefined)
{
if (pAttrs.protection.kind == AST.Prot.Kind.package_ && pkg_prot_idents)
if (pAttrs.visibility.kind == AST.Visibility.Kind.package_ && pkg_prot_idents)
s = new AST.VisibilityDeclaration(attrloc, pkg_prot_idents, a);
else
s = new AST.VisibilityDeclaration(attrloc, pAttrs.protection, a);
s = new AST.VisibilityDeclaration(attrloc, pAttrs.visibility, a);
pAttrs.protection = AST.Prot(AST.Prot.Kind.undefined);
pAttrs.visibility = AST.Visibility(AST.Visibility.Kind.undefined);
}
break;
}
@ -1305,7 +1305,7 @@ final class Parser(AST) : Lexer
}
/********************************************
* Parse declarations after an align, protection, or extern decl.
* Parse declarations after an align, visibility, or extern decl.
*/
private AST.Dsymbols* parseBlock(AST.Dsymbol* pLastDecl, PrefixAttributes!AST* pAttrs = null)
{

View file

@ -105,8 +105,8 @@ struct Scope
CPPMANGLE cppmangle; // C++ mangle type
PINLINE inlining; // inlining strategy for functions
Prot protection; // protection for class members
int explicitProtection; // set if in an explicit protection attribute
Visibility visibility; // visibility for class members
int explicitVisibility; // set if in an explicit visibility attribute
StorageClass stc; // storage class

View file

@ -315,8 +315,8 @@ private extern(C++) final class Semantic3Visitor : Visitor
sc2.fes = funcdecl.fes;
sc2.linkage = LINK.d;
sc2.stc &= STCFlowThruFunction;
sc2.protection = Prot(Prot.Kind.public_);
sc2.explicitProtection = 0;
sc2.visibility = Visibility(Visibility.Kind.public_);
sc2.explicitVisibility = 0;
sc2.aligndecl = null;
if (funcdecl.ident != Id.require && funcdecl.ident != Id.ensure)
sc2.flags = sc.flags & ~SCOPE.contract;

View file

@ -69,7 +69,7 @@ public:
bool isTrivialAliasSeq; // matches `template AliasSeq(T...) { alias AliasSeq = T; }
bool isTrivialAlias; // matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
bool deprecated_; // this template declaration is deprecated
Prot protection;
Visibility visibility;
int inuse; // for recursive expansion detection
TemplatePrevious *previous; // threaded list of previous instantiation attempts on stack
@ -80,7 +80,7 @@ public:
const char *kind() const;
const char *toChars() const;
Prot prot();
Visibility visible();
MATCH leastAsSpecialized(Scope *sc, TemplateDeclaration *td2, Expressions *fargs);
RootObject *declareParameter(Scope *sc, TemplateParameter *tp, RootObject *o);

View file

@ -64,24 +64,24 @@ extern (C++):
/******************************
* CV4 pg. 25
* Convert D protection attribute to cv attribute.
* Convert D visibility attribute to cv attribute.
*/
uint PROTtoATTR(Prot.Kind prot) pure nothrow @safe @nogc
uint visibilityToCVAttr(Visibility.Kind vis) pure nothrow @safe @nogc
{
uint attribute;
final switch (prot)
final switch (vis)
{
case Prot.Kind.private_: attribute = 1; break;
case Prot.Kind.package_: attribute = 2; break;
case Prot.Kind.protected_: attribute = 2; break;
case Prot.Kind.public_: attribute = 3; break;
case Prot.Kind.export_: attribute = 3; break;
case Visibility.Kind.private_: attribute = 1; break;
case Visibility.Kind.package_: attribute = 2; break;
case Visibility.Kind.protected_: attribute = 2; break;
case Visibility.Kind.public_: attribute = 3; break;
case Visibility.Kind.export_: attribute = 3; break;
case Prot.Kind.undefined:
case Prot.Kind.none:
//printf("prot = %d\n", prot);
case Visibility.Kind.undefined:
case Visibility.Kind.none:
//printf("vis = %d\n", vis);
assert(0);
}
return attribute;
@ -742,7 +742,7 @@ void toDebug(ClassDeclaration cd)
{
BaseClass *bc = (*cd.baseclasses)[i];
const idx_t typidx2 = cv4_typidx(Type_toCtype(bc.sym.type).Tnext);
const uint attribute = PROTtoATTR(Prot.Kind.public_);
const uint attribute = visibilityToCVAttr(Visibility.Kind.public_);
uint elementlen;
final switch (config.fulltypes)
@ -1026,7 +1026,7 @@ int cvMember(Dsymbol s, ubyte *p)
q += 2;
// for (s = sf; s; s = s.Sfunc.Foversym)
{
uint attribute = PROTtoATTR(fd.prot().kind);
uint attribute = visibilityToCVAttr(fd.visible().kind);
/* 0*4 vanilla method
* 1*4 virtual method
@ -1135,7 +1135,7 @@ int cvMember(Dsymbol s, ubyte *p)
else
{
idx_t typidx = cv_typidx(Type_toCtype(vd.type));
uint attribute = PROTtoATTR(vd.prot().kind);
uint attribute = visibilityToCVAttr(vd.visible().kind);
assert((attribute & ~3) == 0);
switch (config.fulltypes)
{

View file

@ -544,7 +544,7 @@ void toObjFile(Dsymbol ds, bool multiobj)
override void visit(VarDeclaration vd)
{
//printf("VarDeclaration.toObjFile(%p '%s' type=%s) protection %d\n", vd, vd.toChars(), vd.type.toChars(), vd.protection);
//printf("VarDeclaration.toObjFile(%p '%s' type=%s) visibility %d\n", vd, vd.toChars(), vd.type.toChars(), vd.visibility);
//printf("\talign = %d\n", vd.alignment);
if (vd.type.ty == Terror)
@ -695,7 +695,7 @@ void toObjFile(Dsymbol ds, bool multiobj)
//printf("-speculative '%s'\n", tid.toPrettyChars());
return;
}
//printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", tid, tid.toChars(), tid.protection);
//printf("TypeInfoDeclaration.toObjFile(%p '%s') visibility %d\n", tid, tid.toChars(), tid.visibility);
if (multiobj)
{

View file

@ -838,13 +838,13 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
if (!s)
{
if (!isError(o))
e.error("argument `%s` has no protection", o.toChars());
e.error("argument `%s` has no visibility", o.toChars());
return ErrorExp.get();
}
if (s.semanticRun == PASS.init)
s.dsymbolSemantic(null);
auto protName = protectionToString(s.prot().kind); // TODO: How about package(names)
auto protName = visibilityToString(s.visible().kind); // TODO: How about package(names)
assert(protName);
auto se = new StringExp(e.loc, protName);
return se.expressionSemantic(sc);
@ -1153,7 +1153,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
return 0;
auto fa = new FuncAliasDeclaration(fd.ident, fd, false);
fa.protection = fd.protection;
fa.visibility = fd.visibility;
auto e = ex ? new DotVarExp(Loc.initial, ex, fa, false)
: new DsymbolExp(Loc.initial, fa, false);
@ -1841,7 +1841,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
uniqueUnitTests[cast(void*)ud] = true;
auto ad = new FuncAliasDeclaration(ud.ident, ud, false);
ad.protection = ud.protection;
ad.visibility = ud.visibility;
auto e = new DsymbolExp(Loc.initial, ad, false);
exps.push(e);

View file

@ -1307,7 +1307,7 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
*/
Scope* argsc = sc.push();
argsc.stc = 0; // don't inherit storage class
argsc.protection = Prot(Prot.Kind.public_);
argsc.visibility = Visibility(Visibility.Kind.public_);
argsc.func = null;
size_t dim = tf.parameterList.length;

View file

@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice13385.d(9): Error: protection attribute `package(a)` does not bind to one of ancestor packages of module `ice13385`
fail_compilation/ice13385.d(9): Error: visibility attribute `package(a)` does not bind to one of ancestor packages of module `ice13385`
---
*/
module ice13385;

View file

@ -43,8 +43,8 @@ extern(C++, foo) extern(C++, bar) void f8() {} // OK
/*
TEST_OUTPUT:
---
fail_compilation/parseStc2.d(50): Error: redundant protection attribute `public`
fail_compilation/parseStc2.d(51): Error: conflicting protection attribute `public` and `private`
fail_compilation/parseStc2.d(50): Error: redundant visibility attribute `public`
fail_compilation/parseStc2.d(51): Error: conflicting visibility attribute `public` and `private`
---
*/
public public void f9() {}

View file

@ -2,7 +2,7 @@
EXTRA_FILES: protection/subpkg/test1.d
TEST_OUTPUT:
---
fail_compilation/protection/subpkg/test1.d(3): Error: protection attribute `package(undefined)` does not bind to one of ancestor packages of module `protection.subpkg.test1`
fail_compilation/protection/subpkg/test1.d(3): Error: visibility attribute `package(undefined)` does not bind to one of ancestor packages of module `protection.subpkg.test1`
---
*/
import protection.subpkg.test1;

View file

@ -2,7 +2,7 @@
EXTRA_FILES: protection/subpkg/test2.d
TEST_OUTPUT:
---
fail_compilation/protection/subpkg/test2.d(3): Error: protection attribute `package(protection.subpkg2)` does not bind to one of ancestor packages of module `protection.subpkg.test2`
fail_compilation/protection/subpkg/test2.d(3): Error: visibility attribute `package(protection.subpkg2)` does not bind to one of ancestor packages of module `protection.subpkg.test2`
---
*/
import protection.subpkg.test2;