From a2d90fb275962da84611160f8ddd74d934a68dbd Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 4 Aug 2023 15:47:39 -0700 Subject: Redesign `DeclRef` and systematic `Val` deduplication (#3049) * Redesign DeclRef + Deduplicate Val. * Update project files * Fix warning. * Fix. * Fix. * Remove `Val::_equalsImplOverride`. * Rmove `Val::_getHashCodeOverride`. * Remove `semanticVisitor` param from `resolve`. * Cleanups. --------- Co-authored-by: Yong He --- source/slang/slang-ast-dump.cpp | 55 ++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'source/slang/slang-ast-dump.cpp') diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp index 0ab440a18..65718833b 100644 --- a/source/slang/slang-ast-dump.cpp +++ b/source/slang/slang-ast-dump.cpp @@ -65,18 +65,6 @@ struct ASTDumpContext } } - void dump(Substitutions* subs) - { - if (subs == nullptr) - { - _dumpPtr(nullptr); - } - else - { - dumpObject(subs->getClassInfo(), subs); - } - } - void dump(const Name* name) { if (name == nullptr) @@ -608,6 +596,40 @@ struct ASTDumpContext m_writer->emit("\n"); } + template + void dump(const ShortList& operands) + { + m_writer->emit("("); + bool isFirst = true; + for (auto operand : operands) + { + if (!isFirst) + { + m_writer->emit(", "); + } + isFirst = false; + dumpField("operand", operand); + } + + m_writer->emit(")"); + } + + void dump(ValNodeOperand operand) + { + switch (operand.kind) + { + case ValNodeOperandKind::ConstantValue: + dump(operand.values.intOperand); + break; + case ValNodeOperandKind::ValNode: + dump(operand.values.nodeOperand); + break; + case ValNodeOperandKind::ASTNode: + dump(operand.values.nodeOperand); + break; + } + } + void dump(ASTNodeType nodeType) { // Get the class @@ -616,6 +638,15 @@ struct ASTDumpContext m_writer->emit(info->m_name); } + void dump(KeyValuePair pair) + { + m_writer->emit("("); + dump(pair.key); + m_writer->emit(", "); + dump(pair.value); + m_writer->emit(")"); + } + void dumpObjectFull(NodeBase* node); ASTDumpContext(SourceWriter* writer, ASTDumpUtil::Flags flags, ASTDumpUtil::Style dumpStyle): -- cgit v1.2.3