Dummy tokenization of asm operands.

This commit is contained in:
Bartosz Taudul 2022-09-16 00:30:29 +02:00
parent 4913f0e1e6
commit d823a24534
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
4 changed files with 34 additions and 0 deletions

View File

@ -351,4 +351,26 @@ out:
return TokenColor::Default;
}
std::vector<Tokenizer::AsmToken> Tokenizer::TokenizeAsm( const char* begin, const char* end )
{
std::vector<AsmToken> ret;
while( begin != end )
{
while( begin != end && isspace( (uint8_t)*begin ) ) begin++;
const auto pos = begin;
const auto col = IdentifyAsmToken( begin, end );
ret.emplace_back( AsmToken { pos, begin, col } );
}
return ret;
}
Tokenizer::AsmTokenColor Tokenizer::IdentifyAsmToken( const char*& begin, const char* end )
{
static const auto s_regs = GetAsmRegs();
static const auto s_sizes = GetAsmSizeDirectives();
begin = end;
return AsmTokenColor::Default;
}
}

View File

@ -47,12 +47,21 @@ public:
Literal, // 0x04, etc
};
struct AsmToken
{
const char* begin;
const char* end;
AsmTokenColor color;
};
Tokenizer();
std::vector<Token> Tokenize( const char* begin, const char* end );
std::vector<AsmToken> TokenizeAsm( const char* begin, const char* end );
private:
TokenColor IdentifyToken( const char*& begin, const char* end );
AsmTokenColor IdentifyAsmToken( const char*& begin, const char* end );
bool m_isInComment;
bool m_isInPreprocessor;

View File

@ -891,6 +891,8 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
}
}
m_asm.emplace_back( AsmLine { op.address, jumpAddr, op.mnemonic, op.op_str, (uint8_t)op.size, leaData, opType, jumpConditional, std::move( params ) } );
const auto& operands = m_asm.back().operands;
m_asm.back().opTokens = m_tokenizer.TokenizeAsm( operands.c_str(), operands.c_str() + operands.size() );
#if CS_API_MAJOR >= 4
auto& entry = m_asm.back();

View File

@ -98,6 +98,7 @@ private:
OpType opType;
bool jumpConditional;
std::vector<AsmOpParams> params;
std::vector<Tokenizer::AsmToken> opTokens;
union
{
RegsX86 readX86[12];