@idlizer/arktscgen 2.1.10-arktscgen-6 → 2.1.10-arktscgen-9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/build/libarkts-copy/generator/options.json5 +88 -97
  2. package/build/libarkts-copy/native/meson.build +60 -7
  3. package/build/libarkts-copy/native/mingw.cross +2 -5
  4. package/build/libarkts-copy/native/src/bridges.cpp +175 -0
  5. package/build/libarkts-copy/native/src/{common.cc → common.cpp} +176 -139
  6. package/build/libarkts-copy/native/src/common.h +22 -37
  7. package/build/libarkts-copy/native/src/{memoryTracker.cc → memoryTracker.cpp} +9 -3
  8. package/build/libarkts-copy/package.json +5 -9
  9. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +0 -56
  10. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +8 -3
  11. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +4 -0
  12. package/build/libarkts-copy/src/arkts-api/index.ts +0 -2
  13. package/build/libarkts-copy/src/arkts-api/node-utilities/OpaqueTypeNode.ts +1 -1
  14. package/build/libarkts-copy/src/arkts-api/node-utilities/OverloadDeclaration.ts +29 -0
  15. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +25 -59
  16. package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +8 -13
  17. package/build/libarkts-copy/src/arkts-api/plugins.ts +5 -12
  18. package/build/libarkts-copy/src/arkts-api/static/global.ts +8 -4
  19. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +4 -4
  20. package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +9 -12
  21. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +10 -34
  22. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +8 -5
  23. package/build/libarkts-copy/src/index.ts +0 -2
  24. package/build/libarkts-copy/src/plugin-utils.ts +60 -34
  25. package/build/libarkts-copy/src/reexport-for-generated.ts +3 -2
  26. package/build/libarkts-copy/tsconfig.json +0 -3
  27. package/lib/index.js +505 -216
  28. package/package.json +3 -4
  29. package/templates/Es2pandaNativeModule.ts +1 -0
  30. package/templates/{bridges.cc → bridges.cpp} +1 -1
  31. package/templates/peer.ts +1 -0
  32. package/build/libarkts-copy/native/src/bridges.cc +0 -443
  33. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -45
  34. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +0 -1250
  35. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +0 -125
  36. package/build/libarkts-copy/src/ts-api/index.ts +0 -27
  37. package/build/libarkts-copy/src/ts-api/static/enums.ts +0 -18
  38. package/build/libarkts-copy/src/ts-api/types.ts +0 -1075
  39. package/build/libarkts-copy/src/ts-api/utilities/private.ts +0 -292
  40. package/build/libarkts-copy/src/ts-api/utilities/public.ts +0 -55
  41. package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +0 -139
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idlizer/arktscgen",
3
- "version": "2.1.10-arktscgen-6",
3
+ "version": "2.1.10-arktscgen-9",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "bin": "lib/index.js",
@@ -18,8 +18,7 @@
18
18
  "license": "Apache-2.0",
19
19
  "keywords": [],
20
20
  "dependencies": {
21
- "@idlizer/core": "2.1.10-arktscgen-6",
22
- "@types/node": "^18.0.0",
21
+ "@idlizer/core": "2.1.10-arktscgen-9",
23
22
  "commander": "^10.0.0",
24
23
  "typescript": "^4.9.5"
25
24
  },
@@ -30,7 +29,7 @@
30
29
  "@rollup/plugin-typescript": "^11.1.6",
31
30
  "@types/chai": "^4.3.1",
32
31
  "@types/json5": "^2.2.0",
33
- "@types/node": "^18.0.0",
32
+ "@types/node": "^18.19.127",
34
33
  "json5": "^2.2.3",
35
34
  "source-map-support": "^0.5.21",
36
35
  "rimraf": "^6.0.1"
@@ -26,6 +26,7 @@ import {
26
26
  KBoolean,
27
27
  KDouble,
28
28
  KFloat,
29
+ KULong,
29
30
  KLong
30
31
  } from "@koalaui/interop"
31
32
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
2
+ * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
package/templates/peer.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  unpackNonNullableNode,
26
26
  unpackNode,
27
27
  unpackNodeArray,
28
+ unpackNativeObjectArray,
28
29
  AstNode,
