Skip to content

Commit 3b7131c

Browse files
committed
Factor each variant into a separate function. Facter out Decl dispatch.
1 parent e9298a1 commit 3b7131c

File tree

2 files changed

+471
-222
lines changed

2 files changed

+471
-222
lines changed

include/swift/AST/NameLookup.h

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ class UnqualifiedLookup {
108108
///
109109
/// If the current DeclContext is nested in a function body, the SourceLoc
110110
/// is used to determine which declarations in that body are visible.
111-
UnqualifiedLookup(const char* dummy, DeclName Name, DeclContext *DC, LazyResolver *TypeResolver,
112-
SourceLoc Loc = SourceLoc(), Options options = Options());
111+
UnqualifiedLookup(const char *dummy, DeclName Name, DeclContext *DC,
112+
LazyResolver *TypeResolver, SourceLoc Loc = SourceLoc(),
113+
Options options = Options());
113114
UnqualifiedLookup(DeclName Name, DeclContext *DC, LazyResolver *TypeResolver,
114115
SourceLoc Loc = SourceLoc(), Options options = Options());
115116

@@ -127,14 +128,18 @@ class UnqualifiedLookup {
127128

128129
/// Get the result as a single type, or a null type if that fails.
129130
TypeDecl *getSingleTypeResult();
131+
132+
public: // for exp debugging
133+
SourceFile const *recordedSF = nullptr;
134+
DeclName recordedName;
135+
bool recordedIsCascadingUse = false;
130136
};
131137

132138
inline UnqualifiedLookup::Options operator|(UnqualifiedLookup::Flags flag1,
133139
UnqualifiedLookup::Flags flag2) {
134140
return UnqualifiedLookup::Options(flag1) | flag2;
135141
}
136142

137-
138143
/// This class implements and represents the result of performing
139144
/// unqualified lookup (i.e. lookup for a plain identifier).
140145
class ExpUnqualifiedLookup {
@@ -147,8 +152,9 @@ inline UnqualifiedLookup::Options operator|(UnqualifiedLookup::Flags flag1,
147152
///
148153
/// If the current DeclContext is nested in a function body, the SourceLoc
149154
/// is used to determine which declarations in that body are visible.
150-
ExpUnqualifiedLookup(DeclName Name, DeclContext *DC, LazyResolver *TypeResolver,
151-
SourceLoc Loc = SourceLoc(), Options options = Options());
155+
ExpUnqualifiedLookup(DeclName Name, DeclContext *DC,
156+
LazyResolver *TypeResolver, SourceLoc Loc = SourceLoc(),
157+
Options options = Options());
152158

153159
SmallVector<LookupResultEntry, 4> Results;
154160
/// The index of the first result that isn't from the innermost scope
@@ -186,6 +192,27 @@ inline UnqualifiedLookup::Options operator|(UnqualifiedLookup::Flags flag1,
186192
}
187193

188194
bool verifyEqual(const UnqualifiedLookup &) const;
195+
196+
public: // for exp debugging
197+
SourceFile const *recordedSF = nullptr;
198+
DeclName recordedName;
199+
bool recordedIsCascadingUse = false;
200+
201+
using LookupDecls = SmallVector<NominalTypeDecl *, 2>;
202+
enum class ScopeLookupResult { next, stop, finished };
203+
struct PerScopeLookupState {
204+
ScopeLookupResult result;
205+
DeclContext *nextDC;
206+
LookupDecls foundDecls;
207+
DeclContext *BaseDC;
208+
DeclContext *MetaBaseDC;
209+
Optional<bool> isCascadingUse;
210+
GenericParamList *GenericParams;
211+
212+
void dump() const;
213+
};
214+
std::vector<PerScopeLookupState> breadcrumbs;
215+
void dumpBreadcrumbs() const;
189216
};
190217

191218
/// Describes the reason why a certain declaration is visible.

0 commit comments

Comments
 (0)