• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    KNativePointer,
23    nodeByType,
24    Es2pandaAstNodeType,
25} from '../../reexport-for-generated';
26import { Expression } from './Expression';
27import { LoopStatement } from './LoopStatement';
28import { Statement } from './Statement';
29
30export class ForUpdateStatement extends LoopStatement {
31    constructor(pointer: KNativePointer) {
32        assertValidPeer(pointer, Es2pandaAstNodeType.AST_NODE_TYPE_FOR_UPDATE_STATEMENT);
33        super(pointer);
34    }
35    static createForUpdateStatement(
36        init?: AstNode,
37        test?: Expression,
38        update?: Expression,
39        body?: Statement
40    ): ForUpdateStatement {
41        return new ForUpdateStatement(
42            global.generatedEs2panda._CreateForUpdateStatement(
43                global.context,
44                passNode(init),
45                passNode(test),
46                passNode(update),
47                passNode(body)
48            )
49        );
50    }
51
52    static updateForUpdateStatement(
53        original: ForUpdateStatement,
54        init?: AstNode,
55        test?: Expression,
56        update?: Expression,
57        body?: Statement
58    ): ForUpdateStatement {
59        return new ForUpdateStatement(
60            global.generatedEs2panda._UpdateForUpdateStatement(
61                global.context,
62                passNode(original),
63                passNode(init),
64                passNode(test),
65                passNode(update),
66                passNode(body)
67            )
68        );
69    }
70
71    get init(): AstNode | undefined {
72        return unpackNode(global.generatedEs2panda._ForUpdateStatementInit(global.context, this.peer));
73    }
74    get test(): Expression | undefined {
75        return unpackNode(global.generatedEs2panda._ForUpdateStatementTest(global.context, this.peer));
76    }
77    get update(): Expression | undefined {
78        return unpackNode(global.generatedEs2panda._ForUpdateStatementUpdateConst(global.context, this.peer));
79    }
80    get body(): Statement | undefined {
81        return unpackNode(global.generatedEs2panda._ForUpdateStatementBody(global.context, this.peer));
82    }
83    protected readonly brandForUpdateStatement: undefined;
84}
85
86export function isForUpdateStatement(node: object | undefined): node is ForUpdateStatement {
87    return node instanceof ForUpdateStatement;
88}
89
90if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_UPDATE_STATEMENT)) {
91    nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_UPDATE_STATEMENT, ForUpdateStatement);
92}
93