1# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14
15change_types:
16  - es2panda_arg:
17      name: '|arg_name|'
18      type:
19        name: ArenaVector
20        template_args:
21        - type: '|element_type|'
22    new_args:
23    - type: '|element_type|'
24      name: '|arg_name|'
25      increase_ptr_depth: 1
26      local_var_name: '|arg_name|'
27      namespace: ''
28    - type:
29        name: size_t
30      name: '|arg_name|Len'
31    return_args:
32    - type:
33        name: size_t
34        ptr_depth: 1
35      name: '|arg_name|Len'
36    cast:
37        expression: "\
38          ArenaVector<|new_args.0.namespace||es2panda_arg.type.template_args.0.type.name| |es2panda_arg.type.template_args.0.type.ptr_depth|> |arg_name|ArenaVector
39          {reinterpret_cast<Context *>(context)->allocator->Adapter()};\n
40          \tfor (size_t i = 0; i < |arg_name|Len; ++i) {\n
41          \t\tauto |es2panda_arg.type.template_args.0.type.ptr_depth||es2panda_arg.type.template_args.0.type.ref_depth||arg_name|Element1 = |arg_name|[i];\n
42          \t\t|template_nested_expression_1|\n
43          \t\t|arg_name|ArenaVector.push_back(|new_args.0.local_var_name|);\n
44          \t}"
45        var_name: '|arg_name|ArenaVector'
46        reverse_cast:
47          start: "\n
48            \tauto *ctx = reinterpret_cast<Context *>(context);\n
49            \tauto *ctxAllocator = ctx->allocator;\n
50            \tauto resultVector = "
51          end: ";\n
52            \t*|return_args.0.name| = resultVector|accessor|size();\n
53            \tauto res = ctxAllocator->New<|new_args.0.type.name| |new_args.0.type.ptr_depth - 1||new_args.0.type.ref_depth|[]>(*|return_args.0.name|);\n
54            \tfor (size_t i = 0; i < *|return_args.0.name|; ++i) {\n
55            \tauto toPush = |reverse_template_nested_expression_1_start|(resultVector|accessor|at(i))|reverse_template_nested_expression_1_end|;\n
56            \t\tres[i] = reinterpret_cast<|new_args.0.type.name| |new_args.0.type.ptr_depth - 1||new_args.0.type.ref_depth|>(toPush);\n
57            \t}"
58
59  - es2panda_arg:
60      name: '|arg_name|'
61      type:
62        name: vector
63        template_args:
64        - type: '|element_type|'
65    new_args:
66    - type: '|element_type|'
67      name: '|arg_name|'
68      increase_ptr_depth: 1
69      local_var_name: '|arg_name|'
70      namespace: ''
71    - type:
72        name: size_t
73      name: '|arg_name|Len'
74    return_args:
75    - type:
76        name: size_t
77        ptr_depth: 1
78      name: '|arg_name|Len'
79    cast:
80        expression: "\
81          \t\tstd::vector<|new_args.0.namespace||es2panda_arg.type.template_args.0.type.name| |es2panda_arg.type.template_args.0.type.ptr_depth|> |arg_name|Vector;\n
82          \t\tfor (size_t i = 0; i < |arg_name|Len; ++i) {\n
83          \t\tauto |es2panda_arg.type.template_args.0.type.ptr_depth||es2panda_arg.type.template_args.0.type.ref_depth||arg_name|Element1 = |arg_name|[i];\n
84          \t\t|template_nested_expression_1|\n
85          \t\t\t|arg_name|Vector.push_back(|new_args.0.local_var_name|);\n
86          \t\t}"
87        var_name: '|arg_name|Vector'
88        reverse_cast:
89          start: "\n
90            auto *ctx = reinterpret_cast<Context *>(context);\n
91            auto *ctxAllocator = ctx->allocator;\n
92            auto resultVector = "
93          end: ";\n
94            \t/* WARNING! This section has not been tested! */\n
95            \t*|return_args.0.name| = resultVector|accessor|size();\n
96            \tauto res = ctxAllocator->New<|new_args.0.type.name| |new_args.0.type.ptr_depth - 1||new_args.0.type.ref_depth|[]>(*|return_args.0.name|);\n
97            \tfor (size_t i = 0; i < *|return_args.0.name|; ++i) {\n
98            \tauto toPush = |reverse_template_nested_expression_1_start|(resultVector|accessor|at(i))|reverse_template_nested_expression_1_end|;\n
99            \t\tres[i] = reinterpret_cast<|new_args.0.type.name| |new_args.0.type.ptr_depth - 1||new_args.0.type.ref_depth|>(toPush);\n
100            \t}"
101
102  - es2panda_arg:
103      name: '|arg_name|'
104      type:
105        name: ArenaSet
106        template_args:
107        - type: '|element_type|'
108      max_ptr_depth: 0
109    new_args:
110    - type: '|element_type|'
111      name: '|arg_name|'
112      increase_ptr_depth: 1
113      local_var_name: '|arg_name|'
114      namespace: ''
115    - type:
116        name: size_t
117      name: '|arg_name|Len'
118    return_args:
119    - type:
120        name: size_t
121        ptr_depth: 1
122      name: '|arg_name|Len'
123    cast:
124        expression: "\
125          \tArenaSet<|new_args.0.namespace||es2panda_arg.type.template_args.0.type.name| |es2panda_arg.type.template_args.0.type.ptr_depth|> |arg_name|ArenaSet
126          {reinterpret_cast<Context *>(context)->allocator->Adapter()};\n
127          \t\tfor (size_t i = 0; i < |arg_name|Len; ++i) {\n
128          \t\tauto |es2panda_arg.type.template_args.0.type.ptr_depth||es2panda_arg.type.template_args.0.type.ref_depth||arg_name|Element1 = |arg_name|[i];\n
129          \t\t|template_nested_expression_1|\n
130          \t\t\t|arg_name|ArenaSet.insert(|new_args.0.local_var_name|);\n
131          \t\t}"
132        var_name: '|arg_name|ArenaSet'
133        reverse_cast:
134          start: "\n
135            \tauto *ctx = reinterpret_cast<Context *>(context);\n
136            \tauto *ctxAllocator = ctx->allocator;\n
137            \tauto resultSet = "
138          end: ";\n
139            \t*|return_args.0.name| = resultSet|accessor|size();\n
140            \tauto res = ctxAllocator->New<|new_args.0.type.name| |new_args.0.type.ptr_depth - 1||new_args.0.type.ref_depth|[]>(*|return_args.0.name|);\n
141            \tsize_t i = 0;\n
142            \tfor (auto elem : resultSet) {\n
143            \tauto toPush = |reverse_template_nested_expression_1_start|(elem)|reverse_template_nested_expression_1_end|;\n
144            \t\tres[i] = reinterpret_cast<|new_args.0.type.name| |new_args.0.type.ptr_depth - 1||new_args.0.type.ref_depth|>(toPush);\n
145            \t}"
146
147  - es2panda_arg:
148      name: '|arg_name|'
149      type:
150        name: pair
151        template_args:
152        - type: '|element_type_1|'
153        - type: '|element_type_2|'
154      max_ptr_depth: 0
155    new_args:
156    - type: '|element_type_1|'
157      name: '|arg_name|First'
158      local_var_name: '|arg_name|First'
159    - type: '|element_type_2|'
160      name: '|arg_name|Second'
161      local_var_name: '|arg_name|Second'
162    return_args:
163    - type: '|element_type_2|'
164      name: '|arg_name|Second'
165      increase_ptr_depth: 1
166    cast:
167        expression: " /* ERROR! NOT IMPLEMENTED EXPRESSION FOR STD::PAIR */ \n"
168        var_name: '|arg_name|ArenaSet'
169        reverse_cast:
170          start: "\n
171            \tauto *ctx = reinterpret_cast<Context *>(context);\n
172            \tauto *ctxAllocator = ctx->allocator;\n
173            \tauto resultPair = "
174          end: ";\n
175            \t*|arg_name|Second = |reverse_template_nested_expression_2_start|(const_cast<|new_args.1.namespace||es2panda_arg.type.template_args.1.type.name| |es2panda_arg.type.template_args.1.type.ptr_depth|>(resultPair|accessor|second))|reverse_template_nested_expression_2_end|;\n
176            \tauto res = |reverse_template_nested_expression_1_start|(resultPair|accessor|first)|reverse_template_nested_expression_1_end|;\n
177            "
178
179  - es2panda_arg:
180      name: '|arg_name|'
181      type:
182        name: 'Typed'
183        ptr_depth: '|arg_ptr_depth|'
184      min_ptr_depth: 1
185    new_args:
186    - type:
187        name: 'es2panda_AstNode'
188        ptr_depth: '|arg_ptr_depth|'
189      name: '|arg_name|'
190      namespace: 'ir::'
191    cast:
192        expression: >-
193          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
194          reinterpret_cast<ir::Typed<AstNode> |es2panda_arg.type.ptr_depth|>(|arg_name|);
195        reverse_cast:
196          start: >-
197            reinterpret_cast<?const? es2panda_AstNode |es2panda_arg.type.ptr_depth|>
198        call_cast:
199          call_var: 'es2panda_AstNode *ast'
200          start: >-
201            (reinterpret_cast<?const? ir::Typed<ir::AstNode> *>(ast))->
202        constructor_cast:
203          start: >-
204            ctxAllocator->New<ir::Typed<AstNode>>(
205          end: )
206        var_name: '|arg_name|E2p'
207
208  - es2panda_arg:
209      name: '|arg_name|'
210      type: '|AstNode|'
211      min_ptr_depth: 1
212    new_args:
213    - type:
214        name: "es2panda_AstNode"
215        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
216      name: '|arg_name|'
217      namespace: 'ir::'
218    cast:
219        expression: >-
220          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
221          reinterpret_cast<ir::|es2panda_arg.type.name| |es2panda_arg.type.ptr_depth|>(|arg_name|);
222        reverse_cast:
223          start: >-
224            reinterpret_cast<?const? es2panda_AstNode |es2panda_arg.type.ptr_depth|>
225        call_cast:
226          call_var: 'es2panda_AstNode *ast'
227          start: >-
228            (reinterpret_cast<?const? ir::|es2panda_arg.type.name| *>(ast))->
229        constructor_cast:
230          start: >-
231            ctxAllocator->New<ir::|es2panda_arg.type.name|>(
232          end: )
233        var_name: '|arg_name|E2p'
234
235  - es2panda_arg:
236      name: '|arg_name|'
237      type: '|AstNode|'
238      max_ptr_depth: 0
239    new_args:
240    - type:
241        name: "es2panda_AstNode"
242        ptr_depth: 1
243      name: '|arg_name|'
244      namespace: 'ir::'
245    cast:
246        expression: ""
247        var_name: '*reinterpret_cast<ir::|es2panda_arg.type.name| *>(|arg_name|)'
248
249  - es2panda_arg:
250      name: '|arg_name|'
251      type: '|AstNodeAdditionalChildren|'
252      min_ptr_depth: 1
253    new_args:
254    - type:
255        name: "es2panda_AstNode"
256        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
257      name: '|arg_name|'
258      namespace: 'ir::'
259    cast:
260        expression: >-
261          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
262          reinterpret_cast<ir::|es2panda_arg.type.name| |es2panda_arg.type.ptr_depth|>(|arg_name|);
263        reverse_cast:
264          start : >-
265            reinterpret_cast<?const? es2panda_AstNode |es2panda_arg.type.ptr_depth|>
266        call_cast:
267          call_var: 'es2panda_AstNode *ast'
268          start: >-
269            (reinterpret_cast<?const? ir::|es2panda_arg.type.name| *>(ast))->
270        constructor_cast:
271          start: >-
272            ctxAllocator->New<ir::|es2panda_arg.type.name|>(
273          end: )
274        var_name: '|arg_name|E2p'
275
276  - es2panda_arg:
277      name: '|arg_name|'
278      type: '|AstNodeAdditionalChildren|'
279      max_ptr_depth: 0
280    new_args:
281    - type:
282        name: "es2panda_AstNode"
283        ptr_depth: 1
284      name: '|arg_name|'
285      namespace: 'ir::'
286    cast:
287        expression: ""
288        var_name: '*reinterpret_cast<ir::|es2panda_arg.type.name| *>(|arg_name|)'
289
290  - es2panda_arg:
291      name: '|arg_name|'
292      type: '|CodeGen|'
293      min_ptr_depth: 1
294    new_args:
295    - type:
296        name: "es2panda_CodeGen"
297        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
298      name: '|arg_name|'
299      namespace: 'compiler::'
300    cast:
301        expression: >-
302          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
303          reinterpret_cast<compiler::|es2panda_arg.type.name| |es2panda_arg.type.ptr_depth|>(|arg_name|);
304        reverse_cast:
305          start : >-
306            reinterpret_cast<?const? es2panda_CodeGen |es2panda_arg.type.ptr_depth|>
307        call_cast:
308          call_var: 'es2panda_CodeGen *ast'
309          start: >-
310            (reinterpret_cast<?const? compiler::|es2panda_arg.type.name| *>(ast))->
311        constructor_cast:
312          start: >-
313            ctxAllocator->New<compiler::|es2panda_arg.type.name|>(
314          end: )
315        var_name: '|arg_name|E2p'
316
317  - es2panda_arg:
318      name: '|arg_name|'
319      type: '|AstType|'
320      min_ptr_depth: 1
321    new_args:
322    - type:
323        name: 'es2panda_Type'
324        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
325      name: '|arg_name|'
326      namespace: 'checker::'
327    cast:
328        expression: >-
329          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
330          reinterpret_cast<checker::|es2panda_arg.type.name| |es2panda_arg.type.ptr_depth|>(|arg_name|);
331        reverse_cast:
332          start: >-
333            reinterpret_cast<?const? es2panda_Type |es2panda_arg.type.ptr_depth|>
334        call_cast:
335          call_var: 'es2panda_Type *ast'
336          start: >-
337            (reinterpret_cast<?const? checker::|es2panda_arg.type.name| *>(ast))->
338        constructor_cast:
339          start: >-
340            ctxAllocator->New<checker::|es2panda_arg.type.name|>(
341          end: )
342        var_name: '|arg_name|E2p'
343
344  - es2panda_arg:
345      name: '|arg_name|'
346      type: '|Variable|'
347      min_ptr_depth: 1
348    new_args:
349    - type:
350        name: 'es2panda_Variable '
351        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
352      name: '|arg_name|'
353      namespace: 'varbinder::'
354    cast:
355        expression: >-
356          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
357          reinterpret_cast<varbinder::|es2panda_arg.type.name| |es2panda_arg.type.ptr_depth|>(|arg_name|);
358        reverse_cast:
359          start: >-
360            reinterpret_cast<?const? es2panda_Variable |es2panda_arg.type.ptr_depth|>
361        call_cast:
362          call_var: 'es2panda_Variable *ast'
363          start: >-
364            (reinterpret_cast<?const? varbinder::|es2panda_arg.type.name| *>(ast))->
365        constructor_cast:
366          start: >-
367            ctxAllocator->New<varbinder::|es2panda_arg.type.name|>(
368          end: )
369        var_name: '|arg_name|E2p'
370
371  - es2panda_arg:
372      name: '|arg_name|'
373      type: '|Enum|'
374      max_ptr_depth: 0
375    new_args:
376      - type:
377          name: 'Es2panda|es2panda_arg.type.name|'
378        name: '|arg_name|'
379    cast:
380        expression: >-
381          auto |arg_name|E2p = E2pToIr|es2panda_arg.type.name|(|arg_name|);
382        reverse_cast:
383          start: >-
384            IrToE2p|es2panda_arg.type.name|
385        var_name: '|arg_name|E2p'
386
387  - es2panda_arg:
388      name: '|arg_name|'
389      type: '|Scope|'
390      min_ptr_depth: 1
391    new_args:
392    - type:
393        name: "es2panda_Scope"
394        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
395      name: '|arg_name|'
396      namespace: 'varbinder::'
397    cast:
398        expression: >-
399          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
400          reinterpret_cast<varbinder::|es2panda_arg.type.name| |es2panda_arg.type.ptr_depth|>(|arg_name|);
401        reverse_cast:
402          start : >-
403            reinterpret_cast<?const? es2panda_Scope |es2panda_arg.type.ptr_depth|>
404        call_cast:
405          call_var: 'es2panda_Scope *ast'
406          start: >-
407            (reinterpret_cast<?const? varbinder::|es2panda_arg.type.name| *>(ast))->
408        constructor_cast:
409          start: >-
410            ctxAllocator->New<varbinder::|es2panda_arg.type.name|>(
411          end: )
412        var_name: '|arg_name|E2p'
413
414  - es2panda_arg:
415      name: '|arg_name|'
416      type: '|Scope|'
417      max_ptr_depth: 0
418    new_args:
419    - type:
420        name: "es2panda_Scope"
421        ptr_depth: 1
422      name: '|arg_name|'
423      namespace: 'varbinder::'
424    cast:
425        expression: ""
426        var_name: '*reinterpret_cast<varbinder::|es2panda_arg.type.name| *>(|arg_name|)'
427
428
429  - es2panda_arg:
430      name: '|arg_name|'
431      type:
432        name: Checker
433      min_ptr_depth: 1
434      max_ptr_depth: 1
435    new_args:
436    - type:
437        name: ""
438      name: ""
439    cast:
440      expression: auto |es2panda_arg.type.ptr_depth||arg_name|E2p = reinterpret_cast<Context *>(context)->checker;
441      var_name: '|arg_name|E2p'
442
443  - es2panda_arg:
444      name: '|arg_name|'
445      type:
446        name: ETSChecker
447      min_ptr_depth: 1
448      max_ptr_depth: 1
449    new_args:
450    - type:
451        name: ""
452      name: ""
453      namespace: 'checker'
454    cast:
455      expression: >-
456        auto *|arg_name|E2p = reinterpret_cast<Context *>(context)->checker->AsETSChecker();
457      var_name: '|arg_name|E2p'
458
459  - es2panda_arg:
460      name: '|arg_name|'
461      type:
462        name: ArenaAllocator
463      min_ptr_depth: 1
464      max_ptr_depth: 1
465    new_args:
466    - type:
467        name: ""
468      name: ""
469    cast:
470      expression: auto |es2panda_arg.type.ptr_depth||arg_name|E2p = reinterpret_cast<Context *>(context)->allocator;
471      var_name: '|arg_name|E2p'
472
473  - es2panda_arg:
474      name: '|arg_name|'
475      type:
476        name: Program
477        namespace: 'pandasm'
478      min_ptr_depth: 1
479      max_ptr_depth: 1
480    new_args:
481    - type:
482        name: ""
483      name: ""
484    cast:
485      expression: auto |es2panda_arg.type.ptr_depth||arg_name|E2p = reinterpret_cast<Context *>(context)->program;
486      var_name: '|arg_name|E2p'
487
488  - es2panda_arg:
489      name: '|arg_name|'
490      type:
491        name: Program
492        namespace: 'parser'
493      min_ptr_depth: 1
494      max_ptr_depth: 1
495    new_args:
496    - type:
497        name: ""
498      name: ""
499    cast:
500      expression: auto |es2panda_arg.type.ptr_depth||arg_name|E2p = reinterpret_cast<Context *>(context)->parserProgram;
501      var_name: '|arg_name|E2p'
502
503  - es2panda_arg:
504      name: '|arg_name|'
505      type:
506        name: 'FunctionSignature'
507      min_ptr_depth: 1
508    new_args:
509    - type:
510        name: "es2panda_FunctionSignature"
511        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
512      name: '|arg_name|'
513    cast:
514        expression: >-
515          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
516          reinterpret_cast<ir::FunctionSignature |es2panda_arg.type.ptr_depth|>(|arg_name|);
517        reverse_cast:
518          start: >-
519            reinterpret_cast<?const? es2panda_FunctionSignature |es2panda_arg.type.ptr_depth|>
520        call_cast:
521          call_var: 'es2panda_FunctionSignature *ast'
522          start: >-
523            (reinterpret_cast<?const? ir::FunctionSignature *>(ast))->
524        constructor_cast:
525          start: >-
526            ctxAllocator->New<ir::FunctionSignature>(
527          end: )
528        var_name: '|arg_name|E2p'
529
530  - es2panda_arg:
531      name: '|arg_name|'
532      type:
533        name: 'FunctionSignature'
534      max_ptr_depth: 0
535    new_args:
536    - type:
537        name: "es2panda_FunctionSignature"
538        ptr_depth: 1
539      name: '|arg_name|'
540    cast:
541        expression: ''
542        var_name: 'std::forward<ir::FunctionSignature>(*reinterpret_cast<ir::FunctionSignature *>(|arg_name|))'
543        reverse_cast:
544          start: >-
545            reinterpret_cast<?const? es2panda_FunctionSignature *>(
546            reinterpret_cast<Context *>(context)->allocator->New<ir::FunctionSignature>(
547          end: '))'
548
549  - es2panda_arg:
550      name: '|arg_name|'
551      type:
552        name: 'Language'
553      min_ptr_depth: 1
554    new_args:
555    - type:
556        name: "es2panda_Language"
557        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
558      name: '|arg_name|'
559    cast:
560        expression: >-
561          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
562          reinterpret_cast<Language |es2panda_arg.type.ptr_depth|>(|arg_name|);
563        reverse_cast:
564          start: >-
565            reinterpret_cast<?const? es2panda_Language |es2panda_arg.type.ptr_depth|>
566        call_cast:
567          call_var: 'es2panda_Language *ast'
568          start: >-
569            (reinterpret_cast<?const? Language *>(ast))->
570        constructor_cast:
571          start: >-
572            ctxAllocator->New<Language>(
573          end: )
574        var_name: '|arg_name|E2p'
575
576  - es2panda_arg:
577      name: '|arg_name|'
578      type:
579        name: 'Language'
580      max_ptr_depth: 0
581    new_args:
582    - type:
583        name: "es2panda_Language"
584        ptr_depth: 1
585      name: '|arg_name|'
586    cast:
587        expression: >-
588          auto |arg_name|E2p = *reinterpret_cast<Language *>(|arg_name|);
589        reverse_cast:
590          start: >-
591            reinterpret_cast<?const? es2panda_Language *>(
592            reinterpret_cast<Context *>(context)->allocator->New<Language>(
593          end: '))'
594        var_name: '|arg_name|E2p'
595
596  - es2panda_arg:
597      name: '|arg_name|'
598      type:
599        name: 'SourcePosition'
600        namespace: 'lexer'
601      min_ptr_depth: 1
602    new_args:
603    - type:
604        name: "es2panda_SourcePosition"
605        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
606      name: '|arg_name|'
607      namespace: 'lexer::'
608    cast:
609        expression: >-
610          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
611          reinterpret_cast<lexer::SourcePosition |es2panda_arg.type.ptr_depth|>(|arg_name|);
612        reverse_cast:
613          start : >-
614            reinterpret_cast<?const? es2panda_SourcePosition |es2panda_arg.type.ptr_depth|>
615        call_cast:
616          call_var: 'es2panda_SourcePosition *ast'
617          start: >-
618            (reinterpret_cast<?const? lexer::SourcePosition *>(ast))->
619        constructor_cast:
620          start: >-
621            ctxAllocator->New<lexer::SourcePosition>(
622          end: )
623        var_name: '|arg_name|E2p'
624
625  - es2panda_arg:
626      name: '|arg_name|'
627      type:
628        name: 'SourcePosition'
629        namespace: 'lexer'
630      max_ptr_depth: 0
631    new_args:
632    - type:
633        name: "es2panda_SourcePosition"
634        ptr_depth: 1
635      name: '|arg_name|'
636      namespace: 'lexer::'
637    cast:
638        expression: >-
639          auto |arg_name|E2p = *reinterpret_cast<lexer::SourcePosition *>(|arg_name|);
640        reverse_cast:
641          start: >-
642            reinterpret_cast<?const? es2panda_SourcePosition *>(
643            reinterpret_cast<Context *>(context)->allocator->New<lexer::SourcePosition>(
644          end: '))'
645        var_name: '|arg_name|E2p'
646
647  - es2panda_arg:
648      name: '|arg_name|'
649      type:
650        name: 'SourceRange'
651        namespace: 'lexer'
652      min_ptr_depth: 1
653    new_args:
654    - type:
655        name: "es2panda_SourceRange"
656        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
657      name: '|arg_name|'
658      namespace: 'lexer::'
659    cast:
660        expression: >-
661          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
662          reinterpret_cast<lexer::SourceRange |es2panda_arg.type.ptr_depth|>(|arg_name|);
663        reverse_cast:
664          start : >-
665            reinterpret_cast<?const? es2panda_SourceRange |es2panda_arg.type.ptr_depth|>
666        call_cast:
667          call_var: 'es2panda_SourceRange *ast'
668          start: >-
669            (reinterpret_cast<?const? lexer::SourceRange *>(ast))->
670        constructor_cast:
671          start: >-
672            ctxAllocator->New<lexer::SourceRange>(
673          end: )
674        var_name: '|arg_name|E2p'
675
676  - es2panda_arg:
677      name: '|arg_name|'
678      type:
679        name: 'SourceRange'
680        namespace: 'lexer'
681      max_ptr_depth: 0
682    new_args:
683    - type:
684        name: "es2panda_SourceRange"
685        ptr_depth: 1
686      name: '|arg_name|'
687      namespace: 'lexer::'
688    cast:
689        expression: >-
690          auto |arg_name|E2p = *reinterpret_cast<lexer::SourceRange *>(|arg_name|);
691        reverse_cast:
692          start: >-
693            reinterpret_cast<?const? es2panda_SourceRange *>(
694            reinterpret_cast<Context *>(context)->allocator->New<lexer::SourceRange>(
695          end: '))'
696        var_name: '|arg_name|E2p'
697
698  - es2panda_arg:
699      name: '|arg_name|'
700      type:
701        name: 'VReg'
702        namespace: 'compiler'
703      min_ptr_depth: 1
704    new_args:
705    - type:
706        name: "es2panda_VReg"
707        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
708      name: '|arg_name|'
709      namespace: 'compiler::'
710    cast:
711        expression: >-
712          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
713          reinterpret_cast<compiler::VReg |es2panda_arg.type.ptr_depth|>(|arg_name|);
714        reverse_cast:
715          start : >-
716            reinterpret_cast<?const? es2panda_VReg |es2panda_arg.type.ptr_depth|>
717        call_cast:
718          call_var: 'es2panda_VReg *ast'
719          start: >-
720            (reinterpret_cast<?const? compiler::VReg *>(ast))->
721        constructor_cast:
722          start: >-
723            ctxAllocator->New<compiler::VReg>(
724          end: )
725        var_name: '|arg_name|E2p'
726
727  - es2panda_arg:
728      name: '|arg_name|'
729      type:
730        name: 'VReg'
731        namespace: 'compiler'
732      max_ptr_depth: 0
733    new_args:
734    - type:
735        name: "es2panda_VReg"
736        ptr_depth: 1
737      name: '|arg_name|'
738      namespace: 'compiler::'
739    cast:
740        expression: >-
741          auto |arg_name|E2p = *reinterpret_cast<compiler::VReg *>(|arg_name|);
742        reverse_cast:
743          start: >-
744            reinterpret_cast<?const? es2panda_VReg *>(
745            reinterpret_cast<Context *>(context)->allocator->New<compiler::VReg>(
746          end: '))'
747        var_name: '|arg_name|E2p'
748
749  - es2panda_arg:
750      name: '|arg_name|'
751      type:
752        name: 'ScriptFunctionData'
753      min_ptr_depth: 1
754    new_args:
755    - type:
756        name: "es2panda_ScriptFunctionData"
757        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
758      name: '|arg_name|'
759    cast:
760        expression: >-
761          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
762          reinterpret_cast<ir::ScriptFunction::ScriptFunctionData |es2panda_arg.type.ptr_depth|>(|arg_name|);
763        reverse_cast:
764          start : >-
765            reinterpret_cast<?const? es2panda_ScriptFunctionData |es2panda_arg.type.ptr_depth|>
766        call_cast:
767          call_var: 'es2panda_ScriptFunctionData *ast'
768          start: >-
769            (reinterpret_cast<?const? ir::ScriptFunction::ScriptFunctionData *>(ast))->
770        constructor_cast:
771          start: >-
772            ctxAllocator->New<ir::ScriptFunction::ScriptFunctionData>(
773          end: )
774        var_name: '|arg_name|E2p'
775
776  - es2panda_arg:
777      name: '|arg_name|'
778      type:
779        name: 'ScriptFunctionData'
780      max_ptr_depth: 0
781    new_args:
782    - type:
783        name: "es2panda_ScriptFunctionData"
784        ptr_depth: 1
785      name: '|arg_name|'
786    cast:
787        expression: ''
788        var_name: 'std::forward<ir::ScriptFunction::ScriptFunctionData>(*reinterpret_cast<ir::ScriptFunction::ScriptFunctionData *>(|arg_name|))'
789
790  - es2panda_arg:
791      name: '|arg_name|'
792      type:
793        name: 'SrcDumper'
794      min_ptr_depth: 1
795    new_args:
796    - type:
797        name: "es2panda_SrcDumper"
798        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
799      name: '|arg_name|'
800      namespace: ''
801    cast:
802        expression: >-
803          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
804          reinterpret_cast<ir::SrcDumper |es2panda_arg.type.ptr_depth|>(|arg_name|);
805        reverse_cast:
806          start : >-
807            reinterpret_cast<?const? es2panda_SrcDumper |es2panda_arg.type.ptr_depth|>
808        call_cast:
809          call_var: 'es2panda_SrcDumper *ast'
810          start: >-
811            (reinterpret_cast<?const? ir::SrcDumper *>(ast))->
812        constructor_cast:
813          start: >-
814            ctxAllocator->New<ir::SrcDumper>(
815          end: )
816        var_name: '|arg_name|E2p'
817
818  - es2panda_arg:
819      name: '|arg_name|'
820      type:
821        name: 'SrcDumper'
822      max_ptr_depth: 0
823    new_args:
824    - type:
825        name: "es2panda_SrcDumper"
826        ptr_depth: 1
827      name: '|arg_name|'
828      namespace: ''
829    cast:
830        expression: ''
831        var_name: 'std::forward<ir::SrcDumper>(*reinterpret_cast<ir::SrcDumper *>(|arg_name|))'
832
833
834  - es2panda_arg:
835      name: '|arg_name|'
836      type:
837        name: 'AstDumper'
838      min_ptr_depth: 1
839    new_args:
840    - type:
841        name: "es2panda_AstDumper"
842        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
843      name: '|arg_name|'
844      namespace: ''
845    cast:
846        expression: >-
847          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
848          reinterpret_cast<ir::AstDumper |es2panda_arg.type.ptr_depth|>(|arg_name|);
849        reverse_cast:
850          start : >-
851            reinterpret_cast<?const? es2panda_AstDumper |es2panda_arg.type.ptr_depth|>
852        call_cast:
853          call_var: 'es2panda_AstDumper *ast'
854          start: >-
855            (reinterpret_cast<?const? ir::AstDumper *>(ast))->
856        constructor_cast:
857          start: >-
858            ctxAllocator->New<ir::AstDumper>(
859          end: )
860        var_name: '|arg_name|E2p'
861
862  - es2panda_arg:
863      name: '|arg_name|'
864      type:
865        name: 'AstDumper'
866      max_ptr_depth: 0
867    new_args:
868    - type:
869        name: "es2panda_AstDumper"
870        ptr_depth: 1
871      name: '|arg_name|'
872      namespace: ''
873    cast:
874        expression: ''
875        var_name: 'std::forward<ir::AstDumper>(*reinterpret_cast<ir::AstDumper *>(|arg_name|))'
876
877  - es2panda_arg:
878      name: '|arg_name|'
879      type:
880        name: 'LabelPair'
881      min_ptr_depth: 1
882    new_args:
883    - type:
884        name: "es2panda_LabelPair"
885        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
886      name: '|arg_name|'
887      namespace: 'compiler::'
888    cast:
889        expression: >-
890          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
891          reinterpret_cast<compiler::LabelPair |es2panda_arg.type.ptr_depth|>(|arg_name|);
892        reverse_cast:
893          start : >-
894            reinterpret_cast<?const? es2panda_LabelPair |es2panda_arg.type.ptr_depth|>
895        call_cast:
896          call_var: 'es2panda_LabelPair *ast'
897          start: >-
898            (reinterpret_cast<?const? compiler::LabelPair *>(ast))->
899        constructor_cast:
900          start: >-
901            ctxAllocator->New<compiler::LabelPair>(
902          end: )
903        var_name: '|arg_name|E2p'
904
905  - es2panda_arg:
906      name: '|arg_name|'
907      type:
908        name: 'LabelPair'
909      max_ptr_depth: 0
910    new_args:
911    - type:
912        name: "es2panda_LabelPair"
913        ptr_depth: 1
914      name: '|arg_name|'
915      namespace: 'compiler::'
916    cast:
917        expression: ''
918        var_name: 'std::forward<compiler::LabelPair>(*reinterpret_cast<compiler::LabelPair *>(|arg_name|))'
919        reverse_cast:
920          start: >-
921            reinterpret_cast<?const? es2panda_LabelPair *>(ctxAllocator->New<compiler::LabelPair>
922          end: )
923
924  - es2panda_arg:
925      name: '|arg_name|'
926      type:
927        name: 'ImportSource'
928      min_ptr_depth: 1
929    new_args:
930    - type:
931        name: "es2panda_ImportSource"
932        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
933      name: '|arg_name|'
934    cast:
935        expression: >-
936          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
937          reinterpret_cast<ir::ImportSource |es2panda_arg.type.ptr_depth|>(|arg_name|);
938        reverse_cast:
939          start : >-
940            reinterpret_cast<?const? es2panda_ImportSource |es2panda_arg.type.ptr_depth|>
941        call_cast:
942          call_var: 'es2panda_ImportSource *ast'
943          start: >-
944            (reinterpret_cast<?const? ir::ImportSource *>(ast))->
945        constructor_cast:
946          start: >-
947            ctxAllocator->New<ir::ImportSource>(
948          end: )
949        var_name: '|arg_name|E2p'
950
951  - es2panda_arg:
952      name: '|arg_name|'
953      type:
954        name: 'ValidationInfo'
955      min_ptr_depth: 1
956    new_args:
957    - type:
958        name: "es2panda_ValidationInfo"
959        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
960      name: '|arg_name|'
961    cast:
962        expression: >-
963          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
964          reinterpret_cast<ir::ValidationInfo |es2panda_arg.type.ptr_depth|>(|arg_name|);
965        reverse_cast:
966          start : >-
967            reinterpret_cast<?const? es2panda_ValidationInfo |es2panda_arg.type.ptr_depth|>
968        call_cast:
969          call_var: 'es2panda_ValidationInfo *ast'
970          start: >-
971            (reinterpret_cast<?const? ir::ValidationInfo *>(ast))->
972        constructor_cast:
973          start: >-
974            ctxAllocator->New<ir::ValidationInfo>(
975          end: )
976        var_name: '|arg_name|E2p'
977
978  - es2panda_arg:
979      name: '|arg_name|'
980      type:
981        name: 'ValidationInfo'
982      max_ptr_depth: 0
983    new_args:
984    - type:
985        name: "es2panda_ValidationInfo"
986        ptr_depth: 1
987      name: '|arg_name|'
988    cast:
989        expression: ''
990        reverse_cast:
991          start : >-
992            reinterpret_cast<?const? es2panda_ValidationInfo *>(reinterpret_cast<Context *>(context)->
993            allocator->New<ir::ValidationInfo>(
994          end: '))'
995        var_name: '*reinterpret_cast<ir::ValidationInfo |es2panda_arg.type.ptr_depth|>(|arg_name|)'
996
997  - es2panda_arg:
998      name: '|arg_name|'
999      type:
1000        name: 'ASTAbstractVisitor'
1001        namespace: 'visitor'
1002      min_ptr_depth: 1
1003    new_args:
1004    - type:
1005        name: "es2panda_AstVisitor"
1006        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
1007      name: '|arg_name|'
1008      namespace: 'ir::visitor::'
1009    cast:
1010        expression: >-
1011          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
1012          reinterpret_cast<ir::visitor::ASTAbstractVisitor |es2panda_arg.type.ptr_depth|>(|arg_name|);
1013        reverse_cast:
1014          start : >-
1015            reinterpret_cast<?const? es2panda_AstVisitor |es2panda_arg.type.ptr_depth|>
1016        call_cast:
1017          call_var: 'es2panda_AstVisitor *ast'
1018          start: >-
1019            (reinterpret_cast<?const? ir::visitor::ASTAbstractVisitor *>(ast))->
1020        constructor_cast:
1021          start: >-
1022            ctxAllocator->New<ir::visitor::ASTAbstractVisitor>(
1023          end: )
1024        var_name: '|arg_name|E2p'
1025
1026  - es2panda_arg:
1027      name: '|arg_name|'
1028      type:
1029        name: 'Signature'
1030      min_ptr_depth: 1
1031    new_args:
1032    - type:
1033        name: "es2panda_Signature"
1034        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
1035      name: '|arg_name|'
1036    cast:
1037        expression: >-
1038          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
1039          reinterpret_cast<checker::Signature |es2panda_arg.type.ptr_depth|>(|arg_name|);
1040        reverse_cast:
1041          start: >-
1042            reinterpret_cast<?const? es2panda_Signature |es2panda_arg.type.ptr_depth|>
1043        call_cast:
1044          call_var: 'es2panda_Signature *ast'
1045          start: >-
1046            (reinterpret_cast<?const? checker::Signature *>(ast))->
1047        constructor_cast:
1048          start: >-
1049            ctxAllocator->New<checker::Signature>(
1050          end: )
1051        var_name: '|arg_name|E2p'
1052
1053  - es2panda_arg:
1054      name: '|arg_name|'
1055      type:
1056        name: StringView
1057      min_ptr_depth: 0
1058      max_ptr_depth: 0
1059    new_args:
1060    - type:
1061        name: "char"
1062        ptr_depth: 1
1063      name: "|arg_name|"
1064    cast:
1065      expression: util::StringView |arg_name|E2p {|arg_name|};
1066      var_name: '|arg_name|E2p'
1067      reverse_cast:
1068          start: StringViewToCString(reinterpret_cast<Context *>(context)->allocator,
1069          end: )
1070
1071  - es2panda_arg:
1072      name: '|arg_name|'
1073      type:
1074        name: string_view
1075      min_ptr_depth: 0
1076      max_ptr_depth: 0
1077    new_args:
1078    - type:
1079        name: "char"
1080        ptr_depth: 1
1081      name: "|arg_name|"
1082    cast:
1083      expression: std::string_view |arg_name|E2p {|arg_name|};
1084      var_name: '|arg_name|E2p'
1085      reverse_cast:
1086          start: StringViewToCString(reinterpret_cast<Context *>(context)->allocator,
1087          end: )
1088
1089  - es2panda_arg:
1090      name: '|arg_name|'
1091      type:
1092        name: 'Variable'
1093      min_ptr_depth: 1
1094    new_args:
1095    - type:
1096        name: 'es2panda_Variable'
1097        ptr_depth: '|es2panda_arg.type.ptr_depth_int|'
1098      name: "|arg_name|"
1099    cast:
1100      expression: >-
1101          auto |es2panda_arg.type.ptr_depth||arg_name|E2p =
1102          reinterpret_cast<varbinder::Variable |es2panda_arg.type.ptr_depth|>(|arg_name|);
1103      reverse_cast:
1104          start: >-
1105            reinterpret_cast<?const? es2panda_Variable |es2panda_arg.type.ptr_depth|>
1106      call_cast:
1107          call_var: 'es2panda_Variable *ast'
1108          start: >-
1109            (reinterpret_cast<?const? varbinder::Variable *>(ast))->
1110      constructor_cast:
1111        start: >-
1112          ctxAllocator->New<varbinder::Variable>(
1113        end: )
1114      var_name: '|arg_name|E2p'
1115
1116  - es2panda_arg:
1117      name: '|arg_name|'
1118      type:
1119        name: "string"
1120      max_ptr_depth: 0
1121      min_ptr_depth: 0
1122    new_args:
1123      - name: '|arg_name|'
1124        type:
1125          name: char
1126          ptr_depth: 1
1127        namespace: 'std::'
1128    cast:
1129      expression: std::string |arg_name|E2p {|arg_name|};
1130      reverse_cast:
1131        start: 'StdStringToCString(reinterpret_cast<Context *>(context)->allocator, '
1132        end: ')'
1133      var_name: '|arg_name|E2p'
1134
1135  - es2panda_arg:
1136      name: '|arg_name|'
1137      type:
1138        name: "EnumMemberResult"
1139      max_ptr_depth: 0
1140      min_ptr_depth: 0
1141    new_args:
1142      - name: '|arg_name|'
1143        type:
1144          name: es2panda_variantDoubleCharArrayBool
1145          ptr_depth: 0
1146        namespace: 'varbinder::'
1147    cast:
1148      expression: >-
1149        varbinder::EnumMemberResult |arg_name|E2p {
1150        |arg_name|.index == 0 ? |arg_name|.variant.d : |arg_name|.index == 1 ? std::string(|arg_name|.variant.c) :
1151         |arg_name|.variant.b};
1152      reverse_cast:
1153        start: 'EnumMemberResultToEs2pandaVariant(reinterpret_cast<Context *>(context)->allocator, '
1154        end: ')'
1155      var_name: '|arg_name|E2p'
1156
1157  - es2panda_arg:
1158      name: '|arg_name|'
1159      type:
1160        name: "NodeTraverser"
1161      max_ptr_depth: 0
1162      min_ptr_depth: 0
1163    new_args:
1164      - name: '|arg_name|'
1165        type:
1166          name: NodeTraverser
1167          ptr_depth: 0
1168        namespace: ''
1169    cast:
1170      expression: >-
1171        std::function<void(ir::AstNode *)> |arg_name|E2p =
1172        [|arg_name|](ir::AstNode *traverserLambdaNode)
1173        {|arg_name|(reinterpret_cast<es2panda_AstNode *>(traverserLambdaNode));};
1174      var_name: '|arg_name|E2p'
1175
1176  - es2panda_arg:
1177      name: '|arg_name|'
1178      type:
1179        name: "NodeTransformer"
1180      max_ptr_depth: 0
1181      min_ptr_depth: 0
1182    new_args:
1183      - name: '|arg_name|'
1184        type:
1185          name: NodeTransformer
1186          ptr_depth: 0
1187        namespace: ''
1188    cast:
1189      expression: >-
1190        std::function<ir::AstNode *(ir::AstNode *)> |arg_name|E2p =
1191        [|arg_name|](ir::AstNode *traverserLambdaNode)
1192        {return reinterpret_cast<ir::AstNode *>(|arg_name|(reinterpret_cast<es2panda_AstNode *>(traverserLambdaNode)));};
1193      var_name: '|arg_name|E2p'
1194
1195  - es2panda_arg:
1196      name: '|arg_name|'
1197      type:
1198        name: "NodePredicate"
1199      max_ptr_depth: 0
1200      min_ptr_depth: 0
1201    new_args:
1202      - name: '|arg_name|'
1203        type:
1204          name: NodePredicate
1205          ptr_depth: 0
1206        namespace: ''
1207    cast:
1208      expression: >-
1209        std::function<bool(ir::AstNode *)> |arg_name|E2p =
1210        [|arg_name|](ir::AstNode *traverserLambdaNode)
1211        {return |arg_name|(reinterpret_cast<es2panda_AstNode *>(traverserLambdaNode));};
1212      var_name: '|arg_name|E2p'
1213
1214  - es2panda_arg:
1215      name: '|arg_name|'
1216      type:
1217        name: ConstructorFlags
1218        current_class: TSModuleDeclaration
1219      max_ptr_depth: 0
1220      min_ptr_depth: 0
1221    new_args:
1222      - name: declare
1223        type:
1224          name: bool
1225      - name: global
1226        type:
1227          name: bool
1228      - name: isExternalAmbient
1229        type:
1230          name: bool
1231    cast:
1232      expression: ""
1233      var_name: "ir::TSModuleDeclaration::ConstructorFlags {declare, global, isExternalAmbient}"
1234
1235  - es2panda_arg:
1236      name: '|arg_name|'
1237      type:
1238        name: "ConstructorFlags"
1239        current_class: TSEnumDeclaration
1240      max_ptr_depth: 0
1241      min_ptr_depth: 0
1242    new_args:
1243      - name: 'isConst'
1244        type:
1245          name: bool
1246      - name: 'isStatic'
1247        type:
1248          name: bool
1249      - name: 'isDeclare'
1250        type:
1251          name: bool
1252    cast:
1253      expression: ""
1254      var_name: "ir::TSEnumDeclaration::ConstructorFlags {isConst, isStatic, isDeclare}"
1255
1256  - es2panda_arg:
1257      name: '|arg_name|'
1258      type:
1259        name: "ConstructorData"
1260        current_class: TSInterfaceDeclaration
1261      max_ptr_depth: 0
1262      min_ptr_depth: 0
1263    new_args:
1264      - name: 'id'
1265        type:
1266          name: es2panda_AstNode
1267          ptr_depth: 1
1268      - name: 'typeParams'
1269        type:
1270          name: es2panda_AstNode
1271          ptr_depth: 1
1272      - name: 'body'
1273        type:
1274          name: es2panda_AstNode
1275          ptr_depth: 1
1276      - name: isStatic
1277        type:
1278          name: bool
1279      - name: isExternal
1280        type:
1281          name: bool
1282      - name: lang
1283        type:
1284          name: "es2panda_Language"
1285          ptr_depth: 1
1286    cast:
1287      expression: "\
1288        auto es2pandaId = reinterpret_cast<ir::Identifier *>(id);\n
1289        auto es2pandaTypeParams = reinterpret_cast<ir::TSTypeParameterDeclaration *>(typeParams);\n
1290        auto es2pandaBody = reinterpret_cast<ir::TSInterfaceBody *>(body);\n
1291        auto es2pandaLang = *reinterpret_cast<Language *>(lang);\n
1292        "
1293      var_name: "ir::TSInterfaceDeclaration::ConstructorData {es2pandaId, es2pandaTypeParams, es2pandaBody, isStatic, isExternal, es2pandaLang}"
1294