diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-16 06:14:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-16 06:14:39 +0000 |
commit | 693fbb8fee1ce39a8729587f910fc916a76ced23 (patch) | |
tree | 1e2f40e97054264d29019e11374f534db7284f35 /llvm/tools/llvm-mc/AsmLexer.cpp | |
parent | 3afa3e1d918058af30c2dae3902d2852a4198d71 (diff) | |
download | bcm5719-llvm-693fbb8fee1ce39a8729587f910fc916a76ced23.tar.gz bcm5719-llvm-693fbb8fee1ce39a8729587f910fc916a76ced23.zip |
implement .include in the lexer/parser instead of passing it into the streamer.
llvm-svn: 75896
Diffstat (limited to 'llvm/tools/llvm-mc/AsmLexer.cpp')
-rw-r--r-- | llvm/tools/llvm-mc/AsmLexer.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mc/AsmLexer.cpp b/llvm/tools/llvm-mc/AsmLexer.cpp index 7b744fbde65..6ee91455b71 100644 --- a/llvm/tools/llvm-mc/AsmLexer.cpp +++ b/llvm/tools/llvm-mc/AsmLexer.cpp @@ -54,6 +54,21 @@ asmtok::TokKind AsmLexer::ReturnError(const char *Loc, const std::string &Msg) { return asmtok::Error; } +/// EnterIncludeFile - Enter the specified file. This prints an error and +/// returns true on failure. +bool AsmLexer::EnterIncludeFile(const std::string &Filename) { + int NewBuf = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr)); + if (NewBuf == -1) + return true; + + // Save the line number and lex buffer of the includer. + CurBuffer = NewBuf; + CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); + CurPtr = CurBuf->getBufferStart(); + return false; +} + + int AsmLexer::getNextChar() { char CurChar = *CurPtr++; switch (CurChar) { @@ -72,6 +87,10 @@ int AsmLexer::getNextChar() { CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc); CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); CurPtr = ParentIncludeLoc.getPointer(); + + // Reset the token start pointer to the start of the new file. + TokStart = CurPtr; + return getNextChar(); } |