1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { 17 global, 18 passNode, 19 unpackNode, 20 assertValidPeer, 21 AstNode, 22 Es2pandaAstNodeType, 23 KNativePointer, 24 nodeByType, 25} from '../../reexport-for-generated'; 26 27import { LoopStatement } from './LoopStatement'; 28import { Expression } from './Expression'; 29import { Statement } from './Statement'; 30export class ForInStatement extends LoopStatement { 31 constructor(pointer: KNativePointer) { 32 assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_FOR_IN_STATEMENT); 33 super(pointer); 34 } 35 static createForInStatement(left?: AstNode, right?: Expression, body?: Statement): ForInStatement { 36 return new ForInStatement( 37 global.generatedEs2panda._CreateForInStatement( 38 global.context, 39 passNode(left), 40 passNode(right), 41 passNode(body) 42 ) 43 ); 44 } 45 static updateForInStatement( 46 original?: ForInStatement, 47 left?: AstNode, 48 right?: Expression, 49 body?: Statement 50 ): ForInStatement { 51 return new ForInStatement( 52 global.generatedEs2panda._UpdateForInStatement( 53 global.context, 54 passNode(original), 55 passNode(left), 56 passNode(right), 57 passNode(body) 58 ) 59 ); 60 } 61 get left(): AstNode | undefined { 62 return unpackNode(global.generatedEs2panda._ForInStatementLeft(global.context, this.peer)); 63 } 64 get right(): Expression | undefined { 65 return unpackNode(global.generatedEs2panda._ForInStatementRight(global.context, this.peer)); 66 } 67 get body(): Statement | undefined { 68 return unpackNode(global.generatedEs2panda._ForInStatementBody(global.context, this.peer)); 69 } 70 protected readonly brandForInStatement: undefined; 71} 72export function isForInStatement(node: object | undefined): node is ForInStatement { 73 return node instanceof ForInStatement; 74} 75if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_IN_STATEMENT)) { 76 nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_IN_STATEMENT, ForInStatement); 77} 78