* The core base class for all nodes
| 10 | * The core base class for all nodes |
| 11 | */ |
| 12 | class Node { |
| 13 | type: NodeType; |
| 14 | childList: Node[]; |
| 15 | expressionId: number; |
| 16 | nodeParam: NodeParamStruct; |
| 17 | constructor() { |
| 18 | this.childList = []; |
| 19 | this.type = "UNDEFINED"; |
| 20 | this.expressionId = 0; |
| 21 | this.nodeParam = { |
| 22 | STRING_ARRAY: [], |
| 23 | ADDRESS_2DARRAY: [], |
| 24 | UINT256_2DARRAY: [], |
| 25 | BYTES: [], |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Just generate a condition node struct for the expression node |
| 31 | * @param id The id of the condition node |
| 32 | * @returns The condition node struct |
| 33 | */ |
| 34 | private generateExpressionConditionNodeStruct(id: bigint): ConditionNodeStruct { |
| 35 | if (this.type !== "EXPRESSION") { |
| 36 | throw new Error("Node type is not EXPRESSION"); |
| 37 | } |
| 38 | const conditionNodeStruct: ConditionNodeStruct = { |
| 39 | id: id, |
| 40 | nodeType: 1, |
| 41 | logicalOperator:0, |
| 42 | conditionExpression: this.expressionId, |
| 43 | childList: [], |
| 44 | param: this.nodeParam, |
| 45 | }; |
| 46 | return conditionNodeStruct; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Generate a condition node struct for BOOLEAN_TRUE or BOOLEAN_FALSE |
| 51 | * @param id The id of the condition node |
| 52 | * @returns The condition node struct |
| 53 | */ |
| 54 | private generateBooleanConditionNodeStruct(id: bigint): ConditionNodeStruct { |
| 55 | if (this.type !== "TRUE" && this.type !== "FALSE") { |
| 56 | throw new Error("Node type is not TRUE or FALSE"); |
| 57 | } |
| 58 | if (this.type === "TRUE") { |
| 59 | const conditionNodeStruct: ConditionNodeStruct = { |
| 60 | id: id, |
| 61 | nodeType: 3, |
| 62 | logicalOperator: 0, |
| 63 | conditionExpression: 0, |
| 64 | childList: [], |
| 65 | param: this.nodeParam, |
| 66 | }; |
| 67 | return conditionNodeStruct; |
| 68 | } |
| 69 | else { |
nothing calls this directly
no outgoing calls
no test coverage detected