diff --git a/EqSat/include/Luau/Language.h b/EqSat/include/Luau/Language.h index d606c1db..c3a9fde1 100644 --- a/EqSat/include/Luau/Language.h +++ b/EqSat/include/Luau/Language.h @@ -80,7 +80,7 @@ public: return {}; } - Slice operands() const + Slice operands() const { return {}; } @@ -116,7 +116,7 @@ struct NodeVector { } - const Id& operator[](size_t i) const + Id operator[](size_t i) const { return vector[i]; } @@ -203,9 +203,9 @@ public: return Slice{array}; } - Slice operands() const + Slice operands() const { - return Slice{array}; + return Slice{array.data(), array.size()}; } template @@ -260,7 +260,9 @@ private: using FnDtor = void (*)(void*); using FnPred = bool (*)(const void*, const void*); using FnHash = size_t (*)(const void*); - using FnOper = Slice (*)(void*); + + template + using FnSlice = Slice (*)(std::conditional_t, const void*, void*>); template static void fnCopy(void* dst, const void* src) noexcept @@ -292,10 +294,10 @@ private: return typename T::Hash{}(*static_cast(buffer)); } - template - static Slice fnOper(void* buffer) noexcept + template + static Slice fnOperands(std::conditional_t, const void*, void*> buffer) noexcept { - return static_cast(buffer)->operands(); + return static_cast, const T*, T*>>(buffer)->operands(); } static constexpr FnCopy tableCopy[sizeof...(Ts)] = {&fnCopy...}; @@ -303,7 +305,8 @@ private: static constexpr FnDtor tableDtor[sizeof...(Ts)] = {&fnDtor...}; static constexpr FnPred tablePred[sizeof...(Ts)] = {&fnPred...}; static constexpr FnHash tableHash[sizeof...(Ts)] = {&fnHash...}; - static constexpr FnOper tableOper[sizeof...(Ts)] = {&fnOper...}; + static constexpr FnSlice tableSliceId[sizeof...(Ts)] = {&fnOperands...}; + static constexpr FnSlice tableSliceConstId[sizeof...(Ts)] = {&fnOperands...}; static constexpr int getIndexFromTag(const char* tag) noexcept { @@ -369,12 +372,12 @@ public: /// Reading is ok, but you should also never assume that these `Id`s are stable. Slice operands() noexcept { - return tableOper[getIndexFromTag(tag)](&buffer); + return tableSliceId[getIndexFromTag(tag)](&buffer); } - Slice operands() const noexcept + Slice operands() const noexcept { - return const_cast(this)->operands(); + return tableSliceConstId[getIndexFromTag(tag)](&buffer); } template