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

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 (31) hide show
  1. package/build/libarkts-copy/native/meson.build +4 -4
  2. package/build/libarkts-copy/native/src/{bridges.cc → bridges.cpp} +11 -11
  3. package/build/libarkts-copy/native/src/{common.cc → common.cpp} +163 -108
  4. package/build/libarkts-copy/native/src/common.h +22 -22
  5. package/build/libarkts-copy/native/src/{memoryTracker.cc → memoryTracker.cpp} +9 -3
  6. package/build/libarkts-copy/package.json +2 -2
  7. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +8 -3
  8. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +4 -0
  9. package/build/libarkts-copy/src/arkts-api/index.ts +0 -1
  10. package/build/libarkts-copy/src/arkts-api/node-utilities/OverloadDeclaration.ts +29 -0
  11. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +0 -1
  12. package/build/libarkts-copy/src/arkts-api/plugins.ts +3 -10
  13. package/build/libarkts-copy/src/arkts-api/static/global.ts +0 -3
  14. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +4 -4
  15. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +7 -34
  16. package/build/libarkts-copy/src/index.ts +0 -1
  17. package/build/libarkts-copy/src/plugin-utils.ts +58 -33
  18. package/build/libarkts-copy/src/reexport-for-generated.ts +1 -1
  19. package/build/libarkts-copy/tsconfig.json +0 -3
  20. package/lib/index.js +218 -36
  21. package/package.json +2 -2
  22. package/templates/{bridges.cc → bridges.cpp} +1 -1
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -45
  24. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +0 -1250
  25. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +0 -125
  26. package/build/libarkts-copy/src/ts-api/index.ts +0 -27
  27. package/build/libarkts-copy/src/ts-api/static/enums.ts +0 -18
  28. package/build/libarkts-copy/src/ts-api/types.ts +0 -1075
  29. package/build/libarkts-copy/src/ts-api/utilities/private.ts +0 -292
  30. package/build/libarkts-copy/src/ts-api/utilities/public.ts +0 -55
  31. package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +0 -139
@@ -23,10 +23,10 @@ project(
23
23
  is_cross = get_option('cross_compile')
24
24
 
25
25
  sources = [
26
- './src/common.cc',
27
- './src/memoryTracker.cc',
28
- './src/bridges.cc',
29
- '../generated/native/bridges.cc',
26
+ './src/common.cpp',
27
+ './src/memoryTracker.cpp',
28
+ './src/bridges.cpp',
29
+ '../generated/native/bridges.cpp',
30
30
  get_option('interop_src_dir') / 'common-interop.cpp',
31
31
  get_option('interop_src_dir') / 'callback-resource.cpp',
32
32
  get_option('interop_src_dir') / 'interop-logging.cpp',
@@ -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
@@ -40,7 +40,7 @@ KNativePointer impl_AnnotationAllowedAnnotations(
40
40
  auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
41
41
  std::size_t params_len = 0;
42
42
  auto annotations = GetImpl()->AnnotationAllowedAnnotations(context, node, &params_len);
43
- return StageArena::cloneVector(annotations, params_len);
43
+ return StageArena::CloneVector(annotations, params_len);
44
44
  }
45
45
  KOALA_INTEROP_3(AnnotationAllowedAnnotations, KNativePointer, KNativePointer, KNativePointer, KNativePointer)
46
46
 
@@ -51,7 +51,7 @@ KNativePointer impl_AnnotationAllowedAnnotationsConst(
51
51
  auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
52
52
  std::size_t params_len = 0;
53
53
  auto annotations = GetImpl()->AnnotationAllowedAnnotationsConst(context, node, &params_len);
54
- return StageArena::cloneVector(annotations, params_len);
54
+ return StageArena::CloneVector(annotations, params_len);
55
55
  }
56
56
  KOALA_INTEROP_3(AnnotationAllowedAnnotationsConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer)
57
57
 
@@ -107,7 +107,7 @@ static KNativePointer impl_ProgramExternalSources(KNativePointer contextPtr, KNa
107
107
  auto&& instance = reinterpret_cast<es2panda_Program*>(instancePtr);
108
108
  std::size_t source_len = 0;
109
109
  auto external_sources = GetImpl()->ProgramExternalSources(context, instance, &source_len);
110
- return StageArena::cloneVector(external_sources, source_len);
110
+ return StageArena::CloneVector(external_sources, source_len);
111
111
  }
112
112
  KOALA_INTEROP_2(ProgramExternalSources, KNativePointer, KNativePointer, KNativePointer);
113
113
 
@@ -126,7 +126,7 @@ static KNativePointer impl_ProgramSourceFilePath(KNativePointer contextPtr, KNat
126
126
  auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
127
127
  auto&& instance = reinterpret_cast<es2panda_Program*>(instancePtr);
128
128
  auto&& result = GetImpl()->ProgramSourceFilePathConst(context, instance);
129
- return StageArena::strdup(result);
129
+ return StageArena::Strdup(result);
130
130
  }
131
131
  KOALA_INTEROP_2(ProgramSourceFilePath, KNativePointer, KNativePointer, KNativePointer);
132
132
 
@@ -134,7 +134,7 @@ static KNativePointer impl_ExternalSourceName(KNativePointer instance)
134
134
  {
135
135
  auto&& _instance_ = reinterpret_cast<es2panda_ExternalSource*>(instance);
136
136
  auto&& result = GetImpl()->ExternalSourceName(_instance_);
137
- return StageArena::strdup(result);
137
+ return StageArena::Strdup(result);
138
138
  }
139
139
  KOALA_INTEROP_1(ExternalSourceName, KNativePointer, KNativePointer);
140
140
 
@@ -143,7 +143,7 @@ static KNativePointer impl_ExternalSourcePrograms(KNativePointer instance)
143
143
  auto&& _instance_ = reinterpret_cast<es2panda_ExternalSource*>(instance);
144
144
  std::size_t program_len = 0;
145
145
  auto programs = GetImpl()->ExternalSourcePrograms(_instance_, &program_len);
146
- return StageArena::cloneVector(programs, program_len);
146
+ return StageArena::CloneVector(programs, program_len);
147
147
  }
148
148
  KOALA_INTEROP_1(ExternalSourcePrograms, KNativePointer, KNativePointer);
149
149
 
@@ -275,7 +275,7 @@ KNativePointer impl_Checker_TypeToString(KNativePointer context, KNativePointer
275
275
  auto _context = reinterpret_cast<es2panda_Context*>(context);
276
276
  auto _type = reinterpret_cast<es2panda_Type*>(type);
277
277
  auto result = GetImpl()->TypeToStringConst(_context, _type);
278
- return StageArena::strdup(result);
278
+ return StageArena::Strdup(result);
279
279
  }
280
280
  KOALA_INTEROP_2(Checker_TypeToString, KNativePointer, KNativePointer, KNativePointer)
281
281
 
@@ -347,7 +347,7 @@ KNativePointer impl_TSInterfaceBodyBodyPtr(KNativePointer context, KNativePointe
347
347
  const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
348
348
  std::size_t length;
349
349
  auto result = GetImpl()->TSInterfaceBodyBodyPtr(_context, _receiver, &length);
350
- return StageArena::cloneVector(result, length);
350
+ return StageArena::CloneVector(result, length);
351
351
  }
352
352
  KOALA_INTEROP_2(TSInterfaceBodyBodyPtr, KNativePointer, KNativePointer, KNativePointer);
353
353
 
@@ -357,7 +357,7 @@ KNativePointer impl_AnnotationDeclarationPropertiesPtrConst(KNativePointer conte
357
357
  const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
358
358
  std::size_t length;
359
359
  auto result = GetImpl()->AnnotationDeclarationPropertiesPtrConst(_context, _receiver, &length);
360
- return StageArena::cloneVector(result, length);
360
+ return StageArena::CloneVector(result, length);
361
361
  }
362
362
  KOALA_INTEROP_2(AnnotationDeclarationPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer);
363
363
 
@@ -394,7 +394,7 @@ KNativePointer impl_AnnotationUsageIrPropertiesPtrConst(KNativePointer context,
394
394
  const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
395
395
  std::size_t length;
396
396
  auto result = GetImpl()->AnnotationUsageIrPropertiesPtrConst(_context, _receiver, &length);
397
- return StageArena::cloneVector(result, length);
397
+ return StageArena::CloneVector(result, length);
398
398
  }
399
399
  KOALA_INTEROP_2(AnnotationUsageIrPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer);
400
400
 
@@ -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
@@ -24,22 +24,23 @@
24
24
  #include "interop-types.h"
25
25
 
26
26
  using std::string, std::cout, std::endl, std::vector;
27
+ constexpr int AST_NODE_TYPE_LIMIT = 256;
27
28
 
28
29
  es2panda_Impl* es2pandaImplementation = nullptr;
29
30
  static thread_local StageArena currentArena;
30
31
 
31
- StageArena* StageArena::instance()
32
+ StageArena* StageArena::Instance()
32
33
  {
33
34
  return &currentArena;
34
35
  }
35
36
 
36
- void StageArena::add(void* pointer)
37
+ void StageArena::Add(void* pointer)
37
38
  {
38
39
  if (pointer)
39
40
  allocated.push_back(pointer);
40
41
  }
41
42
 
42
- void StageArena::cleanup()
43
+ void StageArena::Cleanup()
43
44
  {
44
45
  if (totalSize > 0 && false)
45
46
  printf("cleanup %d objects %d bytes\n", (int)allocated.size(), (int)totalSize);
@@ -57,26 +58,26 @@ StageArena::StageArena()
57
58
 
58
59
  StageArena::~StageArena()
59
60
  {
60
- cleanup();
61
+ Cleanup();
61
62
  }
62
63
 
63
- char* StageArena::strdup(const char* string)
64
+ char* StageArena::Strdup(const char* string)
64
65
  {
65
- auto* arena = StageArena::instance();
66
+ auto* arena = StageArena::Instance();
66
67
  auto size = strlen(string) + 1;
67
- char* memory = (char*)arena->alloc(size);
68
+ char* memory = (char*)arena->Alloc(size);
68
69
  interop_memcpy(memory, size, string, size);
69
70
  return memory;
70
71
  }
71
72
 
72
- void* StageArena::alloc(size_t size)
73
+ void* StageArena::Alloc(size_t size)
73
74
  {
74
75
  void* result = malloc(size);
75
76
  if (!result) {
76
77
  INTEROP_FATAL("Cannot allocate memory");
77
78
  }
78
79
  totalSize += size;
79
- add(result);
80
+ Add(result);
80
81
  return result;
81
82
  }
82
83
 
@@ -178,7 +179,6 @@ void* TryLibrary(const char* name)
178
179
  return nullptr;
179
180
  }
180
181
 
181
- // TODO: @panda/sdk will be changed to match ohos-sdk
182
182
  void* FindLibrary()
183
183
  {
184
184
  void* res = nullptr;
@@ -227,7 +227,7 @@ const char** getStringArray(KStringArray& ptr)
227
227
 
228
228
  char* getStringCopy(KStringPtr& ptr)
229
229
  {
230
- return StageArena::strdup(ptr.c_str() ? ptr.c_str() : "");
230
+ return StageArena::Strdup(ptr.c_str() ? ptr.c_str() : "");
231
231
  }
232
232
 
233
233
  void impl_DestroyConfig(KNativePointer config)
@@ -236,27 +236,51 @@ void impl_DestroyConfig(KNativePointer config)
236
236
  // panda prints diagnostics here and do not clone our strings
237
237
  // so keep arena alive until this moment.
238
238
  GetImpl()->DestroyConfig(_config);
239
- StageArena::instance()->cleanup();
239
+ StageArena::Instance()->Cleanup();
240
240
  printf("[libarkts native] Arena cleaned up!\n");
241
241
  }
242
- KOALA_INTEROP_V1(DestroyConfig, KNativePointer);
242
+ KOALA_INTEROP_V1(DestroyConfig, KNativePointer)
243
+
244
+ // ─── Helpers to lower function size/complexity ────────────────────────────────
245
+ namespace {
246
+ template <class T, class U>
247
+ inline T As(U v) { return reinterpret_cast<T>(v); }
248
+
249
+ struct CallExprArgs {
250
+ es2panda_Context* context;
251
+ es2panda_AstNode* node;
252
+ es2panda_AstNode* callee;
253
+ es2panda_AstNode** arguments;
254
+ KInt argumentsLen;
255
+ es2panda_AstNode* typeParams;
256
+ bool optional;
257
+ bool trailingComma;
258
+ };
259
+
260
+ inline KNativePointer DoUpdateCallExpression(const CallExprArgs& a)
261
+ {
262
+ auto nn = GetImpl()->CreateCallExpression(
263
+ a.context, a.callee, a.arguments, a.argumentsLen, a.typeParams, a.optional, a.trailingComma);
264
+ GetImpl()->AstNodeSetOriginalNode(a.context, nn, a.node);
265
+ return nn;
266
+ }
267
+ } // namespace
243
268
 
244
269
  KNativePointer impl_UpdateCallExpression(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer calleePtr,
245
270
  KNativePointerArray argumentsPtr, KInt argumentsLen, KNativePointer typeParamsPtr, KBoolean optionalT,
246
271
  KBoolean trailingCommaT)
247
272
  {
248
- auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
249
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
250
- auto callee = reinterpret_cast<es2panda_AstNode*>(calleePtr);
251
- auto arguments = reinterpret_cast<es2panda_AstNode**>(argumentsPtr);
252
- auto typeParams = reinterpret_cast<es2panda_AstNode*>(typeParamsPtr);
253
- auto optional = static_cast<bool>(optionalT);
254
- auto trailingComma = static_cast<bool>(trailingCommaT);
255
-
256
- auto nn =
257
- GetImpl()->CreateCallExpression(context, callee, arguments, argumentsLen, typeParams, optional, trailingComma);
258
- GetImpl()->AstNodeSetOriginalNode(context, nn, node);
259
- return nn;
273
+ const CallExprArgs a{
274
+ As<es2panda_Context*>(contextPtr),
275
+ As<es2panda_AstNode*>(nodePtr),
276
+ As<es2panda_AstNode*>(calleePtr),
277
+ As<es2panda_AstNode**>(argumentsPtr),
278
+ argumentsLen,
279
+ As<es2panda_AstNode*>(typeParamsPtr),
280
+ static_cast<bool>(optionalT),
281
+ static_cast<bool>(trailingCommaT),
282
+ };
283
+ return DoUpdateCallExpression(a);
260
284
  }
261
285
  KOALA_INTEROP_8(UpdateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer,
262
286
  KNativePointerArray, KInt, KNativePointer, KBoolean, KBoolean)
@@ -367,7 +391,7 @@ KNativePointer impl_AstNodeChildren(KNativePointer contextPtr, KNativePointer no
367
391
  cachedChildren.clear();
368
392
 
369
393
  GetImpl()->AstNodeIterateConst(context, node, visitChild);
370
- return StageArena::clone(cachedChildren);
394
+ return StageArena::Clone(cachedChildren);
371
395
  }
372
396
  KOALA_INTEROP_2(AstNodeChildren, KNativePointer, KNativePointer, KNativePointer);
373
397
 
@@ -380,10 +404,29 @@ struct Pattern {
380
404
  std::regex regex;
381
405
 
382
406
  Pattern(const Pattern&) = delete;
407
+ Pattern& operator=(const Pattern&) = default;
408
+
409
+ Pattern(Pattern&& other) noexcept
410
+ : context(other.context),
411
+ key(std::move(other.key)),
412
+ value(std::move(other.value)),
413
+ impl(other.impl),
414
+ isWildcard(other.isWildcard),
415
+ regex(other.regex)
416
+ {
417
+ other.isWildcard = false;
418
+ }
383
419
 
384
- Pattern(Pattern&& other) noexcept :
385
- context(other.context), key(std::move(other.key)), value(std::move(other.value)), impl(other.impl), isWildcard(other.isWildcard), regex(other.regex) {
420
+ Pattern& operator=(Pattern&& other) noexcept
421
+ {
422
+ context = other.context;
423
+ key = std::move(other.key);
424
+ value = std::move(other.value);
425
+ impl = other.impl;
426
+ isWildcard = other.isWildcard;
427
+ regex = other.regex;
386
428
  other.isWildcard = false;
429
+ return *this;
387
430
  }
388
431
 
389
432
  Pattern(es2panda_Context* context, const std::string& part) : context(context), impl(GetImpl())
@@ -392,95 +435,102 @@ struct Pattern {
392
435
  std::getline(stream, key, '=');
393
436
  std::getline(stream, value, '=');
394
437
  isWildcard = value.find('*') != std::string::npos;
395
-
396
438
  if (isWildcard) {
397
439
  this->regex = std::regex(value);
398
440
  }
399
441
  }
400
-
442
+
401
443
  ~Pattern() = default;
402
444
 
403
445
  bool match(es2panda_AstNode* node) const
404
446
  {
405
447
  if (key == "type") {
406
- auto type = impl->AstNodeTypeConst(context, node);
407
- switch (type) {
408
- case Es2pandaAstNodeType::AST_NODE_TYPE_METHOD_DEFINITION:
409
- return value == "method";
410
- case Es2pandaAstNodeType::AST_NODE_TYPE_SCRIPT_FUNCTION:
411
- return value == "function";
412
- case Es2pandaAstNodeType::AST_NODE_TYPE_STRUCT_DECLARATION:
413
- return value == "struct";
414
- case Es2pandaAstNodeType::AST_NODE_TYPE_CALL_EXPRESSION:
415
- return value == "call";
416
- case Es2pandaAstNodeType::AST_NODE_TYPE_ASSIGNMENT_EXPRESSION:
417
- return value == "assignment";
418
- default:
419
- return false;
420
- }
448
+ return matchByType(node, impl->AstNodeTypeConst(context, node));
421
449
  }
422
450
  if (key == "annotation") {
423
- std::size_t length = 0;
424
- Es2pandaAstNodeType type = impl->AstNodeTypeConst(context, node);
425
- es2panda_AstNode** result = nullptr;
426
- switch (type) {
427
- case Es2pandaAstNodeType::AST_NODE_TYPE_SCRIPT_FUNCTION: {
428
- result = impl->ScriptFunctionAnnotations(context, node, &length);
429
- break;
430
- }
431
- case Es2pandaAstNodeType::AST_NODE_TYPE_FUNCTION_DECLARATION: {
432
- result = impl->FunctionDeclarationAnnotations(context, node, &length);
433
- break;
434
- }
435
- case Es2pandaAstNodeType::AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION: {
436
- result = impl->ArrowFunctionExpressionAnnotations(context, node, &length);
437
- break;
438
- }
439
- case Es2pandaAstNodeType::AST_NODE_TYPE_ETS_FUNCTION_TYPE: {
440
- result = impl->TypeNodeAnnotations(context, node, &length);
441
- break;
442
- }
443
- case Es2pandaAstNodeType::AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION: {
444
- result = impl->TSTypeAliasDeclarationAnnotations(context, node, &length);
445
- break;
446
- }
447
- case Es2pandaAstNodeType::AST_NODE_TYPE_VARIABLE_DECLARATION: {
448
- result = impl->VariableDeclarationAnnotations(context, node, &length);
449
- break;
450
- }
451
- case Es2pandaAstNodeType::AST_NODE_TYPE_ETS_UNION_TYPE: {
452
- result = impl->TypeNodeAnnotations(context, node, &length);
453
- break;
454
- }
455
- case Es2pandaAstNodeType::AST_NODE_TYPE_CLASS_PROPERTY: {
456
- result = impl->ClassPropertyAnnotations(context, node, &length);
457
- break;
458
- }
459
- case Es2pandaAstNodeType::AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION: {
460
- result = impl->ETSParameterExpressionAnnotations(context, node, &length);
461
- break;
462
- }
463
- default:
464
- return false;
451
+ return matchByAnnotation(node, impl->AstNodeTypeConst(context, node));
452
+ }
453
+ return false;
454
+ }
455
+
456
+ bool matchByType(es2panda_AstNode* node, Es2pandaAstNodeType type) const
457
+ {
458
+ switch (type) {
459
+ case Es2pandaAstNodeType::AST_NODE_TYPE_METHOD_DEFINITION:
460
+ return value == "method";
461
+ case Es2pandaAstNodeType::AST_NODE_TYPE_SCRIPT_FUNCTION:
462
+ return value == "function";
463
+ case Es2pandaAstNodeType::AST_NODE_TYPE_STRUCT_DECLARATION:
464
+ return value == "struct";
465
+ case Es2pandaAstNodeType::AST_NODE_TYPE_CALL_EXPRESSION:
466
+ return value == "call";
467
+ case Es2pandaAstNodeType::AST_NODE_TYPE_ASSIGNMENT_EXPRESSION:
468
+ return value == "assignment";
469
+ default:
470
+ return false;
471
+ }
472
+ }
473
+
474
+ bool matchByAnnotation(es2panda_AstNode* node, Es2pandaAstNodeType type) const
475
+ {
476
+ std::size_t length = 0;
477
+ es2panda_AstNode** result = nullptr;
478
+ switch (type) {
479
+ case Es2pandaAstNodeType::AST_NODE_TYPE_SCRIPT_FUNCTION: {
480
+ result = impl->ScriptFunctionAnnotations(context, node, &length);
481
+ break;
482
+ }
483
+ case Es2pandaAstNodeType::AST_NODE_TYPE_FUNCTION_DECLARATION: {
484
+ result = impl->FunctionDeclarationAnnotations(context, node, &length);
485
+ break;
486
+ }
487
+ case Es2pandaAstNodeType::AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION: {
488
+ result = impl->ArrowFunctionExpressionAnnotations(context, node, &length);
489
+ break;
490
+ }
491
+ case Es2pandaAstNodeType::AST_NODE_TYPE_ETS_FUNCTION_TYPE: {
492
+ result = impl->TypeNodeAnnotations(context, node, &length);
493
+ break;
465
494
  }
466
- bool found = false;
467
- for (std::size_t i = 0; i < length && result; i++) {
468
- es2panda_AstNode* ident = impl->AnnotationUsageIrGetBaseNameConst(context, result[i]);
469
- const char* name = impl->IdentifierNameConst(context, ident);
470
- found |= matchWildcard(value, name);
495
+ case Es2pandaAstNodeType::AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION: {
496
+ result = impl->TSTypeAliasDeclarationAnnotations(context, node, &length);
497
+ break;
471
498
  }
472
- return found;
499
+ case Es2pandaAstNodeType::AST_NODE_TYPE_VARIABLE_DECLARATION: {
500
+ result = impl->VariableDeclarationAnnotations(context, node, &length);
501
+ break;
502
+ }
503
+ case Es2pandaAstNodeType::AST_NODE_TYPE_ETS_UNION_TYPE: {
504
+ result = impl->TypeNodeAnnotations(context, node, &length);
505
+ break;
506
+ }
507
+ case Es2pandaAstNodeType::AST_NODE_TYPE_CLASS_PROPERTY: {
508
+ result = impl->ClassPropertyAnnotations(context, node, &length);
509
+ break;
510
+ }
511
+ case Es2pandaAstNodeType::AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION: {
512
+ result = impl->ETSParameterExpressionAnnotations(context, node, &length);
513
+ break;
514
+ }
515
+ default:
516
+ return false;
473
517
  }
474
- return false;
518
+
519
+ bool found = false;
520
+ for (std::size_t i = 0; i < length && result; i++) {
521
+ es2panda_AstNode* ident = impl->AnnotationUsageIrGetBaseNameConst(context, result[i]);
522
+ found |= MatchWildcard(value, impl->IdentifierNameConst(context, ident));
523
+ }
524
+ return found;
475
525
  }
476
526
 
477
- bool matchWildcard(const std::string& pattern, const char* value) const
527
+ bool MatchWildcard(const std::string& pattern, const char* foundValue) const
478
528
  {
479
529
  if (!isWildcard) {
480
- return pattern == value;
530
+ return pattern == foundValue;
481
531
  }
482
532
 
483
- return std::regex_search(value, this->regex);
533
+ return std::regex_search(foundValue, this->regex);
484
534
  }
485
535
  };
486
536
 
@@ -507,11 +557,11 @@ struct Matcher {
507
557
  }
508
558
  };
509
559
 
510
- KNativePointer impl_FilterNodes(KNativePointer context, KNativePointer node, const KStringPtr& filters, KBoolean deeperAfterMatch)
560
+ static KNativePointer DoFilterNodes(es2panda_Context* _context,
561
+ es2panda_AstNode* _node,
562
+ const char* _filters,
563
+ bool deeperAfterMatch)
511
564
  {
512
- auto _node = reinterpret_cast<es2panda_AstNode*>(node);
513
- auto _context = reinterpret_cast<es2panda_Context*>(context);
514
- const char* _filters = filters.c_str();
515
565
  std::vector<es2panda_AstNode*> result;
516
566
  es2panda_Impl* impl = GetImpl();
517
567
  Matcher matcher(_context, _filters);
@@ -526,18 +576,23 @@ KNativePointer impl_FilterNodes(KNativePointer context, KNativePointer node, con
526
576
  }
527
577
  if (!isMatch || deeperAfterMatch) {
528
578
  impl->AstNodeIterateConst(_context, current, visitChild);
529
- // We want to retain match order, so add children in reverse order.
530
579
  for (auto it = cachedChildren.rbegin(); it != cachedChildren.rend(); ++it) {
531
580
  queue.push_back(*it);
532
581
  }
533
582
  cachedChildren.clear();
534
583
  }
535
584
  }
536
- return StageArena::cloneVector(result.data(), result.size());
585
+ return StageArena::CloneVector(result.data(), result.size());
537
586
  }
538
- KOALA_INTEROP_4(FilterNodes, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KBoolean)
539
587
 
540
- constexpr int AST_NODE_TYPE_LIMIT = 256;
588
+ KNativePointer impl_FilterNodes(
589
+ KNativePointer context, KNativePointer node, const KStringPtr& filters, KBoolean deeperAfterMatch)
590
+ {
591
+ auto* _node = reinterpret_cast<es2panda_AstNode*>(node);
592
+ auto* _context = reinterpret_cast<es2panda_Context*>(context);
593
+ return DoFilterNodes(_context, _node, filters.c_str(), static_cast<bool>(deeperAfterMatch));
594
+ }
595
+ KOALA_INTEROP_4(FilterNodes, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KBoolean)
541
596
 
542
597
  struct FilterArgs {
543
598
  es2panda_Impl *impl;
@@ -564,7 +619,7 @@ KNativePointer impl_FilterNodes2(KNativePointer context, KNativePointer node, KI
564
619
  std::vector<es2panda_AstNode *> result;
565
620
  FilterArgs args = { GetImpl(), _context, &typesMask, &result };
566
621
  GetImpl()->AstNodeForEach(_node, filterByType, &args);
567
- return StageArena::cloneVector(result.data(), result.size());
622
+ return StageArena::CloneVector(result.data(), result.size());
568
623
  }
569
624
  KOALA_INTEROP_3(FilterNodes2, KNativePointer, KNativePointer, KNativePointer, KInt)
570
625
 
@@ -579,7 +634,7 @@ KNativePointer impl_FilterNodes3(KNativePointer context, KNativePointer node, KI
579
634
  std::vector<es2panda_AstNode *> result;
580
635
  FilterArgs args = { GetImpl(), _context, &typesMask, &result };
581
636
  GetImpl()->AstNodeForEach(_node, filterByType, &args);
582
- return StageArena::cloneVector(result.data(), result.size());
637
+ return StageArena::CloneVector(result.data(), result.size());
583
638
  }
584
639
  KOALA_INTEROP_4(FilterNodes3, KNativePointer, KNativePointer, KNativePointer, KInt*, KInt)
585
640
 
@@ -82,52 +82,52 @@ class StageArena {
82
82
  public:
83
83
  StageArena();
84
84
  ~StageArena();
85
- static StageArena* instance();
85
+ static StageArena* Instance();
86
86
  template<typename T>
87
- static T* alloc()
87
+ static T* Alloc()
88
88
  {
89
- auto* arena = StageArena::instance();
90
- void* memory = arena->alloc(sizeof(T));
89
+ auto* arena = StageArena::Instance();
90
+ void* memory = arena->Alloc(sizeof(T));
91
91
  return new (memory) T();
92
92
  }
93
93
  template<class T, class T1>
94
- static T* alloc(T1 arg1)
94
+ static T* Alloc(T1 arg1)
95
95
  {
96
- auto* arena = StageArena::instance();
97
- void* memory = arena->alloc(sizeof(T));
96
+ auto* arena = StageArena::Instance();
97
+ void* memory = arena->Alloc(sizeof(T));
98
98
  return new (memory) T(std::forward(arg1));
99
99
  }
100
100
  template<class T, class T1, class T2>
101
- static T* alloc(T1 arg1, T2 arg2)
101
+ static T* Alloc(T1 arg1, T2 arg2)
102
102
  {
103
- auto* arena = StageArena::instance();
104
- void* memory = arena->alloc(sizeof(T));
103
+ auto* arena = StageArena::Instance();
104
+ void* memory = arena->Alloc(sizeof(T));
105
105
  return new (memory) T(arg1, arg2);
106
106
  }
107
107
  template<typename T>
108
- static T* allocArray(size_t count)
108
+ static T* AllocArray(size_t count)
109
109
  {
110
- auto* arena = StageArena::instance();
110
+ auto* arena = StageArena::Instance();
111
111
  // align?
112
- void* memory = arena->alloc(sizeof(T) * count);
112
+ void* memory = arena->Alloc(sizeof(T) * count);
113
113
  return new (memory) T();
114
114
  }
115
115
  template<class T>
116
- static T* clone(const T& arg)
116
+ static T* Clone(const T& arg)
117
117
  {
118
- auto* arena = StageArena::instance();
119
- void* memory = arena->alloc(sizeof(T));
118
+ auto* arena = StageArena::Instance();
119
+ void* memory = arena->Alloc(sizeof(T));
120
120
  return new (memory) T(arg);
121
121
  }
122
122
  template<class T>
123
- static std::vector<const void*>* cloneVector(const T* arg, size_t count)
123
+ static std::vector<const void*>* CloneVector(const T* arg, size_t count)
124
124
  {
125
- return alloc<std::vector<const void*>, const T*, const T*>(arg, arg + count);
125
+ return Alloc<std::vector<const void*>, const T*, const T*>(arg, arg + count);
126
126
  }
127
- void* alloc(size_t size);
128
- static char* strdup(const char* original);
129
- void add(void* pointer);
130
- void cleanup();
127
+ void* Alloc(size_t size);
128
+ static char* Strdup(const char* original);
129
+ void Add(void* pointer);
130
+ void Cleanup();
131
131
  };
132
132
 
133
133
  #endif // COMMON_H
@@ -163,9 +163,15 @@ void MemoryTracker::Report(MemoryStats stats)
163
163
  const double mb = kb * BYTES_PER_KB;
164
164
  const double gb = mb * BYTES_PER_KB;
165
165
 
166
- if (bytes > gb) return std::to_string(bytes / gb) + " GB";
167
- if (bytes > mb) return std::to_string(bytes / mb) + " MB";
168
- if (bytes > kb) return std::to_string(bytes / kb) + " KB";
166
+ if (bytes > gb) {
167
+ return std::to_string(bytes / gb) + " GB";
168
+ }
169
+ if (bytes > mb) {
170
+ return std::to_string(bytes / mb) + " MB";
171
+ }
172
+ if (bytes > kb) {
173
+ return std::to_string(bytes / kb) + " KB";
174
+ }
169
175
  return std::to_string(bytes) + " B";
170
176
  };
171
177
 
@@ -42,7 +42,7 @@
42
42
  "tsconfig-paths": "^4.2.0",
43
43
  "rimraf": "^6.0.1",
44
44
  "@koalaui/fast-arktsc": "1.7.10+devel",
45
- "@idlizer/arktscgen": "2.1.10-arktscgen-5",
45
+ "@idlizer/arktscgen": "2.1.10-arktscgen-6",
46
46
  "mocha": "^9.2.2",
47
47
  "@koalaui/harness": "1.7.10+devel",
48
48
  "@koalaui/ets-tsc": "4.9.5-r6",
@@ -63,7 +63,7 @@
63
63
  "compile": "npm run regenerate && npm run compile:native && npm run compile:js",
64
64
  "compile:current": "npm run regenerate:current && npm run compile:native && npm run compile:js",
65
65
  "compile:release": "npm run regenerate && npm run crosscompile:native && npm run compile:js",
66
- "compile:js": "rm -rf lib/ && rollup -c rollup.lib.mjs && rollup -c rollup.es2panda.mjs",
66
+ "compile:js": "rm -rf lib/ && rollup -c rollup.libarkts.mjs && rollup -c rollup.es2panda.mjs",
67
67
  "compile:plugins": "rollup -c ./rollup.printer-plugin.mjs",
68
68
  "direct": "fast-arktsc --config arktsconfig.json --compiler ../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/main.abc && ninja -f build/abc/build.ninja",
69
69
  "simultaneous": "mkdir -p build/abc && bash ../incremental/tools/panda/arkts/ui2abc --simultaneous --arktsconfig arktsconfig.json --output ./build/abc/main.abc:./build/abc/library.abc plugins/input/main.ets:plugins/input/library.ets",