diff --git a/Import/VlppGlrParser.cpp b/Import/VlppGlrParser.cpp index 316d5aa0..58b35e63 100644 --- a/Import/VlppGlrParser.cpp +++ b/Import/VlppGlrParser.cpp @@ -14,6 +14,7 @@ namespace vl { using namespace collections; using namespace stream; + using namespace astins_slots; /*********************************************************************** JsonVisitorBase @@ -4600,7 +4601,7 @@ PartialExecuteOrdinaryTrace { throw TraceException(*this, { trace, insRef }, TRACE_MAMAGER_PHRASE, L"[CreateObject] context.createStack is empty."); } - ForEachStack(context.createStack, [=](InsExec_Stack* topStack) + ForEachStack(context.createStack, [=, this](InsExec_Stack* topStack) { PushInsRefLink(topStack->createObjectInsRefs, { trace, insRef }); PushStackRefLink(insExec->operatingStacks, topStack); diff --git a/Import/VlppGlrParser.h b/Import/VlppGlrParser.h index 5f86a6e1..607d575e 100644 --- a/Import/VlppGlrParser.h +++ b/Import/VlppGlrParser.h @@ -366,15 +366,28 @@ IAstInsReceiver virtual Ptr Finished() = 0; }; - class AstInsReceiverBase : public Object, public virtual IAstInsReceiver + namespace astins_slots { - private: struct TokenSlot { regex::RegexToken token; vint32_t index = -1; - auto operator<=>(const TokenSlot&) const = default; + auto operator<=>(const TokenSlot& slot) const + { + auto result = token.length <=> slot.token.length; + if (result != 0) return result; + result = token.token <=> slot.token.token; + if (result != 0) return result; + result = token.reading <=> slot.token.reading; + if (result != 0) return result; + return index <=> slot.index; + } + + bool operator==(const TokenSlot& slot) const + { + return (*this <=> slot) == 0; + } }; struct EnumItemSlot @@ -382,22 +395,71 @@ IAstInsReceiver vint32_t value = -1; auto operator<=>(const EnumItemSlot&) const = default; + bool operator==(const EnumItemSlot& slot) const + { + return (*this <=> slot) == 0; + } }; using SlotValue = Variant>; + inline auto operator<=>(const SlotValue& a, const SlotValue& b) + { + auto result = a.Index() <=> b.Index(); + if (result != 0) return result; + switch (a.Index()) + { + case 0: + return a.Get() <=> b.Get(); + case 1: + return a.Get() <=> b.Get(); + case 2: + return a.Get>() <=> b.Get>(); + default: + return std::strong_ordering::equal; + } + } + + inline auto operator==(const SlotValue& a, const SlotValue& b) + { + return (a <=> b) == 0; + } + struct SlotStorage { SlotValue value; Ptr> additionalValues; - auto operator<=>(const SlotStorage&) const = default; + auto operator<=>(const SlotStorage& slotStorage) const + { + auto result = value <=> slotStorage.value; + if (result != 0) return result; + result = static_cast(additionalValues) <=> static_cast(slotStorage.additionalValues); + if (result != 0) return result; + + if (additionalValues) + { + result = collections::CompareEnumerable(*additionalValues.Obj(), *slotStorage.additionalValues.Obj()); + if (result != 0) return result; + } + return std::strong_ordering::equal; + } + + bool operator==(const SlotStorage& slotStorage) const + { + return (*this <=> slotStorage) == 0; + } }; using SlotMap = collections::Dictionary; + } + + class AstInsReceiverBase : public Object, public virtual IAstInsReceiver + { + private: struct StackFrame { - SlotMap slots; + astins_slots::SlotMap slots; ParsingTextPos codeRangeStart; }; using StackFrameList = collections::List; @@ -415,7 +477,7 @@ IAstInsReceiver bool corrupted = false; void EnsureContinuable(); - void SetField(ParsingAstBase* object, vint32_t field, const SlotValue& value, bool weakAssignment); + void SetField(ParsingAstBase* object, vint32_t field, const astins_slots::SlotValue& value, bool weakAssignment); protected: virtual Ptr CreateAstNode(vint32_t type) = 0;