diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 5b08e72fe6e600776d6686a52e1bd0f32e7d4ef2..0a724cf0d7e6f21d80a75d3dfc640b4b1a9d6e4e 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -675,8 +675,7 @@ void ETSGen::BranchIfIsInstance(const ir::AstNode *const node, const VReg srcReg void ETSGen::IsInstance(const ir::AstNode *const node, const VReg srcReg, const checker::Type *target) { target = Checker()->GetApparentType(target); - ES2PANDA_ASSERT(target != nullptr); - ES2PANDA_ASSERT(target->IsETSReferenceType() && GetAccumulatorType() != nullptr); + ES2PANDA_ASSERT(target != nullptr && target->IsETSReferenceType() && GetAccumulatorType() != nullptr); if (target->IsETSAnyType()) { // should be IsSupertypeOf(target, source) LoadAccumulatorBoolean(node, true); @@ -1978,6 +1977,7 @@ static std::optional> SelectL ES2PANDA_ASSERT(alhs != nullptr && arhs != nullptr); alhs = alhs->IsETSStringType() ? checker->GlobalBuiltinETSStringType() : alhs; arhs = arhs->IsETSStringType() ? checker->GlobalBuiltinETSStringType() : arhs; + ES2PANDA_ASSERT(alhs != nullptr && arhs != nullptr); if (!alhs->IsETSObjectType() || !arhs->IsETSObjectType()) { return std::nullopt; } diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index 8db2e4c678fc9769adbcfd0cfafe417f656c7ac7..8a1fad31ae7248628e6545271e15a9825218e500 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -345,6 +345,7 @@ void EnumLoweringPhase::CreateCCtorForEnumClass(ir::ClassDefinition *const enumC ir::ScriptFunctionFlags::STATIC_BLOCK | ir::ScriptFunctionFlags::HIDDEN, ir::ModifierFlags::STATIC, Language(Language::Id::ETS)}); + ES2PANDA_ASSERT(func != nullptr); func->SetIdent(id); id->SetParent(func); diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index c5a750ef4538fe80e89d750b8958610e26b9c6ee..7e8115aa0605a7847aa2d53149f81f9082adccc0 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -78,6 +78,7 @@ ir::FunctionSignature InterfacePropertyDeclarationsPhase::GenerateGetterOrSetter if (isSetter) { auto paramIdent = field->Key()->AsIdentifier()->Clone(ctx->Allocator(), nullptr); + ES2PANDA_ASSERT(paramIdent != nullptr); paramIdent->SetTsTypeAnnotation(field->TypeAnnotation()->Clone(ctx->Allocator(), nullptr)); paramIdent->TypeAnnotation()->SetParent(paramIdent); diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index 780c1346a8de45da66b1ccd3040cffeef8875a04..94db1887d7a1c843dd3d7155e8df1401b3c4a36c 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -989,6 +989,7 @@ void InitScopesPhaseETS::DeclareClassMethod(ir::MethodDefinition *method) } const auto methodName = method->Id(); + ES2PANDA_ASSERT(methodName != nullptr); auto *const clsScope = VarBinder()->GetScope()->AsClassScope(); auto options = method->IsStatic() @@ -1029,8 +1030,9 @@ void InitScopesPhaseETS::MaybeAddOverload(ir::MethodDefinition *method, ir::Iden methodName->SetVariable(var); } for (auto *overload : method->Overloads()) { - ES2PANDA_ASSERT((overload->Function()->Flags() & ir::ScriptFunctionFlags::OVERLOAD) || - (overload->Function()->Flags() & ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD)); + ES2PANDA_ASSERT(overload->Id() != nullptr && + ((overload->Function()->Flags() & ir::ScriptFunctionFlags::OVERLOAD) || + (overload->Function()->Flags() & ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD))); overload->Id()->SetVariable(var); overload->SetParent(var->Declaration()->Node()); } @@ -1210,6 +1212,7 @@ void InitScopesPhaseETS::VisitMethodDefinition(ir::MethodDefinition *method) auto *curScope = VarBinder()->GetScope(); const auto methodName = method->Id(); + ES2PANDA_ASSERT(methodName != nullptr); auto res = curScope->Find(methodName->Name(), method->IsStatic() ? varbinder::ResolveBindingOptions::ALL_STATIC : varbinder::ResolveBindingOptions::ALL_NON_STATIC); diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index 2b9490bd7abc70ad54b9bc80a62e319a10e5285b..bc544f0631ac06023e9935aaead84e8acbd664f7 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -345,6 +345,7 @@ void ETSBinder::ResolveInterfaceDeclaration(ir::TSInterfaceDeclaration *decl) auto fieldVar = ResolvePropertyReference(stmt->AsClassProperty(), decl->Scope()->AsClassScope()) ->FindLocal(stmt->AsClassProperty()->Id()->Name(), varbinder::ResolveBindingOptions::BINDINGS); + ES2PANDA_ASSERT(fieldVar != nullptr); fieldVar->AddFlag(VariableFlags::INITIALIZED); } @@ -418,6 +419,7 @@ void ETSBinder::ResolveMethodDefinition(ir::MethodDefinition *methodDef) methodDef->ResolveReferences([this](auto *childNode) { ResolveReference(childNode); }); auto *func = methodDef->Function(); + ES2PANDA_ASSERT(func != nullptr); for (auto *anno : func->Annotations()) { ResolveReference(anno); } @@ -597,6 +599,7 @@ void AddOverloadFlag(ArenaAllocator *allocator, bool isStdLib, varbinder::Variab ES2PANDA_ASSERT(method->Function() != nullptr); if (!method->Overloads().empty() && !method->HasOverload(currentNode)) { method->AddOverload(currentNode); + ES2PANDA_ASSERT(currentNode->Function() != nullptr); currentNode->Function()->Id()->SetVariable(importedVar); currentNode->Function()->AddFlag(ir::ScriptFunctionFlags::OVERLOAD); currentNode->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD); @@ -1497,6 +1500,7 @@ bool ETSBinder::ImportGlobalPropertiesForNotDefaultedExports(varbinder::Variable return true; } + ES2PANDA_ASSERT(classElement->Id() != nullptr); ThrowRedeclarationError(classElement->Id()->Start(), var, variable, name.Utf8()); } @@ -1509,6 +1513,7 @@ bool ETSBinder::ImportGlobalPropertiesForNotDefaultedExports(varbinder::Variable return true; } + ES2PANDA_ASSERT(classElement->Id() != nullptr); ThrowRedeclarationError(classElement->Id()->Start(), var, insRes.first->second, name.Utf8()); return false; } diff --git a/ets2panda/varbinder/scope.cpp b/ets2panda/varbinder/scope.cpp index efd86c2ee0bb01aee061af4b98088361ff092e41..010ccd2e8a7499f7ef535e1ed54ea9f9f94fda08 100644 --- a/ets2panda/varbinder/scope.cpp +++ b/ets2panda/varbinder/scope.cpp @@ -1035,6 +1035,7 @@ void LoopDeclarationScope::ConvertToVariableScope(ArenaAllocator *allocator) slotIndex_++; loopType_ = ScopeType::LOOP_DECL; auto *copiedVar = var->AsLocalVariable()->Copy(allocator, var->Declaration()); + ES2PANDA_ASSERT(copiedVar != nullptr); copiedVar->AddFlag(VariableFlags::INITIALIZED | VariableFlags::PER_ITERATION); var->AddFlag(VariableFlags::LOOP_DECL); loopScope_->InsertBinding(name, copiedVar); @@ -1046,6 +1047,7 @@ void LoopDeclarationScope::ConvertToVariableScope(ArenaAllocator *allocator) slotIndex_ = std::max(slotIndex_, parentVarScope->LexicalSlots()); evalBindings_ = parentVarScope->EvalBindings(); initScope_ = allocator->New(allocator, Parent()); + ES2PANDA_ASSERT(initScope_ != nullptr); initScope_->BindNode(Node()); initScope_->MergeBindings(bindings); }