13af6ab5fSopenharmony_ci/*
23af6ab5fSopenharmony_ci * Copyright (c) 2021-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#ifndef ES2PANDA_CHECKER_ETSANALYZERHELPERS_H
173af6ab5fSopenharmony_ci#define ES2PANDA_CHECKER_ETSANALYZERHELPERS_H
183af6ab5fSopenharmony_ci
193af6ab5fSopenharmony_ci#include "checker/types/type.h"
203af6ab5fSopenharmony_ci#include "varbinder/ETSBinder.h"
213af6ab5fSopenharmony_ci#include "checker/ETSchecker.h"
223af6ab5fSopenharmony_ci#include "checker/ets/castingContext.h"
233af6ab5fSopenharmony_ci#include "checker/ets/typeRelationContext.h"
243af6ab5fSopenharmony_ci#include "util/helpers.h"
253af6ab5fSopenharmony_ci
263af6ab5fSopenharmony_ci#include <memory>
273af6ab5fSopenharmony_ci
283af6ab5fSopenharmony_cinamespace ark::es2panda::checker {
293af6ab5fSopenharmony_civoid CheckExtensionIsShadowedInCurrentClassOrInterface(checker::ETSChecker *checker, checker::ETSObjectType *objType,
303af6ab5fSopenharmony_ci                                                       ir::ScriptFunction *extensionFunc,
313af6ab5fSopenharmony_ci                                                       checker::Signature *signature);
323af6ab5fSopenharmony_civoid CheckExtensionIsShadowedByMethod(checker::ETSChecker *checker, checker::ETSObjectType *objType,
333af6ab5fSopenharmony_ci                                      ir::ScriptFunction *extensionFunc, checker::Signature *signature);
343af6ab5fSopenharmony_civoid CheckExtensionMethod(checker::ETSChecker *checker, ir::ScriptFunction *extensionFunc, ir::MethodDefinition *node);
353af6ab5fSopenharmony_civoid DoBodyTypeChecking(ETSChecker *checker, ir::MethodDefinition *node, ir::ScriptFunction *scriptFunc);
363af6ab5fSopenharmony_civoid ComposeAsyncImplFuncReturnType(ETSChecker *checker, ir::ScriptFunction *scriptFunc);
373af6ab5fSopenharmony_civoid ComposeAsyncImplMethod(ETSChecker *checker, ir::MethodDefinition *node);
383af6ab5fSopenharmony_civoid CheckPredefinedMethodReturnType(ETSChecker *checker, ir::ScriptFunction *scriptFunc);
393af6ab5fSopenharmony_civoid CheckIteratorMethodReturnType(ETSChecker *checker, ir::ScriptFunction *scriptFunc,
403af6ab5fSopenharmony_ci                                   const lexer::SourcePosition &position, const std::string &methodName);
413af6ab5fSopenharmony_cichecker::Type *InitAnonymousLambdaCallee(checker::ETSChecker *checker, ir::Expression *callee,
423af6ab5fSopenharmony_ci                                         checker::Type *calleeType);
433af6ab5fSopenharmony_cichecker::Signature *ResolveCallExtensionFunction(checker::ETSFunctionType *functionType, checker::ETSChecker *checker,
443af6ab5fSopenharmony_ci                                                 ir::CallExpression *expr);
453af6ab5fSopenharmony_cichecker::Signature *ResolveCallForETSExtensionFuncHelperType(checker::ETSExtensionFuncHelperType *type,
463af6ab5fSopenharmony_ci                                                             checker::ETSChecker *checker, ir::CallExpression *expr);
473af6ab5fSopenharmony_ciArenaVector<checker::Signature *> GetUnionTypeSignatures(ETSChecker *checker, checker::ETSUnionType *etsUnionType);
483af6ab5fSopenharmony_ciArenaVector<checker::Signature *> &ChooseSignatures(ETSChecker *checker, checker::Type *calleeType,
493af6ab5fSopenharmony_ci                                                    bool isConstructorCall, bool isFunctionalInterface,
503af6ab5fSopenharmony_ci                                                    bool isUnionTypeWithFunctionalInterface);
513af6ab5fSopenharmony_cichecker::ETSObjectType *ChooseCalleeObj(ETSChecker *checker, ir::CallExpression *expr, checker::Type *calleeType,
523af6ab5fSopenharmony_ci                                        bool isConstructorCall);
533af6ab5fSopenharmony_civoid ProcessExclamationMark(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType);
543af6ab5fSopenharmony_civoid SetTsTypeForUnaryExpression(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType);
553af6ab5fSopenharmony_cichecker::ETSObjectType *CreateSyntheticType(ETSChecker *checker, util::StringView const &syntheticName,
563af6ab5fSopenharmony_ci                                            checker::ETSObjectType *lastObjectType, ir::Identifier *id);
573af6ab5fSopenharmony_cichecker::Type *GetIteratorType(ETSChecker *checker, checker::Type *elemType, ir::AstNode *left);
583af6ab5fSopenharmony_cibool CheckArgumentVoidType(checker::Type *&funcReturnType, ETSChecker *checker, const std::string &name,
593af6ab5fSopenharmony_ci                           ir::ReturnStatement *st);
603af6ab5fSopenharmony_cibool CheckReturnType(ETSChecker *checker, checker::Type *funcReturnType, checker::Type *argumentType,
613af6ab5fSopenharmony_ci                     ir::Expression *stArgument, bool isAsync);
623af6ab5fSopenharmony_civoid InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, checker::Type *&funcReturnType,
633af6ab5fSopenharmony_ci                     ir::Expression *stArgument);
643af6ab5fSopenharmony_civoid ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containingFunc, checker::Type *&funcReturnType,
653af6ab5fSopenharmony_ci                             ir::ReturnStatement *st, ir::Expression *stArgument);
663af6ab5fSopenharmony_cibool IsAsyncMethod(ir::AstNode *node);
673af6ab5fSopenharmony_ci
683af6ab5fSopenharmony_ciETSObjectType *CreateOptionalSignaturesForFunctionalType(ETSChecker *checker, ir::ETSFunctionType *node,
693af6ab5fSopenharmony_ci                                                         ETSObjectType *genericInterfaceType,
703af6ab5fSopenharmony_ci                                                         Substitution *substitution, size_t optionalParameterIndex);
713af6ab5fSopenharmony_ciETSObjectType *CreateInterfaceTypeForETSFunctionType(ETSChecker *checker, ir::ETSFunctionType *node,
723af6ab5fSopenharmony_ci                                                     ETSObjectType *genericInterfaceType, Substitution *substitution);
733af6ab5fSopenharmony_ciType *CreateParamTypeWithDefaultParam(ETSChecker *checker, ir::Expression *params);
743af6ab5fSopenharmony_ci
753af6ab5fSopenharmony_ciType *InstantiateBoxedPrimitiveType(ETSChecker *checker, ir::Expression *param, Type *paramType);
763af6ab5fSopenharmony_ci}  // namespace ark::es2panda::checker
773af6ab5fSopenharmony_ci
783af6ab5fSopenharmony_ci#endif  // ES2PANDA_CHECKER_ETSANALYZERHELPERS_H
79