Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions source/core/core.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
</Expand>
</Type>

<Type Name="Slang::RelativePtr&lt;*,*&gt;">
<SmartPointer Usage="Minimal">_offset == 0 ? nullptr : ($T1*)((char*)this + _offset)</SmartPointer>
<DisplayString Condition="_offset == 0">{($T1*)0}</DisplayString>
<DisplayString Condition="_offset != 0">{($T1*)((char*)this + _offset)}</DisplayString>
<Expand>
<ExpandedItem>_offset == 0 ? nullptr : ($T1*)((char*)this + _offset)</ExpandedItem>
</Expand>
</Type>

<Type Name="Slang::Safe32Ptr&lt;*&gt;">
<Expand>
Expand Down
16 changes: 16 additions & 0 deletions source/core/slang-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,22 @@ UnownedStringSlice UnownedStringSlice::subString(Index idx, Index len) const
return UnownedStringSlice(m_begin + idx, m_begin + idx + len);
}

int compare(UnownedStringSlice const& lhs, UnownedStringSlice const& rhs)
{
auto lhsSize = lhs.getLength();
auto rhsSize = rhs.getLength();

auto lhsData = lhs.begin();
auto rhsData = rhs.begin();

auto sharedPrefixSize = std::min(lhsSize, rhsSize);
int sharedPrefixCmp = memcmp(lhsData, rhsData, sharedPrefixSize);
if (sharedPrefixCmp != 0)
return sharedPrefixCmp;

return int(lhsSize - rhsSize);
}

bool UnownedStringSlice::operator==(ThisType const& other) const
{
// Note that memcmp is undefined when passed in null ptrs, so if we want to handle
Expand Down
8 changes: 8 additions & 0 deletions source/core/slang-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ struct SLANG_RT_API UnownedStringSlice
char const* m_end;
};

/// Three-way comparison of string slices.
///
/// * Returns 0 if `lhs == rhs`
/// * Returns a value < 0 if `lhs < rhs`
/// * Returns a value > 0 if `lhs > rhs`
///
int compare(UnownedStringSlice const& lhs, UnownedStringSlice const& rhs);

// A more convenient way to make slices from *string literals*
template<size_t SIZE>
SLANG_FORCE_INLINE UnownedStringSlice toSlice(const char (&in)[SIZE])
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ast-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class Decl : public DeclBase
/// method, which ensures that the `_prevInContainerWithSameName` fields
/// have been properly set for all declarations in that container.
///
Decl* _prevInContainerWithSameName = nullptr;
FIDDLE() Decl* _prevInContainerWithSameName = nullptr;

bool isChecked(DeclCheckState state) const { return checkState >= state; }
void setCheckState(DeclCheckState state)
Expand Down
Loading
Loading