29
30
  KNativePointer,
30
31
  nodeByType,
@@ -1,443 +0,0 @@
1
- /*
2
- * Copyright (c) 2022-2023 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
-
16
- #include <mutex>
17
- #include <set>
18
- #include <string>
19
-
20
- #include "common.h"
21
- #include "memoryTracker.h"
22
-
23
- /** XXX: If you add or remove methods that exist in C API,
24
- * please change generator/options.json5 accordingly.
25
- */
26
-
27
- KNativePointer impl_AstNodeRebind(KNativePointer contextPtr, KNativePointer nodePtr)
28
- {
29
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
30
- auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
31
- GetImpl()->AstNodeRebind(context, node);
32
- return nullptr;
33
- }
34
- KOALA_INTEROP_2(AstNodeRebind, KNativePointer, KNativePointer, KNativePointer)
35
-
36
- KNativePointer impl_AnnotationAllowedAnnotations(
37
- KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer returnLen)
38
- {
39
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
40
- auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
41
- std::size_t params_len = 0;
42
- auto annotations = GetImpl()->AnnotationAllowedAnnotations(context, node, &params_len);
43
- return StageArena::cloneVector(annotations, params_len);
44
- }
45
- KOALA_INTEROP_3(AnnotationAllowedAnnotations, KNativePointer, KNativePointer, KNativePointer, KNativePointer)
46
-
47
- KNativePointer impl_AnnotationAllowedAnnotationsConst(
48
- KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer returnLen)
49
- {
50
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
51
- auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
52
- std::size_t params_len = 0;
53
- auto annotations = GetImpl()->AnnotationAllowedAnnotationsConst(context, node, &params_len);
54
- return StageArena::cloneVector(annotations, params_len);
55
- }
56
- KOALA_INTEROP_3(AnnotationAllowedAnnotationsConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer)
57
-
58
- KNativePointer impl_VariableDeclaration(KNativePointer contextPtr, KNativePointer variablePtr)
59
- {
60
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
61
- auto variable = reinterpret_cast<es2panda_Variable*>(variablePtr);
62
-
63
- return GetImpl()->VariableDeclaration(context, variable);
64
- }
65
- KOALA_INTEROP_2(VariableDeclaration, KNativePointer, KNativePointer, KNativePointer)
66
-
67
- KNativePointer impl_DeclNode(KNativePointer contextPtr, KNativePointer declPtr)
68
- {
69
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
70
- auto decl = reinterpret_cast<es2panda_Declaration*>(declPtr);
71
-
72
- return GetImpl()->DeclNode(context, decl);
73
- }
74
- KOALA_INTEROP_2(DeclNode, KNativePointer, KNativePointer, KNativePointer)
75
-
76
- KNativePointer impl_ScopeSetParent(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer parentPtr)
77
- {
78
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
79
- auto node = reinterpret_cast<es2panda_Scope*>(nodePtr);
80
- auto parent = reinterpret_cast<es2panda_Scope*>(parentPtr);
81
- GetImpl()->ScopeSetParent(context, node, parent);
82
- return node;
83
- }
84
- KOALA_INTEROP_3(ScopeSetParent, KNativePointer, KNativePointer, KNativePointer, KNativePointer)
85
-
86
- KNativePointer impl_ETSParserCreateExpression(KNativePointer contextPtr, KStringPtr& sourceCodePtr, KInt flagsT)
87
- {
88
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
89
- auto flags = static_cast<Es2pandaExpressionParseFlags>(flagsT);
90
-
91
- return GetImpl()->ETSParserCreateExpression(context, getStringCopy(sourceCodePtr), flags);
92
- }
93
- KOALA_INTEROP_3(ETSParserCreateExpression, KNativePointer, KNativePointer, KStringPtr, KInt)
94
-
95
- KNativePointer impl_SignatureFunction(KNativePointer context, KNativePointer classInstance)
96
- {
97
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
98
- const auto _classInstance = reinterpret_cast<es2panda_Signature*>(classInstance);
99
- const auto result = GetImpl()->SignatureFunction(_context, _classInstance);
100
- return result;
101
- }
102
- KOALA_INTEROP_2(SignatureFunction, KNativePointer, KNativePointer, KNativePointer)
103
-
104
- static KNativePointer impl_ProgramExternalSources(KNativePointer contextPtr, KNativePointer instancePtr)
105
- {
106
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
107
- auto&& instance = reinterpret_cast<es2panda_Program*>(instancePtr);
108
- std::size_t source_len = 0;
109
- auto external_sources = GetImpl()->ProgramExternalSources(context, instance, &source_len);
110
- return StageArena::cloneVector(external_sources, source_len);
111
- }
112
- KOALA_INTEROP_2(ProgramExternalSources, KNativePointer, KNativePointer, KNativePointer);
113
-
114
- static KNativePointer impl_ProgramDirectExternalSources(KNativePointer contextPtr, KNativePointer instancePtr)
115
- {
116
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
117
- auto&& instance = reinterpret_cast<es2panda_Program*>(instancePtr);
118
- std::size_t sourceLen = 0;
119
- auto externalSources = GetImpl()->ProgramDirectExternalSources(context, instance, &sourceLen);
120
- return new std::vector<void*>(externalSources, externalSources + sourceLen);
121
- }
122
- KOALA_INTEROP_2(ProgramDirectExternalSources, KNativePointer, KNativePointer, KNativePointer);
123
-
124
- static KNativePointer impl_ProgramSourceFilePath(KNativePointer contextPtr, KNativePointer instancePtr)
125
- {
126
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
127
- auto&& instance = reinterpret_cast<es2panda_Program*>(instancePtr);
128
- auto&& result = GetImpl()->ProgramSourceFilePathConst(context, instance);
129
- return StageArena::strdup(result);
130
- }
131
- KOALA_INTEROP_2(ProgramSourceFilePath, KNativePointer, KNativePointer, KNativePointer);
132
-
133
- static KNativePointer impl_ExternalSourceName(KNativePointer instance)
134
- {
135
- auto&& _instance_ = reinterpret_cast<es2panda_ExternalSource*>(instance);
136
- auto&& result = GetImpl()->ExternalSourceName(_instance_);
137
- return StageArena::strdup(result);
138
- }
139
- KOALA_INTEROP_1(ExternalSourceName, KNativePointer, KNativePointer);
140
-
141
- static KNativePointer impl_ExternalSourcePrograms(KNativePointer instance)
142
- {
143
- auto&& _instance_ = reinterpret_cast<es2panda_ExternalSource*>(instance);
144
- std::size_t program_len = 0;
145
- auto programs = GetImpl()->ExternalSourcePrograms(_instance_, &program_len);
146
- return StageArena::cloneVector(programs, program_len);
147
- }
148
- KOALA_INTEROP_1(ExternalSourcePrograms, KNativePointer, KNativePointer);
149
-
150
- KNativePointer impl_ETSParserBuildImportDeclaration(KNativePointer context, KInt importKinds,
151
- KNativePointerArray specifiers, KUInt specifiersSequenceLength, KNativePointer source, KNativePointer program,
152
- KInt importFlag)
153
- {
154
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
155
- const auto _kinds = static_cast<Es2pandaImportKinds>(importKinds);
156
- const auto _specifiers = reinterpret_cast<es2panda_AstNode**>(specifiers);
157
- const auto _specifiersSequenceLength = static_cast<size_t>(specifiersSequenceLength);
158
- const auto _source = reinterpret_cast<es2panda_AstNode*>(source);
159
- const auto _program = reinterpret_cast<es2panda_Program*>(program);
160
- const auto _importFlag = static_cast<Es2pandaImportFlags>(importFlag);
161
-
162
- return GetImpl()->ETSParserBuildImportDeclaration(
163
- _context, _kinds, _specifiers, _specifiersSequenceLength, _source, _program, _importFlag);
164
- }
165
- KOALA_INTEROP_7(ETSParserBuildImportDeclaration, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt,
166
- KNativePointer, KNativePointer, KInt)
167
-
168
- KNativePointer impl_ETSParserGetImportPathManager(KNativePointer contextPtr)
169
- {
170
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
171
- return GetImpl()->ETSParserGetImportPathManager(context);
172
- }
173
- KOALA_INTEROP_1(ETSParserGetImportPathManager, KNativePointer, KNativePointer);
174
-
175
- KInt impl_SourcePositionCol(KNativePointer context, KNativePointer instance)
176
- {
177
- auto&& _context_ = reinterpret_cast<es2panda_Context*>(context);
178
- auto&& _instance_ = reinterpret_cast<es2panda_SourcePosition*>(instance);
179
- return GetImpl()->SourcePositionCol(_context_, _instance_);
180
- }
181
- KOALA_INTEROP_2(SourcePositionCol, KInt, KNativePointer, KNativePointer);
182
-
183
- KNativePointer impl_ConfigGetOptions(KNativePointer config)
184
- {
185
- const auto _config = reinterpret_cast<es2panda_Config*>(config);
186
- auto result = GetImpl()->ConfigGetOptions(_config);
187
- return (void*)result;
188
- }
189
- KOALA_INTEROP_1(ConfigGetOptions, KNativePointer, KNativePointer)
190
-
191
- KNativePointer impl_OptionsArkTsConfig(KNativePointer context, KNativePointer options)
192
- {
193
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
194
- const auto _options = reinterpret_cast<es2panda_Options*>(options);
195
- auto result = GetImpl()->OptionsUtilArkTSConfigConst(_context, _options);
196
- return (void*)result;
197
- }
198
- KOALA_INTEROP_2(OptionsArkTsConfig, KNativePointer, KNativePointer, KNativePointer)
199
-
200
- // All these "Checker_" bridges are related to checker namespace in es2panda, so work with them carefully
201
- // Checker.Type does reset on recheck, so modifying them makes no sence
202
- // It seems that compiler does not provide API to convert Checker.Type to ir.Type
203
- KNativePointer impl_Checker_CreateOpaqueTypeNode(KNativePointer context, KNativePointer type)
204
- {
205
- auto _context = reinterpret_cast<es2panda_Context*>(context);
206
- auto _type = reinterpret_cast<es2panda_Type*>(type);
207
- return GetImpl()->CreateOpaqueTypeNode(_context, _type);
208
- }
209
- KOALA_INTEROP_2(Checker_CreateOpaqueTypeNode, KNativePointer, KNativePointer, KNativePointer)
210
-
211
- KNativePointer impl_Checker_ScriptFunctionSignature(KNativePointer context, KNativePointer node)
212
- {
213
- auto _context = reinterpret_cast<es2panda_Context*>(context);
214
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
215
- return GetImpl()->ScriptFunctionSignature(_context, _node);
216
- }
217
- KOALA_INTEROP_2(Checker_ScriptFunctionSignature, KNativePointer, KNativePointer, KNativePointer)
218
-
219
- void impl_Checker_ScriptFunctionSetSignature(KNativePointer context, KNativePointer node, KNativePointer signature)
220
- {
221
- auto _context = reinterpret_cast<es2panda_Context*>(context);
222
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
223
- auto _signature = reinterpret_cast<es2panda_Signature*>(signature);
224
- GetImpl()->ScriptFunctionSetSignature(_context, _node, _signature);
225
- return;
226
- }
227
- KOALA_INTEROP_V3(Checker_ScriptFunctionSetSignature, KNativePointer, KNativePointer, KNativePointer)
228
-
229
- KNativePointer impl_Checker_SignatureReturnType(KNativePointer context, KNativePointer signature)
230
- {
231
- auto _context = reinterpret_cast<es2panda_Context*>(context);
232
- auto _signature = reinterpret_cast<es2panda_Signature*>(signature);
233
- return GetImpl()->SignatureReturnType(_context, _signature);
234
- }
235
- KOALA_INTEROP_2(Checker_SignatureReturnType, KNativePointer, KNativePointer, KNativePointer)
236
-
237
- KNativePointer impl_Checker_ScriptFunctionGetPreferredReturnType(KNativePointer context, KNativePointer node)
238
- {
239
- auto _context = reinterpret_cast<es2panda_Context*>(context);
240
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
241
- return GetImpl()->ScriptFunctionGetPreferredReturnType(_context, _node);
242
- }
243
- KOALA_INTEROP_2(Checker_ScriptFunctionGetPreferredReturnType, KNativePointer, KNativePointer, KNativePointer)
244
-
245
- void impl_Checker_ScriptFunctionSetPreferredReturnType(KNativePointer context, KNativePointer node, KNativePointer type)
246
- {
247
- auto _context = reinterpret_cast<es2panda_Context*>(context);
248
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
249
- auto _type = reinterpret_cast<es2panda_Type*>(type);
250
- GetImpl()->ScriptFunctionSetPreferredReturnType(_context, _node, _type);
251
- return;
252
- }
253
- KOALA_INTEROP_V3(Checker_ScriptFunctionSetPreferredReturnType, KNativePointer, KNativePointer, KNativePointer)
254
-
255
- KNativePointer impl_Checker_ExpressionGetPreferredType(KNativePointer context, KNativePointer node)
256
- {
257
- auto _context = reinterpret_cast<es2panda_Context*>(context);
258
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
259
- return GetImpl()->ExpressionPreferredTypeConst(_context, _node);
260
- }
261
- KOALA_INTEROP_2(Checker_ExpressionGetPreferredType, KNativePointer, KNativePointer, KNativePointer)
262
-
263
- void impl_Checker_ExpressionSetPreferredType(KNativePointer context, KNativePointer node, KNativePointer type)
264
- {
265
- auto _context = reinterpret_cast<es2panda_Context*>(context);
266
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
267
- auto _type = reinterpret_cast<es2panda_Type*>(type);
268
- GetImpl()->ExpressionSetPreferredType(_context, _node, _type);
269
- return;
270
- }
271
- KOALA_INTEROP_V3(Checker_ExpressionSetPreferredType, KNativePointer, KNativePointer, KNativePointer)
272
-
273
- KNativePointer impl_Checker_TypeToString(KNativePointer context, KNativePointer type)
274
- {
275
- auto _context = reinterpret_cast<es2panda_Context*>(context);
276
- auto _type = reinterpret_cast<es2panda_Type*>(type);
277
- auto result = GetImpl()->TypeToStringConst(_context, _type);
278
- return StageArena::strdup(result);
279
- }
280
- KOALA_INTEROP_2(Checker_TypeToString, KNativePointer, KNativePointer, KNativePointer)
281
-
282
- KNativePointer impl_Checker_TypeClone(KNativePointer context, KNativePointer type)
283
- {
284
- auto _context = reinterpret_cast<es2panda_Context*>(context);
285
- auto _type = reinterpret_cast<es2panda_Type*>(type);
286
- return GetImpl()->TypeClone(_context, _type);
287
- }
288
- KOALA_INTEROP_2(Checker_TypeClone, KNativePointer, KNativePointer, KNativePointer)
289
-
290
- KNativePointer impl_Checker_TypeNodeGetType(KNativePointer context, KNativePointer astNode)
291
- {
292
- auto _context = reinterpret_cast<es2panda_Context*>(context);
293
- auto _astNode = reinterpret_cast<es2panda_AstNode*>(astNode);
294
- return GetImpl()->TypeNodeGetType(_context, _astNode);
295
- }
296
- KOALA_INTEROP_2(Checker_TypeNodeGetType, KNativePointer, KNativePointer, KNativePointer)
297
-
298
- // From koala-wrapper
299
- // Improve: check if some code should be generated
300
-
301
- std::set<std::string> globalStructInfo;
302
- #ifdef _GLIBCXX_HAS_GTHREADS
303
- std::mutex g_structMutex;
304
- #endif
305
-
306
- void impl_InsertGlobalStructInfo(KNativePointer contextPtr, KStringPtr& instancePtr)
307
- {
308
- #ifdef _GLIBCXX_HAS_GTHREADS
309
- std::lock_guard<std::mutex> lock(g_structMutex);
310
- #endif
311
- globalStructInfo.insert(getStringCopy(instancePtr));
312
- return;
313
- }
314
- KOALA_INTEROP_V2(InsertGlobalStructInfo, KNativePointer, KStringPtr);
315
-
316
- KBoolean impl_HasGlobalStructInfo(KNativePointer contextPtr, KStringPtr& instancePtr)
317
- {
318
- #ifdef _GLIBCXX_HAS_GTHREADS
319
- std::lock_guard<std::mutex> lock(g_structMutex);
320
- #endif
321
- return globalStructInfo.count(getStringCopy(instancePtr));
322
- }
323
- KOALA_INTEROP_2(HasGlobalStructInfo, KBoolean, KNativePointer, KStringPtr);
324
-
325
- KNativePointer impl_ClassVariableDeclaration(KNativePointer context, KNativePointer classInstance)
326
- {
327
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
328
- const auto _classInstance = reinterpret_cast<es2panda_AstNode*>(classInstance);
329
- auto _typedTsType = GetImpl()->TypedTsType(_context, _classInstance);
330
- if (_typedTsType == nullptr) {
331
- return nullptr;
332
- }
333
- const auto _instanceType = reinterpret_cast<es2panda_Type*>(_typedTsType);
334
- auto _typeVar = GetImpl()->TypeVariable(_context, _instanceType);
335
- if (_typeVar == nullptr) {
336
- return nullptr;
337
- }
338
- const auto result = reinterpret_cast<es2panda_Declaration*>(GetImpl()->VariableDeclaration(_context, _typeVar));
339
- const auto declNode = GetImpl()->DeclNode(_context, result);
340
- return declNode;
341
- }
342
- KOALA_INTEROP_2(ClassVariableDeclaration, KNativePointer, KNativePointer, KNativePointer)
343
-
344
- KNativePointer impl_TSInterfaceBodyBodyPtr(KNativePointer context, KNativePointer receiver)
345
- {
346
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
347
- const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
348
- std::size_t length;
349
- auto result = GetImpl()->TSInterfaceBodyBodyPtr(_context, _receiver, &length);
350
- return StageArena::cloneVector(result, length);
351
- }
352
- KOALA_INTEROP_2(TSInterfaceBodyBodyPtr, KNativePointer, KNativePointer, KNativePointer);
353
-
354
- KNativePointer impl_AnnotationDeclarationPropertiesPtrConst(KNativePointer context, KNativePointer receiver)
355
- {
356
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
357
- const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
358
- std::size_t length;
359
- auto result = GetImpl()->AnnotationDeclarationPropertiesPtrConst(_context, _receiver, &length);
360
- return StageArena::cloneVector(result, length);
361
- }
362
- KOALA_INTEROP_2(AnnotationDeclarationPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer);
363
-
364
- KNativePointer impl_ETSParserGetGlobalProgramAbsName(KNativePointer contextPtr)
365
- {
366
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
367
- auto result = GetImpl()->ETSParserGetGlobalProgramAbsName(context);
368
- return new std::string(result);
369
- }
370
- KOALA_INTEROP_1(ETSParserGetGlobalProgramAbsName, KNativePointer, KNativePointer)
371
-
372
- KNativePointer impl_CreateDiagnosticKind(KNativePointer context, KStringPtr& message, KInt type)
373
- {
374
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
375
- const auto _message = getStringCopy(message);
376
- const auto _type = static_cast<es2panda_PluginDiagnosticType>(type);
377
- return const_cast<es2panda_DiagnosticKind*>(GetImpl()->CreateDiagnosticKind(_context, _message, _type));
378
- }
379
- KOALA_INTEROP_3(CreateDiagnosticKind, KNativePointer, KNativePointer, KStringPtr, KInt)
380
-
381
- void impl_LogDiagnostic(
382
- KNativePointer context, KNativePointer kind, KStringArray& argvPtr, KInt argc, KNativePointer pos)
383
- {
384
- auto&& _context_ = reinterpret_cast<es2panda_Context*>(context);
385
- auto&& _kind_ = reinterpret_cast<es2panda_DiagnosticKind*>(kind);
386
- auto&& _pos_ = reinterpret_cast<es2panda_SourcePosition*>(pos);
387
- GetImpl()->LogDiagnostic(_context_, _kind_, getStringArray(argvPtr), argc, _pos_);
388
- }
389
- KOALA_INTEROP_V5(LogDiagnostic, KNativePointer, KNativePointer, KStringArray, KInt, KNativePointer)
390
-
391
- KNativePointer impl_AnnotationUsageIrPropertiesPtrConst(KNativePointer context, KNativePointer receiver)
392
- {
393
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
394
- const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
395
- std::size_t length;
396
- auto result = GetImpl()->AnnotationUsageIrPropertiesPtrConst(_context, _receiver, &length);
397
- return StageArena::cloneVector(result, length);
398
- }
399
- KOALA_INTEROP_2(AnnotationUsageIrPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer);
400
-
401
- KInt impl_GetCompilationMode(KNativePointer configPtr)
402
- {
403
- auto _config = reinterpret_cast<es2panda_Config*>(configPtr);
404
- auto _options = const_cast<es2panda_Options*>(GetImpl()->ConfigGetOptions(_config));
405
- return GetImpl()->OptionsUtilGetCompilationModeConst(nullptr, _options);
406
- }
407
- KOALA_INTEROP_1(GetCompilationMode, KInt, KNativePointer)
408
-
409
- KNativePointer impl_CreateTypeNodeFromTsType(KNativePointer context, KNativePointer nodePtr)
410
- {
411
- const auto _context = reinterpret_cast<es2panda_Context*>(context);
412
- const auto _nodePtr = reinterpret_cast<es2panda_AstNode*>(nodePtr);
413
- auto _tsType = GetImpl()->TypedTsType(_context, _nodePtr);
414
- if (_tsType == nullptr) {
415
- _tsType = GetImpl()->ExpressionTsType(_context, _nodePtr);
416
- }
417
- if (_tsType == nullptr) {
418
- return nullptr;
419
- }
420
- const auto _nodeTsType = reinterpret_cast<es2panda_Type*>(_tsType);
421
- auto _typeAnnotation = GetImpl()->CreateOpaqueTypeNode(_context, _nodeTsType);
422
- return _typeAnnotation;
423
- }
424
- KOALA_INTEROP_2(CreateTypeNodeFromTsType, KNativePointer, KNativePointer, KNativePointer)
425
-
426
- MemoryTracker tracker;
427
- void impl_MemoryTrackerReset(KNativePointer context)
428
- {
429
- tracker.Reset();
430
- }
431
- KOALA_INTEROP_V1(MemoryTrackerReset, KNativePointer);
432
-
433
- void impl_MemoryTrackerGetDelta(KNativePointer context)
434
- {
435
- tracker.Report(tracker.GetDelta());
436
- }
437
- KOALA_INTEROP_V1(MemoryTrackerGetDelta, KNativePointer);
438
-
439
- void impl_MemoryTrackerPrintCurrent(KNativePointer context)
440
- {
441
- tracker.Report(GetMemoryStats());
442
- }
443
- KOALA_INTEROP_V1(MemoryTrackerPrintCurrent, KNativePointer);
@@ -1,45 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 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
-
16
- import { Program } from '../../../generated';
17
- import { traceGlobal } from '../../tracer';
18
-
19
- export function dumpProgramInfo(program: Program) {
20
- traceGlobal(() => `Program info:`);
21
- traceGlobal(() => `\tAbsoluteName: ${program.absoluteName}`);
22
- traceGlobal(() => `\tFileName: ${program.fileName}`);
23
- traceGlobal(() => `\tFileNameWithExtension: ${program.fileNameWithExtension}`);
24
- traceGlobal(() => `\tModuleName: ${program.moduleName}`);
25
- traceGlobal(() => `\tModulePrefix: ${program.modulePrefix}`);
26
- traceGlobal(() => `\tRelativeFilePath: ${program.relativeFilePath}`);
27
- traceGlobal(() => `\tResolvedFilePath: ${program.resolvedFilePath}`);
28
- traceGlobal(() => `\tSourceFileFolder: ${program.sourceFileFolder}`);
29
- traceGlobal(() => `\tSourceFilePath: ${program.sourceFilePath}`);
30
- }
31
-
32
- export function dumpProgramSrcFormatted(program: Program, recursive: boolean, withLines: boolean = true) {
33
- const lines = program.ast.dumpSrc();
34
- console.log(`// file: ${program.absoluteName}`);
35
- if (withLines) {
36
- console.log(
37
- lines
38
- .split('\n')
39
- .map((it, index) => `${`${index + 1}`.padStart(4)} |${it}`)
40
- .join('\n')
41
- );
42
- } else {
43
- console.log(lines);
44
- }
45
- }