本文整理汇总了C++中AsmToken::getKind方法的典型用法代码示例。如果您正苦于以下问题:C++ AsmToken::getKind方法的具体用法?C++ AsmToken::getKind怎么用?C++ AsmToken::getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsmToken
的用法示例。
在下文中一共展示了AsmToken::getKind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AsLexInput
static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI,
tool_output_file *Out) {
AsmLexer Lexer(MAI);
Lexer.setBuffer(SrcMgr.getMemoryBuffer(SrcMgr.getMainFileID())->getBuffer());
bool Error = false;
while (Lexer.Lex().isNot(AsmToken::Eof)) {
AsmToken Tok = Lexer.getTok();
switch (Tok.getKind()) {
default:
SrcMgr.PrintMessage(Lexer.getLoc(), SourceMgr::DK_Warning,
"unknown token");
Error = true;
break;
case AsmToken::Error:
Error = true; // error already printed.
break;
case AsmToken::Identifier:
Out->os() << "identifier: " << Lexer.getTok().getString();
break;
case AsmToken::Integer:
Out->os() << "int: " << Lexer.getTok().getString();
break;
case AsmToken::Real:
Out->os() << "real: " << Lexer.getTok().getString();
break;
case AsmToken::String:
Out->os() << "string: " << Lexer.getTok().getString();
break;
case AsmToken::Amp: Out->os() << "Amp"; break;
case AsmToken::AmpAmp: Out->os() << "AmpAmp"; break;
case AsmToken::At: Out->os() << "At"; break;
case AsmToken::Caret: Out->os() << "Caret"; break;
case AsmToken::Colon: Out->os() << "Colon"; break;
case AsmToken::Comma: Out->os() << "Comma"; break;
case AsmToken::Dollar: Out->os() << "Dollar"; break;
case AsmToken::Dot: Out->os() << "Dot"; break;
case AsmToken::EndOfStatement: Out->os() << "EndOfStatement"; break;
case AsmToken::Eof: Out->os() << "Eof"; break;
case AsmToken::Equal: Out->os() << "Equal"; break;
case AsmToken::EqualEqual: Out->os() << "EqualEqual"; break;
case AsmToken::Exclaim: Out->os() << "Exclaim"; break;
case AsmToken::ExclaimEqual: Out->os() << "ExclaimEqual"; break;
case AsmToken::Greater: Out->os() << "Greater"; break;
case AsmToken::GreaterEqual: Out->os() << "GreaterEqual"; break;
case AsmToken::GreaterGreater: Out->os() << "GreaterGreater"; break;
case AsmToken::Hash: Out->os() << "Hash"; break;
case AsmToken::LBrac: Out->os() << "LBrac"; break;
case AsmToken::LCurly: Out->os() << "LCurly"; break;
case AsmToken::LParen: Out->os() << "LParen"; break;
case AsmToken::Less: Out->os() << "Less"; break;
case AsmToken::LessEqual: Out->os() << "LessEqual"; break;
case AsmToken::LessGreater: Out->os() << "LessGreater"; break;
case AsmToken::LessLess: Out->os() << "LessLess"; break;
case AsmToken::Minus: Out->os() << "Minus"; break;
case AsmToken::Percent: Out->os() << "Percent"; break;
case AsmToken::Pipe: Out->os() << "Pipe"; break;
case AsmToken::PipePipe: Out->os() << "PipePipe"; break;
case AsmToken::Plus: Out->os() << "Plus"; break;
case AsmToken::RBrac: Out->os() << "RBrac"; break;
case AsmToken::RCurly: Out->os() << "RCurly"; break;
case AsmToken::RParen: Out->os() << "RParen"; break;
case AsmToken::Slash: Out->os() << "Slash"; break;
case AsmToken::Star: Out->os() << "Star"; break;
case AsmToken::Tilde: Out->os() << "Tilde"; break;
}
// Print the token string.
Out->os() << " (\"";
Out->os().write_escaped(Tok.getString());
Out->os() << "\")\n";
}
return Error;
}
示例2: regStr
AsmToken X86AsmLexer::LexTokenATT() {
AsmToken lexedToken = lexDefinite();
switch (lexedToken.getKind()) {
default:
return lexedToken;
case AsmToken::Error:
SetError(Lexer->getErrLoc(), Lexer->getErr());
return lexedToken;
case AsmToken::Percent: {
const AsmToken &nextToken = lexTentative();
if (nextToken.getKind() != AsmToken::Identifier)
return lexedToken;
if (unsigned regID = MatchRegisterName(nextToken.getString())) {
lexDefinite();
// FIXME: This is completely wrong when there is a space or other
// punctuation between the % and the register name.
StringRef regStr(lexedToken.getString().data(),
lexedToken.getString().size() +
nextToken.getString().size());
return AsmToken(AsmToken::Register, regStr,
static_cast<int64_t>(regID));
}
// Match register name failed. If this is "db[0-7]", match it as an alias
// for dr[0-7].
if (nextToken.getString().size() == 3 &&
nextToken.getString().startswith("db")) {
int RegNo = -1;
switch (nextToken.getString()[2]) {
case '0': RegNo = X86::DR0; break;
case '1': RegNo = X86::DR1; break;
case '2': RegNo = X86::DR2; break;
case '3': RegNo = X86::DR3; break;
case '4': RegNo = X86::DR4; break;
case '5': RegNo = X86::DR5; break;
case '6': RegNo = X86::DR6; break;
case '7': RegNo = X86::DR7; break;
}
if (RegNo != -1) {
lexDefinite();
// FIXME: This is completely wrong when there is a space or other
// punctuation between the % and the register name.
StringRef regStr(lexedToken.getString().data(),
lexedToken.getString().size() +
nextToken.getString().size());
return AsmToken(AsmToken::Register, regStr,
static_cast<int64_t>(RegNo));
}
}
return lexedToken;
}
}
}