mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-12 19:31:47 +00:00
Allow parsing arbitrary source code fragments.
This commit is contained in:
parent
16bc01551e
commit
ef1c8e8512
@ -60,10 +60,27 @@ void SourceContents::Parse( const char* fileName, const Worker& worker, const Vi
|
||||
}
|
||||
}
|
||||
|
||||
if( m_file )
|
||||
{
|
||||
if( m_file ) Tokenize( m_data, sz );
|
||||
}
|
||||
}
|
||||
|
||||
void SourceContents::Parse( const char* source )
|
||||
{
|
||||
if( source == m_data ) return;
|
||||
|
||||
const size_t len = strlen( source );
|
||||
|
||||
m_file = nullptr;
|
||||
m_fileStringIdx = 0;
|
||||
m_data = source;
|
||||
m_dataBuf = nullptr;
|
||||
m_dataSize = len;
|
||||
Tokenize( source, len );
|
||||
}
|
||||
|
||||
void SourceContents::Tokenize( const char* txt, size_t sz )
|
||||
{
|
||||
Tokenizer tokenizer;
|
||||
auto txt = m_data;
|
||||
for(;;)
|
||||
{
|
||||
auto end = txt;
|
||||
@ -83,8 +100,6 @@ void SourceContents::Parse( const char* fileName, const Worker& worker, const Vi
|
||||
if( end - m_data == sz ) break;
|
||||
txt = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
~SourceContents();
|
||||
|
||||
void Parse( const char* fileName, const Worker& worker, const View& view );
|
||||
void Parse( const char* source );
|
||||
|
||||
const std::vector<Tokenizer::Line>& get() const { return m_lines; }
|
||||
bool empty() const { return m_lines.empty(); }
|
||||
@ -31,6 +32,8 @@ public:
|
||||
size_t data_size() const { return m_dataSize; }
|
||||
|
||||
private:
|
||||
void Tokenize( const char* txt, size_t sz );
|
||||
|
||||
const char* m_file;
|
||||
uint32_t m_fileStringIdx;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user