Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move newScope methods from dclass.d to newScope visitor in dsymbolsem.d #17038

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions compiler/src/dmd/dclass.d
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,6 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
return cd;
}

override Scope* newScope(Scope* sc)
thewilsonator marked this conversation as resolved.
Show resolved Hide resolved
{
auto sc2 = super.newScope(sc);
if (isCOMclass())
{
/* This enables us to use COM objects under Linux and
* work with things like XPCOM
*/
sc2.linkage = target.systemLinkage();
}
return sc2;
}

/*********************************************
* Determine if 'this' is a base class of cd.
* This is used to detect circular inheritance only.
Expand Down Expand Up @@ -975,19 +962,6 @@ extern (C++) final class InterfaceDeclaration : ClassDeclaration
return id;
}


override Scope* newScope(Scope* sc)
{
auto sc2 = super.newScope(sc);
if (com)
sc2.linkage = LINK.windows;
else if (classKind == ClassKind.cpp)
sc2.linkage = LINK.cpp;
else if (classKind == ClassKind.objc)
sc2.linkage = LINK.objc;
return sc2;
}

/*******************************************
* Determine if 'this' is a base class of cd.
* (Actually, if it is an interface supported by cd)
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/dsymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,5 @@ namespace dmd
Dsymbols *include(Dsymbol *d, Scope *sc);
void setScope(Dsymbol *d, Scope *sc);
void importAll(Dsymbol *d, Scope *sc);
Scope* newScope(Dsymbol *d, Scope *sc);
}
26 changes: 25 additions & 1 deletion compiler/src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -7482,8 +7482,32 @@
}
sc = sc2;
}
}

override void visit(ClassDeclaration cld)
{
auto sc2 = cld.newScope(sc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you have translated super.newScope here properly. Should be (cast(AggregateDeclaration)cld).newScope(sc);

if (cld.isCOMclass())

Check warning on line 7489 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L7488-L7489

Added lines #L7488 - L7489 were not covered by tests
{
/* This enables us to use COM objects under Linux and
* work with things like XPCOM
*/
sc2.linkage = target.systemLinkage();

Check warning on line 7494 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L7494

Added line #L7494 was not covered by tests
}
sc = sc2;

Check warning on line 7496 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L7496

Added line #L7496 was not covered by tests
}

override void visit(InterfaceDeclaration ifd)
{
auto sc2 = ifd.newScope(sc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same but `cast(ClassDeclaration)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, Let me work on them

if (ifd.com)
sc2.linkage = LINK.windows;
else if (ifd.classKind == ClassKind.cpp)
sc2.linkage = LINK.cpp;
else if (ifd.classKind == ClassKind.objc)
sc2.linkage = LINK.objc;
sc = sc2;

Check warning on line 7508 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L7501-L7508

Added lines #L7501 - L7508 were not covered by tests
}
}

extern(C++) Dsymbols* include(Dsymbol d, Scope* sc)
{
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -6508,7 +6508,6 @@ class ClassDeclaration : public AggregateDeclaration
static ClassDeclaration* create(const Loc& loc, Identifier* id, Array<BaseClass* >* baseclasses, Array<Dsymbol* >* members, bool inObject);
const char* toPrettyChars(bool qualifyTypes = false) override;
ClassDeclaration* syntaxCopy(Dsymbol* s) override;
Scope* newScope(Scope* sc) override;
enum : int32_t { OFFSET_RUNTIME = 1985229328 };

enum : int32_t { OFFSET_FWDREF = 1985229329 };
Expand Down Expand Up @@ -6536,7 +6535,6 @@ class InterfaceDeclaration final : public ClassDeclaration
{
public:
InterfaceDeclaration* syntaxCopy(Dsymbol* s) override;
Scope* newScope(Scope* sc) override;
bool isBaseOf(ClassDeclaration* cd, int32_t* poffset) override;
const char* kind() const override;
int32_t vtblOffset() const override;
Expand Down
Loading