-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ASTScope: Redo 'selfDC' computation #33989
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
Merged
slavapestov
merged 7 commits into
swiftlang:master
from
slavapestov:astscope-self-dc-cleanup
Sep 19, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d7f4b1a
AST: Capture list bindings now point back to their parent CaptureList…
slavapestov 38883ce
ASTScope: Remove unused shouldCreateAccessorScope() method
slavapestov 9c4c959
AST: Generalize CaptureListEntry::isSimpleSelfCapture() to work witho…
slavapestov 9b851bf
ASTScope: Collapse PureFunctionBodyScope and MethodBodyScope
slavapestov ed17c33
ASTScope: Compute 'selfDC' directly in ASTScopeDeclConsumerForUnquali…
slavapestov 7cb809b
ASTScope: Remove old implementation of 'selfDC' computation
slavapestov d4cc35a
AST: Remove VarDecl::hasNonPatternBindingInit()
slavapestov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ namespace swift { | |
class DynamicSelfType; | ||
class Type; | ||
class Expr; | ||
class CaptureListExpr; | ||
class DeclRefExpr; | ||
class ForeignAsyncConvention; | ||
class ForeignErrorConvention; | ||
|
@@ -352,21 +353,13 @@ class alignas(1 << DeclAlignInBits) Decl { | |
IsStatic : 1 | ||
); | ||
|
||
SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 1+1+1+1+1+1+1+1, | ||
SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 1+1+1+1+1+1, | ||
/// Encodes whether this is a 'let' binding. | ||
Introducer : 1, | ||
|
||
/// Whether this declaration was an element of a capture list. | ||
IsCaptureList : 1, | ||
|
||
/// Whether this declaration captures the 'self' param under the same name. | ||
IsSelfParamCapture : 1, | ||
|
||
/// Whether this vardecl has an initial value bound to it in a way | ||
/// that isn't represented in the AST with an initializer in the pattern | ||
/// binding. This happens in cases like "for i in ...", switch cases, etc. | ||
HasNonPatternBindingInit : 1, | ||
|
||
/// Whether this is a property used in expressions in the debugger. | ||
/// It is up to the debugger to instruct SIL how to access this variable. | ||
IsDebuggerVar : 1, | ||
|
@@ -4892,16 +4885,19 @@ class VarDecl : public AbstractStorageDecl { | |
}; | ||
|
||
protected: | ||
PointerUnion<PatternBindingDecl *, Stmt *, VarDecl *> Parent; | ||
PointerUnion<PatternBindingDecl *, | ||
Stmt *, | ||
VarDecl *, | ||
CaptureListExpr *> Parent; | ||
|
||
VarDecl(DeclKind kind, bool isStatic, Introducer introducer, | ||
bool isCaptureList, SourceLoc nameLoc, Identifier name, | ||
DeclContext *dc, StorageIsMutable_t supportsMutation); | ||
SourceLoc nameLoc, Identifier name, DeclContext *dc, | ||
StorageIsMutable_t supportsMutation); | ||
|
||
public: | ||
VarDecl(bool isStatic, Introducer introducer, bool isCaptureList, | ||
VarDecl(bool isStatic, Introducer introducer, | ||
SourceLoc nameLoc, Identifier name, DeclContext *dc) | ||
: VarDecl(DeclKind::Var, isStatic, introducer, isCaptureList, nameLoc, | ||
: VarDecl(DeclKind::Var, isStatic, introducer, nameLoc, | ||
name, dc, StorageIsMutable_t(introducer == Introducer::Var)) {} | ||
|
||
SourceRange getSourceRange() const; | ||
|
@@ -5091,25 +5087,29 @@ class VarDecl : public AbstractStorageDecl { | |
Bits.VarDecl.Introducer = uint8_t(value); | ||
} | ||
|
||
CaptureListExpr *getParentCaptureList() const { | ||
if (!Parent) | ||
return nullptr; | ||
return Parent.dyn_cast<CaptureListExpr *>(); | ||
} | ||
|
||
/// Set \p v to be the pattern produced VarDecl that is the parent of this | ||
/// var decl. | ||
void setParentCaptureList(CaptureListExpr *expr) { | ||
assert(expr != nullptr); | ||
Parent = expr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can |
||
} | ||
/// Is this an element in a capture list? | ||
bool isCaptureList() const { return Bits.VarDecl.IsCaptureList; } | ||
bool isCaptureList() const { | ||
return getParentCaptureList() != nullptr; | ||
} | ||
|
||
/// Is this a capture of the self param? | ||
bool isSelfParamCapture() const { return Bits.VarDecl.IsSelfParamCapture; } | ||
void setIsSelfParamCapture(bool IsSelfParamCapture = true) { | ||
Bits.VarDecl.IsSelfParamCapture = IsSelfParamCapture; | ||
} | ||
|
||
/// Return true if this vardecl has an initial value bound to it in a way | ||
/// that isn't represented in the AST with an initializer in the pattern | ||
/// binding. This happens in cases like "for i in ...", switch cases, etc. | ||
bool hasNonPatternBindingInit() const { | ||
return Bits.VarDecl.HasNonPatternBindingInit; | ||
} | ||
void setHasNonPatternBindingInit(bool V = true) { | ||
Bits.VarDecl.HasNonPatternBindingInit = V; | ||
} | ||
|
||
/// Determines if this var has an initializer expression that should be | ||
/// exposed to clients. | ||
/// There's a very narrow case when we would: if the decl is an instance | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice clean up.