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

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 (287) hide show
  1. package/build/libarkts-copy/generator/options.json5 +24 -47
  2. package/build/libarkts-copy/native/meson.build +26 -10
  3. package/build/libarkts-copy/native/meson_options.txt +9 -3
  4. package/build/libarkts-copy/native/mingw.cross +2 -0
  5. package/build/libarkts-copy/native/src/bridges.cc +55 -159
  6. package/build/libarkts-copy/native/src/common.cc +316 -97
  7. package/build/libarkts-copy/native/src/common.h +22 -22
  8. package/build/libarkts-copy/native/src/memoryTracker.cc +5 -5
  9. package/build/libarkts-copy/native/src/memoryTracker.h +5 -5
  10. package/build/libarkts-copy/package.json +31 -25
  11. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +139 -116
  12. package/build/libarkts-copy/src/InteropNativeModule.ts +18 -15
  13. package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +24 -19
  14. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +30 -31
  15. package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +30 -18
  16. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +30 -12
  17. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +38 -29
  18. package/build/libarkts-copy/src/arkts-api/index.ts +23 -24
  19. package/build/libarkts-copy/src/arkts-api/node-cache.ts +22 -13
  20. package/build/libarkts-copy/src/arkts-api/node-utilities/ArkTsConfig.ts +8 -8
  21. package/build/libarkts-copy/src/arkts-api/node-utilities/ArrayExpression.ts +9 -21
  22. package/build/libarkts-copy/src/arkts-api/node-utilities/AssignmentExpression.ts +12 -14
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/BlockStatement.ts +5 -5
  24. package/build/libarkts-copy/src/arkts-api/node-utilities/CallExpression.ts +26 -24
  25. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +62 -32
  26. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +14 -13
  27. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +24 -21
  28. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +10 -12
  29. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSModule.ts +14 -18
  30. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +15 -16
  31. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSStructDeclaration.ts +5 -8
  32. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTuple.ts +6 -12
  33. package/build/libarkts-copy/src/arkts-api/node-utilities/MemberExpression.ts +12 -11
  34. package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +14 -33
  35. package/build/libarkts-copy/src/arkts-api/node-utilities/NumberLiteral.ts +12 -23
  36. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +17 -21
  37. package/build/libarkts-copy/src/arkts-api/node-utilities/OpaqueTypeNode.ts +9 -8
  38. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +21 -16
  39. package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +52 -53
  40. package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +22 -32
  41. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameter.ts +12 -14
  42. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeReferencePart.ts +10 -12
  43. package/build/libarkts-copy/src/arkts-api/node-utilities/TryStatement.ts +10 -9
  44. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclarator.ts +10 -12
  45. package/build/libarkts-copy/src/arkts-api/peers/ArktsObject.ts +8 -8
  46. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +53 -65
  47. package/build/libarkts-copy/src/arkts-api/peers/Config.ts +18 -25
  48. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +35 -42
  49. package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +9 -9
  50. package/build/libarkts-copy/src/arkts-api/peers/ImportPathManager.ts +6 -8
  51. package/build/libarkts-copy/src/arkts-api/peers/Options.ts +8 -8
  52. package/build/libarkts-copy/src/arkts-api/plugins.ts +205 -32
  53. package/build/libarkts-copy/src/arkts-api/static/global.ts +35 -36
  54. package/build/libarkts-copy/src/arkts-api/static/globalUtils.ts +5 -5
  55. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +107 -91
  56. package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +54 -37
  57. package/build/libarkts-copy/src/arkts-api/utilities/nativePtrDecoder.ts +86 -69
  58. package/build/libarkts-copy/src/arkts-api/utilities/performance.ts +41 -24
  59. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +69 -62
  60. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +254 -175
  61. package/build/libarkts-copy/src/arkts-api/visitor.ts +599 -756
  62. package/build/libarkts-copy/src/arkts-api/wrapper-compat.ts +8 -8
  63. package/build/libarkts-copy/src/checkSdk.ts +15 -18
  64. package/build/libarkts-copy/src/index.ts +29 -29
  65. package/build/libarkts-copy/src/memo-node-cache.ts +143 -0
  66. package/build/libarkts-copy/src/plugin-utils.ts +64 -45
  67. package/build/libarkts-copy/src/reexport-for-generated.ts +13 -10
  68. package/build/libarkts-copy/src/tracer.ts +76 -70
  69. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +134 -274
  70. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +23 -23
  71. package/build/libarkts-copy/src/ts-api/index.ts +27 -35
  72. package/build/libarkts-copy/src/ts-api/static/enums.ts +3 -3
  73. package/build/libarkts-copy/src/ts-api/types.ts +535 -395
  74. package/build/libarkts-copy/src/ts-api/utilities/private.ts +116 -113
  75. package/build/libarkts-copy/src/ts-api/utilities/public.ts +18 -18
  76. package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +33 -49
  77. package/build/libarkts-copy/src/utils.ts +103 -80
  78. package/build/libarkts-copy/tsconfig.json +3 -2
  79. package/lib/index.js +2713 -7729
  80. package/package.json +53 -52
  81. package/templates/Es2pandaNativeModule.ts +1 -0
  82. package/templates/peer.ts +1 -0
  83. package/build/libarkts-copy/native/src/generated/bridges.cc +0 -16375
  84. package/build/libarkts-copy/src/arkts-api/peers/DiagnosticKind.ts +0 -24
  85. package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +0 -1344
  86. package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +0 -5192
  87. package/build/libarkts-copy/src/generated/factory.ts +0 -1285
  88. package/build/libarkts-copy/src/generated/index.ts +0 -222
  89. package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +0 -44
  90. package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +0 -54
  91. package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +0 -45
  92. package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +0 -165
  93. package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +0 -84
  94. package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +0 -73
  95. package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +0 -109
  96. package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +0 -119
  97. package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +0 -65
  98. package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +0 -111
  99. package/build/libarkts-copy/src/generated/peers/AstDumper.ts +0 -49
  100. package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +0 -40
  101. package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +0 -40
  102. package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +0 -61
  103. package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +0 -61
  104. package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +0 -110
  105. package/build/libarkts-copy/src/generated/peers/BindingProps.ts +0 -40
  106. package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +0 -72
  107. package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +0 -94
  108. package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +0 -61
  109. package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +0 -78
  110. package/build/libarkts-copy/src/generated/peers/CallExpression.ts +0 -129
  111. package/build/libarkts-copy/src/generated/peers/CatchClause.ts +0 -74
  112. package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +0 -68
  113. package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +0 -58
  114. package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +0 -76
  115. package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +0 -365
  116. package/build/libarkts-copy/src/generated/peers/ClassElement.ts +0 -76
  117. package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +0 -62
  118. package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +0 -137
  119. package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +0 -66
  120. package/build/libarkts-copy/src/generated/peers/CodeGen.ts +0 -40
  121. package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +0 -82
  122. package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +0 -78
  123. package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +0 -58
  124. package/build/libarkts-copy/src/generated/peers/Declaration.ts +0 -40
  125. package/build/libarkts-copy/src/generated/peers/Decorator.ts +0 -62
  126. package/build/libarkts-copy/src/generated/peers/DiagnosticInfo.ts +0 -40
  127. package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +0 -60
  128. package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +0 -66
  129. package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +0 -40
  130. package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +0 -62
  131. package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +0 -102
  132. package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +0 -90
  133. package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +0 -69
  134. package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +0 -61
  135. package/build/libarkts-copy/src/generated/peers/ETSModule.ts +0 -129
  136. package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +0 -75
  137. package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +0 -79
  138. package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +0 -75
  139. package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +0 -58
  140. package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +0 -59
  141. package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +0 -189
  142. package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +0 -62
  143. package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +0 -55
  144. package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +0 -58
  145. package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +0 -59
  146. package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +0 -89
  147. package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +0 -66
  148. package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +0 -78
  149. package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +0 -58
  150. package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +0 -75
  151. package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +0 -63
  152. package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +0 -66
  153. package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +0 -40
  154. package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +0 -66
  155. package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +0 -64
  156. package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +0 -94
  157. package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +0 -82
  158. package/build/libarkts-copy/src/generated/peers/Expression.ts +0 -84
  159. package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +0 -67
  160. package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +0 -69
  161. package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +0 -72
  162. package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +0 -67
  163. package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +0 -106
  164. package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +0 -74
  165. package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +0 -70
  166. package/build/libarkts-copy/src/generated/peers/IRNode.ts +0 -40
  167. package/build/libarkts-copy/src/generated/peers/Identifier.ts +0 -162
  168. package/build/libarkts-copy/src/generated/peers/IfStatement.ts +0 -78
  169. package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +0 -87
  170. package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +0 -62
  171. package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +0 -61
  172. package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +0 -62
  173. package/build/libarkts-copy/src/generated/peers/ImportSource.ts +0 -40
  174. package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +0 -73
  175. package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +0 -40
  176. package/build/libarkts-copy/src/generated/peers/LabelPair.ts +0 -40
  177. package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +0 -68
  178. package/build/libarkts-copy/src/generated/peers/Literal.ts +0 -53
  179. package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +0 -45
  180. package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +0 -53
  181. package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +0 -115
  182. package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +0 -62
  183. package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +0 -152
  184. package/build/libarkts-copy/src/generated/peers/NamedType.ts +0 -84
  185. package/build/libarkts-copy/src/generated/peers/NewExpression.ts +0 -64
  186. package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +0 -58
  187. package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +0 -78
  188. package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +0 -40
  189. package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +0 -94
  190. package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +0 -58
  191. package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +0 -58
  192. package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +0 -101
  193. package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +0 -65
  194. package/build/libarkts-copy/src/generated/peers/Program.ts +0 -206
  195. package/build/libarkts-copy/src/generated/peers/Property.ts +0 -92
  196. package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +0 -65
  197. package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +0 -75
  198. package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +0 -40
  199. package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +0 -310
  200. package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +0 -40
  201. package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +0 -61
  202. package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +0 -40
  203. package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +0 -48
  204. package/build/libarkts-copy/src/generated/peers/SourceRange.ts +0 -40
  205. package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +0 -83
  206. package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +0 -120
  207. package/build/libarkts-copy/src/generated/peers/Statement.ts +0 -44
  208. package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +0 -66
  209. package/build/libarkts-copy/src/generated/peers/SuggestionInfo.ts +0 -40
  210. package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +0 -58
  211. package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +0 -70
  212. package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +0 -71
  213. package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +0 -58
  214. package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +0 -61
  215. package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +0 -84
  216. package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +0 -58
  217. package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +0 -58
  218. package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +0 -70
  219. package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +0 -71
  220. package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +0 -73
  221. package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +0 -112
  222. package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +0 -76
  223. package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +0 -61
  224. package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +0 -75
  225. package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +0 -69
  226. package/build/libarkts-copy/src/generated/peers/TSImportType.ts +0 -72
  227. package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +0 -73
  228. package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +0 -64
  229. package/build/libarkts-copy/src/generated/peers/TSInferType.ts +0 -62
  230. package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +0 -61
  231. package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +0 -160
  232. package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +0 -62
  233. package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +0 -62
  234. package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +0 -62
  235. package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +0 -72
  236. package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +0 -79
  237. package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +0 -61
  238. package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +0 -71
  239. package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +0 -68
  240. package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +0 -58
  241. package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +0 -66
  242. package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +0 -58
  243. package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +0 -58
  244. package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +0 -58
  245. package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +0 -74
  246. package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +0 -62
  247. package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +0 -80
  248. package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +0 -71
  249. package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +0 -75
  250. package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +0 -58
  251. package/build/libarkts-copy/src/generated/peers/TSThisType.ts +0 -58
  252. package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +0 -61
  253. package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +0 -151
  254. package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +0 -71
  255. package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +0 -61
  256. package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +0 -71
  257. package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +0 -121
  258. package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +0 -75
  259. package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +0 -62
  260. package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +0 -68
  261. package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +0 -62
  262. package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +0 -70
  263. package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +0 -58
  264. package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +0 -61
  265. package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +0 -58
  266. package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +0 -58
  267. package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +0 -69
  268. package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +0 -69
  269. package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +0 -68
  270. package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +0 -58
  271. package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +0 -62
  272. package/build/libarkts-copy/src/generated/peers/TryStatement.ts +0 -89
  273. package/build/libarkts-copy/src/generated/peers/TypeNode.ts +0 -81
  274. package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +0 -44
  275. package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +0 -45
  276. package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +0 -61
  277. package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +0 -70
  278. package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +0 -58
  279. package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +0 -68
  280. package/build/libarkts-copy/src/generated/peers/VReg.ts +0 -40
  281. package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +0 -50
  282. package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +0 -113
  283. package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +0 -79
  284. package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +0 -40
  285. package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +0 -40
  286. package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +0 -71
  287. package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +0 -64
@@ -14,12 +14,18 @@
14
14
  */
15
15
 
16
16
  #include <common.h>
17
+ #include <iterator>
18
+ #include <regex>
19
+ #include <sstream>
17
20
  #include <utility>
21
+ #include <vector>
22
+ #include <bitset>
23
+
18
24
  #include "interop-types.h"
19
25
 
20
26
  using std::string, std::cout, std::endl, std::vector;
21
27
 
22
- es2panda_Impl *es2pandaImplementation = nullptr;
28
+ es2panda_Impl* es2pandaImplementation = nullptr;
23
29
  static thread_local StageArena currentArena;
24
30
 
25
31
  StageArena* StageArena::instance()
@@ -75,28 +81,28 @@ void* StageArena::alloc(size_t size)
75
81
  }
76
82
 
77
83
  #ifdef KOALA_WINDOWS
78
- #include <windows.h>
79
- #define PLUGIN_DIR "windows_host_tools"
80
- #define LIB_PREFIX "lib"
81
- #define LIB_SUFFIX ".dll"
84
+ #include <windows.h>
85
+ #define PLUGIN_DIR "windows_host_tools"
86
+ #define LIB_PREFIX "lib"
87
+ #define LIB_SUFFIX ".dll"
82
88
  #endif
83
89
 
84
90
  #if defined(KOALA_LINUX) || defined(KOALA_MACOS)
85
- #include <dlfcn.h>
91
+ #include <dlfcn.h>
86
92
 
87
- #ifdef __x86_64__
88
- #define PLUGIN_DIR "linux_host_tools"
89
- #else
90
- #define PLUGIN_DIR "linux_arm64_host_tools"
91
- #endif
93
+ #ifdef __x86_64__
94
+ #define PLUGIN_DIR "linux_host_tools"
95
+ #else
96
+ #define PLUGIN_DIR "linux_arm64_host_tools"
97
+ #endif
92
98
 
93
- #define LIB_PREFIX "lib"
94
- #define LIB_SUFFIX ".so"
99
+ #define LIB_PREFIX "lib"
100
+ #define LIB_SUFFIX ".so"
95
101
  #endif
96
102
 
97
- const char* DEFAULT_SDK_PATH = "../../../incremental/tools/panda/node_modules/@panda/sdk" ;
98
- const char* NAME = LIB_PREFIX "es2panda-public" LIB_SUFFIX;
103
+ const char* DEFAULT_SDK_PATH = "../../../incremental/tools/panda/node_modules/@panda/sdk";
99
104
 
105
+ const char* LIB_ES2PANDA_PUBLIC_ALT = LIB_PREFIX "es2panda-public" LIB_SUFFIX;
100
106
  const char* LIB_ES2PANDA_PUBLIC = LIB_PREFIX "es2panda_public" LIB_SUFFIX;
101
107
  const char* IS_UI_FLAG = "IS_UI_FLAG";
102
108
  const char* NOT_UI_FLAG = "NOT_UI_FLAG";
@@ -104,15 +110,15 @@ const string MODULE_SUFFIX = ".d.ets";
104
110
  const string ARKUI = "arkui";
105
111
 
106
112
  #ifdef KOALA_WINDOWS
107
- const char *SEPARATOR = "\\";
113
+ const char* SEPARATOR = "\\";
108
114
  #else
109
- const char *SEPARATOR = "/";
115
+ const char* SEPARATOR = "/";
110
116
  #endif
111
- const char *LIB_DIR = "lib";
117
+ const char* LIB_DIR = "lib";
112
118
 
113
119
  static std::string ES2PANDA_LIB_PATH = "";
114
120
 
115
- std::string joinPath(vector<string> &paths)
121
+ std::string joinPath(vector<string>& paths)
116
122
  {
117
123
  std::string res;
118
124
  for (std::size_t i = 0; i < paths.size(); ++i) {
@@ -125,20 +131,20 @@ std::string joinPath(vector<string> &paths)
125
131
  return res;
126
132
  }
127
133
 
128
- void impl_SetUpSoPath(KStringPtr &soPath)
134
+ void impl_SetUpSoPath(KStringPtr& soPath)
129
135
  {
130
136
  ES2PANDA_LIB_PATH = std::string(soPath.c_str());
131
137
  }
132
138
  KOALA_INTEROP_V1(SetUpSoPath, KStringPtr);
133
139
 
134
- // Improve: simplify this
135
- void* FindLibrary() {
136
- void *res = nullptr;
140
+ void* TryLibrary(const char* name)
141
+ {
142
+ void* res = nullptr;
137
143
  std::vector<std::string> pathArray;
138
144
 
139
145
  // find by SetUpSoPath
140
146
  if (!ES2PANDA_LIB_PATH.empty()) {
141
- pathArray = {ES2PANDA_LIB_PATH, LIB_DIR, LIB_ES2PANDA_PUBLIC};
147
+ pathArray = { ES2PANDA_LIB_PATH, LIB_DIR, name };
142
148
  res = loadLibrary(joinPath(pathArray));
143
149
  if (res) {
144
150
  return res;
@@ -148,7 +154,7 @@ void* FindLibrary() {
148
154
  // find by set PANDA_SDK_PATH
149
155
  char* envValue = getenv("PANDA_SDK_PATH");
150
156
  if (envValue) {
151
- pathArray = {envValue, PLUGIN_DIR, LIB_DIR, NAME};
157
+ pathArray = { envValue, PLUGIN_DIR, LIB_DIR, name };
152
158
  res = loadLibrary(joinPath(pathArray));
153
159
  if (res) {
154
160
  return res;
@@ -156,14 +162,14 @@ void* FindLibrary() {
156
162
  }
157
163
 
158
164
  // find by set LD_LIBRARY_PATH
159
- pathArray = {LIB_ES2PANDA_PUBLIC};
165
+ pathArray = { name };
160
166
  res = loadLibrary(joinPath(pathArray));
161
167
  if (res) {
162
168
  return res;
163
169
  }
164
170
 
165
171
  // find by DEFAULT_SDK_PATH
166
- pathArray = {DEFAULT_SDK_PATH, PLUGIN_DIR, LIB_DIR, NAME};
172
+ pathArray = { DEFAULT_SDK_PATH, PLUGIN_DIR, LIB_DIR, name };
167
173
  res = loadLibrary(joinPath(pathArray));
168
174
  if (res) {
169
175
  return res;
@@ -172,7 +178,25 @@ void* FindLibrary() {
172
178
  return nullptr;
173
179
  }
174
180
 
175
- es2panda_Impl *GetImplSlow()
181
+ // TODO: @panda/sdk will be changed to match ohos-sdk
182
+ void* FindLibrary()
183
+ {
184
+ void* res = nullptr;
185
+
186
+ res = TryLibrary(LIB_ES2PANDA_PUBLIC);
187
+ if (res) {
188
+ return res;
189
+ }
190
+
191
+ res = TryLibrary(LIB_ES2PANDA_PUBLIC_ALT);
192
+ if (res) {
193
+ return res;
194
+ }
195
+
196
+ return nullptr;
197
+ }
198
+
199
+ es2panda_Impl* GetImplSlow()
176
200
  {
177
201
  if (es2pandaImplementation) {
178
202
  return es2pandaImplementation;
@@ -187,7 +211,7 @@ es2panda_Impl *GetImplSlow()
187
211
  printf("no entry point");
188
212
  abort();
189
213
  }
190
- es2pandaImplementation = reinterpret_cast<es2panda_Impl *(*)(int)>(symbol)(ES2PANDA_LIB_VERSION);
214
+ es2pandaImplementation = reinterpret_cast<es2panda_Impl* (*)(int)>(symbol)(ES2PANDA_LIB_VERSION);
191
215
  return es2pandaImplementation;
192
216
  }
193
217
 
@@ -196,51 +220,31 @@ string getString(KStringPtr ptr)
196
220
  return ptr.data();
197
221
  }
198
222
 
199
- char* getStringCopy(KStringPtr& ptr)
223
+ const char** getStringArray(KStringArray& ptr)
200
224
  {
201
- return StageArena::strdup(ptr.c_str() ? ptr.c_str() : "");
202
- }
203
-
204
- KNativePointer impl_CreateConfig(KInt argc, KStringArray argvPtr) {
205
- const std::size_t headerLen = 4;
206
-
207
- const char** argv = StageArena::allocArray<const char*>(argc);
208
- std::size_t position = headerLen;
209
- std::size_t strLen;
210
- for (std::size_t i = 0; i < static_cast<std::size_t>(argc); ++i) {
211
- strLen = unpackUInt(argvPtr + position);
212
- position += headerLen;
213
- argv[i] = StageArena::strdup(std::string(reinterpret_cast<const char*>(argvPtr + position), strLen).c_str());
214
- position += strLen;
215
- }
216
- return GetImpl()->CreateConfig(argc, argv);
225
+ return const_cast<const char**>(ptr.get()); // release()?
217
226
  }
218
- KOALA_INTEROP_2(CreateConfig, KNativePointer, KInt, KStringArray)
219
227
 
220
- KNativePointer impl_DestroyConfig(KNativePointer configPtr) {
221
- auto config = reinterpret_cast<es2panda_Config*>(configPtr);
222
- GetImpl()->DestroyConfig(config);
223
- return nullptr;
228
+ char* getStringCopy(KStringPtr& ptr)
229
+ {
230
+ return StageArena::strdup(ptr.c_str() ? ptr.c_str() : "");
224
231
  }
225
- KOALA_INTEROP_1(DestroyConfig, KNativePointer, KNativePointer)
226
232
 
227
- void impl_DestroyContext(KNativePointer contextPtr) {
228
- auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
229
- GetImpl()->DestroyContext(context);
233
+ void impl_DestroyConfig(KNativePointer config)
234
+ {
235
+ const auto _config = reinterpret_cast<es2panda_Config*>(config);
236
+ // panda prints diagnostics here and do not clone our strings
237
+ // so keep arena alive until this moment.
238
+ GetImpl()->DestroyConfig(_config);
230
239
  StageArena::instance()->cleanup();
240
+ printf("[libarkts native] Arena cleaned up!\n");
231
241
  }
232
- KOALA_INTEROP_V1(DestroyContext, KNativePointer)
233
-
234
- KNativePointer impl_UpdateCallExpression(
235
- KNativePointer contextPtr,
236
- KNativePointer nodePtr,
237
- KNativePointer calleePtr,
238
- KNativePointerArray argumentsPtr,
239
- KInt argumentsLen,
240
- KNativePointer typeParamsPtr,
241
- KBoolean optionalT,
242
- KBoolean trailingCommaT
243
- ) {
242
+ KOALA_INTEROP_V1(DestroyConfig, KNativePointer);
243
+
244
+ KNativePointer impl_UpdateCallExpression(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer calleePtr,
245
+ KNativePointerArray argumentsPtr, KInt argumentsLen, KNativePointer typeParamsPtr, KBoolean optionalT,
246
+ KBoolean trailingCommaT)
247
+ {
244
248
  auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
245
249
  auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
246
250
  auto callee = reinterpret_cast<es2panda_AstNode*>(calleePtr);
@@ -249,26 +253,28 @@ KNativePointer impl_UpdateCallExpression(
249
253
  auto optional = static_cast<bool>(optionalT);
250
254
  auto trailingComma = static_cast<bool>(trailingCommaT);
251
255
 
252
- auto nn = GetImpl()->CreateCallExpression(
253
- context, callee, arguments, argumentsLen, typeParams, optional, trailingComma
254
- );
256
+ auto nn =
257
+ GetImpl()->CreateCallExpression(context, callee, arguments, argumentsLen, typeParams, optional, trailingComma);
255
258
  GetImpl()->AstNodeSetOriginalNode(context, nn, node);
256
259
  return nn;
257
260
  }
258
- KOALA_INTEROP_8(UpdateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KInt, KNativePointer, KBoolean, KBoolean)
261
+ KOALA_INTEROP_8(UpdateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer,
262
+ KNativePointerArray, KInt, KNativePointer, KBoolean, KBoolean)
259
263
 
260
- KInt impl_IdentifierIdentifierFlags(KNativePointer contextPtr, KNativePointer nodePtr) {
264
+ KInt impl_IdentifierIdentifierFlags(KNativePointer contextPtr, KNativePointer nodePtr)
265
+ {
261
266
  auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
262
267
  auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
263
268
 
264
- return
265
- (GetImpl()->IdentifierIsOptionalConst(context, node) ? (1 << 0) : 0) |
266
- (GetImpl()->IdentifierIsReferenceConst(context, node) ? (1 << 1) : 0) |
267
- (GetImpl()->IdentifierIsTdzConst(context, node) ? (1 << 2) : 0);
269
+ return (GetImpl()->IdentifierIsOptionalConst(context, node) ? (1 << 0) : 0) |
270
+ (GetImpl()->IdentifierIsReferenceConst(context, node) ? (1 << 1) : 0) |
271
+ (GetImpl()->IdentifierIsTdzConst(context, node) ? (1 << 2) : 0);
268
272
  }
269
273
  KOALA_INTEROP_2(IdentifierIdentifierFlags, KInt, KNativePointer, KNativePointer)
270
274
 
271
- void impl_ClassDefinitionSetBody(KNativePointer context, KNativePointer receiver, KNativePointerArray body, KUInt bodyLength) {
275
+ void impl_ClassDefinitionSetBody(
276
+ KNativePointer context, KNativePointer receiver, KNativePointerArray body, KUInt bodyLength)
277
+ {
272
278
  const auto _context = reinterpret_cast<es2panda_Context*>(context);
273
279
  const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
274
280
  const auto _body = reinterpret_cast<es2panda_AstNode**>(body);
@@ -285,24 +291,25 @@ Improve: NOT FROM API (shouldn't be there)
285
291
  -----------------------------------------------------------------------------------------------------------------------------
286
292
  */
287
293
 
288
- es2panda_AstNode * cachedParentNode;
289
- es2panda_Context * cachedContext;
294
+ es2panda_AstNode* cachedParentNode;
295
+ es2panda_Context* cachedContext;
290
296
 
291
- static void changeParent(es2panda_AstNode *child)
297
+ static void changeParent(es2panda_AstNode* child)
292
298
  {
293
299
  GetImpl()->AstNodeSetParent(cachedContext, child, cachedParentNode);
294
300
  }
295
301
 
296
- static void SetRightParent(es2panda_AstNode *node, void *arg)
302
+ static void SetRightParent(es2panda_AstNode* node, void* arg)
297
303
  {
298
- es2panda_Context *ctx = static_cast<es2panda_Context *>(arg);
304
+ es2panda_Context* ctx = static_cast<es2panda_Context*>(arg);
299
305
  cachedContext = ctx;
300
306
  cachedParentNode = node;
301
307
 
302
308
  GetImpl()->AstNodeIterateConst(ctx, node, changeParent);
303
309
  }
304
310
 
305
- KNativePointer impl_AstNodeUpdateAll(KNativePointer contextPtr, KNativePointer programPtr) {
311
+ KNativePointer impl_AstNodeUpdateAll(KNativePointer contextPtr, KNativePointer programPtr)
312
+ {
306
313
  auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
307
314
  auto program = reinterpret_cast<es2panda_AstNode*>(programPtr);
308
315
 
@@ -311,7 +318,8 @@ KNativePointer impl_AstNodeUpdateAll(KNativePointer contextPtr, KNativePointer p
311
318
  }
312
319
  KOALA_INTEROP_2(AstNodeUpdateAll, KNativePointer, KNativePointer, KNativePointer)
313
320
 
314
- void impl_AstNodeSetChildrenParentPtr(KNativePointer contextPtr, KNativePointer nodePtr) {
321
+ void impl_AstNodeSetChildrenParentPtr(KNativePointer contextPtr, KNativePointer nodePtr)
322
+ {
315
323
  auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
316
324
  auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
317
325
  cachedParentNode = node;
@@ -320,7 +328,8 @@ void impl_AstNodeSetChildrenParentPtr(KNativePointer contextPtr, KNativePointer
320
328
  }
321
329
  KOALA_INTEROP_V2(AstNodeSetChildrenParentPtr, KNativePointer, KNativePointer)
322
330
 
323
- void impl_AstNodeOnUpdate(KNativePointer context, KNativePointer newNode, KNativePointer replacedNode) {
331
+ void impl_AstNodeOnUpdate(KNativePointer context, KNativePointer newNode, KNativePointer replacedNode)
332
+ {
324
333
  auto _context = reinterpret_cast<es2panda_Context*>(context);
325
334
  auto _newNode = reinterpret_cast<es2panda_AstNode*>(newNode);
326
335
  auto _replacedNode = reinterpret_cast<es2panda_AstNode*>(replacedNode);
@@ -343,17 +352,15 @@ void impl_AstNodeOnUpdate(KNativePointer context, KNativePointer newNode, KNativ
343
352
  }
344
353
  KOALA_INTEROP_V3(AstNodeOnUpdate, KNativePointer, KNativePointer, KNativePointer)
345
354
 
346
- std::vector<void*> cachedChildren;
355
+ static thread_local std::vector<es2panda_AstNode*> cachedChildren;
347
356
 
348
- static void visitChild(es2panda_AstNode *node)
357
+ static void visitChild(es2panda_AstNode* node)
349
358
  {
350
359
  cachedChildren.emplace_back(node);
351
360
  }
352
361
 
353
- KNativePointer impl_AstNodeChildren(
354
- KNativePointer contextPtr,
355
- KNativePointer nodePtr
356
- ) {
362
+ KNativePointer impl_AstNodeChildren(KNativePointer contextPtr, KNativePointer nodePtr)
363
+ {
357
364
  auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
358
365
  auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
359
366
  cachedContext = context;
@@ -362,7 +369,219 @@ KNativePointer impl_AstNodeChildren(
362
369
  GetImpl()->AstNodeIterateConst(context, node, visitChild);
363
370
  return StageArena::clone(cachedChildren);
364
371
  }
365
- KOALA_INTEROP_2(AstNodeChildren, KNativePointer, KNativePointer, KNativePointer)
372
+ KOALA_INTEROP_2(AstNodeChildren, KNativePointer, KNativePointer, KNativePointer);
373
+
374
+ struct Pattern {
375
+ es2panda_Context* context;
376
+ std::string key;
377
+ std::string value;
378
+ es2panda_Impl* impl;
379
+ bool isWildcard = false;
380
+ std::regex regex;
381
+
382
+ Pattern(const Pattern&) = delete;
383
+
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) {
386
+ other.isWildcard = false;
387
+ }
388
+
389
+ Pattern(es2panda_Context* context, const std::string& part) : context(context), impl(GetImpl())
390
+ {
391
+ std::istringstream stream(part);
392
+ std::getline(stream, key, '=');
393
+ std::getline(stream, value, '=');
394
+ isWildcard = value.find('*') != std::string::npos;
395
+
396
+ if (isWildcard) {
397
+ this->regex = std::regex(value);
398
+ }
399
+ }
400
+
401
+ ~Pattern() = default;
402
+
403
+ bool match(es2panda_AstNode* node) const
404
+ {
405
+ 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
+ }
421
+ }
422
+ 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;
465
+ }
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);
471
+ }
472
+ return found;
473
+ }
474
+ return false;
475
+ }
476
+
477
+ bool matchWildcard(const std::string& pattern, const char* value) const
478
+ {
479
+ if (!isWildcard) {
480
+ return pattern == value;
481
+ }
482
+
483
+ return std::regex_search(value, this->regex);
484
+ }
485
+ };
486
+
487
+ struct Matcher {
488
+ es2panda_Context* context;
489
+ const char* query;
490
+ std::vector<Pattern> patterns;
491
+ es2panda_Impl* impl;
492
+ Matcher(es2panda_Context* context, const char* query) : context(context), query(query), impl(GetImpl())
493
+ {
494
+ std::istringstream stream(query);
495
+ std::string item;
496
+ while (std::getline(stream, item, ';')) {
497
+ patterns.emplace_back(std::forward<Pattern>(Pattern(context, item)));
498
+ }
499
+ }
500
+ bool match(es2panda_AstNode* node)
501
+ {
502
+ bool result = true;
503
+ for (const auto& pattern : patterns) {
504
+ result &= pattern.match(node);
505
+ }
506
+ return result;
507
+ }
508
+ };
509
+
510
+ KNativePointer impl_FilterNodes(KNativePointer context, KNativePointer node, const KStringPtr& filters, KBoolean deeperAfterMatch)
511
+ {
512
+ auto _node = reinterpret_cast<es2panda_AstNode*>(node);
513
+ auto _context = reinterpret_cast<es2panda_Context*>(context);
514
+ const char* _filters = filters.c_str();
515
+ std::vector<es2panda_AstNode*> result;
516
+ es2panda_Impl* impl = GetImpl();
517
+ Matcher matcher(_context, _filters);
518
+ std::vector<es2panda_AstNode*> queue;
519
+ queue.push_back(_node);
520
+ while (queue.size() > 0) {
521
+ auto* current = queue.back();
522
+ queue.pop_back();
523
+ bool isMatch = matcher.match(current);
524
+ if (isMatch) {
525
+ result.push_back(current);
526
+ }
527
+ if (!isMatch || deeperAfterMatch) {
528
+ impl->AstNodeIterateConst(_context, current, visitChild);
529
+ // We want to retain match order, so add children in reverse order.
530
+ for (auto it = cachedChildren.rbegin(); it != cachedChildren.rend(); ++it) {
531
+ queue.push_back(*it);
532
+ }
533
+ cachedChildren.clear();
534
+ }
535
+ }
536
+ return StageArena::cloneVector(result.data(), result.size());
537
+ }
538
+ KOALA_INTEROP_4(FilterNodes, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KBoolean)
539
+
540
+ constexpr int AST_NODE_TYPE_LIMIT = 256;
541
+
542
+ struct FilterArgs {
543
+ es2panda_Impl *impl;
544
+ es2panda_Context *context;
545
+ std::bitset<AST_NODE_TYPE_LIMIT> *typesMask;
546
+ std::vector<es2panda_AstNode *> *result;
547
+ };
548
+
549
+ void filterByType(es2panda_AstNode *node, void *argsPointer)
550
+ {
551
+ FilterArgs *args = reinterpret_cast<FilterArgs *>(argsPointer);
552
+ auto type = args->impl->AstNodeTypeConst(args->context, node);
553
+ if ((*args->typesMask)[type]) {
554
+ args->result->push_back(node);
555
+ }
556
+ }
557
+
558
+ KNativePointer impl_FilterNodes2(KNativePointer context, KNativePointer node, KInt type)
559
+ {
560
+ auto _node = reinterpret_cast<es2panda_AstNode*>(node);
561
+ auto _context = reinterpret_cast<es2panda_Context*>(context);
562
+ std::bitset<AST_NODE_TYPE_LIMIT> typesMask;
563
+ typesMask.set(type);
564
+ std::vector<es2panda_AstNode *> result;
565
+ FilterArgs args = { GetImpl(), _context, &typesMask, &result };
566
+ GetImpl()->AstNodeForEach(_node, filterByType, &args);
567
+ return StageArena::cloneVector(result.data(), result.size());
568
+ }
569
+ KOALA_INTEROP_3(FilterNodes2, KNativePointer, KNativePointer, KNativePointer, KInt)
570
+
571
+ KNativePointer impl_FilterNodes3(KNativePointer context, KNativePointer node, KInt* types, KInt typesSize)
572
+ {
573
+ auto _node = reinterpret_cast<es2panda_AstNode*>(node);
574
+ auto _context = reinterpret_cast<es2panda_Context*>(context);
575
+ std::bitset<AST_NODE_TYPE_LIMIT> typesMask;
576
+ for (int i = 0; i < typesSize; i++) {
577
+ typesMask.set(types[i]);
578
+ }
579
+ std::vector<es2panda_AstNode *> result;
580
+ FilterArgs args = { GetImpl(), _context, &typesMask, &result };
581
+ GetImpl()->AstNodeForEach(_node, filterByType, &args);
582
+ return StageArena::cloneVector(result.data(), result.size());
583
+ }
584
+ KOALA_INTEROP_4(FilterNodes3, KNativePointer, KNativePointer, KNativePointer, KInt*, KInt)
366
585
 
367
586
  /*
368
587
  -----------------------------------------------------------------------------------------------------------------------------
@@ -390,9 +609,9 @@ static bool isUIHeaderFile(es2panda_Context* context, es2panda_Program* program)
390
609
  result = GetImpl()->ProgramModuleNameConst(context, program);
391
610
  string moduleName(result);
392
611
 
393
- return fileNameWithExtension.length() >= MODULE_SUFFIX.length()
394
- && fileNameWithExtension.substr(fileNameWithExtension.length() - MODULE_SUFFIX.length()) == MODULE_SUFFIX
395
- && moduleName.find(ARKUI) != std::string::npos;
612
+ return fileNameWithExtension.length() >= MODULE_SUFFIX.length() &&
613
+ fileNameWithExtension.substr(fileNameWithExtension.length() - MODULE_SUFFIX.length()) == MODULE_SUFFIX &&
614
+ moduleName.find(ARKUI) != std::string::npos;
396
615
  }
397
616
 
398
617
  KBoolean impl_ProgramCanSkipPhases(KNativePointer context, KNativePointer program)
@@ -405,8 +624,8 @@ KBoolean impl_ProgramCanSkipPhases(KNativePointer context, KNativePointer progra
405
624
  return false;
406
625
  }
407
626
  std::size_t sourceLen;
408
- const auto externalSources = reinterpret_cast<es2panda_ExternalSource **>
409
- (GetImpl()->ProgramExternalSources(_context, _program, &sourceLen));
627
+ const auto externalSources =
628
+ reinterpret_cast<es2panda_ExternalSource**>(GetImpl()->ProgramExternalSources(_context, _program, &sourceLen));
410
629
  for (std::size_t i = 0; i < sourceLen; ++i) {
411
630
  std::size_t programLen;
412
631
  auto programs = GetImpl()->ExternalSourcePrograms(externalSources[i], &programLen);