import { AbstractInvokeExpr } from '../../../core/base/Expr'; import { Stmt } from '../../../core/base/Stmt'; import { ClassType, EnumValueType, FunctionType, GenericType, Type, UnclearReferenceType } from '../../../core/base/Type'; import { ArkMethod } from '../../../core/model/ArkMethod'; import { ArkExport } from '../../../core/model/ArkExport'; import { ArkClass } from '../../../core/model/ArkClass'; import { ArkField } from '../../../core/model/ArkField'; import { Value } from '../../../core/base/Value'; import { MethodSignature, MethodSubSignature } from '../../../core/model/ArkSignature'; import { MethodParameter } from '../../../core/model/builder/ArkMethodBuilder'; export declare class TypeInference { static inferTypeInArkField(arkField: ArkField): void; /** * Infer type for a given unclear type. * It returns an array with 2 items, original object and original type. * The original object is null if there is no object, or it failed to find the object. * The original type is null if failed to infer the type. * @param leftOpType * @param declaringArkClass * @param visited * @returns */ static inferUnclearedType(leftOpType: Type, declaringArkClass: ArkClass, visited?: Set): Type | null | undefined; static inferUnclearComplexType(leftOpType: Type, declaringArkClass: ArkClass, visited: Set): Type | undefined; /** * Type information in inference method * @param arkMethod Ark method object for type inference */ static inferTypeInMethod(arkMethod: ArkMethod): void; /** * Parse statement and process various references and expressions within it * @param stmt Statement object to be parsed * @param arkMethod Current Ark method context */ private static resolveStmt; /** * @Deprecated * @param arkMethod */ static inferSimpleTypeInMethod(arkMethod: ArkMethod): void; /** * infer type for Exprs in stmt which invoke method. * such as ArkInstanceInvokeExpr ArkStaticInvokeExpr ArkNewExpr */ private static resolveExprsInStmt; /** * infer value type for TypeExprs in stmt which specify the type such as TypeQueryExpr */ private static resolveTypeExprsInStmt; /** * infer type for fieldRefs in stmt. */ private static resolveFieldRefsInStmt; /** *Process field references, perform corresponding conversion processing according to the reference type and statement type, * process static field references, process instance field references and field references as array references, * and try to replace them with local variables when the index is a string constant *@param use - abstract reference object, which may be a static field reference or an instance field reference *@param stmt - statement object, used to replace references *@param arkMethod - Ark method object, used to obtain method body information *@param replaceUse - is new fieldRef replace use */ private static processRef; private static getLocalFromMethodBody; /** * Parse ArkExport object into corresponding Type * @param arkExport - The ArkExport object to parse, may be undefined or null * @returns The parsed Type object, or null if it cannot be parsed */ static parseArkExport2Type(arkExport: ArkExport | undefined | null): Type | null; /** * infer and pass type for ArkAssignStmt right and left * @param stmt * @param arkMethod */ static resolveArkAssignStmt(stmt: Stmt, arkMethod: ArkMethod): void; /** * Resolve type inference and setting for the left operand of an assignment statement * * @param stmt Assignment statement node * @param arkClass The current Ark class * @param rightType Type of the right-hand expression in the assignment * @param arkMethod The current Ark method */ private static resolveLeftOp; /** * Infer the type of the left operand in an assignment statement * * @param arkClass Current class object * @param rightType The type on the right side of the assignment statement * @param leftOp The operand on the left side of the assignment * @param arkMethod Current method object * @param stmt Assignment statement object * @returns The inferred left type, or null/undefined if it cannot be inferred */ private static inferLeftOpType; /** * Set the type of value * * @param value The value object whose type needs to be set * @param type The type to be set */ private static setValueType; /** * Determine if the given type is an unclear type * @param type The type to check, which can be null or undefined * @returns true if the type is unclear, otherwise false */ static isUnclearType(type: Type | null | undefined): boolean; /** * This is the temporal function to check Type recursively and can be removed after typeInfer supports multiple candidate types. * @param type The type to check * @param check Condition checking function that takes a type parameter and returns a boolean * @param visited Set of visited types to prevent infinite recursion from circular references, defaults to empty set * @returns true if the type meets the condition, otherwise false */ static checkType(type: Type, check: (t: Type) => boolean, visited?: Set): boolean; /** * Infer simple types in a statement * @param stmt The statement to perform type inference on */ static inferSimpleTypeInStmt(stmt: Stmt): void; /** * Build corresponding Type object based on TypeScript type string * Deal only with simple situations * @param tsTypeStr TypeScript type string used to identify basic types * @param cxxTypeStr Optional C++ type string used for detailed type information of number and string types * @returns Returns the Type instance corresponding to the input string */ static buildTypeFromStr(tsTypeStr: string, cxxTypeStr?: string): Type; static buildTypeFromCxxNumberStr(cxxTypeStr?: string): Type; static buildTypeFromCxxStringStr(cxxTypeStr?: string): Type; /** * Infer the type of value * @param value The value whose type needs to be inferred * @param arkMethod The current method context * @returns The inferred type, or null if it cannot be inferred */ static inferValueType(value: Value, arkMethod: ArkMethod): Type | null; /** * Infer the type of method parameters and update the parameter's type information. * * @param param - The parameter object whose type needs to be inferred * @param arkMethod - The method object that the parameter belongs to */ static inferParameterType(param: MethodParameter, arkMethod: ArkMethod): void; /** * Infer the return type of method signature and update the return type information in the signature. * * @param oldSignature - The method signature object whose return type needs to be inferred * @param arkMethod - The method object that corresponds to the signature */ static inferSignatureReturnType(oldSignature: MethodSignature, arkMethod: ArkMethod): void; /** * Infer the return type of method and update the return type information in the method. * * @param arkMethod - The method object whose return type needs to be inferred */ private static inferReturnType; /** * Infer the type of generic type and update the generic type information. * * @param types - The generic type array that needs to be inferred * @param arkClass - The class object that the generic type belongs to */ static inferGenericType(types: GenericType[] | undefined, arkClass: ArkClass): void; /** * Infer type for a given {@link UnclearReferenceType} type. * It returns original type. * The original type is null if it failed to infer the type. * @param urType * @param arkClass * @returns */ static inferUnclearRefType(urType: UnclearReferenceType, arkClass: ArkClass): Type | null; /** * Find out the original object and type for a given unclear reference type name. * It returns original type. * The original type is null if it failed to infer the type. * @param refName * @param arkClass * @returns */ static inferUnclearRefName(refName: string, arkClass: ArkClass): Type | null; /** *Inferred field type *@ param baseType Base Type *@ param fieldName *@ param declareClass Declare the class *@ returns a tuple of attributes and types. If the inference fails, null is returned */ static inferFieldType(baseType: Type, fieldName: string, declareClass: ArkClass): [any, Type] | null; /** *Infer type information of class fields *@ param declareClass Declare the class object *@ param baseType Basic class type *@ param fieldName *@ returns a tuple containing property and type information. If it cannot be inferred, it returns null */ private static inferClassFieldType; static getEnumValueType(property: ArkField): EnumValueType | null; private static inferArrayFieldType; /** *Infer Base Type *@ param baseName *@ param arkClass Ark class object *@ returns the inferred type. If it cannot be inferred, it returns null */ static inferBaseType(baseName: string, arkClass: ArkClass): Type | null; /** *Infer type information based on type name *@ param typeName - the type name to infer *@ param arkClass - the current Ark class object *@ returns The type object inferred. If it cannot be inferred, null is returned */ static inferTypeByName(typeName: string, arkClass: ArkClass): Type | null; /** * Infer real generic types * * This function iterates through the passed type array, infers unclear types, * and replaces the unclear types in the original array with the inferred concrete types. * * @param realTypes - Type array that may contain unclear types, returns directly if undefined * @param arkClass - ArkClass object used for type inference */ static inferRealGenericTypes(realTypes: Type[] | undefined, arkClass: ArkClass): void; /** *Infer type information of dynamic import *@ param from - import source path *@ param arkClass - Ark class information *@ returns The type information obtained by parsing. If it cannot be parsed, null is returned */ static inferDynamicImportType(from: string, arkClass: ArkClass): Type | null; /** *Replace generic parameters in type with actual types *@ param type - the original type to be replaced *@ param realTypes - array of actual types, used to replace generic parameters *@ param visited - the accessed type collection, used to prevent circular references *@ returns The actual type after replacement */ static replaceTypeWithReal(type: Type, realTypes?: Type[], visited?: Set): Type; /** * Recursively replace generic parameters in types with actual types. * * @param type The original type to process * @param visited Set of visited types to prevent infinite recursion * @param realTypes List of actual types used to replace generic parameters * @returns The replaced type */ static replaceRecursiveType(type: Type, visited: Set, realTypes?: Type[]): Type; /** * Replace alias types with their original types * * This function recursively resolves alias types by following the chain of type aliases * until it reaches the original underlying type. If the input type is an alias type, * it will trace through to the non-alias type. * * @param type - The type to be replaced, which may be an alias type * @returns Returns the resolved original type; if the input is not an alias type, it returns the original type directly */ static replaceAliasType(type: Type): Type; /** * Infer function type for generic type inference * @param argType Function argument type * @param paramSubSignature Parameter sub-signature * @param realTypes Array of real types */ static inferFunctionType(argType: FunctionType, paramSubSignature: MethodSubSignature | undefined, realTypes: Type[] | undefined): void; /** * Resolve Ark return statement, perform type inference processing * @param stmt The statement object that needs to be parsed * @param arkMethod The current Ark method */ private static resolveArkReturnStmt; static inferMethodFromImportNamespace(baseType: Type, expr: AbstractInvokeExpr, arkMethod: ArkMethod, methodName: string): AbstractInvokeExpr | null; static inferNestedClassType(declareClass: ArkClass, baseType: ClassType, fieldName: string): [ArkClass, Type] | null; } //# sourceMappingURL=TypeInference.d.ts.map