symbol: Add operator<()
Change-Id: I8e3eafd775a3aaa20cf8425e45f5bcae1e9e9851 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60206 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
fb91e3c8f3
commit
13969024c9
|
@ -37,6 +37,12 @@ bool Symbol::operator==(const Symbol& other) const {
|
||||||
return val_ == other.val_;
|
return val_ == other.val_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Symbol::operator<(const Symbol& other) const {
|
||||||
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Symbol, program_id_,
|
||||||
|
other.program_id_);
|
||||||
|
return val_ < other.val_;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Symbol::to_str() const {
|
std::string Symbol::to_str() const {
|
||||||
return "$" + std::to_string(val_);
|
return "$" + std::to_string(val_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,11 @@ class Symbol {
|
||||||
/// @returns true if the symbols are the same
|
/// @returns true if the symbols are the same
|
||||||
bool operator==(const Symbol& o) const;
|
bool operator==(const Symbol& o) const;
|
||||||
|
|
||||||
|
/// Less-than operator
|
||||||
|
/// @param o the other symbol
|
||||||
|
/// @returns true if this symbol is ordered before symbol `o`
|
||||||
|
bool operator<(const Symbol& o) const;
|
||||||
|
|
||||||
/// @returns true if the symbol is valid
|
/// @returns true if the symbol is valid
|
||||||
bool IsValid() const { return val_ != static_cast<uint32_t>(-1); }
|
bool IsValid() const { return val_ != static_cast<uint32_t>(-1); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue