SMLoc getLoc() const;
+ /// getString - Get the string for the current token, this includes all
+ /// characters (for example, the quotes on strings) in the token.
+ ///
+ /// The returned StringRef points into the source manager's memory buffer, and
+ /// is safe to store across calls to Lex().
StringRef getString() const { return Str; }
// FIXME: Don't compute this in advance, it makes every token larger, and is
bool is(AsmToken::TokenKind K) const { return CurTok.is(K); }
bool isNot(AsmToken::TokenKind K) const { return CurTok.isNot(K); }
- /// getCurStrVal - Get the string for the current token, this includes all
- /// characters (for example, the quotes on strings) in the token.
- ///
- /// The returned StringRef points into the source manager's memory buffer, and
- /// is safe to store across calls to Lex().
- StringRef getCurStrVal() const {
- return CurTok.getString();
- }
- int64_t getCurIntVal() const {
- return CurTok.getIntVal();
- }
-
SMLoc getLoc() const;
-
- const AsmToken &getTok() const;
+
+ /// getTok - Return a reference to the current (last) lexed token.
+ const AsmToken &getTok() const { return CurTok; }
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
bool EnterIncludeFile(const std::string &Filename);
case AsmToken::Identifier: {
// This is a label, this should be parsed as part of an expression, to
// handle things like LFOO+4.
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
// If this is use of an undefined symbol then mark it external.
if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym))
return false;
}
case AsmToken::Integer:
- Res = new AsmConstantExpr(Lexer.getCurIntVal());
+ Res = new AsmConstantExpr(Lexer.getTok().getIntVal());
Lexer.Lex(); // Eat identifier.
return false;
case AsmToken::LParen:
}
// If we have an identifier, handle it as the key symbol.
- SMLoc IDLoc = Lexer.getLoc();
- StringRef IDVal = Lexer.getCurStrVal();
+ AsmToken ID = Lexer.getTok();
+ SMLoc IDLoc = ID.getLoc();
+ StringRef IDVal = ID.getString();
// Consume the identifier, see what is after it.
switch (Lexer.Lex()) {
if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier after '.set' directive");
- StringRef Name = Lexer.getCurStrVal();
+ StringRef Name = Lexer.getTok().getString();
if (Lexer.Lex() != AsmToken::Comma)
return TokError("unexpected token in '.set'");
if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier after '.section' directive");
- std::string Section = Lexer.getCurStrVal();
+ std::string Section = Lexer.getTok().getString();
Lexer.Lex();
// Accept a comma separated list of modifiers.
if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in '.section' directive");
Section += ',';
- Section += Lexer.getCurStrVal().str();
+ Section += Lexer.getTok().getString().str();
Lexer.Lex();
}
// FIXME: This shouldn't use a const char* + strlen, the string could have
// embedded nulls.
// FIXME: Should have accessor for getting string contents.
- StringRef Str = Lexer.getCurStrVal();
+ StringRef Str = Lexer.getTok().getString();
Out.EmitBytes(Str.substr(1, Str.size() - 2));
if (ZeroTerminated)
Out.EmitBytes(StringRef("\0", 1));
if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in directive");
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
Lexer.Lex();
// If this is use of an undefined symbol then mark it external.
// handle the identifier as the key symbol.
SMLoc IDLoc = Lexer.getLoc();
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
Lexer.Lex();
if (Lexer.isNot(AsmToken::Comma))
// handle the identifier as the key symbol.
SMLoc IDLoc = Lexer.getLoc();
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
Lexer.Lex();
if (Lexer.isNot(AsmToken::Comma))
bool AsmParser::ParseDirectiveDarwinZerofill() {
if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected segment name after '.zerofill' directive");
- std::string Section = Lexer.getCurStrVal();
+ std::string Section = Lexer.getTok().getString();
Lexer.Lex();
if (Lexer.isNot(AsmToken::Comma))
if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected section name after comma in '.zerofill' "
"directive");
- Section += Lexer.getCurStrVal().str();
+ Section += Lexer.getTok().getString().str();
Lexer.Lex();
// FIXME: we will need to tell GetSection() that this is to be created with or
// handle the identifier as the key symbol.
SMLoc IDLoc = Lexer.getLoc();
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
Lexer.Lex();
if (Lexer.isNot(AsmToken::Comma))
if (Lexer.isNot(AsmToken::String))
return TokError("expected string in '.abort' directive");
- Str = Lexer.getCurStrVal();
+ Str = Lexer.getTok().getString();
Lexer.Lex();
}
// handle the identifier as the key symbol.
SMLoc IDLoc = Lexer.getLoc();
- MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString());
Lexer.Lex();
if (Lexer.isNot(AsmToken::Comma))
if (Lexer.isNot(AsmToken::String))
return TokError("expected string in '.include' directive");
- std::string Filename = Lexer.getCurStrVal();
+ std::string Filename = Lexer.getTok().getString();
SMLoc IncludeLoc = Lexer.getLoc();
Lexer.Lex();
if (Lexer.isNot(AsmToken::String))
return TokError("expected string in '.dump' or '.load' directive");
- Lexer.getCurStrVal();
-
Lexer.Lex();
if (Lexer.isNot(AsmToken::EndOfStatement))