mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 13:40:11 +03:00
Move ClassDeclaration.isFuncHidden to dsymbolsem (#20945)
This commit is contained in:
parent
bc4c7e4452
commit
6df52b0ef2
7 changed files with 47 additions and 39 deletions
|
@ -46,6 +46,7 @@ namespace dmd
|
||||||
FuncDeclaration *search_toString(StructDeclaration *sd);
|
FuncDeclaration *search_toString(StructDeclaration *sd);
|
||||||
void semanticTypeInfoMembers(StructDeclaration *sd);
|
void semanticTypeInfoMembers(StructDeclaration *sd);
|
||||||
bool fill(StructDeclaration* sd, Loc loc, Expressions &elements, bool ctorinit);
|
bool fill(StructDeclaration* sd, Loc loc, Expressions &elements, bool ctorinit);
|
||||||
|
bool isFuncHidden(ClassDeclaration* cd, FuncDeclaration* fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ClassKind : uint8_t
|
enum class ClassKind : uint8_t
|
||||||
|
@ -287,7 +288,6 @@ public:
|
||||||
bool isBaseInfoComplete();
|
bool isBaseInfoComplete();
|
||||||
void finalizeSize() override;
|
void finalizeSize() override;
|
||||||
bool hasMonitor();
|
bool hasMonitor();
|
||||||
bool isFuncHidden(FuncDeclaration *fd);
|
|
||||||
bool isCOMclass() const;
|
bool isCOMclass() const;
|
||||||
virtual bool isCOMinterface() const;
|
virtual bool isCOMinterface() const;
|
||||||
bool isCPPclass() const;
|
bool isCPPclass() const;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import dmd.arraytypes;
|
||||||
import dmd.astenums;
|
import dmd.astenums;
|
||||||
import dmd.attrib;
|
import dmd.attrib;
|
||||||
import dmd.common.outbuffer : OutBuffer;
|
import dmd.common.outbuffer : OutBuffer;
|
||||||
|
import dmd.dclass : ClassDeclaration;
|
||||||
import dmd.denum : EnumDeclaration;
|
import dmd.denum : EnumDeclaration;
|
||||||
import dmd.dmodule /*: Module*/;
|
import dmd.dmodule /*: Module*/;
|
||||||
import dmd.dscope : Scope;
|
import dmd.dscope : Scope;
|
||||||
|
@ -178,6 +179,12 @@ Dsymbols* include(Dsymbol d, Scope* sc)
|
||||||
return dmd.dsymbolsem.include(d, sc);
|
return dmd.dsymbolsem.include(d, sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isFuncHidden(ClassDeclaration cd, FuncDeclaration fd)
|
||||||
|
{
|
||||||
|
import dmd.dsymbolsem;
|
||||||
|
return dmd.dsymbolsem.isFuncHidden(cd, fd);
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* dtemplate.d
|
* dtemplate.d
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,7 +23,7 @@ import dmd.gluelayer;
|
||||||
import dmd.declaration;
|
import dmd.declaration;
|
||||||
import dmd.dscope;
|
import dmd.dscope;
|
||||||
import dmd.dsymbol;
|
import dmd.dsymbol;
|
||||||
import dmd.dsymbolsem : dsymbolSemantic, addMember, search, setFieldOffset;
|
import dmd.dsymbolsem : dsymbolSemantic, addMember, setFieldOffset;
|
||||||
import dmd.errors;
|
import dmd.errors;
|
||||||
import dmd.func;
|
import dmd.func;
|
||||||
import dmd.id;
|
import dmd.id;
|
||||||
|
@ -614,40 +614,6 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
|
||||||
return classKind == ClassKind.d;
|
return classKind == ClassKind.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
final bool isFuncHidden(FuncDeclaration fd)
|
|
||||||
{
|
|
||||||
import dmd.funcsem : overloadApply;
|
|
||||||
//printf("ClassDeclaration.isFuncHidden(class = %s, fd = %s)\n", toChars(), fd.toPrettyChars());
|
|
||||||
Dsymbol s = this.search(Loc.initial, fd.ident, SearchOpt.ignoreAmbiguous | SearchOpt.ignoreErrors);
|
|
||||||
if (!s)
|
|
||||||
{
|
|
||||||
//printf("not found\n");
|
|
||||||
/* Because, due to a hack, if there are multiple definitions
|
|
||||||
* of fd.ident, NULL is returned.
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
s = s.toAlias();
|
|
||||||
if (auto os = s.isOverloadSet())
|
|
||||||
{
|
|
||||||
foreach (sm; os.a)
|
|
||||||
{
|
|
||||||
auto fm = sm.isFuncDeclaration();
|
|
||||||
if (overloadApply(fm, s => fd == s.isFuncDeclaration()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto f = s.isFuncDeclaration();
|
|
||||||
//printf("%s fdstart = %p\n", s.kind(), fdstart);
|
|
||||||
if (overloadApply(f, s => fd == s.isFuncDeclaration()))
|
|
||||||
return false;
|
|
||||||
return !fd.parent.isTemplateMixin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Find virtual function matching identifier and type.
|
* Find virtual function matching identifier and type.
|
||||||
* Used to build virtual function tables for interface implementations.
|
* Used to build virtual function tables for interface implementations.
|
||||||
|
|
|
@ -8160,3 +8160,37 @@ private extern(C++) class HasStaticCtorOrDtor : Visitor
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern(C++) bool isFuncHidden(ClassDeclaration cd, FuncDeclaration fd)
|
||||||
|
{
|
||||||
|
import dmd.funcsem : overloadApply;
|
||||||
|
//printf("ClassDeclaration.isFuncHidden(class = %s, fd = %s)\n", toChars(), fd.toPrettyChars());
|
||||||
|
Dsymbol s = cd.search(Loc.initial, fd.ident, SearchOpt.ignoreAmbiguous | SearchOpt.ignoreErrors);
|
||||||
|
if (!s)
|
||||||
|
{
|
||||||
|
//printf("not found\n");
|
||||||
|
/* Because, due to a hack, if there are multiple definitions
|
||||||
|
* of fd.ident, NULL is returned.
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s = s.toAlias();
|
||||||
|
if (auto os = s.isOverloadSet())
|
||||||
|
{
|
||||||
|
foreach (sm; os.a)
|
||||||
|
{
|
||||||
|
auto fm = sm.isFuncDeclaration();
|
||||||
|
if (overloadApply(fm, s => fd == s.isFuncDeclaration()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto f = s.isFuncDeclaration();
|
||||||
|
//printf("%s fdstart = %p\n", s.kind(), fdstart);
|
||||||
|
if (overloadApply(f, s => fd == s.isFuncDeclaration()))
|
||||||
|
return false;
|
||||||
|
return !fd.parent.isTemplateMixin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6680,7 +6680,6 @@ public:
|
||||||
bool isBaseInfoComplete() const;
|
bool isBaseInfoComplete() const;
|
||||||
void finalizeSize() final override;
|
void finalizeSize() final override;
|
||||||
bool hasMonitor();
|
bool hasMonitor();
|
||||||
bool isFuncHidden(FuncDeclaration* fd);
|
|
||||||
bool isCOMclass() const;
|
bool isCOMclass() const;
|
||||||
virtual bool isCOMinterface() const;
|
virtual bool isCOMinterface() const;
|
||||||
bool isCPPclass() const;
|
bool isCPPclass() const;
|
||||||
|
@ -7546,6 +7545,8 @@ public:
|
||||||
|
|
||||||
extern bool hasStaticCtorOrDtor(Dsymbol* d);
|
extern bool hasStaticCtorOrDtor(Dsymbol* d);
|
||||||
|
|
||||||
|
extern bool isFuncHidden(ClassDeclaration* cd, FuncDeclaration* fd);
|
||||||
|
|
||||||
extern void lowerNonArrayAggregate(StaticForeach* sfe, Scope* sc);
|
extern void lowerNonArrayAggregate(StaticForeach* sfe, Scope* sc);
|
||||||
|
|
||||||
class NrvoWalker final : public StatementRewriteWalker
|
class NrvoWalker final : public StatementRewriteWalker
|
||||||
|
|
|
@ -35,7 +35,7 @@ import dmd.dmodule;
|
||||||
import dmd.dscope;
|
import dmd.dscope;
|
||||||
import dmd.dstruct;
|
import dmd.dstruct;
|
||||||
import dmd.dsymbol;
|
import dmd.dsymbol;
|
||||||
import dmd.dsymbolsem : include, hasStaticCtorOrDtor;
|
import dmd.dsymbolsem : hasStaticCtorOrDtor, include, isFuncHidden;
|
||||||
import dmd.dtemplate;
|
import dmd.dtemplate;
|
||||||
import dmd.errors;
|
import dmd.errors;
|
||||||
import dmd.errorsink;
|
import dmd.errorsink;
|
||||||
|
|
|
@ -1323,7 +1323,7 @@ public:
|
||||||
continue;
|
continue;
|
||||||
if (!dmd::functionSemantic(fd))
|
if (!dmd::functionSemantic(fd))
|
||||||
return;
|
return;
|
||||||
if (!d->isFuncHidden(fd) || fd->isFuture())
|
if (!dmd::isFuncHidden(d, fd) || fd->isFuture())
|
||||||
continue;
|
continue;
|
||||||
for (size_t j = 1; j < d->vtbl.length; j++)
|
for (size_t j = 1; j < d->vtbl.length; j++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue