@idlizer/arktscgen 2.1.2 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/build/libarkts-copy/README.md +36 -0
  2. package/build/libarkts-copy/generator/options.json5 +113 -44
  3. package/build/libarkts-copy/native/meson.build +13 -0
  4. package/build/libarkts-copy/native/meson_options.txt +13 -0
  5. package/build/libarkts-copy/native/src/bridges.cc +78 -10
  6. package/build/libarkts-copy/native/src/common.cc +56 -8
  7. package/build/libarkts-copy/native/src/common.h +48 -0
  8. package/build/libarkts-copy/native/src/generated/bridges.cc +825 -325
  9. package/build/libarkts-copy/package.json +67 -49
  10. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +42 -4
  11. package/build/libarkts-copy/src/InteropNativeModule.ts +5 -2
  12. package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +50 -0
  13. package/build/libarkts-copy/src/arkts-api/CheckedBackFilter.ts +53 -0
  14. package/build/libarkts-copy/src/arkts-api/SetBaseOverloads.ts +51 -0
  15. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +8 -6
  16. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +95 -117
  17. package/build/libarkts-copy/src/arkts-api/index.ts +6 -1
  18. package/build/libarkts-copy/src/arkts-api/node-cache.ts +35 -0
  19. package/build/libarkts-copy/src/arkts-api/node-utilities/ArrayExpression.ts +42 -0
  20. package/build/libarkts-copy/src/arkts-api/node-utilities/ArrowFunctionExpression.ts +49 -0
  21. package/build/libarkts-copy/src/arkts-api/node-utilities/AssignmentExpression.ts +50 -0
  22. package/build/libarkts-copy/src/arkts-api/node-utilities/{createCallExpression.ts → CallExpression.ts} +27 -4
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +73 -0
  24. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +64 -0
  25. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +65 -0
  26. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +69 -0
  27. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +60 -0
  28. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSStructDeclaration.ts +31 -0
  29. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTuple.ts +31 -0
  30. package/build/libarkts-copy/src/arkts-api/node-utilities/MemberExpression.ts +41 -0
  31. package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +75 -0
  32. package/build/libarkts-copy/src/arkts-api/node-utilities/{createNumberLiteral.ts → NumberLiteral.ts} +15 -0
  33. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +34 -0
  34. package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +99 -0
  35. package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +81 -0
  36. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +68 -0
  37. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameter.ts +39 -0
  38. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeReferencePart.ts +36 -0
  39. package/build/libarkts-copy/src/arkts-api/node-utilities/TryStatement.ts +44 -0
  40. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclaration.ts +54 -0
  41. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclarator.ts +37 -0
  42. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +16 -15
  43. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +1 -2
  44. package/build/libarkts-copy/src/arkts-api/peers/ImportPathManager.ts +30 -0
  45. package/build/libarkts-copy/src/arkts-api/peers/Program.ts +7 -5
  46. package/build/libarkts-copy/src/arkts-api/peers/SourcePosition.ts +38 -0
  47. package/build/libarkts-copy/src/arkts-api/plugins.ts +48 -0
  48. package/build/libarkts-copy/src/arkts-api/static/global.ts +8 -2
  49. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +40 -0
  50. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +18 -14
  51. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +76 -12
  52. package/build/libarkts-copy/src/arkts-api/visitor.ts +324 -42
  53. package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +504 -458
  54. package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +225 -75
  55. package/build/libarkts-copy/src/generated/factory.ts +21 -43
  56. package/build/libarkts-copy/src/generated/index.ts +24 -3
  57. package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +1 -2
  58. package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +1 -2
  59. package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +1 -2
  60. package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +7 -7
  61. package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +12 -12
  62. package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +10 -5
  63. package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +7 -7
  64. package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +5 -5
  65. package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +13 -7
  66. package/build/libarkts-copy/src/generated/peers/AstDumper.ts +1 -2
  67. package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +35 -0
  68. package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +35 -0
  69. package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +4 -4
  70. package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +4 -4
  71. package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +14 -7
  72. package/build/libarkts-copy/src/generated/peers/BindingProps.ts +35 -0
  73. package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +5 -5
  74. package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +15 -5
  75. package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +4 -4
  76. package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +8 -5
  77. package/build/libarkts-copy/src/generated/peers/CallExpression.ts +8 -8
  78. package/build/libarkts-copy/src/generated/peers/CatchClause.ts +6 -6
  79. package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +12 -5
  80. package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +4 -4
  81. package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +5 -5
  82. package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +30 -15
  83. package/build/libarkts-copy/src/generated/peers/ClassElement.ts +7 -8
  84. package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +4 -4
  85. package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +21 -5
  86. package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +5 -5
  87. package/build/libarkts-copy/src/generated/peers/CodeGen.ts +35 -0
  88. package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +7 -7
  89. package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +8 -5
  90. package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +4 -4
  91. package/build/libarkts-copy/src/generated/peers/Declaration.ts +35 -0
  92. package/build/libarkts-copy/src/generated/peers/Decorator.ts +4 -4
  93. package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +4 -4
  94. package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +6 -6
  95. package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +35 -0
  96. package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +4 -4
  97. package/build/libarkts-copy/src/generated/peers/ETSDynamicFunctionType.ts +1 -2
  98. package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +15 -15
  99. package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +26 -17
  100. package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +53 -0
  101. package/build/libarkts-copy/src/generated/peers/ETSModule.ts +6 -6
  102. package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +11 -6
  103. package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +5 -5
  104. package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +11 -6
  105. package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +6 -6
  106. package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +4 -4
  107. package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +10 -10
  108. package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +4 -4
  109. package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +5 -5
  110. package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +50 -0
  111. package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +4 -4
  112. package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +5 -5
  113. package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +5 -5
  114. package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +8 -8
  115. package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +6 -6
  116. package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +7 -7
  117. package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +5 -5
  118. package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +4 -4
  119. package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +35 -0
  120. package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +4 -4
  121. package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +5 -5
  122. package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +4 -4
  123. package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +4 -4
  124. package/build/libarkts-copy/src/generated/peers/Expression.ts +4 -5
  125. package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +6 -6
  126. package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +7 -7
  127. package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +7 -7
  128. package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +7 -7
  129. package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +1 -2
  130. package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +8 -8
  131. package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +5 -5
  132. package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +6 -7
  133. package/build/libarkts-copy/src/generated/peers/IRNode.ts +35 -0
  134. package/build/libarkts-copy/src/generated/peers/Identifier.ts +5 -5
  135. package/build/libarkts-copy/src/generated/peers/IfStatement.ts +9 -9
  136. package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +10 -10
  137. package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +5 -5
  138. package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +5 -5
  139. package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +5 -5
  140. package/build/libarkts-copy/src/generated/peers/ImportSource.ts +1 -15
  141. package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +14 -6
  142. package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +35 -0
  143. package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +1 -2
  144. package/build/libarkts-copy/src/generated/peers/LabelPair.ts +35 -0
  145. package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +6 -6
  146. package/build/libarkts-copy/src/generated/peers/Literal.ts +1 -2
  147. package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +1 -2
  148. package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +1 -2
  149. package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +24 -8
  150. package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +4 -4
  151. package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +25 -8
  152. package/build/libarkts-copy/src/generated/peers/NamedType.ts +4 -4
  153. package/build/libarkts-copy/src/generated/peers/NewExpression.ts +4 -4
  154. package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +4 -4
  155. package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +19 -4
  156. package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +35 -0
  157. package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +4 -4
  158. package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +4 -4
  159. package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +4 -4
  160. package/build/libarkts-copy/src/generated/peers/OverloadInfo.ts +35 -0
  161. package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +4 -4
  162. package/build/libarkts-copy/src/generated/peers/Property.ts +6 -6
  163. package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +4 -4
  164. package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +8 -5
  165. package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +35 -0
  166. package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +16 -11
  167. package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +35 -0
  168. package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +5 -5
  169. package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +35 -0
  170. package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +35 -0
  171. package/build/libarkts-copy/src/generated/peers/SourceRange.ts +35 -0
  172. package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +5 -5
  173. package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +1 -2
  174. package/build/libarkts-copy/src/generated/peers/Statement.ts +1 -2
  175. package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +4 -4
  176. package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +4 -4
  177. package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +5 -5
  178. package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +6 -6
  179. package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +4 -4
  180. package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +4 -4
  181. package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +5 -5
  182. package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +4 -4
  183. package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +4 -4
  184. package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +5 -5
  185. package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +4 -4
  186. package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +6 -6
  187. package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +5 -5
  188. package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +6 -6
  189. package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +4 -4
  190. package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +6 -6
  191. package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +4 -4
  192. package/build/libarkts-copy/src/generated/peers/TSImportType.ts +4 -4
  193. package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +4 -4
  194. package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +4 -4
  195. package/build/libarkts-copy/src/generated/peers/TSInferType.ts +4 -4
  196. package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +5 -5
  197. package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +10 -10
  198. package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +5 -5
  199. package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +4 -4
  200. package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +4 -4
  201. package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +4 -4
  202. package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +7 -7
  203. package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +4 -4
  204. package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +4 -4
  205. package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +5 -5
  206. package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +4 -4
  207. package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +5 -5
  208. package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +4 -4
  209. package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +4 -4
  210. package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +4 -4
  211. package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +4 -4
  212. package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +4 -4
  213. package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +5 -5
  214. package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +7 -7
  215. package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +6 -6
  216. package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +4 -4
  217. package/build/libarkts-copy/src/generated/peers/TSThisType.ts +4 -4
  218. package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +4 -4
  219. package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +8 -8
  220. package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +4 -4
  221. package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +4 -4
  222. package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +4 -4
  223. package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +7 -7
  224. package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +4 -4
  225. package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +4 -4
  226. package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +4 -4
  227. package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +4 -4
  228. package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +4 -4
  229. package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +4 -4
  230. package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +4 -4
  231. package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +4 -4
  232. package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +4 -4
  233. package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +4 -4
  234. package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +4 -4
  235. package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +4 -4
  236. package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +4 -4
  237. package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +4 -4
  238. package/build/libarkts-copy/src/generated/peers/TryStatement.ts +10 -6
  239. package/build/libarkts-copy/src/generated/peers/TypeNode.ts +2 -3
  240. package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +1 -2
  241. package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +1 -2
  242. package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +4 -4
  243. package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +5 -5
  244. package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +4 -4
  245. package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +5 -5
  246. package/build/libarkts-copy/src/generated/peers/VReg.ts +35 -0
  247. package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +4 -4
  248. package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +5 -5
  249. package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +7 -7
  250. package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +35 -0
  251. package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +35 -0
  252. package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +6 -6
  253. package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +4 -4
  254. package/build/libarkts-copy/src/index.ts +35 -0
  255. package/build/libarkts-copy/src/reexport-for-generated.ts +1 -1
  256. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +15 -0
  257. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +15 -0
  258. package/build/libarkts-copy/src/ts-api/types.ts +15 -0
  259. package/build/libarkts-copy/src/utils.ts +301 -9
  260. package/build/libarkts-copy/tsconfig.json +5 -4
  261. package/lib/index.js +2861 -1209
  262. package/package.json +6 -6
  263. package/templates/factory.ts +0 -1
  264. package/templates/peer.ts +0 -1
  265. package/build/libarkts-copy/src/Es2pandaEnums.ts +0 -183
  266. package/build/libarkts-copy/src/arkts-api/node-utilities/createScriptFunction.ts +0 -55
  267. package/build/libarkts-copy/src/es2panda.ts +0 -277
  268. package/build/libarkts-copy/src/generated/node-map.ts +0 -182
  269. package/build/libarkts-copy/src/generated/peers/ETSLaunchExpression.ts +0 -57
