diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 040790ec1bbe6291835f0531d64e083dda06ee76..fab6f7ac3757d7599a8a338e0f252f6988762be7 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -860,8 +860,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); @@ -2561,6 +2560,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 7f1149d8fb631487acf39c684bce605649a48c7b..069521a1734a9c11b3a8d18da7721be3e3b6a3a3 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -309,6 +309,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 ae1341ff0522e398c043a7cb82371cf0c4ea356b..d64c98cb1c4eca929c2223d6e298718328a5820e 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -77,6 +77,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 9ddc20f714cbb926dcc2dc8368f3ed801bccaabb..64d1105ae54deaa56dd2b6e3f1970543d70d8209 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -969,6 +969,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() @@ -1009,8 +1010,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()); } @@ -1100,6 +1102,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 a31ba893c50dee06a3106e330b257e806d370f3f..43eb2ceffc8173620047c493aae906f525a0400a 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -367,6 +367,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); } @@ -440,6 +441,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); } @@ -651,6 +653,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); @@ -1542,6 +1545,7 @@ bool ETSBinder::ImportGlobalPropertiesForNotDefaultedExports(varbinder::Variable return true; } + ES2PANDA_ASSERT(classElement->Id() != nullptr); ThrowRedeclarationError(classElement->Id()->Start(), var, variable, name.Utf8()); } @@ -1554,6 +1558,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 1fb08a81768224e0df0894091574060dec11704d..ac412d9f836469ab1dc6caf80566ac5c09420c89 100644 --- a/ets2panda/varbinder/scope.cpp +++ b/ets2panda/varbinder/scope.cpp @@ -1032,6 +1032,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); @@ -1043,6 +1044,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); }