import { Value } from '../../../core/base/Value'; import { ArkMethod } from '../../../core/model/ArkMethod'; import { ArkCxxIRTransformer, ValueAndStmts } from './ArkIRTransformer'; import { ArkValueTransformer } from '../../../core/common/ArkValueTransformer'; import { CxxOpcode, CxxAstNode, CxxTranslationUnit } from '../utils/ArkCxxAstNode'; export declare class ArkCxxValueTransformer extends ArkValueTransformer { private ArkCxxIRTransformer; private readonly cxxSourceFile; private nodeTransformerFuncMap; constructor(arkIRTransformer: ArkCxxIRTransformer, sourceFile: CxxTranslationUnit, declaringMethod: ArkMethod); /** *Convert C++AST nodes into a combination of values and statements *@ param node - C++AST node to be converted *@ returns Objects containing converted values and related statements */ cxxNodeToValueAndStmts(node: CxxAstNode): ValueAndStmts; /** * Convert an unprocessed C++AST node into a combination of values and statements * @param aggregate - C++AST node to be converted * @returns Objects containing converted values and related statements * @throws Error if the node cannot be processed * For example: * struct Point q = (struct Point){.x = 5, .y = 8, .name = 'c'}; * int* arr = (int[5]){1, 2, 3, 4, 5}; * the right value is {},its kind is CompoundLiteralExpr or InitListExpr */ private cxxAggregateToValueAndStmts; private cxxThisExpressionToValueAndStmts; private isNodeRelatedToCXXLambdaFunc; private isNodeRelatedToImplicitNode; private isNodeRelatedToMaterializeTemporaryExpr; private isNodeRelatedToCXXMember; private isPairConstructExpr; private isNodeRelatedToTemporary; private isNotNewExpression; private isNodeRelatedToCXXFuncCast; private undefinedToValueAndStmts; private unprocessedNodeToValueAndStmts; private cxxNamespaceRefToValueAndStmts; private cxxTemporaryObjectExprToValueAndStmts; /** *Convert the C++construction expression node into a combination of values and statements. * The main scenarios are structure and class construction, STL data structure object construction, and thread object construction *@ param node - C++AST node, representing the construction expression *@ returns ValueAndStmts object, including converted values and related statements */ private cxxConstructExprToValueAndStmts; bindingNodeToValueAndStmts(node: CxxAstNode, yieldValue?: Value): ValueAndStmts; private processInnerNodeToValueAndStmts; /** *Converts an implicit conversion expression node to a combination of values and statements *@ param node - C++AST node, representing implicit type conversion expression *@ returns ValueAndStmts object, including converted values and related statements */ private implicitCastExprToValueAndStmts; /** *Convert declaration and type reference nodes to collections of values and statements *@ param node - C++AST node *@ returns ValueAndStmts object, including converted values and related statements */ private declAndTypeRefToValueAndStmts; private staticMemberExprToValueAndStmts; private materializeTemporaryExprToValueAndStmts; /** *Initialize a list expression into a collection of values and statements *@ param node - C++abstract syntax tree node *@ returns ValueAndStmts object, including converted values and related statements */ private initListExprToValueAndStmts; /** *Convert the unary operator node into a combination of values and statements *@ param node - C++AST node, representing unary operator expression *@ returns ValueAndStmts object, including converted values and related statements */ private unaryOperatorToValueAndStmts; private unaryExprToValueAndStmts; /** *Convert user-defined literals into sets of values and statements *The syntax format of user-defined literals is: original value+suffix (for example: 123_km, "hello" _s, 'a' _s) * *@ param userDefinedLiteral - AST node of user-defined literal *@ returns The ValueAndStmts object containing the converted value and related statements */ private userDefinedLiteralToValueAndStmts; /** *Convert the C++constructor initialization list node to a collection of values and statements * 1. C++uses the initialization list to initialize class member variables: Base (char pname): name (pname) {...}. * The final effect is similar to this ->name=pname, which is also processed as an assignment here * 2. using parent::parent, The constructor of the subclass calls the constructor inherited from the parent class *@ param cxxCtorInitializer C++constructor initializes list nodes *@ returns An object containing a collection of values and statements */ private cxxCtorInitializerToValueAndStmts; /** *Convert the C++inheritance constructor initialization expression to a collection of values and statements * Using parent:: parent==>The constructor of the sub——class calls the constructor inherited from the parent * class==>The same as calling the constructor of the parent class directly *@ param cxxInheritedCtorInitExpr - C++inheritance constructor initialization expression node *@ returns The object containing the converted value and statement array */ private cxxInheritedCtorInitExprToValueAndStmts; /** *Convert super expression in C++to IR * C++subclasses call the parent class constructor for initialization, * similar to ts super (xx). For example, Left (const char&name, int power): Base (name) {...} *@ param cxxConstructExpr C++construction expression node *@ returns The ValueAndStmts object containing the converted value and related statements */ private cxxSuperExpressionToValueAndStmts; /** *Convert array type characteristic expression to IR * ArrayTypeTraitExpr is processed by function call *@ param ArrayTypeTraitExpr - C++AST node, representing array type characteristic expression *@ returns ValueAndStmts object, including converted values and related statements */ private arrayTypeTraitExprToValueAndStmts; /** * Convert C++typeid expression to IR, And CXXTypeidExpr is processed by function call. *@ param CXXTypeidExpr - typeid expression node in C++AST *@ returns Objects containing converted values and related statements */ private cxxTypeidExprToValueAndStmts; /** *Convert the noexcept expression of C++syntax tree to IR *@ param CXXNoexceptExpr - AST node representing C++noexcept expression *@ returns Objects containing converted values and related statements */ private cxxNoexceptExprToValueAndStmts; /** *Process the C++scalar value initialization expression and convert it to IR *@ param CXXScalarValueInitExpr - C++abstract syntax tree node, representing scalar value initialization expression *@ returns an object containing initialization values and related statements. If it cannot be processed, it returns null */ private cxxScalarValueInitToValueAndStmts; /** *Convert C++delete expression to IR *@ param deleteExpression - C++AST node, representing delete expression *@ returns The object containing the converted value and statement array */ private cxxDeleteExpressionToValueAndStmts; /** *Convert C++type conversion expression to IR *@ param castExpression C++AST node, representing type conversion expression *@ returns ValueAndStmts object, including converted values, original location information and related statements */ private castExpressionToValueAndStmts; private cxxFoldExprToValueAndStmts; /** *Convert C++conditional expression to IR *@ param conditionalExpression - C++AST node, representing conditional expression *@ returns ValueAndStmts object, including converted values, original location information and related statements */ private cxxConditionalExpressionToValueAndStmts; /** *Extract the calling node and parameter node from the internal AST node array for overwriting *@ param innerAsNodes An AST node array containing call information and parameters. The first element is the call node, and the rest are parameter nodes *@ returns an array containing two elements: the first element is the call node, and the second element is the parameter node array */ private getArgumentNodeForRecover; private getArgumentNode; private getDeclRef; private cxxGenerateSystemComponentStmt; private cxxGenerateCustomViewStmt; private cxxGenerateComponentCreationStmts; /** *Convert C++identifiers to collections of values and statements *@ param identifier C++AST node identifier *@ param variableDefFlag Optional variable definition flag, used to distinguish variable declaration from variable use *@ returns Objects containing values, location information and statement arrays */ private cxxIdentifierToValueAndStmts; /** *Convert the member expression of C++(such as testMap. insert) to ValueAndStmts of Ark IR *@ param memberExpression - shaped like an AST MemberExpr/MemberRef node, which usually means obj. field or obj ->field *@ param localValue - (Optional) The scenario where the baseValue is specified directly ( * such as determining the base in advance when resolving the parent node) */ private memberExpressionToValueAndStmts; private buildFieldSignatureFromMemberExpr; /** *Convert element access expressions (such as array [index] or object. field) in C++AST to values and statements in intermediate representation (IR). * *@ param elementAccessExpression represents the AST node of C++element access expression *@ returns contains the generated IR value, original location information and the ValueAndStmts object of related statements */ private cxxElementAccessExpressionToValueAndStmts; private cxxCallExpressionToValueAndStmts; /** *Process the 'cout<<...' or lambda expression in C++, extract its operands and construct corresponding statements and values. * *@ param callExpression - The currently processed C++AST node, which represents an operator calling expression (such as<<). *@ param callArgus - An array used to collect the parameter nodes involved in the expression. *@ returns the ValueAndStmts object containing values and statements. If it cannot be processed, it returns null. */ private streamOrLambdaExprToValueAndStmts; /** *Build a collection of values and statements for stream operations or lambda function call * *@ param streamNode The AST node of the stream node *@ param args parameter array of stream operation *@ param stmts statement array *@ param streamExpr AST node of stream expression *@ returns The ValueAndStmts object containing values and statements */ private buildValueAndStmtsForStreamOrLambdaCall; /** *Build values and statements of overloaded flow operators *@ param streamNode *@ param overloadedArg overload parameter node *@ param currValueAndStmts Current value and statement collection */ private buildValueAndStmtsForOverloadedStream; /** *Build a collection of values and statements for standard flow or lambda call nodes *@ param streamNode - AST node of the stream node *@ param nonOverlooadedArgs - non overloaded parameter array *@ param streamExpr - AST node of stream expression *@ param currValueAndStmts - current value and statement collection object, used to store processing results */ private buildValueAndStmtsForStdStreamOrLambdaCall; /** *Convert C++operator expression to binary operator expression *@ param expression - C++AST node, representing operator expression *@ returns the converted values and statements */ private CXXOperatorExpressionToBinaryOperator; /** *Convert C++operator expression to unary operator expression *@ param expression - C++AST node, representing operator expression *@ returns ValueAndStmts object, including converted values and statements */ private CXXOperatorExpressionToUnaryOperator; /** *Convert C++operator expressions to lists of values and statements *@ param callExpression - C++AST node, representing the operator expression to be converted *@ param layer - Boolean value, which controls whether to process the final output layer. The default value is true *@ returns a list of converted values and statements, which may include special operator processing results or array reference expressions */ private cxxOperatorExpressionToValueAndStmts; /** * Handle special operator scenarios and return early if matched */ private handleSpecialOperators; /** * Collect ValueAndStmts from each inner node */ private collectInnerOperatorStmts; private getOperatorTokenFromNode; private getDeclRefScopePrefix; private isCxxStreamSyntaxNode; private getOverloadOpName; /** *Handling C++overloaded operator call expressions *@ param cxxOperatorCallExpr C++AST node, representing operator calling expression *@ returns the processed value and statement object. If it cannot be processed, it returns null */ private handleOverloadedOp; /** *Build values and statements called by overloaded flow operators, such as<>. * Call IR for the function corresponding to the overload construction of the input/output stream operators operator<<, operator>> *This function is used to handle operator overloading call expressions in C++, especially for input/output stream operators. *It will parse parameters, find matching Ark methods, and generate corresponding call expressions. * *@ param cxxOperatorCallExpr represents the AST node of the C++operator call expression *@ returns an object containing values and statements. If it cannot be constructed, it returns null */ private buildInvokeValueForOverloadedStreamOp; private buildInvokeValueForNormalOverloadedOp; private RecoverExpressionToValueAndStmts; /** *Generate the value and statement block of the C++call expression (ValueAndStmts). * *@ param functionNameNode - the node corresponding to the function name, which is used to resolve the caller information. *@ param argus - The object containing the actual generic type, parameter value list, and parameter location information. *- realGenericTypes: list of actual generic types. *- args: parameter value list. *- argPositions: The location information of the parameter in the source code. *@ param currStmts - List of existing statements. The newly generated statements will be appended on this basis. *@ param callExpression - represents the AST node of the call expression, which is used to obtain the call location information. *@ returns a ValueAndStmts object that contains the call value, value location information, and related statements. */ private cxxGenerateInvokeValueAndStmts; /** *IR Processing of C++Function Calls *@ param callExpression - C++AST node, representing member call expression *@ returns ValueAndStmts object, including converted values and related statements */ private cxxMemberCallExpressionToValueAndStmts; /** *Build values and statements called by members *@ param stmts statement array, used to collect generated statements *@ param callerNode Caller Node *@ param argNodes parameter node array *@ param callExpression calls the expression node *@ param realGenericTypes Actual generic type array *@ returns The ValueAndStmts object containing values, location information, and statements */ private buildValueAndStmtsForMemberCall; /** *Build the call value referenced by the field * *@ param callerValue The caller value indicates the field reference *@ param args calls the parameter array *@ param realGenericTypes The actual generic type array may be undefined *@ param invokeValuePositions calls the value position information array *@ param callerPositions Caller position information array *@ returns the ArkInstanceFieldRef or ArkStaticInvokeExpr instance */ private buildInvokeValueForFieldRef; private buildInvokeValueForLocal; private cxxParseArgumentsOfCallExpression; private getRealGenericTypes; /** * Resolves the type string based on priority (provided qualType > desugared > default). */ private getTargetQualType; /** * Splits template arguments by comma, but remains aware of nested brackets * to prevent incorrect splitting of nested templates. */ private splitTemplateArguments; private cxxParseArguments; private cxxCallableNodeToValueAndStmts; private cxxNewExpressionToValueAndStmts; /** *Generate C++code representation of constructor calls and member initialization, and add related statements to stmts. * Extracted tail logic: construction call+special case processing+member initialization *@ param stmts - an array that stores the generated statement nodes *@ param newExpression - C++AST node representing new expression *@ param newLocal - local variable representing the newly created object *@ param newLocalPositions - the location information of the new local variable in the source code *@ param constructorMethodSignature - constructor's method signature *@ param className - the name of the current class, which is used for special processing of certain types (such as napi_property_descriptor) */ private cxxEmitCtorInvokeAndMemberInits; private getConstructorSignatureByClassTypeAndArgs; /** *Get the constructor parameter list, and process parameter resolution and conversion of various AST node types *@ param constructArgs constructor parameter, which can be a single AST node or AST node array *@ returns The constructor parameter array after parsing */ private getConstructArgs; /** *Get the class name of the new expression *@ param newExpression - new expression node of CxxAstNode type *@ returns the processed class name string */ private getNewExpressionClassName; /** *Remove the outermost template parameter (angle brackets and their contents) from the string *@ param typeStr is a type string containing template parameters *@ returns string after removing the outermost template parameter */ private removeOutermostTemplateArgs; /** *Convert the new array expression of C++to ValueAndStmts *@ param newArrayExpression - C++AST node, representing new array expression *@ returns ValueAndStmts object, including converted values and related statements */ private cxxNewArrayExpressionToValueAndStmts; /** *Convert C++array literal expression to ValueAndStmts *@ param arrayLiteralExpression - Array literal node in C++abstract syntax tree *@ returns The ValueAndStmts object containing the converted value and related statements */ private cxxArrayLiteralExpressionToValueAndStmts; private getArrayDimensions; /** *Process array literal expression and convert it to intermediate representation *@ param arrayLiteralExpression array literal expression node *@ param stmts is used to collect the generated statement list *@ param elementTypes is used to collect the collection of array element types *@ param elementValues is used to collect the list of array element values *@ param elementPositions is used to collect the list of array element position information */ private getArrayLiteralExpression; /** *Generate IR expressed by C++array * *@ param baseType - the basic type of the array element *@ param arrayLengthValue - value object of array length *@ param arrayLengthPosition - position information of array length *@ param arrayLength - the actual length of the array *@ param initializerValues - array initialization value list *@ param initializerPositions - List of location information of initialization values *@ param currStmts - List of existing statements *@ param newArrayExprPosition - position information of the new array expression *@ param fromLiteral - whether from literal *@ returns The ValueAndStmts object containing values and statements */ private cxxGenerateArrayExprAndStmts; /** *Converts C++prefix unary expression nodes to IR values and statement lists. * *@ param prefixUnaryExpression - prefix unary expression node in C++AST *@ returns The object containing the converted value and the generated statement list */ private cxxPrefixIncDecToValueAndStmts; private cxxPrefixUnaryExpressionToValueAndStmts; /** *Convert a C++suffix unary expression to a sequence of values and statements * *@ param postfixUnaryExpression - suffix unary expression node in C++AST *@ returns The object containing the converted value and related statements */ private cxxPostfixUnaryExpressionToValueAndStmts; declStmtToValueAndStmts(decl: CxxAstNode): ValueAndStmts; /** *Convert C++variable declarations to combinations of values and statements *@ param variableDeclaration - C++variable declaration node *@ param isConst - whether it is a constant declaration *@ param needRightOp - Whether the right operand is required, the default is true *@ returns the ValueAndStmts object containing values and statements */ cxxVariableDeclarationToValueAndStmts(variableDeclaration: CxxAstNode, needRightOp?: boolean): ValueAndStmts; private isCxxArray; /** *Process C++assignment expressions and convert them into ValueAndStmts structures. * *@ param leftOpNode The AST node of the left operand *@ param rightOpNode The AST node of the right operand, which may be undefined *@ param variableDefFlag indicates whether the variable is defined *@ param isConst indicates whether it is a constant *@ param declarationType Declared type *@ param needRightOp Whether to process the right operand, the default is true *@ returns the ValueAndStmts object containing the value, original position and statement list */ private cxxAssignmentToValueAndStmts; /** *CPP implementation of converting the right operand node to a list of values and statements *@ param rightOpNode The AST node of the right operand, which may be undefined *@ param leftValue Left value object *@ returns Objects containing values, location information, and statement lists */ private cxxAssignmentRightOpToValueAndStmts; /** *Convert the C++AST node to a single address value and statement list *@ param node - C++AST node to be converted *@ returns An object containing a list of values, original positions, and statements */ private cxxNodeToSingleAddressValueAndStmts; /** *Converts a C++binary expression node to a list of values and statements. *In assignment patterns, the left operand will be an array literal expression *In assignment patterns, the left operand will be an object literal expression *@ param binaryExpression - Binary expression node in C++AST *@ returns The ValueAndStmts object containing calculated values and related statements */ private cxxBinaryExpressionToValueAndStmts; /** *Convert compound assignment expressions (such as+=, -=, etc.) in C++to values and statement lists in intermediate representation (IR). * *@ param binaryExpression represents the C++AST node of the compound assignment operation *@ returns an object containing the calculated value, the original location information, and the generated statement list */ private cxxCompoundAssignmentToValueAndStmts; /** *Convert the compound assignment operator to the corresponding binary operator * *@ param token - compound assignment operator string *@ returns The corresponding binary operator. If no match is found, null is returned */ private cxxCcompoundAssignmentTokenToBinaryOperator; /** *Convert C++conditional expression nodes to a combination of values and statements *@ param condition - Condition node in C++abstract syntax tree *@ returns Objects containing conditional expression values and related statements */ cxxConditionToValueAndStmts(condition: CxxAstNode): ValueAndStmts; private parseFloatAsCxxFloat; /** *Convert literal nodes in C++AST into corresponding value and statement lists. *Literals currently processed: integer, floating point, string, character, Boolean value, null pointer, address label *@ param literalNode - an AST node representing a C++literal *@ returns the object containing the value, original location information and statement list. If the node type cannot be processed, null is returned */ private characterLiteralText; private cxxLiteralNodeToValueAndStmts; static isCxxCompoundAssignmentOperator(op?: CxxOpcode): boolean; private static isRelationalBinaryOperator; } //# sourceMappingURL=ArkValueTransformer.d.ts.map