@@ -13,16 +13,16 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
- import { isNullPtr, KInt, KNativePointer as KPtr, KNativePointer, nullptr } from "@koalaui/interop"
16
+ import { isNullPtr, KInt, KNativePointer, nullptr } from "@koalaui/interop"
17
17
  import { global } from "../static/global"
18
- import { allFlags, nodeType, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private"
18
+ import { allFlags, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private"
19
19
  import { throwError } from "../../utils"
20
20
  import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
21
21
  import { ArktsObject } from "./ArktsObject"
22
- import { Es2pandaAstNodeType } from "../../Es2pandaEnums"
23
22
 
24
23
  export abstract class AstNode extends ArktsObject {
25
24
  protected constructor(peer: KNativePointer) {
25
+ global.profiler.createdNodes ++
26
26
  if (isNullPtr(peer)) {
27
27
  throwError(`attempted to create AstNode from nullptr`)
28
28
  }
@@ -31,7 +31,12 @@ export abstract class AstNode extends ArktsObject {
31
31
  }
32
32
 
33
33
  public get originalPeer(): KNativePointer {
34
- return global.generatedEs2panda._AstNodeOriginalNodeConst(global.context, this.peer)
34
+ const result = global.generatedEs2panda._AstNodeOriginalNodeConst(global.context, this.peer)
35
+ if (result === nullptr) {
36
+ this.originalPeer = this.peer
37
+ return this.peer
38
+ }
39
+ return result
35
40
  }
36
41
 
37
42
  public set originalPeer(peer: KNativePointer) {
@@ -69,7 +74,7 @@ export abstract class AstNode extends ArktsObject {
69
74
  .map((it) => it.dump(indentation + 1))
70
75
  const msg =
71
76
  `${indentation}_`
72
- + ` <mods: ${this.modifiers}>`
77
+ + ` <mods: ${this.modifierFlags}>`
73
78
  + this.dumpMessage()
74
79
  return "> " + " ".repeat(4 * indentation) + msg + "\n" + children.join("")
75
80
  }
@@ -90,6 +95,10 @@ export abstract class AstNode extends ArktsObject {
90
95
  return unpackString(global.es2panda._AstNodeDumpModifiers(global.context, this.peer))
91
96
  }
92
97
 
98
+ public clone(): this {
99
+ return unpackNonNullableNode(global.generatedEs2panda._AstNodeClone(global.context, this.peer, this.parent.peer));
100
+ }
101
+
93
102
  public get parent(): AstNode {
94
103
  const parent = global.generatedEs2panda._AstNodeParent(global.context, this.peer)
95
104
  if (parent === nullptr) {
@@ -102,20 +111,12 @@ export abstract class AstNode extends ArktsObject {
102
111
  global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, node.peer)
103
112
  }
104
113
 
105
- public get modifiers(): KInt {
114
+ public get modifierFlags(): Es2pandaModifierFlags {
106
115
  return global.generatedEs2panda._AstNodeModifiers(global.context, this.peer)
107
116
  }
108
117
 
109
- public set modifiers(flags: KInt | undefined) {
118
+ public set modifierFlags(flags: KInt | undefined) {
110
119
  global.generatedEs2panda._AstNodeClearModifier(global.context, this.peer, allFlags)
111
120
  global.generatedEs2panda._AstNodeAddModifier(global.context, this.peer, flags ?? Es2pandaModifierFlags.MODIFIER_FLAGS_NONE)
112
121
  }
113
122
  }
114
-
115
-
116
- export class UnsupportedNode extends AstNode {
117
- constructor(peer: KPtr) {
118
- super(peer)
119
- console.warn(`Warning: unsupported node ${Es2pandaAstNodeType[nodeType(this)]}`)
120
- }
121
- }
@@ -16,7 +16,6 @@
16
16
  import { ArktsObject } from "./ArktsObject"
17
17
  import { Program } from "./Program"
18
18
  import { global } from "../static/global"
19
- import { throwError } from "../../utils"
20
19
  import { passString } from "../utilities/private"
21
20
  import { KNativePointer } from "@koalaui/interop"
22
21
 
@@ -29,7 +28,7 @@ export class Context extends ArktsObject {
29
28
  source: string
30
29
  ): Context {
31
30
  if (!global.configIsInitialized()) {
32
- throwError(`Config not initialized`)
31
+ throw new Error(`Config not initialized`)
33
32
  }
34
33
  return new Context(
35
34
  global.es2panda._CreateContextFromString(
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import { ArktsObject } from "./ArktsObject"
17
+ import { global } from "../static/global"
18
+ import { KNativePointer } from "@koalaui/interop"
19
+
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
+ }
@@ -16,7 +16,7 @@
16
16
  import { ArktsObject } from "./ArktsObject"
17
17
  import { global } from "../static/global"
18
18
  import { acceptNativeObjectArrayResult, unpackString } from "../utilities/private"
19
- import { KNativePointer } from "@koalaui/interop"
19
+ import { KNativePointer, nullptr } from "@koalaui/interop"
20
20
  import { ETSModule } from "../../generated"
21
21
 
22
22
  export class Program extends ArktsObject {
@@ -25,14 +25,16 @@ export class Program extends ArktsObject {
25
25
  }
26
26
 
27
27
  get astNode(): ETSModule {
28
- return new ETSModule(global.es2panda._ProgramAst(global.context, this.peer));
28
+ let program = global.es2panda._ProgramAst(global.context, this.peer)
29
+ if (program == nullptr) throw new Error(`astNode() cannt get AST`)
30
+ return new ETSModule(program)
29
31
  }
30
32
 
31
33
  get externalSources(): ExternalSource[] {
32
34
  return acceptNativeObjectArrayResult<ExternalSource>(
33
35
  global.es2panda._ProgramExternalSources(global.context, this.peer),
34
36
  (instance: KNativePointer) => new ExternalSource(instance)
35
- );
37
+ )
36
38
  }
37
39
 
38
40
  }
@@ -43,13 +45,13 @@ export class ExternalSource extends ArktsObject {
43
45
  }
44
46
 
45
47
  getName(): string {
46
- return unpackString(global.es2panda._ExternalSourceName(this.peer));
48
+ return unpackString(global.es2panda._ExternalSourceName(this.peer))
47
49
  }
48
50
 
49
51
  get programs(): Program[] {
50
52
  return acceptNativeObjectArrayResult<Program>(
51
53
  global.es2panda._ExternalSourcePrograms(this.peer),
52
54
  (instance: KNativePointer) => new Program(instance)
53
- );
55
+ )
54
56
  }
55
57
  }
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import { ArktsObject } from "./ArktsObject"
17
+ import { global } from "../static/global"
18
+ import { KNativePointer } from "@koalaui/interop"
19
+
20
+ export class SourcePosition extends ArktsObject {
21
+ constructor(peer: KNativePointer) {
22
+ super(peer)
23
+ }
24
+
25
+ static create(index: number, line: number): SourcePosition {
26
+ return new SourcePosition(
27
+ global.es2panda._CreateSourcePosition(global.context, index, line)
28
+ );
29
+ }
30
+
31
+ index(): number {
32
+ return global.es2panda._SourcePositionIndex(global.context, this.peer);
33
+ }
34
+
35
+ line(): number {
36
+ return global.es2panda._SourcePositionLine(global.context, this.peer);
37
+ }
38
+ }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import { Es2pandaContextState } from "../generated/Es2pandaEnums"
17
+ import { ExternalSource, Program } from "./peers/Program"
18
+
19
+ export interface CompilationOptions {
20
+ readonly isMainProgram: boolean,
21
+ readonly name: string,
22
+ readonly stage: Es2pandaContextState,
23
+ }
24
+
25
+ export type ProgramTransformer = (program: Program, compilationOptions: CompilationOptions) => void
26
+
27
+ export function defaultFilter(name: string) {
28
+ if (name.startsWith("std.")) return false
29
+ if (name.startsWith("escompat")) return false
30
+ return true
31
+ }
32
+
33
+ export interface ProgramWithName {
34
+ program: Program,
35
+ name: string
36
+ }
37
+
38
+ export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter): ProgramWithName[] {
39
+ return [
40
+ { program, name: "" },
41
+ ...program.externalSources.flatMap((it: ExternalSource) => {
42
+ if (filter(it.getName())) {
43
+ return it.programs.map(program => ({ program, name: it.getName() } as ProgramWithName))
44
+ }
45
+ return []
46
+ })
47
+ ]
48
+ }
@@ -14,14 +14,17 @@
14
14
  */
15
15
 
16
16
  import { throwError } from "../../utils"
17
- import { KNativePointer } from "@koalaui/interop"
17
+ import { KNativePointer, nullptr } from "@koalaui/interop"
18
18
  import { initEs2panda, Es2pandaNativeModule, initGeneratedEs2panda } from "../../Es2pandaNativeModule"
19
19
  import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from "../../generated/Es2pandaNativeModule"
20
20
  import { initInterop, InteropNativeModule } from "../../InteropNativeModule"
21
21
  import { Context } from "../peers/Context"
22
+ import { Profiler } from "./profiler"
23
+ import { Program } from "../peers/Program"
22
24
 
23
25
  export class global {
24
26
  public static filePath: string = "./plugins/input/main.ets"
27
+ public static packageName: string = ""
25
28
  public static filePathFromPackageRoot: string = global.filePath
26
29
 
27
30
  private static _config?: KNativePointer
@@ -32,7 +35,7 @@ export class global {
32
35
  return global._config ?? throwError('Global.config not initialized')
33
36
  }
34
37
  public static configIsInitialized(): boolean {
35
- return global._config !== undefined
38
+ return global._config !== undefined && global._config !== nullptr
36
39
  }
37
40
 
38
41
  // TODO: rename to contextPeer
@@ -63,5 +66,8 @@ export class global {
63
66
  public static get interop(): InteropNativeModule {
64
67
  if (this._interop === undefined) this._interop = initInterop()
65
68
  return this._interop
69
+
66
70
  }
71
+
72
+ public static profiler = new Profiler()
67
73
  }
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ export class Profiler {
17
+ totalTime = 0
18
+ transformTime = 0
19
+ proceedTime = 0
20
+ restartTime = 0
21
+ visitedNodes = 0
22
+ createdNodes = 0
23
+
24
+ report() {
25
+ console.log(
26
+ "total compiler:",
27
+ this.totalTime,
28
+ " proceeds:",
29
+ this.proceedTime,
30
+ " restarts",
31
+ this.restartTime,
32
+ " transforms:",
33
+ this.transformTime,
34
+ " visited:",
35
+ this.visitedNodes,
36
+ " created:",
37
+ this.createdNodes
38
+ )
39
+ }
40
+ }
@@ -21,15 +21,13 @@ import {
21
21
  KNativePointer,
22
22
  nullptr,
23
23
  withString,
24
- withStringArray,
25
- withStringResult
24
+ withStringArray
26
25
  } from "@koalaui/interop"
27
26
  import { NativePtrDecoder } from "./nativePtrDecoder"
28
- import { Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums"
27
+ import { Es2pandaAstNodeType, Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums"
29
28
  import { classByPeer } from "../class-by-peer"
30
- import type { AstNode } from "../peers/AstNode"
29
+ import { AstNode } from "../peers/AstNode"
31
30
  import { ArktsObject } from "../peers/ArktsObject"
32
- import { Es2pandaAstNodeType } from "../../Es2pandaEnums"
33
31
 
34
32
  export const arrayOfNullptr = new BigUint64Array([nullptr])
35
33
 
@@ -39,7 +37,6 @@ export const allFlags =
39
37
  .reduce(
40
38
  (prev, next) => prev | next,
41
39
  0
42
-
43
40
  )
44
41
 
45
42
  export function assertValidPeer(peer: KPtr, expectedKind: Es2pandaAstNodeType): void {
@@ -72,21 +69,20 @@ export function unpackNonNullableNode<T extends AstNode>(peer: KNativePointer):
72
69
  if (peer === nullptr) {
73
70
  throwError('peer is NULLPTR (maybe you should use unpackNode)')
74
71
  }
75
- return classByPeer(peer) as T
72
+ return classByPeer(peer)
76
73
  }
77
74
 
78
75
  export function unpackNode<T extends AstNode>(peer: KNativePointer): T | undefined {
79
76
  if (peer === nullptr) {
80
77
  return undefined
81
78
  }
82
- return classByPeer(peer) as T
79
+ return classByPeer<T>(peer)
83
80
  }
84
81
 
85
82
  export function passNode(node: ArktsObject | undefined): KNativePointer {
86
83
  return node?.peer ?? nullptr
87
84
  }
88
85
 
89
- // meaning unpackNonNullableNodeArray
90
86
  export function unpackNodeArray<T extends AstNode>(nodesPtr: KNativePointer): T[] {
91
87
  if (nodesPtr === nullptr) {
92
88
  throwError('nodesPtr is NULLPTR (maybe you should use unpackNodeArray)')
@@ -96,9 +92,12 @@ export function unpackNodeArray<T extends AstNode>(nodesPtr: KNativePointer): T[
96
92
  .map((peer: KNativePointer) => unpackNonNullableNode(peer))
97
93
  }
98
94
 
99
- export function passNodeArray(nodes: readonly AstNode[] | undefined): BigUint64Array {
95
+ export function passNodeArray(nodes: readonly ArktsObject[] | undefined): BigUint64Array {
100
96
  return new BigUint64Array(
101
- nodes?.map(node => BigInt(node.peer)) ?? []
97
+ nodes
98
+ ?.filter(it => it.peer != undefined)
99
+ ?.map(node => BigInt(node.peer))
100
+ ?? []
102
101
  )
103
102
  }
104
103
 
@@ -117,9 +116,10 @@ export function unpackObject<T extends ArktsObject>(type: { new (peer: KNativePo
117
116
  }
118
117
 
119
118
  export function unpackString(peer: KNativePointer): string {
120
- return withStringResult(peer) ?? throwError(`failed to unpack (peer shouldn't be NULLPTR)`)
119
+ return global.interop._RawUtf8ToString(peer)
121
120
  }
122
121
 
122
+ // TODO: use direct string arguments instead.
123
123
  export function passString(str: string | undefined): string {
124
124
  if (str === undefined) {
125
125
  return ""
@@ -127,12 +127,14 @@ export function passString(str: string | undefined): string {
127
127
  return withString(str, (it: string) => it)
128
128
  }
129
129
 
130
+
131
+ // TODO: use direct string arguments instead.
130
132
  export function passStringArray(strings: readonly string[]): string[] {
131
133
  return withStringArray(strings, (it: string[]) => it)
132
134
  }
133
135
 
134
136
  export function passNodeWithNewModifiers<T extends AstNode>(node: T, modifiers: KInt): T {
135
- return (unpackNonNullableNode(node.peer) as T).updateModifiers(modifiers)
137
+ return unpackNonNullableNode<T>(node.peer).updateModifiers(modifiers)
136
138
  }
137
139
 
138
140
  export function scriptFunctionHasBody(peer: KNativePointer): boolean {
@@ -145,7 +147,9 @@ export function updateNodeByNode<T extends ArktsObject>(node: T, original: T): T
145
147
  if (original.peer === nullptr) {
146
148
  throwError('update called on NULLPTR')
147
149
  }
148
- global.generatedEs2panda._AstNodeSetOriginalNode(global.context, node.peer, original.peer)
150
+ if (original instanceof AstNode) {
151
+ global.generatedEs2panda._AstNodeSetOriginalNode(global.context, node.peer, original.originalPeer)
152
+ }
149
153
  global.generatedEs2panda._AstNodeSetParent(global.context, node.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
150
154
  global.es2panda._AstNodeUpdateChildren(global.context, node.peer)
151
155
  return node
@@ -15,24 +15,33 @@
15
15
 
16
16
  import { global } from "../static/global"
17
17
  import { isNumber, throwError } from "../../utils"
18
- import { nullptr, withStringResult } from "@koalaui/interop"
18
+ import { KNativePointer, nullptr } from "@koalaui/interop"
19
19
  import { passNode, passNodeArray, unpackNodeArray, unpackNonNullableNode } from "./private"
20
20
  import { Es2pandaContextState, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
21
21
  import type { AstNode } from "../peers/AstNode"
22
22
  import {
23
23
  type AnnotationUsage,
24
24
  ClassDefinition,
25
+ ClassProperty,
26
+ ETSImportDeclaration,
25
27
  ETSModule,
26
28
  isClassDefinition,
29
+ isFunctionDeclaration,
27
30
  isMemberExpression,
28
31
  isScriptFunction,
29
- isFunctionDeclaration
32
+ isIdentifier,
33
+ isETSModule
30
34
  } from "../../generated"
31
35
  import { Config } from "../peers/Config"
32
36
  import { Context } from "../peers/Context"
37
+ import { NodeCache } from "../node-cache"
33
38
 
34
- export function createETSModulefromContext(): ETSModule {
35
- return new ETSModule(global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context)))
39
+ export function createETSModuleFromContext(): ETSModule {
40
+ let program = global.es2panda._ContextProgram(global.context)
41
+ if (program == nullptr) {
42
+ throw new Error(`Program is null for context ${global.context.toString(16)}`)
43
+ }
44
+ return new ETSModule(global.es2panda._ProgramAst(global.context, program))
36
45
  }
37
46
 
38
47
  export function createETSModuleFromSource(
@@ -44,7 +53,10 @@ export function createETSModuleFromSource(
44
53
  }
45
54
  global.compilerContext = Context.createFromString(source)
46
55
  proceedToState(state)
47
- return new ETSModule(global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context)))
56
+ let program = global.es2panda._ContextProgram(global.compilerContext.peer)
57
+ if (program == nullptr)
58
+ throw new Error(`Program is null for ${source} 0x${global.compilerContext.peer.toString(16)}`)
59
+ return new ETSModule(global.es2panda._ProgramAst(global.context, program))
48
60
  }
49
61
 
50
62
  export function updateETSModuleByStatements(
@@ -55,11 +67,7 @@ export function updateETSModuleByStatements(
55
67
  return node
56
68
  }
57
69
 
58
- export function proceedToState(state: Es2pandaContextState): void {
59
- if (state <= global.es2panda._ContextState(global.context)) {
60
- return
61
- }
62
- global.es2panda._ProceedToState(global.context, state)
70
+ export function checkErrors() {
63
71
  if (global.es2panda._ContextState(global.context) === Es2pandaContextState.ES2PANDA_STATE_ERROR) {
64
72
  console.log()
65
73
  global.es2panda._DestroyConfig(global.config)
@@ -68,23 +76,41 @@ export function proceedToState(state: Es2pandaContextState): void {
68
76
  }
69
77
  }
70
78
 
79
+ export function proceedToState(state: Es2pandaContextState): void {
80
+ if (state <= global.es2panda._ContextState(global.context)) {
81
+ return
82
+ }
83
+ const before = Date.now()
84
+ global.es2panda._ProceedToState(global.context, state)
85
+ const after = Date.now()
86
+ global.profiler.proceedTime += after-before
87
+ NodeCache.clear()
88
+ checkErrors()
89
+ }
90
+
71
91
  export function startChecker(): boolean {
72
92
  return global.es2panda._CheckerStartChecker(global.context)
73
93
  }
74
94
 
75
95
  export function recheckSubtree(node: AstNode): void {
76
96
  global.es2panda._AstNodeRecheck(global.context, node.peer)
97
+ checkErrors()
77
98
  }
78
99
 
79
100
  export function rebindSubtree(node: AstNode): void {
80
101
  global.es2panda._AstNodeRebind(global.context, node.peer)
102
+ checkErrors()
81
103
  }
82
104
 
83
105
  export function getDecl(node: AstNode): AstNode | undefined {
84
106
  if (isMemberExpression(node)) {
85
- return getDecl(node.property)
107
+ return getDecl(node.property!)
86
108
  }
87
- const decl = global.es2panda._DeclarationFromIdentifier(global.context, passNode(node))
109
+ return getPeerDecl(passNode(node))
110
+ }
111
+
112
+ export function getPeerDecl(peer: KNativePointer): AstNode | undefined {
113
+ const decl = global.es2panda._DeclarationFromIdentifier(global.context, peer)
88
114
  if (decl === nullptr) {
89
115
  return undefined
90
116
  }
@@ -113,6 +139,10 @@ export function getFileName(): string {
113
139
  return global.filePath
114
140
  }
115
141
 
142
+ export function getPackageName(): string {
143
+ return global.packageName
144
+ }
145
+
116
146
  export function getFilePathFromPackageRoot(): string {
117
147
  return global.filePathFromPackageRoot
118
148
  }
@@ -125,6 +155,28 @@ export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFla
125
155
  return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer)
126
156
  }
127
157
 
158
+ // TODO: ClassProperty's optional flag is set by AstNode's modifiers flags.
159
+ export function classPropertySetOptional(node: ClassProperty, value: boolean): ClassProperty {
160
+ if (value) {
161
+ node.modifierFlags |= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL;
162
+ } else {
163
+ node.modifierFlags &= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL;
164
+ }
165
+ return node;
166
+ }
167
+
168
+ export function hasModifierFlag(node: AstNode, flag: Es2pandaModifierFlags): boolean {
169
+ if (!node) return false;
170
+
171
+ let modifiers;
172
+ if (isClassDefinition(node)) {
173
+ modifiers = classDefinitionFlags(node);
174
+ } else {
175
+ modifiers = node.modifierFlags
176
+ }
177
+ return (modifiers & flag) === flag;
178
+ }
179
+
128
180
  export function modifiersToString(modifiers: Es2pandaModifierFlags): string {
129
181
  return Object.values(Es2pandaModifierFlags)
130
182
  .filter(isNumber)
@@ -133,3 +185,15 @@ export function modifiersToString(modifiers: Es2pandaModifierFlags): string {
133
185
  return ((modifiers.valueOf() & it) === it) ? Es2pandaModifierFlags[it] : ""
134
186
  }).join(" ")
135
187
  }
188
+
189
+ export function nameIfIdentifier(node: AstNode): string {
190
+ return isIdentifier(node) ? `'${node.name}'` : ""
191
+ }
192
+
193
+ export function nameIfETSModule(node: AstNode): string {
194
+ return isETSModule(node) ? `'${node.ident?.name}'` : ""
195
+ }
196
+
197
+ export function asString(node: AstNode|undefined): string {
198
+ return `${node?.constructor.name} ${node ? nameIfIdentifier(node) : undefined}`
199
+ }