13af6ab5fSopenharmony_ci/*
23af6ab5fSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License.
53af6ab5fSopenharmony_ci * You may obtain a copy of the License at
63af6ab5fSopenharmony_ci *
73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
83af6ab5fSopenharmony_ci *
93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and
133af6ab5fSopenharmony_ci * limitations under the License.
143af6ab5fSopenharmony_ci */
153af6ab5fSopenharmony_ci
163af6ab5fSopenharmony_ci#include "localClassLowering.h"
173af6ab5fSopenharmony_ci#include "checker/ETSchecker.h"
183af6ab5fSopenharmony_ci#include "varbinder/ETSBinder.h"
193af6ab5fSopenharmony_ci#include "../util.h"
203af6ab5fSopenharmony_ci
213af6ab5fSopenharmony_cinamespace ark::es2panda::compiler {
223af6ab5fSopenharmony_ci
233af6ab5fSopenharmony_cistd::string_view LocalClassConstructionPhase::Name() const
243af6ab5fSopenharmony_ci{
253af6ab5fSopenharmony_ci    return "LocalClassConstructionPhase";
263af6ab5fSopenharmony_ci}
273af6ab5fSopenharmony_ci
283af6ab5fSopenharmony_cistatic ir::ClassProperty *CreateCapturedField(checker::ETSChecker *checker, const varbinder::Variable *capturedVar,
293af6ab5fSopenharmony_ci                                              varbinder::ClassScope *scope, size_t &idx,
303af6ab5fSopenharmony_ci                                              const lexer::SourcePosition &pos)
313af6ab5fSopenharmony_ci{
323af6ab5fSopenharmony_ci    auto *allocator = checker->Allocator();
333af6ab5fSopenharmony_ci    auto *varBinder = checker->VarBinder();
343af6ab5fSopenharmony_ci
353af6ab5fSopenharmony_ci    // Enter the lambda class instance field scope, every property will be bound to the lambda instance itself
363af6ab5fSopenharmony_ci    auto fieldCtx = varbinder::LexicalScope<varbinder::LocalScope>::Enter(varBinder, scope->InstanceFieldScope());
373af6ab5fSopenharmony_ci
383af6ab5fSopenharmony_ci    // Create the name for the synthetic property node
393af6ab5fSopenharmony_ci    util::UString fieldName(util::StringView("field#"), allocator);
403af6ab5fSopenharmony_ci    fieldName.Append(std::to_string(idx));
413af6ab5fSopenharmony_ci    // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint)
423af6ab5fSopenharmony_ci    auto *fieldIdent = allocator->New<ir::Identifier>(fieldName.View(), allocator);
433af6ab5fSopenharmony_ci
443af6ab5fSopenharmony_ci    // Create the synthetic class property node
453af6ab5fSopenharmony_ci    auto *field =
463af6ab5fSopenharmony_ci        allocator->New<ir::ClassProperty>(fieldIdent, nullptr, nullptr, ir::ModifierFlags::NONE, allocator, false);
473af6ab5fSopenharmony_ci    fieldIdent->SetParent(field);
483af6ab5fSopenharmony_ci
493af6ab5fSopenharmony_ci    // Add the declaration to the scope, and set the type based on the captured variable's scope
503af6ab5fSopenharmony_ci    auto [decl, var] = varBinder->NewVarDecl<varbinder::LetDecl>(pos, fieldIdent->Name());
513af6ab5fSopenharmony_ci    var->SetScope(scope->InstanceFieldScope());
523af6ab5fSopenharmony_ci    var->AddFlag(varbinder::VariableFlags::PROPERTY);
533af6ab5fSopenharmony_ci    var->SetTsType(capturedVar->TsType());
543af6ab5fSopenharmony_ci
553af6ab5fSopenharmony_ci    fieldIdent->SetVariable(var);
563af6ab5fSopenharmony_ci    field->SetTsType(capturedVar->TsType());
573af6ab5fSopenharmony_ci    decl->BindNode(field);
583af6ab5fSopenharmony_ci    return field;
593af6ab5fSopenharmony_ci}
603af6ab5fSopenharmony_ci
613af6ab5fSopenharmony_cistatic ir::Statement *CreateCtorFieldInit(checker::ETSChecker *checker, util::StringView name, varbinder::Variable *var)
623af6ab5fSopenharmony_ci{
633af6ab5fSopenharmony_ci    // Create synthetic field initializers for the local class fields
643af6ab5fSopenharmony_ci    // The node structure is the following: this.field0 = field0, where the left hand side refers to the local
653af6ab5fSopenharmony_ci    // classes field, and the right hand side is refers to the constructors parameter
663af6ab5fSopenharmony_ci    // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint)
673af6ab5fSopenharmony_ci    auto *allocator = checker->Allocator();
683af6ab5fSopenharmony_ci
693af6ab5fSopenharmony_ci    auto *thisExpr = allocator->New<ir::ThisExpression>();
703af6ab5fSopenharmony_ci    auto *fieldAccessExpr = allocator->New<ir::Identifier>(name, allocator);
713af6ab5fSopenharmony_ci    fieldAccessExpr->SetReference();
723af6ab5fSopenharmony_ci    auto *leftHandSide = util::NodeAllocator::ForceSetParent<ir::MemberExpression>(
733af6ab5fSopenharmony_ci        allocator, thisExpr, fieldAccessExpr, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false);
743af6ab5fSopenharmony_ci    auto *rightHandSide = allocator->New<ir::Identifier>(name, allocator);
753af6ab5fSopenharmony_ci    rightHandSide->SetVariable(var);
763af6ab5fSopenharmony_ci    auto *initializer = util::NodeAllocator::ForceSetParent<ir::AssignmentExpression>(
773af6ab5fSopenharmony_ci        allocator, leftHandSide, rightHandSide, lexer::TokenType::PUNCTUATOR_SUBSTITUTION);
783af6ab5fSopenharmony_ci    initializer->SetTsType(var->TsType());
793af6ab5fSopenharmony_ci    return util::NodeAllocator::ForceSetParent<ir::ExpressionStatement>(allocator, initializer);
803af6ab5fSopenharmony_ci}
813af6ab5fSopenharmony_ci
823af6ab5fSopenharmony_civoid LocalClassConstructionPhase::CreateClassPropertiesForCapturedVariables(
833af6ab5fSopenharmony_ci    public_lib::Context *ctx, ir::ClassDefinition *classDef, ArenaSet<varbinder::Variable *> const &capturedVars,
843af6ab5fSopenharmony_ci    ArenaMap<varbinder::Variable *, varbinder::Variable *> &variableMap,
853af6ab5fSopenharmony_ci    ArenaMap<varbinder::Variable *, ir::ClassProperty *> &propertyMap)
863af6ab5fSopenharmony_ci{
873af6ab5fSopenharmony_ci    checker::ETSChecker *const checker = ctx->checker->AsETSChecker();
883af6ab5fSopenharmony_ci    size_t idx = 0;
893af6ab5fSopenharmony_ci    ArenaVector<ir::AstNode *> properties(ctx->allocator->Adapter());
903af6ab5fSopenharmony_ci    for (auto var : capturedVars) {
913af6ab5fSopenharmony_ci        ASSERT(classDef->Scope()->Type() == varbinder::ScopeType::CLASS);
923af6ab5fSopenharmony_ci        auto *property = CreateCapturedField(checker, var, reinterpret_cast<varbinder::ClassScope *>(classDef->Scope()),
933af6ab5fSopenharmony_ci                                             idx, classDef->Start());
943af6ab5fSopenharmony_ci        LOG(DEBUG, ES2PANDA) << "  - Creating property (" << property->Id()->Name()
953af6ab5fSopenharmony_ci                             << ") for captured variable: " << var->Name();
963af6ab5fSopenharmony_ci        properties.push_back(property);
973af6ab5fSopenharmony_ci        variableMap[var] = property->Id()->Variable();
983af6ab5fSopenharmony_ci        propertyMap[var] = property;
993af6ab5fSopenharmony_ci        idx++;
1003af6ab5fSopenharmony_ci    }
1013af6ab5fSopenharmony_ci
1023af6ab5fSopenharmony_ci    classDef->AddProperties(std::move(properties));
1033af6ab5fSopenharmony_ci}
1043af6ab5fSopenharmony_ci
1053af6ab5fSopenharmony_ciir::ETSParameterExpression *LocalClassConstructionPhase::CreateParam(checker::ETSChecker *const checker,
1063af6ab5fSopenharmony_ci                                                                     varbinder::FunctionParamScope *scope,
1073af6ab5fSopenharmony_ci                                                                     util::StringView name, checker::Type *type)
1083af6ab5fSopenharmony_ci{
1093af6ab5fSopenharmony_ci    auto newParam = checker->AddParam(name, nullptr);
1103af6ab5fSopenharmony_ci    newParam->SetTsType(type);
1113af6ab5fSopenharmony_ci    newParam->Ident()->SetTsType(type);
1123af6ab5fSopenharmony_ci    auto paramCtx = varbinder::LexicalScope<varbinder::FunctionParamScope>::Enter(checker->VarBinder(), scope, false);
1133af6ab5fSopenharmony_ci
1143af6ab5fSopenharmony_ci    auto *paramVar = std::get<1>(checker->VarBinder()->AddParamDecl(newParam));
1153af6ab5fSopenharmony_ci    paramVar->SetTsType(newParam->TsType());
1163af6ab5fSopenharmony_ci    newParam->Ident()->SetVariable(paramVar);
1173af6ab5fSopenharmony_ci    return newParam;
1183af6ab5fSopenharmony_ci}
1193af6ab5fSopenharmony_ci
1203af6ab5fSopenharmony_civoid LocalClassConstructionPhase::ModifyConstructorParameters(
1213af6ab5fSopenharmony_ci    public_lib::Context *ctx, ir::ClassDefinition *classDef, ArenaSet<varbinder::Variable *> const &capturedVars,
1223af6ab5fSopenharmony_ci    ArenaMap<varbinder::Variable *, varbinder::Variable *> &variableMap,
1233af6ab5fSopenharmony_ci    ArenaMap<varbinder::Variable *, varbinder::Variable *> &parameterMap)
1243af6ab5fSopenharmony_ci
1253af6ab5fSopenharmony_ci{
1263af6ab5fSopenharmony_ci    auto *classType = classDef->TsType()->AsETSObjectType();
1273af6ab5fSopenharmony_ci    checker::ETSChecker *const checker = ctx->checker->AsETSChecker();
1283af6ab5fSopenharmony_ci
1293af6ab5fSopenharmony_ci    for (auto *signature : classType->ConstructSignatures()) {
1303af6ab5fSopenharmony_ci        LOG(DEBUG, ES2PANDA) << "  - Modifying Constructor: " << signature->InternalName();
1313af6ab5fSopenharmony_ci        auto constructor = signature->Function();
1323af6ab5fSopenharmony_ci        auto &parameters = constructor->Params();
1333af6ab5fSopenharmony_ci        auto &sigParams = signature->Params();
1343af6ab5fSopenharmony_ci        signature->GetSignatureInfo()->minArgCount += capturedVars.size();
1353af6ab5fSopenharmony_ci
1363af6ab5fSopenharmony_ci        ASSERT(signature == constructor->Signature());
1373af6ab5fSopenharmony_ci        for (auto var : capturedVars) {
1383af6ab5fSopenharmony_ci            auto *newParam = CreateParam(checker, constructor->Scope()->ParamScope(), var->Name(), var->TsType());
1393af6ab5fSopenharmony_ci            newParam->SetParent(constructor);
1403af6ab5fSopenharmony_ci            // NOTE(psiket) : Moving the parameter after the 'this'. Should modify the AddParam
1413af6ab5fSopenharmony_ci            // to be able to insert after the this.
1423af6ab5fSopenharmony_ci            auto &paramScopeParams = constructor->Scope()->ParamScope()->Params();
1433af6ab5fSopenharmony_ci            auto thisParamIt = ++paramScopeParams.begin();
1443af6ab5fSopenharmony_ci            paramScopeParams.insert(thisParamIt, paramScopeParams.back());
1453af6ab5fSopenharmony_ci            paramScopeParams.pop_back();
1463af6ab5fSopenharmony_ci
1473af6ab5fSopenharmony_ci            parameters.insert(parameters.begin(), newParam);
1483af6ab5fSopenharmony_ci            ASSERT(newParam->Variable()->Type() == varbinder::VariableType::LOCAL);
1493af6ab5fSopenharmony_ci            sigParams.insert(sigParams.begin(), newParam->Ident()->Variable()->AsLocalVariable());
1503af6ab5fSopenharmony_ci            parameterMap[var] = newParam->Ident()->Variable()->AsLocalVariable();
1513af6ab5fSopenharmony_ci        }
1523af6ab5fSopenharmony_ci        reinterpret_cast<varbinder::ETSBinder *>(checker->VarBinder())->BuildFunctionName(constructor);
1533af6ab5fSopenharmony_ci        LOG(DEBUG, ES2PANDA) << "    Transformed Constructor: " << signature->InternalName();
1543af6ab5fSopenharmony_ci
1553af6ab5fSopenharmony_ci        auto *body = constructor->Body();
1563af6ab5fSopenharmony_ci        ArenaVector<ir::Statement *> initStatements(ctx->allocator->Adapter());
1573af6ab5fSopenharmony_ci        for (auto var : capturedVars) {
1583af6ab5fSopenharmony_ci            auto *propertyVar = variableMap[var];
1593af6ab5fSopenharmony_ci            auto *initStatement = CreateCtorFieldInit(checker, propertyVar->Name(), propertyVar);
1603af6ab5fSopenharmony_ci            auto *fieldInit = initStatement->AsExpressionStatement()->GetExpression()->AsAssignmentExpression();
1613af6ab5fSopenharmony_ci            auto *ctorParamVar = parameterMap[var];
1623af6ab5fSopenharmony_ci            auto *fieldVar = variableMap[var];
1633af6ab5fSopenharmony_ci            auto *leftHandSide = fieldInit->Left();
1643af6ab5fSopenharmony_ci            leftHandSide->AsMemberExpression()->SetObjectType(classType);
1653af6ab5fSopenharmony_ci            leftHandSide->AsMemberExpression()->SetPropVar(fieldVar->AsLocalVariable());
1663af6ab5fSopenharmony_ci            leftHandSide->AsMemberExpression()->SetIgnoreBox();
1673af6ab5fSopenharmony_ci            leftHandSide->AsMemberExpression()->SetTsType(fieldVar->TsType());
1683af6ab5fSopenharmony_ci            leftHandSide->AsMemberExpression()->Object()->SetTsType(classType);
1693af6ab5fSopenharmony_ci            fieldInit->Right()->AsIdentifier()->SetVariable(ctorParamVar);
1703af6ab5fSopenharmony_ci            fieldInit->Right()->SetTsType(ctorParamVar->TsType());
1713af6ab5fSopenharmony_ci            initStatement->SetParent(body);
1723af6ab5fSopenharmony_ci            initStatements.push_back(initStatement);
1733af6ab5fSopenharmony_ci        }
1743af6ab5fSopenharmony_ci        auto &statements = body->AsBlockStatement()->Statements();
1753af6ab5fSopenharmony_ci        statements.insert(statements.begin(), initStatements.begin(), initStatements.end());
1763af6ab5fSopenharmony_ci    }
1773af6ab5fSopenharmony_ci}
1783af6ab5fSopenharmony_ci
1793af6ab5fSopenharmony_civoid LocalClassConstructionPhase::RemapReferencesFromCapturedVariablesToClassProperties(
1803af6ab5fSopenharmony_ci    ir::ClassDefinition *classDef, ArenaMap<varbinder::Variable *, varbinder::Variable *> &variableMap)
1813af6ab5fSopenharmony_ci{
1823af6ab5fSopenharmony_ci    auto *classType = classDef->TsType()->AsETSObjectType();
1833af6ab5fSopenharmony_ci    auto remapCapturedVariables = [&variableMap](ir::AstNode *childNode) {
1843af6ab5fSopenharmony_ci        if (childNode->Type() == ir::AstNodeType::IDENTIFIER) {
1853af6ab5fSopenharmony_ci            LOG(DEBUG, ES2PANDA) << "    checking var:" << (void *)childNode;
1863af6ab5fSopenharmony_ci            const auto &mapIt = variableMap.find(childNode->AsIdentifier()->Variable());
1873af6ab5fSopenharmony_ci            if (mapIt != variableMap.end()) {
1883af6ab5fSopenharmony_ci                LOG(DEBUG, ES2PANDA) << "      Remap: " << childNode->AsIdentifier()->Name()
1893af6ab5fSopenharmony_ci                                     << " (identifier:" << (void *)childNode
1903af6ab5fSopenharmony_ci                                     << ") variable:" << (void *)childNode->AsIdentifier()->Variable()
1913af6ab5fSopenharmony_ci                                     << " -> property variable:" << (void *)mapIt->second;
1923af6ab5fSopenharmony_ci                childNode->AsIdentifier()->SetVariable(mapIt->second);
1933af6ab5fSopenharmony_ci            } else {
1943af6ab5fSopenharmony_ci            }
1953af6ab5fSopenharmony_ci        }
1963af6ab5fSopenharmony_ci    };
1973af6ab5fSopenharmony_ci
1983af6ab5fSopenharmony_ci    for (auto *it : classDef->Body()) {
1993af6ab5fSopenharmony_ci        if (it->IsMethodDefinition() && !it->AsMethodDefinition()->IsConstructor()) {
2003af6ab5fSopenharmony_ci            LOG(DEBUG, ES2PANDA) << "  - Rebinding variable rerferences in: "
2013af6ab5fSopenharmony_ci                                 << it->AsMethodDefinition()->Id()->Name().Mutf8().c_str();
2023af6ab5fSopenharmony_ci            it->AsMethodDefinition()->Function()->Body()->IterateRecursively(remapCapturedVariables);
2033af6ab5fSopenharmony_ci        }
2043af6ab5fSopenharmony_ci    }
2053af6ab5fSopenharmony_ci    // Since the constructor with zero parameter is not listed in the class_def body the constructors
2063af6ab5fSopenharmony_ci    // processed separately
2073af6ab5fSopenharmony_ci    for (auto *signature : classType->ConstructSignatures()) {
2083af6ab5fSopenharmony_ci        auto *constructor = signature->Function();
2093af6ab5fSopenharmony_ci        LOG(DEBUG, ES2PANDA) << "  - Rebinding variable rerferences in: " << constructor->Id()->Name();
2103af6ab5fSopenharmony_ci        constructor->Body()->IterateRecursively(remapCapturedVariables);
2113af6ab5fSopenharmony_ci    }
2123af6ab5fSopenharmony_ci}
2133af6ab5fSopenharmony_ci
2143af6ab5fSopenharmony_cibool LocalClassConstructionPhase::Perform(public_lib::Context *ctx, parser::Program *program)
2153af6ab5fSopenharmony_ci{
2163af6ab5fSopenharmony_ci    auto *allocator = ctx->allocator;
2173af6ab5fSopenharmony_ci    checker::ETSChecker *const checker = ctx->checker->AsETSChecker();
2183af6ab5fSopenharmony_ci    ArenaUnorderedMap<ir::ClassDefinition *, ArenaSet<varbinder::Variable *>> capturedVarsMap {allocator->Adapter()};
2193af6ab5fSopenharmony_ci
2203af6ab5fSopenharmony_ci    auto handleLocalClass = [this, ctx, &capturedVarsMap](ir::ClassDefinition *classDef) {
2213af6ab5fSopenharmony_ci        LOG(DEBUG, ES2PANDA) << "Altering local class with the captured variables: " << classDef->InternalName();
2223af6ab5fSopenharmony_ci        auto capturedVars = FindCaptured(ctx->allocator, classDef);
2233af6ab5fSopenharmony_ci        // Map the captured variable to the variable of the class property
2243af6ab5fSopenharmony_ci        ArenaMap<varbinder::Variable *, varbinder::Variable *> variableMap(ctx->allocator->Adapter());
2253af6ab5fSopenharmony_ci        // Map the captured variable to the class property
2263af6ab5fSopenharmony_ci        ArenaMap<varbinder::Variable *, ir::ClassProperty *> propertyMap(ctx->allocator->Adapter());
2273af6ab5fSopenharmony_ci        // Map the captured variable to the constructor parameter
2283af6ab5fSopenharmony_ci        ArenaMap<varbinder::Variable *, varbinder::Variable *> parameterMap(ctx->allocator->Adapter());
2293af6ab5fSopenharmony_ci
2303af6ab5fSopenharmony_ci        CreateClassPropertiesForCapturedVariables(ctx, classDef, capturedVars, variableMap, propertyMap);
2313af6ab5fSopenharmony_ci        ModifyConstructorParameters(ctx, classDef, capturedVars, variableMap, parameterMap);
2323af6ab5fSopenharmony_ci        RemapReferencesFromCapturedVariablesToClassProperties(classDef, variableMap);
2333af6ab5fSopenharmony_ci        capturedVarsMap.emplace(classDef, std::move(capturedVars));
2343af6ab5fSopenharmony_ci    };
2353af6ab5fSopenharmony_ci
2363af6ab5fSopenharmony_ci    program->Ast()->IterateRecursivelyPostorder([&](ir::AstNode *ast) {
2373af6ab5fSopenharmony_ci        if (ast->IsClassDefinition() && ast->AsClassDefinition()->IsLocal()) {
2383af6ab5fSopenharmony_ci            handleLocalClass(ast->AsClassDefinition());
2393af6ab5fSopenharmony_ci        }
2403af6ab5fSopenharmony_ci    });
2413af6ab5fSopenharmony_ci
2423af6ab5fSopenharmony_ci    // Alter the instantiations
2433af6ab5fSopenharmony_ci    auto handleLocalClassInstantiation = [ctx, checker, &capturedVarsMap](ir::ClassDefinition *classDef,
2443af6ab5fSopenharmony_ci                                                                          ir::ETSNewClassInstanceExpression *newExpr) {
2453af6ab5fSopenharmony_ci        LOG(DEBUG, ES2PANDA) << "Instantiating local class: " << classDef->Ident()->Name();
2463af6ab5fSopenharmony_ci        auto capturedVarsIt = capturedVarsMap.find(classDef);
2473af6ab5fSopenharmony_ci        ASSERT(capturedVarsIt != capturedVarsMap.cend());
2483af6ab5fSopenharmony_ci        auto &capturedVars = capturedVarsIt->second;
2493af6ab5fSopenharmony_ci        for (auto *var : capturedVars) {
2503af6ab5fSopenharmony_ci            LOG(DEBUG, ES2PANDA) << "  - Extending constructor argument with captured variable: " << var->Name();
2513af6ab5fSopenharmony_ci
2523af6ab5fSopenharmony_ci            auto *param = checker->AllocNode<ir::Identifier>(var->Name(), ctx->allocator);
2533af6ab5fSopenharmony_ci            param->SetVariable(var);
2543af6ab5fSopenharmony_ci            param->SetIgnoreBox();
2553af6ab5fSopenharmony_ci            param->SetTsType(param->Variable()->TsType());
2563af6ab5fSopenharmony_ci            param->SetParent(newExpr);
2573af6ab5fSopenharmony_ci            newExpr->AddToArgumentsFront(param);
2583af6ab5fSopenharmony_ci        }
2593af6ab5fSopenharmony_ci    };
2603af6ab5fSopenharmony_ci
2613af6ab5fSopenharmony_ci    program->Ast()->IterateRecursivelyPostorder([&](ir::AstNode *ast) {
2623af6ab5fSopenharmony_ci        if (ast->IsETSNewClassInstanceExpression()) {
2633af6ab5fSopenharmony_ci            auto *newExpr = ast->AsETSNewClassInstanceExpression();
2643af6ab5fSopenharmony_ci            checker::Type *calleeType = newExpr->GetTypeRef()->Check(checker);
2653af6ab5fSopenharmony_ci            auto *calleeObj = calleeType->AsETSObjectType();
2663af6ab5fSopenharmony_ci            auto *classDef = calleeObj->GetDeclNode()->AsClassDefinition();
2673af6ab5fSopenharmony_ci            if (classDef->IsLocal()) {
2683af6ab5fSopenharmony_ci                handleLocalClassInstantiation(classDef, newExpr);
2693af6ab5fSopenharmony_ci            }
2703af6ab5fSopenharmony_ci        }
2713af6ab5fSopenharmony_ci    });
2723af6ab5fSopenharmony_ci
2733af6ab5fSopenharmony_ci    return true;
2743af6ab5fSopenharmony_ci}
2753af6ab5fSopenharmony_ci
2763af6ab5fSopenharmony_ci}  // namespace ark::es2panda::compiler
277