diff --git a/ets2panda/ir/base/classDefinition.cpp b/ets2panda/ir/base/classDefinition.cpp index 5fe57979b3febc8c29b9a88686744169729a3a5f..f097db7d8e8a1390e46c6e8b1f44097cdd07945d 100644 --- a/ets2panda/ir/base/classDefinition.cpp +++ b/ets2panda/ir/base/classDefinition.cpp @@ -31,47 +31,65 @@ namespace ark::es2panda::ir { void ClassDefinition::SetCtor(MethodDefinition *ctor) { - this->GetOrCreateHistoryNodeAs()->ctor_ = ctor; + if (Ctor() != ctor) { + this->GetOrCreateHistoryNodeAs()->ctor_ = ctor; + } } void ClassDefinition::SetTypeParams(TSTypeParameterDeclaration *typeParams) { - this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + if (TypeParams() != typeParams) { + this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + } } void ClassDefinition::SetOrigEnumDecl(TSEnumDeclaration *origEnumDecl) { - this->GetOrCreateHistoryNodeAs()->origEnumDecl_ = origEnumDecl; + if (OrigEnumDecl() != origEnumDecl) { + this->GetOrCreateHistoryNodeAs()->origEnumDecl_ = origEnumDecl; + } } void ClassDefinition::SetAnonClass(ClassDeclaration *anonClass) { - this->GetOrCreateHistoryNodeAs()->anonClass_ = anonClass; + if (GetAnonClass() != anonClass) { + this->GetOrCreateHistoryNodeAs()->anonClass_ = anonClass; + } } void ClassDefinition::SetSuperClass(Expression *superClass) { - this->GetOrCreateHistoryNodeAs()->superClass_ = superClass; + if (SuperClass() != superClass) { + this->GetOrCreateHistoryNodeAs()->superClass_ = superClass; + } } void ClassDefinition::SetSuperTypeParams(TSTypeParameterInstantiation *superTypeParams) { - this->GetOrCreateHistoryNodeAs()->superTypeParams_ = superTypeParams; + if (SuperTypeParams() != superTypeParams) { + this->GetOrCreateHistoryNodeAs()->superTypeParams_ = superTypeParams; + } } void ClassDefinition::SetScope(varbinder::LocalScope *scope) { - this->GetOrCreateHistoryNodeAs()->scope_ = scope; + if (Scope() != scope) { + this->GetOrCreateHistoryNodeAs()->scope_ = scope; + } } void ClassDefinition::SetModifiers(ClassDefinitionModifiers modifiers) { - this->GetOrCreateHistoryNodeAs()->modifiers_ = modifiers; + if (Modifiers() != modifiers) { + this->GetOrCreateHistoryNodeAs()->modifiers_ = modifiers; + } } void ClassDefinition::SetInternalName(util::StringView internalName) { - this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + if (InternalName() != internalName) { + this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + } } void ClassDefinition::EmplaceBody(AstNode *body) @@ -292,8 +310,10 @@ void ClassDefinition::Iterate(const NodeTraverser &cb) const void ClassDefinition::SetIdent(ir::Identifier *ident) noexcept { - auto newNode = this->GetOrCreateHistoryNodeAs(); - newNode->ident_ = ident; + if (Ident() != ident) { + auto newNode = this->GetOrCreateHistoryNodeAs(); + newNode->ident_ = ident; + } if (ident != nullptr) { ident->SetParent(this); } diff --git a/ets2panda/ir/base/classDefinition.h b/ets2panda/ir/base/classDefinition.h index fd71f32cd3f1a783f038df8cb781551345b4e36d..d0b39cbc11995f8d9af4cbb1d90ef74623e074f3 100644 --- a/ets2panda/ir/base/classDefinition.h +++ b/ets2panda/ir/base/classDefinition.h @@ -206,10 +206,12 @@ public: void SetSuper(Expression *superClass) { - auto newNode = this->GetOrCreateHistoryNodeAs(); - newNode->superClass_ = superClass; - if (newNode->superClass_ != nullptr) { - newNode->superClass_->SetParent(this); + if (Super() != superClass) { + auto newNode = this->GetOrCreateHistoryNodeAs(); + newNode->superClass_ = superClass; + } + if (superClass != nullptr) { + superClass->SetParent(this); } } diff --git a/ets2panda/ir/base/classElement.cpp b/ets2panda/ir/base/classElement.cpp index 24c42eeb71e3e6c5ec239cbf148dc7b242d12b50..e705532b4510591a36910d311ec3c3e581c0990a 100644 --- a/ets2panda/ir/base/classElement.cpp +++ b/ets2panda/ir/base/classElement.cpp @@ -22,12 +22,16 @@ namespace ark::es2panda::ir { void ClassElement::SetOrigEnumMember(TSEnumMember *enumMember) { - this->GetOrCreateHistoryNodeAs()->enumMember_ = enumMember; + if (OriginEnumMember() != enumMember) { + this->GetOrCreateHistoryNodeAs()->enumMember_ = enumMember; + } } void ClassElement::SetKey(Expression *key) { - this->GetOrCreateHistoryNodeAs()->key_ = key; + if (Key() != key) { + this->GetOrCreateHistoryNodeAs()->key_ = key; + } } void ClassElement::EmplaceDecorators(Decorator *decorators) diff --git a/ets2panda/ir/base/classProperty.cpp b/ets2panda/ir/base/classProperty.cpp index 2bacec57d1c0375a4dd0d1a93d3bb87634224ae3..4304984cebd212796671d89df8057050952bca31 100644 --- a/ets2panda/ir/base/classProperty.cpp +++ b/ets2panda/ir/base/classProperty.cpp @@ -26,12 +26,16 @@ namespace ark::es2panda::ir { void ClassProperty::SetTypeAnnotation(TypeNode *typeAnnotation) { - this->GetOrCreateHistoryNodeAs()->typeAnnotation_ = typeAnnotation; + if (TypeAnnotation() != typeAnnotation) { + this->GetOrCreateHistoryNodeAs()->typeAnnotation_ = typeAnnotation; + } } void ClassProperty::SetDefaultAccessModifier(bool isDefault) { - this->GetOrCreateHistoryNodeAs()->isDefault_ = isDefault; + if (IsDefaultAccessModifier() != isDefault) { + this->GetOrCreateHistoryNodeAs()->isDefault_ = isDefault; + } } void ClassProperty::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) diff --git a/ets2panda/ir/base/methodDefinition.cpp b/ets2panda/ir/base/methodDefinition.cpp index 6f705a2f977eca5675b1fc2d24eecce979da647c..aa89734abb043abfcf3cf2ab9f7925bafad67190 100644 --- a/ets2panda/ir/base/methodDefinition.cpp +++ b/ets2panda/ir/base/methodDefinition.cpp @@ -26,17 +26,23 @@ namespace ark::es2panda::ir { void MethodDefinition::SetDefaultAccessModifier(bool isDefault) { - this->GetOrCreateHistoryNodeAs()->isDefault_ = isDefault; + if (IsDefaultAccessModifier() != isDefault) { + this->GetOrCreateHistoryNodeAs()->isDefault_ = isDefault; + } } void MethodDefinition::SetBaseOverloadMethod(MethodDefinition *baseOverloadMethod) { - this->GetOrCreateHistoryNodeAs()->baseOverloadMethod_ = baseOverloadMethod; + if (BaseOverloadMethod() != baseOverloadMethod) { + this->GetOrCreateHistoryNodeAs()->baseOverloadMethod_ = baseOverloadMethod; + } } void MethodDefinition::SetAsyncPairMethod(MethodDefinition *asyncPairMethod) { - this->GetOrCreateHistoryNodeAs()->asyncPairMethod_ = asyncPairMethod; + if (AsyncPairMethod() != asyncPairMethod) { + this->GetOrCreateHistoryNodeAs()->asyncPairMethod_ = asyncPairMethod; + } } ScriptFunction *MethodDefinition::Function() diff --git a/ets2panda/ir/base/scriptFunction.cpp b/ets2panda/ir/base/scriptFunction.cpp index 73ef90390f75de42a084ec47c8bf9bbb6816845e..c29f50299f197418390afb26797d7ec99378a797 100644 --- a/ets2panda/ir/base/scriptFunction.cpp +++ b/ets2panda/ir/base/scriptFunction.cpp @@ -27,22 +27,30 @@ namespace ark::es2panda::ir { void ScriptFunction::SetBody(AstNode *body) { - this->GetOrCreateHistoryNodeAs()->body_ = body; + if (Body() != body) { + this->GetOrCreateHistoryNodeAs()->body_ = body; + } } void ScriptFunction::SetSignature(checker::Signature *signature) { - this->GetOrCreateHistoryNodeAs()->signature_ = signature; + if (Signature() != signature) { + this->GetOrCreateHistoryNodeAs()->signature_ = signature; + } } void ScriptFunction::SetScope(varbinder::FunctionScope *scope) { - this->GetOrCreateHistoryNodeAs()->scope_ = scope; + if (Scope() != scope) { + this->GetOrCreateHistoryNodeAs()->scope_ = scope; + } } void ScriptFunction::SetPreferredReturnType(checker::Type *preferredReturnType) { - this->GetOrCreateHistoryNodeAs()->preferredReturnType_ = preferredReturnType; + if (GetPreferredReturnType() != preferredReturnType) { + this->GetOrCreateHistoryNodeAs()->preferredReturnType_ = preferredReturnType; + } } void ScriptFunction::EmplaceParams(Expression *params) @@ -174,7 +182,9 @@ std::size_t ScriptFunction::FormalParamsLength() const noexcept void ScriptFunction::SetIdent(Identifier *id) noexcept { - this->GetOrCreateHistoryNodeAs()->id_ = id; + if (Id() != id) { + this->GetOrCreateHistoryNodeAs()->id_ = id; + } id->SetParent(this); } @@ -215,7 +225,7 @@ void ScriptFunction::TransformChildren(const NodeTransformer &cb, std::string_vi } } - GetOrCreateHistoryNode()->AsScriptFunction()->irSignature_.TransformChildren(cb, transformationName); + GetHistoryNode()->AsScriptFunction()->irSignature_.TransformChildren(cb, transformationName); auto const &body = Body(); if (body != nullptr) { diff --git a/ets2panda/ir/ets/etsFunctionType.h b/ets2panda/ir/ets/etsFunctionType.h index 142e16671c030f44110dc26e1fdf04be458432fb..d4b1e023846a7b13b658b2d154c0474e7a973259 100644 --- a/ets2panda/ir/ets/etsFunctionType.h +++ b/ets2panda/ir/ets/etsFunctionType.h @@ -52,7 +52,9 @@ public: void SetScope(varbinder::Scope *scope) { - GetOrCreateHistoryNodeAs()->scope_ = scope; + if (Scope() != scope) { + GetOrCreateHistoryNodeAs()->scope_ = scope; + } } void ClearScope() noexcept override @@ -97,7 +99,9 @@ public: void SetFunctionalInterface(ir::TSInterfaceDeclaration *functionalInterface) { - GetOrCreateHistoryNodeAs()->functionalInterface_ = functionalInterface; + if (FunctionalInterface() != functionalInterface) { + GetOrCreateHistoryNodeAs()->functionalInterface_ = functionalInterface; + } } ir::ScriptFunctionFlags Flags() diff --git a/ets2panda/ir/ets/etsImportDeclaration.h b/ets2panda/ir/ets/etsImportDeclaration.h index 7f7e56683b221a2bc6ac9471678f65c41a3fe307..1c41189d633c5b572bc2f3fe5ce4ae3544255a5a 100644 --- a/ets2panda/ir/ets/etsImportDeclaration.h +++ b/ets2panda/ir/ets/etsImportDeclaration.h @@ -79,7 +79,9 @@ public: void SetAssemblerName(util::StringView assemblerName) { - GetOrCreateHistoryNode()->AsETSImportDeclaration()->assemblerName_ = assemblerName; + if (AssemblerName() != assemblerName) { + GetOrCreateHistoryNode()->AsETSImportDeclaration()->assemblerName_ = assemblerName; + } } const util::StringView &AssemblerName() const diff --git a/ets2panda/ir/ets/etsParameterExpression.cpp b/ets2panda/ir/ets/etsParameterExpression.cpp index 672d060e2a08ec2ab822eb7c746b074166dabb50..ab9b3e9457e438b2942fc2b741f95538b955ad6b 100644 --- a/ets2panda/ir/ets/etsParameterExpression.cpp +++ b/ets2panda/ir/ets/etsParameterExpression.cpp @@ -24,17 +24,23 @@ namespace ark::es2panda::ir { void ETSParameterExpression::SetRequiredParams(size_t extraValue) { - this->GetOrCreateHistoryNodeAs()->extraValue_ = extraValue; + if (GetRequiredParams() != extraValue) { + this->GetOrCreateHistoryNodeAs()->extraValue_ = extraValue; + } } void ETSParameterExpression::SetLexerSaved(util::StringView savedLexer) { - this->GetOrCreateHistoryNodeAs()->savedLexer_ = savedLexer; + if (LexerSaved() != savedLexer) { + this->GetOrCreateHistoryNodeAs()->savedLexer_ = savedLexer; + } } void ETSParameterExpression::SetSpread(SpreadElement *spread) { - this->GetOrCreateHistoryNodeAs()->spread_ = spread; + if (Spread() != spread) { + this->GetOrCreateHistoryNodeAs()->spread_ = spread; + } } ETSParameterExpression::ETSParameterExpression(AnnotatedExpression *const identOrSpread, bool isOptional, @@ -160,12 +166,12 @@ void ETSParameterExpression::TransformChildren(const NodeTransformer &cb, std::s { auto const spread = Spread(); auto const ident = Ident(); - auto newNode = GetOrCreateHistoryNodeAs(); if (IsRestParameter()) { if (auto *transformedNode = cb(spread); spread != transformedNode) { spread->SetTransformedNode(transformationName, transformedNode); SetSpread(transformedNode->AsRestElement()); } + auto newNode = GetOrCreateHistoryNodeAs(); newNode->ident_ = Spread()->Argument()->AsIdentifier(); } else { if (auto *transformedNode = cb(ident); ident != transformedNode) { diff --git a/ets2panda/ir/ets/etsParameterExpression.h b/ets2panda/ir/ets/etsParameterExpression.h index 976e54149f99a83fb6ea6b93684b221ab2cba7d5..d72f0a5425789e8cb2cf61eff8456e1e19d04d20 100644 --- a/ets2panda/ir/ets/etsParameterExpression.h +++ b/ets2panda/ir/ets/etsParameterExpression.h @@ -54,7 +54,9 @@ public: void SetIdent(Identifier *ident) noexcept { - this->GetOrCreateHistoryNodeAs()->ident_ = ident; + if (Ident() != ident) { + this->GetOrCreateHistoryNodeAs()->ident_ = ident; + } ident->SetParent(this); } @@ -82,13 +84,17 @@ public: void SetOptional(bool value) noexcept { - this->GetOrCreateHistoryNodeAs()->isOptional_ = value; + if (IsOptional() != value) { + this->GetOrCreateHistoryNodeAs()->isOptional_ = value; + } ES2PANDA_ASSERT(IsOptional() || Initializer() == nullptr); } void SetInitializer(Expression *initExpr) noexcept { - this->GetOrCreateHistoryNodeAs()->initializer_ = initExpr; + if (Initializer() != initExpr) { + this->GetOrCreateHistoryNodeAs()->initializer_ = initExpr; + } ES2PANDA_ASSERT(IsOptional() || Initializer() == nullptr); } diff --git a/ets2panda/ir/ets/etsReExportDeclaration.cpp b/ets2panda/ir/ets/etsReExportDeclaration.cpp index 4475c8b08ca38e60ee149065501f58154901a988..84392ad79fbaa3e61837652766998ce65ffdb0fa 100644 --- a/ets2panda/ir/ets/etsReExportDeclaration.cpp +++ b/ets2panda/ir/ets/etsReExportDeclaration.cpp @@ -21,7 +21,9 @@ namespace ark::es2panda::ir { void ETSReExportDeclaration::SetETSImportDeclarations(ETSImportDeclaration *etsImportDeclarations) { - this->GetOrCreateHistoryNodeAs()->etsImportDeclarations_ = etsImportDeclarations; + if (GetETSImportDeclarations() != etsImportDeclarations) { + this->GetOrCreateHistoryNodeAs()->etsImportDeclarations_ = etsImportDeclarations; + } } ETSReExportDeclaration::ETSReExportDeclaration(ETSImportDeclaration *etsImportDeclarations, diff --git a/ets2panda/ir/ets/etsTypeReference.cpp b/ets2panda/ir/ets/etsTypeReference.cpp index 7986198c729d4d33902ce54239119b9df91e4c72..b3a644ff256d5ea7384c76ba0af01ac3e0db2c37 100644 --- a/ets2panda/ir/ets/etsTypeReference.cpp +++ b/ets2panda/ir/ets/etsTypeReference.cpp @@ -24,7 +24,9 @@ namespace ark::es2panda::ir { void ETSTypeReference::SetPart(ETSTypeReferencePart *part) { - this->GetOrCreateHistoryNodeAs()->part_ = part; + if (Part() != part) { + this->GetOrCreateHistoryNodeAs()->part_ = part; + } } void ETSTypeReference::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) diff --git a/ets2panda/ir/ets/etsTypeReferencePart.cpp b/ets2panda/ir/ets/etsTypeReferencePart.cpp index 9dbef072a275a2e41a81acddb471b649f2ec868a..e13abc71a7336a8d15c044e5ec34eff7e04f608b 100644 --- a/ets2panda/ir/ets/etsTypeReferencePart.cpp +++ b/ets2panda/ir/ets/etsTypeReferencePart.cpp @@ -25,17 +25,23 @@ namespace ark::es2panda::ir { void ETSTypeReferencePart::SetName(Expression *name) { - this->GetOrCreateHistoryNodeAs()->name_ = name; + if (Name() != name) { + this->GetOrCreateHistoryNodeAs()->name_ = name; + } } void ETSTypeReferencePart::SetTypeParams(TSTypeParameterInstantiation *typeParams) { - this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + if (TypeParams() != typeParams) { + this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + } } void ETSTypeReferencePart::SetPrevious(ETSTypeReferencePart *prev) { - this->GetOrCreateHistoryNodeAs()->prev_ = prev; + if (Previous() != prev) { + this->GetOrCreateHistoryNodeAs()->prev_ = prev; + } } void ETSTypeReferencePart::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) diff --git a/ets2panda/ir/expression.h b/ets2panda/ir/expression.h index 00c10eaec81bcce401519dc9cef807033c92f126..517319a6ae119a1ee094b89bd9af4117aae6a57d 100644 --- a/ets2panda/ir/expression.h +++ b/ets2panda/ir/expression.h @@ -157,7 +157,9 @@ public: void ClearOptional() noexcept { - GetOrCreateHistoryNodeAs()->optional_ = false; + if (IsOptional()) { + GetOrCreateHistoryNodeAs()->optional_ = false; + } } protected: diff --git a/ets2panda/ir/expressions/identifier.cpp b/ets2panda/ir/expressions/identifier.cpp index 7689fcca3783ffb17e830003d5b1eb4b69be1eac..a108dda5c4a145622927932d6829602781451957 100644 --- a/ets2panda/ir/expressions/identifier.cpp +++ b/ets2panda/ir/expressions/identifier.cpp @@ -60,7 +60,9 @@ Identifier::Identifier(util::StringView const name, TypeNode *const typeAnnotati void Identifier::SetName(const util::StringView &newName) noexcept { ES2PANDA_ASSERT(newName != ERROR_LITERAL); - GetOrCreateHistoryNodeAs()->name_ = newName; + if (Name() != newName) { + GetOrCreateHistoryNodeAs()->name_ = newName; + } } Identifier *Identifier::Clone(ArenaAllocator *const allocator, AstNode *const parent) diff --git a/ets2panda/ir/module/importDeclaration.cpp b/ets2panda/ir/module/importDeclaration.cpp index 161970f5f50147e5d86bb4768247e8a9f2df32ff..b9251485dd3f1f9d211b85d3bbcad359f9d19f62 100644 --- a/ets2panda/ir/module/importDeclaration.cpp +++ b/ets2panda/ir/module/importDeclaration.cpp @@ -26,7 +26,9 @@ namespace ark::es2panda::ir { void ImportDeclaration::SetSource(StringLiteral *source) { - this->GetOrCreateHistoryNodeAs()->source_ = source; + if (Source() != source) { + this->GetOrCreateHistoryNodeAs()->source_ = source; + } } void ImportDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) diff --git a/ets2panda/ir/statements/annotationDeclaration.cpp b/ets2panda/ir/statements/annotationDeclaration.cpp index f353444a467119200613d572cbd67fbcba968163..d94ecdc4cbe3a072cf1c848e5d8913d79953f2c9 100644 --- a/ets2panda/ir/statements/annotationDeclaration.cpp +++ b/ets2panda/ir/statements/annotationDeclaration.cpp @@ -24,12 +24,16 @@ namespace ark::es2panda::ir { void AnnotationDeclaration::SetInternalName(util::StringView internalName) { - this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + if (InternalName() != internalName) { + this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + } } void AnnotationDeclaration::SetExpr(Expression *expr) { - this->GetOrCreateHistoryNodeAs()->expr_ = expr; + if (Expr() != expr) { + this->GetOrCreateHistoryNodeAs()->expr_ = expr; + } } void AnnotationDeclaration::EmplaceProperties(AstNode *properties) diff --git a/ets2panda/ir/statements/annotationDeclaration.h b/ets2panda/ir/statements/annotationDeclaration.h index c3d3b8f2f280616e9dad928cbe0556078a30b3fa..3d3f845abd325e4fd3a6e17891c28c2c745a284e 100644 --- a/ets2panda/ir/statements/annotationDeclaration.h +++ b/ets2panda/ir/statements/annotationDeclaration.h @@ -105,17 +105,23 @@ public: void SetSourceRetention() noexcept { - GetOrCreateHistoryNodeAs()->policy_ = RetentionPolicy::SOURCE; + if (Policy() != RetentionPolicy::SOURCE) { + GetOrCreateHistoryNodeAs()->policy_ = RetentionPolicy::SOURCE; + } } void SetBytecodeRetention() noexcept { - GetOrCreateHistoryNodeAs()->policy_ = RetentionPolicy::BYTECODE; + if (Policy() != RetentionPolicy::BYTECODE) { + GetOrCreateHistoryNodeAs()->policy_ = RetentionPolicy::BYTECODE; + } } void SetRuntimeRetention() noexcept { - GetOrCreateHistoryNodeAs()->policy_ = RetentionPolicy::RUNTIME; + if (Policy() != RetentionPolicy::RUNTIME) { + GetOrCreateHistoryNodeAs()->policy_ = RetentionPolicy::RUNTIME; + } } void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override; @@ -145,12 +151,16 @@ public: void SetScope(varbinder::LocalScope *scope) { ES2PANDA_ASSERT(scope_ == nullptr); - GetOrCreateHistoryNodeAs()->scope_ = scope; + if (Scope() != scope) { + GetOrCreateHistoryNodeAs()->scope_ = scope; + } } void ClearScope() noexcept override { - GetOrCreateHistoryNodeAs()->scope_ = nullptr; + if (Scope() != nullptr) { + GetOrCreateHistoryNodeAs()->scope_ = nullptr; + } } Identifier *GetBaseName() const; diff --git a/ets2panda/ir/statements/classDeclaration.cpp b/ets2panda/ir/statements/classDeclaration.cpp index 398e74f231c4a3fad40511c8d6f3c13d1b066703..8c18aad407b06b13632fe054148451f5cc573549 100644 --- a/ets2panda/ir/statements/classDeclaration.cpp +++ b/ets2panda/ir/statements/classDeclaration.cpp @@ -26,7 +26,9 @@ namespace ark::es2panda::ir { void ClassDeclaration::SetDefinition(ClassDefinition *def) { - this->GetOrCreateHistoryNodeAs()->def_ = def; + if (Definition() != def) { + this->GetOrCreateHistoryNodeAs()->def_ = def; + } } ClassDeclaration *ClassDeclaration::Construct(ArenaAllocator *allocator) diff --git a/ets2panda/ir/statements/functionDeclaration.cpp b/ets2panda/ir/statements/functionDeclaration.cpp index be0f1341c4236c1f037cb58711cdfb5950c63bcd..ac818c46be7c0b6de07803c23c31815828de6267 100644 --- a/ets2panda/ir/statements/functionDeclaration.cpp +++ b/ets2panda/ir/statements/functionDeclaration.cpp @@ -26,7 +26,9 @@ namespace ark::es2panda::ir { void FunctionDeclaration::SetFunction(ScriptFunction *func) { - this->GetOrCreateHistoryNodeAs()->func_ = func; + if (Function() != func) { + this->GetOrCreateHistoryNodeAs()->func_ = func; + } } void FunctionDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) diff --git a/ets2panda/ir/ts/tsEnumDeclaration.cpp b/ets2panda/ir/ts/tsEnumDeclaration.cpp index c3d9c28f0209d0d046394dcbf88c44e6614bb9fb..b7e2a03548d60107c75ebdb49cc5bdc218952999 100644 --- a/ets2panda/ir/ts/tsEnumDeclaration.cpp +++ b/ets2panda/ir/ts/tsEnumDeclaration.cpp @@ -28,17 +28,23 @@ namespace ark::es2panda::ir { void TSEnumDeclaration::SetInternalName(util::StringView internalName) { - this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + if (InternalName() != internalName) { + this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + } } void TSEnumDeclaration::SetBoxedClass(ClassDefinition *boxedClass) { - this->GetOrCreateHistoryNodeAs()->boxedClass_ = boxedClass; + if (BoxedClass() != boxedClass) { + this->GetOrCreateHistoryNodeAs()->boxedClass_ = boxedClass; + } } void TSEnumDeclaration::SetKey(Identifier *key) { - this->GetOrCreateHistoryNodeAs()->key_ = key; + if (Key() != key) { + this->GetOrCreateHistoryNodeAs()->key_ = key; + } } void TSEnumDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) diff --git a/ets2panda/ir/ts/tsEnumDeclaration.h b/ets2panda/ir/ts/tsEnumDeclaration.h index 87bb7c13fd632094d09a98eb9d4f1f3a6b2fc229..ce4b412c49bd853a8f5960f1da71c5e025409314 100644 --- a/ets2panda/ir/ts/tsEnumDeclaration.h +++ b/ets2panda/ir/ts/tsEnumDeclaration.h @@ -89,7 +89,9 @@ public: void SetScope(varbinder::LocalScope *scope) { ES2PANDA_ASSERT(Scope() == nullptr); - GetOrCreateHistoryNode()->AsTSEnumDeclaration()->scope_ = scope; + if (Scope() != scope) { + GetOrCreateHistoryNode()->AsTSEnumDeclaration()->scope_ = scope; + } } void ClearScope() noexcept override diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp index 4455a8b7764190e5cef66af761cd7fd5d742f193..cfb89b5030a4f40291c1059324af4f8d360d8fa6 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp @@ -37,27 +37,37 @@ namespace ark::es2panda::ir { void TSInterfaceDeclaration::SetInternalName(util::StringView internalName) { - this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + if (InternalName() != internalName) { + this->GetOrCreateHistoryNodeAs()->internalName_ = internalName; + } } void TSInterfaceDeclaration::SetAnonClass(ClassDeclaration *anonClass) { - this->GetOrCreateHistoryNodeAs()->anonClass_ = anonClass; + if (GetAnonClass() != anonClass) { + this->GetOrCreateHistoryNodeAs()->anonClass_ = anonClass; + } } void TSInterfaceDeclaration::SetId(Identifier *id) { - this->GetOrCreateHistoryNodeAs()->id_ = id; + if (Id() != id) { + this->GetOrCreateHistoryNodeAs()->id_ = id; + } } void TSInterfaceDeclaration::SetTypeParams(TSTypeParameterDeclaration *typeParams) { - this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + if (TypeParams() != typeParams) { + this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + } } void TSInterfaceDeclaration::SetBody(TSInterfaceBody *body) { - this->GetOrCreateHistoryNodeAs()->body_ = body; + if (Body() != body) { + this->GetOrCreateHistoryNodeAs()->body_ = body; + } } void TSInterfaceDeclaration::EmplaceExtends(TSInterfaceHeritage *extends) diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.h b/ets2panda/ir/ts/tsInterfaceDeclaration.h index 64e6a30e70d85b726d640aee252c352144b97b3b..372f0b35950591f7ea7c41c858a453946b42f22a 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.h +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.h @@ -96,12 +96,16 @@ public: void SetScope(varbinder::LocalScope *scope) { ES2PANDA_ASSERT(Scope() == nullptr); - GetOrCreateHistoryNode()->AsTSInterfaceDeclaration()->scope_ = scope; + if (Scope() != scope) { + GetOrCreateHistoryNode()->AsTSInterfaceDeclaration()->scope_ = scope; + } } void ClearScope() noexcept override { - GetOrCreateHistoryNode()->AsTSInterfaceDeclaration()->scope_ = nullptr; + if (Scope() != nullptr) { + GetOrCreateHistoryNode()->AsTSInterfaceDeclaration()->scope_ = nullptr; + } } TSInterfaceBody *Body() diff --git a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp index 75532d60154cff4050fefed4cab1dfcbdf7e5054..25eabad9bf5c6dbe5391f73dfd59603da14458f3 100644 --- a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp +++ b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp @@ -30,12 +30,16 @@ namespace ark::es2panda::ir { void TSTypeAliasDeclaration::SetTypeParameters(TSTypeParameterDeclaration *typeParams) { - this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + if (TypeParams() != typeParams) { + this->GetOrCreateHistoryNodeAs()->typeParams_ = typeParams; + } } void TSTypeAliasDeclaration::SetId(Identifier *id) { - this->GetOrCreateHistoryNodeAs()->id_ = id; + if (Id() != id) { + this->GetOrCreateHistoryNodeAs()->id_ = id; + } } void TSTypeAliasDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) diff --git a/ets2panda/ir/ts/tsTypeParameter.cpp b/ets2panda/ir/ts/tsTypeParameter.cpp index 4a8d2538091f49b1c2581e45882b1b64083a07af..3ca406011a0b6841099791b446f1341ca176f940 100644 --- a/ets2panda/ir/ts/tsTypeParameter.cpp +++ b/ets2panda/ir/ts/tsTypeParameter.cpp @@ -28,17 +28,23 @@ namespace ark::es2panda::ir { void TSTypeParameter::SetConstraint(TypeNode *constraint) { - this->GetOrCreateHistoryNodeAs()->constraint_ = constraint; + if (Constraint() != constraint) { + this->GetOrCreateHistoryNodeAs()->constraint_ = constraint; + } } void TSTypeParameter::SetDefaultType(TypeNode *defaultType) { - this->GetOrCreateHistoryNodeAs()->defaultType_ = defaultType; + if (DefaultType() != defaultType) { + this->GetOrCreateHistoryNodeAs()->defaultType_ = defaultType; + } } void TSTypeParameter::SetName(Identifier *name) { - this->GetOrCreateHistoryNodeAs()->name_ = name; + if (Name() != name) { + this->GetOrCreateHistoryNodeAs()->name_ = name; + } } void TSTypeParameter::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) diff --git a/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp b/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp index b6d574499828ec0b908aa3377fff49c7ac48b22a..93b379dfe93b743ec6eeaa7bb7c9e33f5e372d5a 100644 --- a/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp +++ b/ets2panda/ir/ts/tsTypeParameterDeclaration.cpp @@ -26,12 +26,16 @@ namespace ark::es2panda::ir { void TSTypeParameterDeclaration::SetScope(varbinder::LocalScope *source) { - this->GetOrCreateHistoryNodeAs()->scope_ = source; + if (Scope() != source) { + this->GetOrCreateHistoryNodeAs()->scope_ = source; + } } void TSTypeParameterDeclaration::SetRequiredParams(size_t source) { - this->GetOrCreateHistoryNodeAs()->requiredParams_ = source; + if (RequiredParams() != source) { + this->GetOrCreateHistoryNodeAs()->requiredParams_ = source; + } } void TSTypeParameterDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName)