[Parse] Make PersistentParserState to hold ParserPosition

instead of PersistentParserState::ParserPos.
This commit is contained in:
Rintaro Ishizaki
2017-12-06 20:45:38 +09:00
parent 574d39bcb6
commit 60bfa893b9
5 changed files with 18 additions and 14 deletions

View File

@@ -261,6 +261,10 @@ public:
return State(getLocForEndOfToken(SourceMgr, Loc));
}
bool isStateForCurrentBuffer(LexerState State) const {
return SourceMgr.findBufferContainingLoc(State.Loc) == getBufferID();
}
/// \brief Restore the lexer state to a given one, that can be located either
/// before or after the current position.
void restoreState(State S, bool enableDiagnostics = false) {

View File

@@ -19,6 +19,7 @@
#include "swift/Basic/SourceLoc.h"
#include "swift/Parse/LocalContext.h"
#include "swift/Parse/ParserPosition.h"
#include "swift/Parse/Scope.h"
#include "llvm/ADT/DenseMap.h"
@@ -114,7 +115,7 @@ private:
DelayedAccessorBodiesTy DelayedAccessorBodies;
/// \brief Parser sets this if it stopped parsing before the buffer ended.
ParserPos MarkedPos;
ParserPosition MarkedPos;
std::unique_ptr<DelayedDeclState> CodeCompletionDelayedDeclState;
@@ -166,16 +167,16 @@ public:
return TopLevelCode;
}
void markParserPosition(SourceLoc Loc, SourceLoc PrevLoc,
void markParserPosition(ParserPosition Pos,
bool InPoundLineEnvironment) {
MarkedPos = {Loc, PrevLoc};
MarkedPos = Pos;
this->InPoundLineEnvironment = InPoundLineEnvironment;
}
/// \brief Returns the marked parser position and resets it.
ParserPos takeParserPosition() {
ParserPos Pos = MarkedPos;
MarkedPos = ParserPos();
ParserPosition takeParserPosition() {
ParserPosition Pos = MarkedPos;
MarkedPos = ParserPosition();
return Pos;
}
};