-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make several improvements and fixes to `EvalString`. * Change the member variable to store the last text segment length (or 0 if the last section is a variable). This keeps things more understandable and doesn't lose any functionality. * Remove the initial `Offset` value pushed into `EvalString` in the constructor and `clear()` methods as this is not necessary. * Assert that text and variables passed in are not empty and check that this cannot happen (the Ninja lexer will complain that the file is not correct) * Add a natvis file for easy debugging.
- Loading branch information
1 parent
f854fd3
commit 8e7ff72
Showing
5 changed files
with
62 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> | ||
<Type Name="trimja::EvalString"> | ||
<Expand> | ||
<CustomListItems MaxItemsPerView="100"> | ||
<Variable Name="mask" InitialValue="((trimja::EvalString::Offset)1) << (sizeof(trimja::EvalString::Offset) * 8 - 1)"/> | ||
<Variable Name="rawLength" InitialValue="(trimja::EvalString::Offset)0"/> | ||
<Variable Name="isVariable" InitialValue="false"/> | ||
<Variable Name="length" InitialValue="(trimja::EvalString::Offset)0"/> | ||
<Variable Name="it" InitialValue="m_data.isShortString() ? m_data._Mypair._Myval2._Bx._Buf : m_data._Mypair._Myval2._Bx._Ptr"/> | ||
<Loop> | ||
<Break Condition="*it == '\0'" /> | ||
<Exec>rawLength = *(const trimja::EvalString::Offset*)it</Exec> | ||
<Exec>isVariable = (rawLength & mask)</Exec> | ||
<Exec>length = rawLength & ~mask</Exec> | ||
<If Condition="isVariable"> | ||
<Item Name="var">it + sizeof(trimja::EvalString::Offset),[length]s8b</Item> | ||
</If> | ||
<If Condition="!isVariable"> | ||
<Item Name="text">it + sizeof(trimja::EvalString::Offset),[length]s8</Item> | ||
</If> | ||
<Exec>it += length + sizeof(length)</Exec> | ||
</Loop> | ||
</CustomListItems> | ||
</Expand> | ||
</Type> | ||
|
||
<Type Name="trimja::EvalString::const_iterator"> | ||
<Intrinsic Name="isEnd" Expression="*m_pos == '\0'"/> | ||
<Intrinsic Name="rawLength" Expression="*(const trimja::EvalString::Offset*)m_pos"/> | ||
<Intrinsic Name="mask" Expression="(trimja::EvalString::Offset)1 << (sizeof(trimja::EvalString::Offset) * 8 - 1)"/> | ||
<Intrinsic Name="isVariable" Expression="(rawLength() & mask()) != 0"/> | ||
<Intrinsic Name="length" Expression="rawLength() & ~mask()"/> | ||
<DisplayString Condition="isEnd()">{{ end }}</DisplayString> | ||
<DisplayString Condition="!isEnd() && isVariable()">{{ var = {m_pos + sizeof(trimja::EvalString::Offset),[length()]s8b} }}</DisplayString> | ||
<DisplayString Condition="!isEnd() && !isVariable()">{{ text = {m_pos + sizeof(trimja::EvalString::Offset),[length()]s8} }}</DisplayString> | ||
</Type> | ||
</AutoVisualizer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters