@idlizer/arktscgen 2.1.9-arktscgen-9 → 2.1.10-arktscgen-3

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 (296) hide show
  1. package/build/libarkts-copy/generator/options.json5 +199 -4
  2. package/build/libarkts-copy/native/meson.build +1 -0
  3. package/build/libarkts-copy/native/mingw.cross +13 -0
  4. package/build/libarkts-copy/native/src/bridges.cc +66 -229
  5. package/build/libarkts-copy/native/src/common.cc +37 -8
  6. package/build/libarkts-copy/native/src/generated/bridges.cc +2047 -766
  7. package/build/libarkts-copy/native/src/memoryTracker.cc +178 -0
  8. package/build/libarkts-copy/native/src/memoryTracker.h +52 -0
  9. package/build/libarkts-copy/package.json +11 -14
  10. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +41 -52
  11. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +1 -1
  12. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +7 -6
  13. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +5 -2
  14. package/build/libarkts-copy/src/arkts-api/index.ts +2 -1
  15. package/build/libarkts-copy/src/arkts-api/node-cache.ts +9 -9
  16. package/build/libarkts-copy/src/arkts-api/node-utilities/ArkTsConfig.ts +7 -6
  17. package/build/libarkts-copy/src/arkts-api/node-utilities/NumberLiteral.ts +3 -1
  18. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +25 -6
  19. package/build/libarkts-copy/src/{wrapper-compat/arkts-api/peers/ImportPathManager.ts → arkts-api/node-utilities/OpaqueTypeNode.ts} +8 -17
  20. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +11 -10
  21. package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +1 -1
  22. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +12 -7
  23. package/build/libarkts-copy/src/arkts-api/peers/Config.ts +6 -0
  24. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +3 -15
  25. package/build/libarkts-copy/src/{wrapper-compat/arkts-api/peers/AstNode.ts → arkts-api/peers/DiagnosticKind.ts} +6 -8
  26. package/build/libarkts-copy/src/arkts-api/static/global.ts +28 -1
  27. package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +64 -7
  28. package/build/libarkts-copy/src/{wrapper-compat/arkts-api → arkts-api}/utilities/performance.ts +122 -3
  29. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +8 -22
  30. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +95 -93
  31. package/build/libarkts-copy/src/arkts-api/visitor.ts +971 -364
  32. package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +6 -0
  33. package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +686 -185
  34. package/build/libarkts-copy/src/generated/factory.ts +2 -3
  35. package/build/libarkts-copy/src/generated/index.ts +3 -2
  36. package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +3 -3
  37. package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +3 -3
  38. package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +3 -3
  39. package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +17 -20
  40. package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +7 -9
  41. package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +4 -1
  42. package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +6 -12
  43. package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +18 -21
  44. package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +5 -7
  45. package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +6 -8
  46. package/build/libarkts-copy/src/generated/peers/AstDumper.ts +3 -1
  47. package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +0 -1
  48. package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +0 -1
  49. package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +5 -7
  50. package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +5 -7
  51. package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +5 -7
  52. package/build/libarkts-copy/src/generated/peers/BindingProps.ts +0 -1
  53. package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +5 -7
  54. package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +5 -7
  55. package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +5 -7
  56. package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +7 -9
  57. package/build/libarkts-copy/src/generated/peers/CallExpression.ts +11 -8
  58. package/build/libarkts-copy/src/generated/peers/CatchClause.ts +6 -8
  59. package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +5 -7
  60. package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +5 -7
  61. package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +6 -30
  62. package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +35 -28
  63. package/build/libarkts-copy/src/generated/peers/ClassElement.ts +5 -32
  64. package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +6 -8
  65. package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +25 -20
  66. package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +6 -8
  67. package/build/libarkts-copy/src/generated/peers/CodeGen.ts +0 -1
  68. package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +5 -7
  69. package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +7 -9
  70. package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +5 -7
  71. package/build/libarkts-copy/src/generated/peers/Declaration.ts +0 -1
  72. package/build/libarkts-copy/src/generated/peers/Decorator.ts +5 -7
  73. package/build/libarkts-copy/src/generated/peers/DiagnosticInfo.ts +0 -1
  74. package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +5 -7
  75. package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +5 -7
  76. package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +0 -1
  77. package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +5 -7
  78. package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +14 -9
  79. package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +5 -7
  80. package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +7 -9
  81. package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +5 -7
  82. package/build/libarkts-copy/src/generated/peers/ETSModule.ts +17 -20
  83. package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +5 -7
  84. package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +6 -8
  85. package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +6 -8
  86. package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +5 -7
  87. package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +5 -7
  88. package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +20 -23
  89. package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +5 -7
  90. package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +4 -6
  91. package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +5 -7
  92. package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +5 -7
  93. package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +9 -11
  94. package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +7 -9
  95. package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +9 -11
  96. package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +5 -7
  97. package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +5 -7
  98. package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +6 -8
  99. package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +6 -8
  100. package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +0 -1
  101. package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +7 -9
  102. package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +5 -7
  103. package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +11 -13
  104. package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +7 -9
  105. package/build/libarkts-copy/src/generated/peers/Expression.ts +7 -3
  106. package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +5 -7
  107. package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +5 -7
  108. package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +5 -7
  109. package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +4 -6
  110. package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +16 -23
  111. package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +8 -10
  112. package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +5 -2
  113. package/build/libarkts-copy/src/generated/peers/IRNode.ts +0 -1
  114. package/build/libarkts-copy/src/generated/peers/Identifier.ts +7 -18
  115. package/build/libarkts-copy/src/generated/peers/IfStatement.ts +5 -7
  116. package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +6 -8
  117. package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +6 -8
  118. package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +5 -7
  119. package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +6 -8
  120. package/build/libarkts-copy/src/generated/peers/ImportSource.ts +0 -1
  121. package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +7 -9
  122. package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +0 -1
  123. package/build/libarkts-copy/src/generated/peers/LabelPair.ts +0 -1
  124. package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +6 -8
  125. package/build/libarkts-copy/src/generated/peers/Literal.ts +3 -3
  126. package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +3 -3
  127. package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +3 -3
  128. package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +5 -11
  129. package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +5 -7
  130. package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +10 -12
  131. package/build/libarkts-copy/src/generated/peers/NamedType.ts +7 -9
  132. package/build/libarkts-copy/src/generated/peers/NewExpression.ts +5 -7
  133. package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +5 -7
  134. package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +10 -10
  135. package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +0 -1
  136. package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +5 -11
  137. package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +5 -7
  138. package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +5 -7
  139. package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +5 -7
  140. package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +5 -7
  141. package/build/libarkts-copy/src/generated/peers/Program.ts +9 -2
  142. package/build/libarkts-copy/src/generated/peers/Property.ts +6 -8
  143. package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +5 -7
  144. package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +6 -8
  145. package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +0 -1
  146. package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +27 -23
  147. package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +0 -1
  148. package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +5 -7
  149. package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +0 -1
  150. package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +8 -1
  151. package/build/libarkts-copy/src/generated/peers/SourceRange.ts +0 -1
  152. package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +5 -11
  153. package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +3 -1
  154. package/build/libarkts-copy/src/generated/peers/Statement.ts +3 -3
  155. package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +6 -8
  156. package/build/libarkts-copy/src/generated/peers/SuggestionInfo.ts +0 -1
  157. package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +5 -7
  158. package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +5 -7
  159. package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +6 -8
  160. package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +5 -7
  161. package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +5 -7
  162. package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +5 -7
  163. package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +5 -7
  164. package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +5 -7
  165. package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +7 -9
  166. package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +5 -7
  167. package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +6 -8
  168. package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +8 -32
  169. package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +6 -8
  170. package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +5 -7
  171. package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +6 -8
  172. package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +6 -8
  173. package/build/libarkts-copy/src/generated/peers/TSImportType.ts +6 -8
  174. package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +5 -7
  175. package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +5 -7
  176. package/build/libarkts-copy/src/generated/peers/TSInferType.ts +6 -8
  177. package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +5 -7
  178. package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +19 -44
  179. package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +5 -7
  180. package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +5 -7
  181. package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +5 -7
  182. package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +6 -8
  183. package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +6 -8
  184. package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +5 -7
  185. package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +5 -7
  186. package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +5 -7
  187. package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +5 -7
  188. package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +5 -7
  189. package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +5 -7
  190. package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +5 -7
  191. package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +5 -7
  192. package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +5 -7
  193. package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +5 -7
  194. package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +5 -7
  195. package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +7 -9
  196. package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +6 -8
  197. package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +5 -7
  198. package/build/libarkts-copy/src/generated/peers/TSThisType.ts +5 -7
  199. package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +5 -7
  200. package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +32 -47
  201. package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +5 -7
  202. package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +5 -7
  203. package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +5 -7
  204. package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +17 -20
  205. package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +6 -8
  206. package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +5 -7
  207. package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +5 -7
  208. package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +5 -7
  209. package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +7 -9
  210. package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +5 -7
  211. package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +5 -7
  212. package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +5 -7
  213. package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +5 -7
  214. package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +7 -9
  215. package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +6 -8
  216. package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +6 -8
  217. package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +5 -7
  218. package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +5 -7
  219. package/build/libarkts-copy/src/generated/peers/TryStatement.ts +7 -9
  220. package/build/libarkts-copy/src/generated/peers/TypeNode.ts +13 -14
  221. package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +3 -3
  222. package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +3 -3
  223. package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +5 -7
  224. package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +5 -7
  225. package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +5 -7
  226. package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +5 -7
  227. package/build/libarkts-copy/src/generated/peers/VReg.ts +0 -1
  228. package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +3 -1
  229. package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +16 -26
  230. package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +6 -8
  231. package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +0 -1
  232. package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +0 -1
  233. package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +5 -7
  234. package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +5 -7
  235. package/build/libarkts-copy/src/index.ts +4 -1
  236. package/build/libarkts-copy/src/plugin-utils.ts +8 -11
  237. package/build/libarkts-copy/src/reexport-for-generated.ts +1 -12
  238. package/build/libarkts-copy/src/tracer.ts +172 -0
  239. package/build/libarkts-copy/src/utils.ts +3 -0
  240. package/lib/index.js +1403 -544
  241. package/package.json +4 -3
  242. package/templates/factory.ts +0 -1
  243. package/templates/peer.ts +0 -1
  244. package/build/libarkts-copy/src/arkts-api/ChainExpressionFilter.ts +0 -79
  245. package/build/libarkts-copy/src/arkts-api/peers/SourcePosition.ts +0 -38
  246. package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +0 -45
  247. package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +0 -45
  248. package/build/libarkts-copy/src/wrapper-compat/README.md +0 -20
  249. package/build/libarkts-copy/src/wrapper-compat/arkts-api/class-by-peer.ts +0 -46
  250. package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeFactory.ts +0 -454
  251. package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeTests.ts +0 -99
  252. package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +0 -88
  253. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrayExpression.ts +0 -38
  254. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrowFunctionExpression.ts +0 -35
  255. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/AssignmentExpression.ts +0 -38
  256. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/BlockStatement.ts +0 -27
  257. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/CallExpression.ts +0 -45
  258. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDeclaration.ts +0 -27
  259. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDefinition.ts +0 -73
  260. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassProperty.ts +0 -51
  261. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSFunctionType.ts +0 -42
  262. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSImportDeclaration.ts +0 -39
  263. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSParameterExpression.ts +0 -43
  264. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ExpressionStatement.ts +0 -28
  265. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionDeclaration.ts +0 -37
  266. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionExpression.ts +0 -28
  267. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/IfStatement.ts +0 -37
  268. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MemberExpression.ts +0 -42
  269. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MethodDefinition.ts +0 -46
  270. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/NumberLiteral.ts +0 -30
  271. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ObjectExpression.ts +0 -37
  272. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/Property.ts +0 -27
  273. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ScriptFunction.ts +0 -46
  274. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/StructDeclaration.ts +0 -28
  275. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSInterfaceDeclaration.ts +0 -47
  276. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +0 -40
  277. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeParameter.ts +0 -36
  278. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TryStatement.ts +0 -41
  279. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclaration.ts +0 -42
  280. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclarator.ts +0 -39
  281. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +0 -38
  282. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +0 -34
  283. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticKind.ts +0 -33
  284. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Program.ts +0 -105
  285. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +0 -38
  286. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourceRange.ts +0 -38
  287. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +0 -34
  288. package/build/libarkts-copy/src/wrapper-compat/arkts-api/static/global.ts +0 -16
  289. package/build/libarkts-copy/src/wrapper-compat/arkts-api/to-be-generated/MemberExpression.ts +0 -108
  290. package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +0 -889
  291. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/nativePtrDecoder.ts +0 -69
  292. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/private.ts +0 -198
  293. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +0 -327
  294. package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +0 -421
  295. package/build/libarkts-copy/src/wrapper-compat/index.ts +0 -20
  296. package/templates/node-map.ts +0 -35
@@ -13,22 +13,41 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
+ import { KNativePointer } from "@koalaui/interop"
16
17
  import { ObjectExpression, Expression } from "../../generated"
17
18
  import { isSameNativeObject } from "../peers/ArktsObject"
18
- import { nodeType, updateNodeByNode } from "../utilities/private"
19
+ import { updateNodeByNode } from "../utilities/private"
20
+ import { Es2pandaAstNodeType } from "../../generated/Es2pandaEnums"
21
+
22
+ export function createObjectExpression(
23
+ properties: readonly Expression[],
24
+ preferredReturnType?: KNativePointer,
25
+ ): ObjectExpression {
26
+ const result = ObjectExpression.createObjectExpression(
27
+ Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION,
28
+ properties,
29
+ false, // Improve: provide trailingComma value from native module through ObjectExpression?
30
+ )
31
+ if (preferredReturnType) {
32
+ result.setPreferredTypePointer(preferredReturnType)
33
+ }
34
+ return result
35
+ }
19
36
 
20
37
  export function updateObjectExpression(
21
38
  original: ObjectExpression,
22
- properties: readonly Expression[]
39
+ properties: readonly Expression[],
40
+ preferredReturnType?: KNativePointer,
23
41
  ): ObjectExpression {
24
- if (isSameNativeObject(properties, original.properties)){
42
+ if (isSameNativeObject(properties, original.properties)
43
+ && preferredReturnType == original.getPreferredTypePointer()) {
25
44
  return original
26
45
  }
27
46
  return updateNodeByNode(
28
- ObjectExpression.createObjectExpression(
29
- nodeType(original),
47
+ createObjectExpression(
30
48
  properties,
31
- false), // Improve: provide trailingComma value from native module through ObjectExpression?
49
+ preferredReturnType
50
+ ),
32
51
  original
33
52
  )
34
53
  }
@@ -13,22 +13,13 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
- import { ArktsObject } from "../../../arkts-api/peers/ArktsObject"
17
- import { global } from "../static/global"
18
16
  import { KNativePointer } from "@koalaui/interop"
17
+ import { global } from "../static/global"
18
+ import { OpaqueTypeNode } from "../../generated"
19
+ import { Es2pandaAstNodeType } from "../../generated/Es2pandaEnums"
19
20
 
20
- export class ImportPathManager extends ArktsObject {
21
- constructor(peer: KNativePointer) {
22
- super(peer)
23
- }
24
-
25
- static create(): ImportPathManager {
26
- return new ImportPathManager(
27
- global.es2panda._ETSParserGetImportPathManager(global.context)
28
- );
29
- }
30
-
31
- resolvePath(currentModulePath: string, importPath: string): string {
32
- return ''; // Improve: no longer support this.
33
- }
34
- }
21
+ export function createOpaqueTypeNode(
22
+ typePointer: KNativePointer
23
+ ): OpaqueTypeNode {
24
+ return new OpaqueTypeNode(global.es2panda._Checker_CreateOpaqueTypeNode(global.context, typePointer), Es2pandaAstNodeType.AST_NODE_TYPE_OPAQUE_TYPE_NODE)
25
+ }
@@ -14,18 +14,19 @@
14
14
  */
15
15
 
16
16
  import { Program } from "../../generated"
17
+ import { traceGlobal } from "../../tracer"
17
18
 
18
19
  export function dumpProgramInfo(program: Program) {
19
- console.log(`Program info:`)
20
- console.log(`\tAbsoluteName: ${program.absoluteName}`)
21
- console.log(`\tFileName: ${program.fileName}`)
22
- console.log(`\tFileNameWithExtension: ${program.fileNameWithExtension}`)
23
- console.log(`\tModuleName: ${program.moduleName}`)
24
- console.log(`\tModulePrefix: ${program.modulePrefix}`)
25
- console.log(`\tRelativeFilePath: ${program.relativeFilePath}`)
26
- console.log(`\tResolvedFilePath: ${program.resolvedFilePath}`)
27
- console.log(`\tSourceFileFolder: ${program.sourceFileFolder}`)
28
- console.log(`\tSourceFilePath: ${program.sourceFilePath}`)
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}`)
29
30
  }
30
31
 
31
32
  export function dumpProgramSrcFormatted(program: Program, recursive: boolean, withLines: boolean = true) {
@@ -107,4 +107,4 @@ export function updateScriptFunction(
107
107
  ),
108
108
  original
109
109
  )
110
- }
110
+ }
@@ -17,19 +17,21 @@ import { isNullPtr, KInt, KNativePointer, nullptr } from "@koalaui/interop"
17
17
  import { global } from "../static/global"
18
18
  import { allFlags, unpackNode, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private"
19
19
  import { throwError } from "../../utils"
20
- import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
20
+ import { Es2pandaAstNodeType, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
21
21
  import { ArktsObject } from "./ArktsObject"
22
- import { SourcePosition } from "./SourcePosition"
22
+ import { SourcePosition } from "../../generated/peers/SourcePosition"
23
23
  import { NodeCache } from "../node-cache"
24
24
 
25
25
  export abstract class AstNode extends ArktsObject {
26
- protected constructor(peer: KNativePointer) {
26
+ public readonly astNodeType: Es2pandaAstNodeType
27
+
28
+ protected constructor(peer: KNativePointer, astNodeType: Es2pandaAstNodeType) {
27
29
  global.profiler.nodeCreated()
28
30
  if (isNullPtr(peer)) {
29
31
  throwError(`attempted to create AstNode from nullptr`)
30
32
  }
31
33
  super(peer)
32
- this.setChildrenParentPtr()
34
+ this.astNodeType = astNodeType
33
35
  NodeCache.addToCache(peer, this)
34
36
  }
35
37
 
@@ -46,6 +48,10 @@ export abstract class AstNode extends ArktsObject {
46
48
  global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, peer)
47
49
  }
48
50
 
51
+ public get original(): this {
52
+ return unpackNonNullableNode(this.originalPeer)
53
+ }
54
+
49
55
  public getChildren(): readonly AstNode[] {
50
56
  return unpackNodeArray(global.es2panda._AstNodeChildren(global.context, this.peer))
51
57
  }
@@ -153,9 +159,8 @@ export abstract class AstNode extends ArktsObject {
153
159
  public override onUpdate(original: AstNode): void {
154
160
  // Improve: Update modifiers only for specific AST nodes in the generated factory code
155
161
  this.modifierFlags = original.modifierFlags
156
- global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, original.originalPeer)
157
- global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
158
- this.setChildrenParentPtr()
162
+
163
+ global.es2panda._AstNodeOnUpdate(global.context, this.peer, original.peer)
159
164
  }
160
165
 
161
166
  public get isExport(): boolean {
@@ -17,6 +17,7 @@ import { ArktsObject } from "./ArktsObject"
17
17
  import { global } from "../static/global"
18
18
  import { passStringArray } from "../utilities/private"
19
19
  import { KNativePointer, nullptr } from "@koalaui/interop"
20
+ import { Es2pandaCompilationMode } from "../../generated/Es2pandaEnums"
20
21
 
21
22
  export class Config extends ArktsObject {
22
23
  constructor(peer: KNativePointer) {
@@ -55,5 +56,10 @@ export class Config extends ArktsObject {
55
56
  }
56
57
  }
57
58
 
59
+ get compilationMode(): Es2pandaCompilationMode {
60
+ return global.es2panda._GetCompilationMode(this.peer);
61
+ }
62
+
63
+
58
64
  readonly path: string
59
65
  }
@@ -52,22 +52,10 @@ export class Context extends ArktsObject {
52
52
  );
53
53
  }
54
54
 
55
- static createFromFile(filePath: string, configPath: string, stdlibPath: string, outputPath: string): Context | undefined {
56
- const config = Config.create([
57
- "",
58
- "--arktsconfig",
59
- configPath,
60
- '--extension',
61
- 'ets',
62
- '--stdlib',
63
- stdlibPath,
64
- filePath,
65
- '--output',
66
- outputPath,
67
- ])
55
+ static createFromFile(filePath: string): Context {
68
56
  return new Context(
69
57
  global.es2panda._CreateContextFromFile(
70
- config.peer,
58
+ global.config,
71
59
  passString(filePath)
72
60
  )
73
61
  )
@@ -112,7 +100,7 @@ export class Context extends ArktsObject {
112
100
  }
113
101
 
114
102
  get program(): Program {
115
- return new Program(global.es2panda._ContextProgram(this.peer));
103
+ return new Program(global.generatedEs2panda._ContextProgram(this.peer));
116
104
  }
117
105
  }
118
106
 
@@ -13,14 +13,12 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
- import { KNativePointer as KPtr } from '@koalaui/interop';
16
+ import { KNativePointer } from "@koalaui/interop";
17
+ import { ArktsObject } from "./ArktsObject"
17
18
 
18
- import { AstNode } from "../../../arkts-api/peers/AstNode"
19
19
 
20
- export { AstNode }
21
-
22
- export class UnsupportedNode extends AstNode {
23
- constructor(peer: KPtr) {
24
- super(peer);
25
- }
20
+ export class DiagnosticKind extends ArktsObject {
21
+ constructor(peer: KNativePointer) {
22
+ super(peer);
23
+ }
26
24
  }
@@ -21,15 +21,34 @@ import { initInterop, InteropNativeModule } from "../../InteropNativeModule"
21
21
  import { Context } from "../peers/Context"
22
22
  import { Profiler } from "./profiler"
23
23
  import { ArkTsConfig } from "../../generated"
24
+ import { Config } from '../peers/Config';
25
+
26
+ export class UpdateTracker {
27
+ stack: boolean[] = []
28
+
29
+ push() {
30
+ this.stack.push(false)
31
+ }
32
+
33
+ update() {
34
+ this.stack[this.stack.length - 1] = true
35
+ }
36
+
37
+ check() {
38
+ return this.stack.pop()
39
+ }
40
+ }
24
41
 
25
42
  export class global {
26
43
  public static filePath: string = "./plugins/input/main.ets"
27
44
 
28
45
  public static arktsconfig?: ArkTsConfig
46
+ public static configObj?: Config;
29
47
 
30
48
  private static _config?: KNativePointer
31
49
  public static set config(config: KNativePointer) {
32
50
  global._config = config
51
+ global.configObj = new Config(global._config);
33
52
  }
34
53
  public static get config(): KNativePointer {
35
54
  return global._config ?? throwError('Global.config not initialized')
@@ -39,6 +58,7 @@ export class global {
39
58
  }
40
59
  public static resetConfig(): void {
41
60
  global._config = undefined
61
+ global.configObj = undefined;
42
62
  }
43
63
 
44
64
  // Improve: rename to contextPeer
@@ -47,7 +67,7 @@ export class global {
47
67
  }
48
68
 
49
69
  // Improve: rename to context when the pointer valued one is eliminated
50
- public static compilerContext: Context
70
+ public static compilerContext: Context | undefined
51
71
  public static isContextGenerateAbcForExternalSourceFiles: boolean = false
52
72
 
53
73
  private static _es2panda: Es2pandaNativeModule | undefined = undefined
@@ -77,4 +97,11 @@ export class global {
77
97
 
78
98
  // Check node type values during node creation
79
99
  public static validatePeerTypes = false
100
+
101
+ public static clearContext(): void {
102
+ global.compilerContext = undefined
103
+ }
104
+
105
+ // Keep track of update info to optimize performance
106
+ public static updateTracker: UpdateTracker = new UpdateTracker()
80
107
  }
@@ -13,17 +13,24 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
- import { KNativePointer } from "@koalaui/interop"
16
+ import { KInt, KNativePointer, KUInt } from "@koalaui/interop"
17
17
  import type {
18
+ ClassDefinition,
19
+ ETSFunctionType,
18
20
  ETSModule,
21
+ ETSParameterExpression,
22
+ Expression,
19
23
  MethodDefinition,
24
+ NumberLiteral,
20
25
  Program,
21
26
  ScriptFunction,
27
+ SourcePosition,
22
28
  } from "../../generated"
23
29
  import { ExternalSource } from "../peers/ExternalSource"
24
- import { Es2pandaModuleFlag } from "../../generated/Es2pandaEnums"
30
+ import { Es2pandaAstNodeType, Es2pandaModuleFlag } from "../../generated/Es2pandaEnums"
25
31
  import { global } from "../static/global"
26
- import { acceptNativeObjectArrayResult } from "./private"
32
+ import { acceptNativeObjectArrayResult, passNodeArray, unpackNodeArray, unpackNonNullableNode } from "./private"
33
+ import type { AstNode } from "../peers/AstNode"
27
34
 
28
35
  export function extension_ETSModuleGetNamespaceFlag(this: ETSModule): Es2pandaModuleFlag {
29
36
  return (this.isETSScript ? Es2pandaModuleFlag.MODULE_FLAG_ETSSCRIPT : 0)
@@ -43,10 +50,7 @@ export function extension_MethodDefinitionSetChildrenParentPtr(this: MethodDefin
43
50
 
44
51
  export function extension_MethodDefinitionOnUpdate(this: MethodDefinition, original: MethodDefinition): void {
45
52
  this.setChildrenParentPtr()
46
- // Improve: Update modifiers only for specific AST nodes in the generated factory code
47
- this.modifierFlags = original.modifierFlags
48
- global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, original.originalPeer)
49
- global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
53
+ global.es2panda._AstNodeOnUpdate(global.context, this.peer, original.peer)
50
54
  const originalBase = original.baseOverloadMethod
51
55
  if (originalBase) {
52
56
  this.setBaseOverloadMethod(originalBase)
@@ -62,6 +66,11 @@ export function extension_ScriptFunctionSetSignaturePointer(this: ScriptFunction
62
66
  global.es2panda._Checker_ScriptFunctionSetSignature(global.context, this.peer, signaturePointer)
63
67
  }
64
68
 
69
+ // Improve: weird API
70
+ export function extension_ScriptFunctionGetParamsCasted(this: ScriptFunction): readonly ETSParameterExpression[] {
71
+ return unpackNodeArray<ETSParameterExpression>(global.generatedEs2panda._ScriptFunctionParams(global.context, this.peer), Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION)
72
+ }
73
+
65
74
  // Improve: perhaps "preferredReturnType" stuff can be removed later if "signature" is always enough
66
75
  export function extension_ScriptFunctionGetPreferredReturnTypePointer(this: ScriptFunction): KNativePointer {
67
76
  return global.es2panda._Checker_ScriptFunctionGetPreferredReturnType(global.context, this.peer)
@@ -71,6 +80,20 @@ export function extension_ScriptFunctionSetPreferredReturnTypePointer(this: Scri
71
80
  global.es2panda._Checker_ScriptFunctionSetPreferredReturnType(global.context, this.peer, typePointer)
72
81
  }
73
82
 
83
+ // Improve: generate checker related stuff
84
+ export function extension_ExpressionGetPreferredTypePointer(this: Expression): KNativePointer {
85
+ return global.es2panda._Checker_ExpressionGetPreferredType(global.context, this.peer)
86
+ }
87
+
88
+ export function extension_ExpressionSetPreferredTypePointer(this: Expression, typePointer: KNativePointer): void {
89
+ global.es2panda._Checker_ExpressionSetPreferredType(global.context, this.peer, typePointer)
90
+ }
91
+
92
+ // Improve: weird API
93
+ export function extension_ProgramGetAstCasted(this: Program): ETSModule {
94
+ return unpackNonNullableNode<ETSModule>(global.generatedEs2panda._ProgramAst(global.context, this.peer), Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE)
95
+ }
96
+
74
97
  // Improve: generate methods with string[] args or return type
75
98
  export function extension_ProgramGetExternalSources(this: Program): ExternalSource[] {
76
99
  return acceptNativeObjectArrayResult<ExternalSource>(
@@ -78,3 +101,37 @@ export function extension_ProgramGetExternalSources(this: Program): ExternalSour
78
101
  ExternalSource.instantiate,
79
102
  )
80
103
  }
104
+
105
+ // Improve: SourcePositionLine is global in idl
106
+ export function extension_SourcePositionGetLine(this: SourcePosition): KUInt {
107
+ return global.generatedEs2panda._SourcePositionLine(global.context, this.peer)
108
+ }
109
+
110
+ // Improve: SourcePositionCol is not described in idl
111
+ export function extension_SourcePositionGetCol(this: SourcePosition): KUInt {
112
+ return global.es2panda._SourcePositionCol(global.context, this.peer)
113
+ }
114
+
115
+ // Improve: SourcePositionIndex is global in idl
116
+ export function extension_SourcePositionGetIndex(this: SourcePosition): KUInt {
117
+ return global.generatedEs2panda._SourcePositionIndex(global.context, this.peer)
118
+ }
119
+
120
+ export function extension_SourcePositionToString(this: SourcePosition): string {
121
+ return `:${this.getLine() + 1}:${this.getCol()}`
122
+ }
123
+
124
+ // Improve: weird API
125
+ export function extension_NumberLiteralValue(this: NumberLiteral): number {
126
+ return +this.dumpSrc()
127
+ }
128
+
129
+ // Improve: weird API
130
+ export function extension_ClassDefinitionSetBody(this: ClassDefinition, body: readonly AstNode[]): void {
131
+ global.es2panda._ClassDefinitionSetBody(global.context, this.peer, passNodeArray(body), body.length)
132
+ }
133
+
134
+ // Improve: weird API
135
+ export function extension_ETSFunctionTypeGetParamsCasted(this: ETSFunctionType): readonly ETSParameterExpression[] {
136
+ return unpackNodeArray<ETSParameterExpression>(global.generatedEs2panda._ETSFunctionTypeParamsConst(global.context, this.peer), Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION)
137
+ }
@@ -13,6 +13,22 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
+ import * as process from 'process';
17
+ import { global as localGlobal} from '../static/global';
18
+
19
+ const BYTES_PER_KIBIBYTE = 1024;
20
+
21
+ interface MemoryContext {
22
+ startTime: number;
23
+ startMemory: {
24
+ rss: number;
25
+ heapTotal: number;
26
+ heapUsed: number;
27
+ external: number;
28
+ arrayBuffers: number;
29
+ };
30
+ }
31
+
16
32
  interface Event {
17
33
  name: string,
18
34
  startTime: number,
@@ -46,12 +62,14 @@ export class Performance {
46
62
  private scopes: string[];
47
63
  private shouldSkip: boolean;
48
64
  private totalDuration: number;
49
-
65
+ private memoryContexts = new Map<string, MemoryContext>();
66
+ private memoryTrackerEnable: boolean;
50
67
  private constructor() {
51
68
  this.events = new Map();
52
69
  this.historyEvents = new Map();
53
70
  this.scopes = [];
54
71
  this.shouldSkip = true;
72
+ this.memoryTrackerEnable = false;
55
73
  this.totalDuration = 0;
56
74
  }
57
75
 
@@ -66,6 +84,10 @@ export class Performance {
66
84
  this.shouldSkip = shouldSkip;
67
85
  }
68
86
 
87
+ enableMemoryTracker(enableMemoryTracker: boolean = false): void {
88
+ this.memoryTrackerEnable = enableMemoryTracker;
89
+ }
90
+
69
91
  createEvent(name: string): Event {
70
92
  if (this.shouldSkip) {
71
93
  return { name: '', startTime: 0 };
@@ -175,7 +197,7 @@ export class Performance {
175
197
  result += `${indent}- ${child.name}: ${formatTime(duration)}(${round(duration)}), ${count}\n`;
176
198
  result += _result;
177
199
  });
178
-
200
+
179
201
  return [result, children.length];
180
202
  }
181
203
 
@@ -187,4 +209,101 @@ export class Performance {
187
209
  console.log(`[PERFORMANCE] ===== FINAL RESULT ====`);
188
210
  }
189
211
  }
190
- }
212
+
213
+ startMemRecord(label: string = `measurement-${Date.now()}`): void {
214
+ // 强制进行垃圾回收(需要 Node.js 启动时添加 --expose-gc 参数)
215
+ if (!this.memoryTrackerEnable) {
216
+ return;
217
+ }
218
+ if (global.gc) {
219
+ (global as any).gc();
220
+ }
221
+ const startMemory = process.memoryUsage();
222
+ this.memoryContexts.set(label, {
223
+ startTime: Date.now(),
224
+ startMemory: {
225
+ rss: startMemory.rss / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE),
226
+ heapTotal: startMemory.heapTotal / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE),
227
+ heapUsed: startMemory.heapUsed / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE),
228
+ external: startMemory.external / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE),
229
+ arrayBuffers: (startMemory.arrayBuffers || 0) / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)
230
+ }
231
+ });
232
+
233
+ return;
234
+ }
235
+
236
+ stopMemRecord(label: string = `measurement-${Date.now()}`, runGc: boolean = false): void {
237
+ if (!this.memoryTrackerEnable) {
238
+ return;
239
+ }
240
+ const context = this.memoryContexts.get(label);
241
+
242
+ if (!context) {
243
+ console.error(`未找到标签为 "${label}" 的内存测量上下文`);
244
+ return;
245
+ }
246
+
247
+ // 可选:在测量结束前执行垃圾回收
248
+ if (runGc && global.gc) {
249
+ (global as any).gc();
250
+ }
251
+
252
+ // 记录结束时的内存使用情况
253
+ const endTime = Date.now();
254
+ const endMemory = process.memoryUsage();
255
+
256
+ // 计算内存使用增量
257
+ const memoryDiff = {
258
+ rss: endMemory.rss / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE) - context.startMemory.rss,
259
+ heapTotal: endMemory.heapTotal / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE) - context.startMemory.heapTotal,
260
+ heapUsed: endMemory.heapUsed / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE) - context.startMemory.heapUsed,
261
+ external: endMemory.external / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE) - context.startMemory.external,
262
+ arrayBuffers: ((endMemory.arrayBuffers || 0) / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)) - context.startMemory.arrayBuffers
263
+ };
264
+ const duration = endTime - context.startTime;
265
+
266
+ console.log('[PERFORMANCE]', `内存测量结果 [标签: ${label}]`);
267
+ console.log('[PERFORMANCE]', `执行时间: ${duration}ms`);
268
+ console.log('---------------------------------------------------------------');
269
+ console.log('[PERFORMANCE]', `内存类型 | 开始值(MB) | 结束值(MB) | 增量(MB)`);
270
+ console.log('---------------------------------------------------------------');
271
+ console.log('[PERFORMANCE]', `RSS | ${context.startMemory.rss.toFixed(2)} | ${(endMemory.rss / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)).toFixed(2)} | ${memoryDiff.rss.toFixed(2)}`);
272
+ console.log('[PERFORMANCE]', `Heap Total | ${context.startMemory.heapTotal.toFixed(2)} | ${(endMemory.heapTotal / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)).toFixed(2)} | ${memoryDiff.heapTotal.toFixed(2)}`);
273
+ console.log('[PERFORMANCE]', `Heap Used | ${context.startMemory.heapUsed.toFixed(2)} | ${(endMemory.heapUsed / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)).toFixed(2)} | ${memoryDiff.heapUsed.toFixed(2)}`);
274
+ console.log('[PERFORMANCE]', `External | ${context.startMemory.external.toFixed(2)} | ${(endMemory.external / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)).toFixed(2)} | ${memoryDiff.external.toFixed(2)}`);
275
+ if (endMemory.arrayBuffers !== undefined) {
276
+ console.log(`Array Buffers | ${context.startMemory.arrayBuffers.toFixed(2)} | ${((endMemory.arrayBuffers || 0) / (BYTES_PER_KIBIBYTE * BYTES_PER_KIBIBYTE)).toFixed(2)} | ${memoryDiff.arrayBuffers.toFixed(2)}`);
277
+ }
278
+ console.log('---------------------------------------------------------------');
279
+ this.memoryContexts.delete(label);
280
+ return;
281
+ }
282
+
283
+ memoryTrackerReset(): void {
284
+ if (!this.memoryTrackerEnable) {
285
+ return;
286
+ }
287
+ localGlobal.es2panda._MemoryTrackerReset(localGlobal.context);
288
+ }
289
+
290
+ memoryTrackerGetDelta(tag: string): void {
291
+ if (!this.memoryTrackerEnable) {
292
+ return;
293
+ }
294
+ console.log('---------------------------------------------------------------');
295
+ console.log('[PERFORMANCE] Increamental memory:', tag);
296
+ localGlobal.es2panda._MemoryTrackerGetDelta(localGlobal.context);
297
+ console.log('---------------------------------------------------------------');
298
+ }
299
+
300
+ memoryTrackerPrintCurrent(tag: string): void {
301
+ if (!this.memoryTrackerEnable) {
302
+ return;
303
+ }
304
+ console.log('---------------------------------------------------------------');
305
+ console.log('[PERFORMANCE] Current total memory:', tag);
306
+ localGlobal.es2panda._MemoryTrackerPrintCurrent(localGlobal.context);
307
+ console.log('---------------------------------------------------------------');
308
+ }
309
+ }
@@ -25,7 +25,7 @@ import {
25
25
  } from "@koalaui/interop"
26
26
  import { NativePtrDecoder } from "./nativePtrDecoder"
27
27
  import { Es2pandaAstNodeType, Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums"
28
- import { classByPeer } from "../class-by-peer"
28
+ import { nodeFrom } from "../class-by-peer"
29
29
  import { AstNode } from "../peers/AstNode"
30
30
  import { ArktsObject } from "../peers/ArktsObject"
31
31
 
@@ -68,31 +68,31 @@ export function acceptNativeObjectArrayResult<T extends ArktsObject>(arrayObject
68
68
  return new NativePtrDecoder().decode(arrayObject).map(factory);
69
69
  }
70
70
 
71
- export function unpackNonNullableNode<T extends AstNode>(peer: KNativePointer): T {
71
+ export function unpackNonNullableNode<T extends AstNode>(peer: KNativePointer, typeHint?: Es2pandaAstNodeType): T {
72
72
  if (peer === nullptr) {
73
73
  throwError('peer is NULLPTR (maybe you should use unpackNode)')
74
74
  }
75
- return classByPeer(peer)
75
+ return nodeFrom(peer, typeHint)
76
76
  }
77
77
 
78
- export function unpackNode<T extends AstNode>(peer: KNativePointer): T | undefined {
78
+ export function unpackNode<T extends AstNode>(peer: KNativePointer, typeHint?: Es2pandaAstNodeType): T | undefined {
79
79
  if (peer === nullptr) {
80
80
  return undefined
81
81
  }
82
- return classByPeer<T>(peer)
82
+ return nodeFrom<T>(peer, typeHint)
83
83
  }
84
84
 
85
85
  export function passNode(node: ArktsObject | undefined): KNativePointer {
86
86
  return node?.peer ?? nullptr
87
87
  }
88
88
 
89
- export function unpackNodeArray<T extends AstNode>(nodesPtr: KNativePointer): T[] {
89
+ export function unpackNodeArray<T extends AstNode>(nodesPtr: KNativePointer, typeHint?: Es2pandaAstNodeType): T[] {
90
90
  if (nodesPtr === nullptr) {
91
- throwError('nodesPtr is NULLPTR (maybe you should use unpackNodeArray)')
91
+ return []
92
92
  }
93
93
  return new NativePtrDecoder()
94
94
  .decode(nodesPtr)
95
- .map((peer: KNativePointer) => unpackNonNullableNode(peer))
95
+ .map((peer: KNativePointer) => unpackNonNullableNode(peer, typeHint))
96
96
  }
97
97
 
98
98
  export function passNodeArray(nodes: readonly ArktsObject[] | undefined): BigUint64Array {
@@ -104,20 +104,6 @@ export function passNodeArray(nodes: readonly ArktsObject[] | undefined): BigUin
104
104
  )
105
105
  }
106
106
 
107
- export function unpackNonNullableObject<T extends ArktsObject>(type: { new (peer: KNativePointer): T }, peer: KNativePointer): T {
108
- if (peer === nullptr) {
109
- throwError('peer is NULLPTR (maybe you should use unpackObject)')
110
- }
111
- return new type(peer)
112
- }
113
-
114
- export function unpackObject<T extends ArktsObject>(type: { new (peer: KNativePointer): T }, peer: KNativePointer): T | undefined {
115
- if (peer === nullptr) {
116
- return undefined
117
- }
118
- return new type(peer)
119
- }
120
-
121
107
  export function unpackString(peer: KNativePointer): string {
122
108
  return global.interop._RawUtf8ToString(peer)
123
109
  }