Skip to content

[Parse] refactor get/set block parsing #19046

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
merged 2 commits into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 2 additions & 15 deletions include/swift/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,25 +379,14 @@ class Parser {

void restoreParserPosition(ParserPosition PP, bool enableDiagnostics = false) {
L->restoreState(PP.LS, enableDiagnostics);

// We might be at tok::eof now, so ensure that consumeToken() does not
// assert about lexing past eof.
Tok.setKind(tok::unknown);
consumeTokenWithoutFeedingReceiver();

L->lex(Tok, LeadingTrivia, TrailingTrivia);
PreviousLoc = PP.PreviousLoc;
}

void backtrackToPosition(ParserPosition PP) {
assert(PP.isValid());

L->backtrackToState(PP.LS);

// We might be at tok::eof now, so ensure that consumeToken() does not
// assert about lexing past eof.
Tok.setKind(tok::unknown);
consumeTokenWithoutFeedingReceiver();

L->lex(Tok, LeadingTrivia, TrailingTrivia);
PreviousLoc = PP.PreviousLoc;
}

Expand Down Expand Up @@ -896,8 +885,6 @@ class Parser {

void consumeGetSetBody(AbstractFunctionDecl *AFD, SourceLoc LBLoc);

void parseAccessorAttributes(DeclAttributes &Attributes);

struct ParsedAccessors;
bool parseGetSetImpl(ParseDeclOptions Flags,
GenericParamList *GenericParams,
Expand Down
29 changes: 0 additions & 29 deletions include/swift/Parse/PersistentParserState.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,6 @@ class PersistentParserState {
{}
};

class AccessorBodyState {
ParserPos BodyPos;
SavedScope Scope;
SourceLoc LBLoc;
friend class Parser;

SavedScope takeScope() {
return std::move(Scope);
}

public:
AccessorBodyState(SourceRange BodyRange, SourceLoc PreviousLoc,
SavedScope &&Scope, SourceLoc LBLoc)
: BodyPos{BodyRange.Start, PreviousLoc}, Scope(std::move(Scope)),
LBLoc(LBLoc) {}
};

enum class DelayedDeclKind {
TopLevelCodeDecl,
Decl,
Expand Down Expand Up @@ -109,11 +92,6 @@ class PersistentParserState {
std::unique_ptr<FunctionBodyState>>;
DelayedFunctionBodiesTy DelayedFunctionBodies;

using DelayedAccessorBodiesTy =
llvm::DenseMap<AbstractFunctionDecl *,
std::unique_ptr<AccessorBodyState>>;
DelayedAccessorBodiesTy DelayedAccessorBodies;

/// \brief Parser sets this if it stopped parsing before the buffer ended.
ParserPosition MarkedPos;

Expand All @@ -133,13 +111,6 @@ class PersistentParserState {

bool hasFunctionBodyState(AbstractFunctionDecl *AFD);

void delayAccessorBodyParsing(AbstractFunctionDecl *AFD,
SourceRange BodyRange,
SourceLoc PreviousLoc,
SourceLoc LBLoc);
std::unique_ptr<AccessorBodyState>
takeAccessorBodyState(AbstractFunctionDecl *AFD);

void delayDecl(DelayedDeclKind Kind, unsigned Flags,
DeclContext *ParentContext,
SourceRange BodyRange, SourceLoc PreviousLoc);
Expand Down
Loading