@idlizer/arktscgen 2.1.2 → 2.1.5

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 (258) 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/src/bridges.cc +70 -2
  4. package/build/libarkts-copy/native/src/generated/bridges.cc +700 -200
  5. package/build/libarkts-copy/package.json +27 -15
  6. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +42 -4
  7. package/build/libarkts-copy/src/InteropNativeModule.ts +2 -1
  8. package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +50 -0
  9. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +8 -6
  10. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +95 -117
  11. package/build/libarkts-copy/src/arkts-api/index.ts +3 -1
  12. package/build/libarkts-copy/src/arkts-api/node-cache.ts +35 -0
  13. package/build/libarkts-copy/src/arkts-api/node-utilities/ArrayExpression.ts +42 -0
  14. package/build/libarkts-copy/src/arkts-api/node-utilities/ArrowFunctionExpression.ts +49 -0
  15. package/build/libarkts-copy/src/arkts-api/node-utilities/AssignmentExpression.ts +50 -0
  16. package/build/libarkts-copy/src/arkts-api/node-utilities/{createCallExpression.ts → CallExpression.ts} +27 -4
  17. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +73 -0
  18. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +41 -0
  19. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +65 -0
  20. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +63 -0
  21. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +60 -0
  22. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSStructDeclaration.ts +31 -0
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTuple.ts +31 -0
  24. package/build/libarkts-copy/src/arkts-api/node-utilities/MemberExpression.ts +41 -0
  25. package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +75 -0
  26. package/build/libarkts-copy/src/arkts-api/node-utilities/{createNumberLiteral.ts → NumberLiteral.ts} +15 -0
  27. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +34 -0
  28. package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +99 -0
  29. package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +61 -0
  30. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +60 -0
  31. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameter.ts +39 -0
  32. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeReferencePart.ts +36 -0
  33. package/build/libarkts-copy/src/arkts-api/node-utilities/TryStatement.ts +44 -0
  34. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclaration.ts +54 -0
  35. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclarator.ts +37 -0
  36. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +15 -14
  37. package/build/libarkts-copy/src/arkts-api/peers/ImportPathManager.ts +30 -0
  38. package/build/libarkts-copy/src/arkts-api/peers/Program.ts +4 -4
  39. package/build/libarkts-copy/src/arkts-api/peers/SourcePosition.ts +38 -0
  40. package/build/libarkts-copy/src/arkts-api/static/global.ts +5 -0
  41. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +25 -0
  42. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +13 -11
  43. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +68 -10
  44. package/build/libarkts-copy/src/arkts-api/visitor.ts +175 -42
  45. package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +504 -458
  46. package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +225 -75
  47. package/build/libarkts-copy/src/generated/factory.ts +21 -43
  48. package/build/libarkts-copy/src/generated/index.ts +24 -3
  49. package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +1 -2
  50. package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +1 -2
  51. package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +1 -2
  52. package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +7 -7
  53. package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +12 -12
  54. package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +10 -5
  55. package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +7 -7
  56. package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +5 -5
  57. package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +13 -7
  58. package/build/libarkts-copy/src/generated/peers/AstDumper.ts +1 -2
  59. package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +35 -0
  60. package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +35 -0
  61. package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +4 -4
  62. package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +4 -4
  63. package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +14 -7
  64. package/build/libarkts-copy/src/generated/peers/BindingProps.ts +35 -0
  65. package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +5 -5
  66. package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +15 -5
  67. package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +4 -4
  68. package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +8 -5
  69. package/build/libarkts-copy/src/generated/peers/CallExpression.ts +8 -8
  70. package/build/libarkts-copy/src/generated/peers/CatchClause.ts +6 -6
  71. package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +12 -5
  72. package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +4 -4
  73. package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +5 -5
  74. package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +30 -15
  75. package/build/libarkts-copy/src/generated/peers/ClassElement.ts +7 -8
  76. package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +4 -4
  77. package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +21 -5
  78. package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +5 -5
  79. package/build/libarkts-copy/src/generated/peers/CodeGen.ts +35 -0
  80. package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +7 -7
  81. package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +8 -5
  82. package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +4 -4
  83. package/build/libarkts-copy/src/generated/peers/Declaration.ts +35 -0
  84. package/build/libarkts-copy/src/generated/peers/Decorator.ts +4 -4
  85. package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +4 -4
  86. package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +6 -6
  87. package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +35 -0
  88. package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +4 -4
  89. package/build/libarkts-copy/src/generated/peers/ETSDynamicFunctionType.ts +1 -2
  90. package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +15 -15
  91. package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +26 -17
  92. package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +53 -0
  93. package/build/libarkts-copy/src/generated/peers/ETSModule.ts +6 -6
  94. package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +11 -6
  95. package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +5 -5
  96. package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +11 -6
  97. package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +6 -6
  98. package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +4 -4
  99. package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +10 -10
  100. package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +4 -4
  101. package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +5 -5
  102. package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +50 -0
  103. package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +4 -4
  104. package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +5 -5
  105. package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +5 -5
  106. package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +8 -8
  107. package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +6 -6
  108. package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +7 -7
  109. package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +5 -5
  110. package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +4 -4
  111. package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +35 -0
  112. package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +4 -4
  113. package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +5 -5
  114. package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +4 -4
  115. package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +4 -4
  116. package/build/libarkts-copy/src/generated/peers/Expression.ts +4 -5
  117. package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +6 -6
  118. package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +7 -7
  119. package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +7 -7
  120. package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +7 -7
  121. package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +1 -2
  122. package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +8 -8
  123. package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +5 -5
  124. package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +6 -7
  125. package/build/libarkts-copy/src/generated/peers/IRNode.ts +35 -0
  126. package/build/libarkts-copy/src/generated/peers/Identifier.ts +5 -5
  127. package/build/libarkts-copy/src/generated/peers/IfStatement.ts +9 -9
  128. package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +10 -10
  129. package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +5 -5
  130. package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +5 -5
  131. package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +5 -5
  132. package/build/libarkts-copy/src/generated/peers/ImportSource.ts +1 -15
  133. package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +14 -6
  134. package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +35 -0
  135. package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +1 -2
  136. package/build/libarkts-copy/src/generated/peers/LabelPair.ts +35 -0
  137. package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +6 -6
  138. package/build/libarkts-copy/src/generated/peers/Literal.ts +1 -2
  139. package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +1 -2
  140. package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +1 -2
  141. package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +24 -8
  142. package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +4 -4
  143. package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +25 -8
  144. package/build/libarkts-copy/src/generated/peers/NamedType.ts +4 -4
  145. package/build/libarkts-copy/src/generated/peers/NewExpression.ts +4 -4
  146. package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +4 -4
  147. package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +19 -4
  148. package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +35 -0
  149. package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +4 -4
  150. package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +4 -4
  151. package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +4 -4
  152. package/build/libarkts-copy/src/generated/peers/OverloadInfo.ts +35 -0
  153. package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +4 -4
  154. package/build/libarkts-copy/src/generated/peers/Property.ts +6 -6
  155. package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +4 -4
  156. package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +8 -5
  157. package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +35 -0
  158. package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +16 -11
  159. package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +35 -0
  160. package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +5 -5
  161. package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +35 -0
  162. package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +35 -0
  163. package/build/libarkts-copy/src/generated/peers/SourceRange.ts +35 -0
  164. package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +5 -5
  165. package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +1 -2
  166. package/build/libarkts-copy/src/generated/peers/Statement.ts +1 -2
  167. package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +4 -4
  168. package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +4 -4
  169. package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +5 -5
  170. package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +6 -6
  171. package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +4 -4
  172. package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +4 -4
  173. package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +5 -5
  174. package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +4 -4
  175. package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +4 -4
  176. package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +5 -5
  177. package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +4 -4
  178. package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +6 -6
  179. package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +5 -5
  180. package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +6 -6
  181. package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +4 -4
  182. package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +6 -6
  183. package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +4 -4
  184. package/build/libarkts-copy/src/generated/peers/TSImportType.ts +4 -4
  185. package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +4 -4
  186. package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +4 -4
  187. package/build/libarkts-copy/src/generated/peers/TSInferType.ts +4 -4
  188. package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +5 -5
  189. package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +10 -10
  190. package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +5 -5
  191. package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +4 -4
  192. package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +4 -4
  193. package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +4 -4
  194. package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +7 -7
  195. package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +4 -4
  196. package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +4 -4
  197. package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +5 -5
  198. package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +4 -4
  199. package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +5 -5
  200. package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +4 -4
  201. package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +4 -4
  202. package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +4 -4
  203. package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +4 -4
  204. package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +4 -4
  205. package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +5 -5
  206. package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +7 -7
  207. package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +6 -6
  208. package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +4 -4
  209. package/build/libarkts-copy/src/generated/peers/TSThisType.ts +4 -4
  210. package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +4 -4
  211. package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +8 -8
  212. package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +4 -4
  213. package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +4 -4
  214. package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +4 -4
  215. package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +7 -7
  216. package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +4 -4
  217. package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +4 -4
  218. package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +4 -4
  219. package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +4 -4
  220. package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +4 -4
  221. package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +4 -4
  222. package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +4 -4
  223. package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +4 -4
  224. package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +4 -4
  225. package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +4 -4
  226. package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +4 -4
  227. package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +4 -4
  228. package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +4 -4
  229. package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +4 -4
  230. package/build/libarkts-copy/src/generated/peers/TryStatement.ts +10 -6
  231. package/build/libarkts-copy/src/generated/peers/TypeNode.ts +2 -3
  232. package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +1 -2
  233. package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +1 -2
  234. package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +4 -4
  235. package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +5 -5
  236. package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +4 -4
  237. package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +5 -5
  238. package/build/libarkts-copy/src/generated/peers/VReg.ts +35 -0
  239. package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +4 -4
  240. package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +5 -5
  241. package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +7 -7
  242. package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +35 -0
  243. package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +35 -0
  244. package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +6 -6
  245. package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +4 -4
  246. package/build/libarkts-copy/src/index.ts +17 -0
  247. package/build/libarkts-copy/src/reexport-for-generated.ts +1 -1
  248. package/build/libarkts-copy/src/utils.ts +307 -9
  249. package/build/libarkts-copy/tsconfig.json +4 -4
  250. package/lib/index.js +1516 -1120
  251. package/package.json +6 -6
  252. package/templates/factory.ts +0 -1
  253. package/templates/peer.ts +0 -1
  254. package/build/libarkts-copy/src/Es2pandaEnums.ts +0 -183
  255. package/build/libarkts-copy/src/arkts-api/node-utilities/createScriptFunction.ts +0 -55
  256. package/build/libarkts-copy/src/es2panda.ts +0 -277
  257. package/build/libarkts-copy/src/generated/node-map.ts +0 -182
  258. package/build/libarkts-copy/src/generated/peers/ETSLaunchExpression.ts +0 -57
@@ -25,11 +25,10 @@ import {
25
25
  withStringResult
26
26
  } from "@koalaui/interop"
27
27
  import { NativePtrDecoder } from "./nativePtrDecoder"
28
- import { Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums"
28
+ import { Es2pandaAstNodeType, Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums"
29
29
  import { classByPeer } from "../class-by-peer"
30
- import type { AstNode } from "../peers/AstNode"
30
+ import { AstNode } from "../peers/AstNode"
31
31
  import { ArktsObject } from "../peers/ArktsObject"
32
- import { Es2pandaAstNodeType } from "../../Es2pandaEnums"
33
32
 
34
33
  export const arrayOfNullptr = new BigUint64Array([nullptr])
35
34
 
@@ -39,7 +38,6 @@ export const allFlags =
39
38
  .reduce(
40
39
  (prev, next) => prev | next,
41
40
  0
42
-
43
41
  )
44
42
 
45
43
  export function assertValidPeer(peer: KPtr, expectedKind: Es2pandaAstNodeType): void {
@@ -72,21 +70,20 @@ export function unpackNonNullableNode<T extends AstNode>(peer: KNativePointer):
72
70
  if (peer === nullptr) {
73
71
  throwError('peer is NULLPTR (maybe you should use unpackNode)')
74
72
  }
75
- return classByPeer(peer) as T
73
+ return classByPeer(peer)
76
74
  }
77
75
 
78
76
  export function unpackNode<T extends AstNode>(peer: KNativePointer): T | undefined {
79
77
  if (peer === nullptr) {
80
78
  return undefined
81
79
  }
82
- return classByPeer(peer) as T
80
+ return classByPeer<T>(peer)
83
81
  }
84
82
 
85
83
  export function passNode(node: ArktsObject | undefined): KNativePointer {
86
84
  return node?.peer ?? nullptr
87
85
  }
88
86
 
89
- // meaning unpackNonNullableNodeArray
90
87
  export function unpackNodeArray<T extends AstNode>(nodesPtr: KNativePointer): T[] {
91
88
  if (nodesPtr === nullptr) {
92
89
  throwError('nodesPtr is NULLPTR (maybe you should use unpackNodeArray)')
@@ -96,9 +93,12 @@ export function unpackNodeArray<T extends AstNode>(nodesPtr: KNativePointer): T[
96
93
  .map((peer: KNativePointer) => unpackNonNullableNode(peer))
97
94
  }
98
95
 
99
- export function passNodeArray(nodes: readonly AstNode[] | undefined): BigUint64Array {
96
+ export function passNodeArray(nodes: readonly ArktsObject[] | undefined): BigUint64Array {
100
97
  return new BigUint64Array(
101
- nodes?.map(node => BigInt(node.peer)) ?? []
98
+ nodes
99
+ ?.filter(it => it.peer != undefined)
100
+ ?.map(node => BigInt(node.peer))
101
+ ?? []
102
102
  )
103
103
  }
104
104
 
@@ -132,7 +132,7 @@ export function passStringArray(strings: readonly string[]): string[] {
132
132
  }
133
133
 
134
134
  export function passNodeWithNewModifiers<T extends AstNode>(node: T, modifiers: KInt): T {
135
- return (unpackNonNullableNode(node.peer) as T).updateModifiers(modifiers)
135
+ return unpackNonNullableNode<T>(node.peer).updateModifiers(modifiers)
136
136
  }
137
137
 
138
138
  export function scriptFunctionHasBody(peer: KNativePointer): boolean {
@@ -145,7 +145,9 @@ export function updateNodeByNode<T extends ArktsObject>(node: T, original: T): T
145
145
  if (original.peer === nullptr) {
146
146
  throwError('update called on NULLPTR')
147
147
  }
148
- global.generatedEs2panda._AstNodeSetOriginalNode(global.context, node.peer, original.peer)
148
+ if (original instanceof AstNode) {
149
+ global.generatedEs2panda._AstNodeSetOriginalNode(global.context, node.peer, original.originalPeer)
150
+ }
149
151
  global.generatedEs2panda._AstNodeSetParent(global.context, node.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer))
150
152
  global.es2panda._AstNodeUpdateChildren(global.context, node.peer)
151
153
  return node
@@ -15,23 +15,27 @@
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
30
33
  } from "../../generated"
31
34
  import { Config } from "../peers/Config"
32
35
  import { Context } from "../peers/Context"
36
+ import { NodeCache } from "../node-cache"
33
37
 
34
- export function createETSModulefromContext(): ETSModule {
38
+ export function createETSModuleFromContext(): ETSModule {
35
39
  return new ETSModule(global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context)))
36
40
  }
37
41
 
@@ -55,11 +59,7 @@ export function updateETSModuleByStatements(
55
59
  return node
56
60
  }
57
61
 
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)
62
+ export function checkErrors() {
63
63
  if (global.es2panda._ContextState(global.context) === Es2pandaContextState.ES2PANDA_STATE_ERROR) {
64
64
  console.log()
65
65
  global.es2panda._DestroyConfig(global.config)
@@ -68,23 +68,41 @@ export function proceedToState(state: Es2pandaContextState): void {
68
68
  }
69
69
  }
70
70
 
71
+ export function proceedToState(state: Es2pandaContextState): void {
72
+ if (state <= global.es2panda._ContextState(global.context)) {
73
+ return
74
+ }
75
+ const before = Date.now()
76
+ global.es2panda._ProceedToState(global.context, state)
77
+ const after = Date.now()
78
+ global.profiler.proceedTime += after-before
79
+ NodeCache.clear()
80
+ checkErrors()
81
+ }
82
+
71
83
  export function startChecker(): boolean {
72
84
  return global.es2panda._CheckerStartChecker(global.context)
73
85
  }
74
86
 
75
87
  export function recheckSubtree(node: AstNode): void {
76
88
  global.es2panda._AstNodeRecheck(global.context, node.peer)
89
+ checkErrors()
77
90
  }
78
91
 
79
92
  export function rebindSubtree(node: AstNode): void {
80
93
  global.es2panda._AstNodeRebind(global.context, node.peer)
94
+ checkErrors()
81
95
  }
82
96
 
83
97
  export function getDecl(node: AstNode): AstNode | undefined {
84
98
  if (isMemberExpression(node)) {
85
- return getDecl(node.property)
99
+ return getDecl(node.property!)
86
100
  }
87
- const decl = global.es2panda._DeclarationFromIdentifier(global.context, passNode(node))
101
+ return getPeerDecl(passNode(node))
102
+ }
103
+
104
+ export function getPeerDecl(peer: KNativePointer): AstNode | undefined {
105
+ const decl = global.es2panda._DeclarationFromIdentifier(global.context, peer)
88
106
  if (decl === nullptr) {
89
107
  return undefined
90
108
  }
@@ -113,6 +131,10 @@ export function getFileName(): string {
113
131
  return global.filePath
114
132
  }
115
133
 
134
+ export function getPackageName(): string {
135
+ return global.packageName
136
+ }
137
+
116
138
  export function getFilePathFromPackageRoot(): string {
117
139
  return global.filePathFromPackageRoot
118
140
  }
@@ -125,6 +147,34 @@ export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFla
125
147
  return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer)
126
148
  }
127
149
 
150
+ // TODO: ClassProperty's optional flag is set by AstNode's modifiers flags.
151
+ export function classPropertySetOptional(node: ClassProperty, value: boolean): ClassProperty {
152
+ if (value) {
153
+ node.modifierFlags |= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL;
154
+ } else {
155
+ node.modifierFlags &= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL;
156
+ }
157
+ return node;
158
+ }
159
+
160
+ // TODO: Import statements should be inserted to the statements.
161
+ export function importDeclarationInsert(node: ETSImportDeclaration): void {
162
+ const program = global.compilerContext.program; // TODO: external source has different program. Currently not considered.
163
+ global.es2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer)
164
+ }
165
+
166
+ export function hasModifierFlag(node: AstNode, flag: Es2pandaModifierFlags): boolean {
167
+ if (!node) return false;
168
+
169
+ let modifiers;
170
+ if (isClassDefinition(node)) {
171
+ modifiers = classDefinitionFlags(node);
172
+ } else {
173
+ modifiers = node.modifierFlags
174
+ }
175
+ return (modifiers & flag) === flag;
176
+ }
177
+
128
178
  export function modifiersToString(modifiers: Es2pandaModifierFlags): string {
129
179
  return Object.values(Es2pandaModifierFlags)
130
180
  .filter(isNumber)
@@ -133,3 +183,11 @@ export function modifiersToString(modifiers: Es2pandaModifierFlags): string {
133
183
  return ((modifiers.valueOf() & it) === it) ? Es2pandaModifierFlags[it] : ""
134
184
  }).join(" ")
135
185
  }
186
+
187
+ export function nameIfIdentifier(node: AstNode): string {
188
+ return isIdentifier(node) ? `'${node.name}'` : ""
189
+ }
190
+
191
+ export function asString(node: AstNode|undefined): string {
192
+ return `${node?.constructor.name} ${node ? nameIfIdentifier(node) : undefined}`
193
+ }
@@ -14,34 +14,50 @@
14
14
  */
15
15
 
16
16
  import { factory } from "./factory/nodeFactory"
17
- import { Es2pandaVariableDeclaratorFlag } from "../generated/Es2pandaEnums"
18
17
  import { AstNode } from "./peers/AstNode"
19
18
  import {
19
+ isArrayExpression,
20
20
  isArrowFunctionExpression,
21
+ isAssignmentExpression,
22
+ isBlockExpression,
21
23
  isBlockStatement,
22
24
  isCallExpression,
25
+ isChainExpression,
23
26
  isClassDeclaration,
24
27
  isClassDefinition,
25
28
  isConditionalExpression,
26
- isETSImportDeclaration,
29
+ isETSModule,
27
30
  isETSStructDeclaration,
31
+ isETSTuple,
28
32
  isExpressionStatement,
29
33
  isFunctionDeclaration,
34
+ isFunctionExpression,
30
35
  isIfStatement,
31
36
  isMemberExpression,
37
+ isMethodDefinition,
38
+ isObjectExpression,
32
39
  isReturnStatement,
33
40
  isScriptFunction,
41
+ isTemplateLiteral,
42
+ isTryStatement,
34
43
  isTSAsExpression,
35
44
  isTSInterfaceBody,
36
45
  isTSInterfaceDeclaration,
46
+ isTSTypeAliasDeclaration,
37
47
  isVariableDeclaration,
38
48
  isVariableDeclarator,
39
- isETSModule,
40
- isMethodDefinition,
49
+ isClassProperty,
50
+ isIdentifier,
51
+ isETSParameterExpression,
52
+ isETSUnionType,
53
+ isETSFunctionType,
54
+ isWhileStatement,
41
55
  } from "../generated"
42
- import { classDefinitionFlags, updateETSModuleByStatements } from "./utilities/public"
56
+ import { updateETSModuleByStatements } from "./utilities/public"
57
+ import { global } from "./static/global"
58
+ import { Es2pandaScriptFunctionFlags } from "../generated/Es2pandaEnums"
43
59
 
44
- type Visitor = (node: AstNode) => AstNode
60
+ type Visitor = (node: AstNode, options?: object) => AstNode
45
61
 
46
62
  export interface DoubleNode {
47
63
  originNode: AstNode;
@@ -50,6 +66,8 @@ export interface DoubleNode {
50
66
 
51
67
  export class StructInfo {
52
68
  stateVariables: Set<DoubleNode> = new Set();
69
+ initializeBody: AstNode[] = [];
70
+ updateBody: AstNode[] = [];
53
71
  }
54
72
 
55
73
  export class GlobalInfo {
@@ -110,6 +128,7 @@ export function visitEachChild(
110
128
  node: AstNode,
111
129
  visitor: Visitor
112
130
  ): AstNode {
131
+ global.profiler.visitedNodes ++
113
132
  if (isETSModule(node)) {
114
133
  return updateETSModuleByStatements(
115
134
  node,
@@ -131,7 +150,7 @@ export function visitEachChild(
131
150
  return factory.updateFunctionDeclaration(
132
151
  node,
133
152
  nodeVisitor(node.function, visitor),
134
- node.annotations,
153
+ nodesVisitor(node.annotations, visitor),
135
154
  node.isAnonymous,
136
155
  )
137
156
  }
@@ -141,6 +160,18 @@ export function visitEachChild(
141
160
  nodesVisitor(node.statements, visitor),
142
161
  )
143
162
  }
163
+ if (isBlockExpression(node)) {
164
+ return factory.updateBlockExpression(
165
+ node,
166
+ nodesVisitor(node.statements, visitor),
167
+ )
168
+ }
169
+ if (isChainExpression(node)) {
170
+ return factory.updateChainExpression(
171
+ node,
172
+ nodeVisitor(node.expression, visitor),
173
+ )
174
+ }
144
175
  if (isExpressionStatement(node)) {
145
176
  return factory.updateExpressionStatement(
146
177
  node,
@@ -154,63 +185,64 @@ export function visitEachChild(
154
185
  )
155
186
  }
156
187
  if (isClassDeclaration(node)) {
157
- return factory.updateClassDeclaration(
188
+ const _node = factory.updateClassDeclaration(
158
189
  node,
159
190
  nodeVisitor(node.definition, visitor)
160
191
  )
192
+ _node.modifierFlags = node.modifierFlags
193
+ return _node
161
194
  }
162
195
  if (isClassDefinition(node)) {
163
- // TODO: fix
164
196
  return factory.updateClassDefinition(
165
197
  node,
166
- node.ident,
167
- node.typeParams,
168
- node.superTypeParams,
169
- node.implements,
170
- undefined,
171
- node.super,
198
+ nodeVisitor(node.ident, visitor),
199
+ nodeVisitor(node.typeParams, visitor),
200
+ nodeVisitor(node.superTypeParams, visitor),
201
+ nodesVisitor(node.implements, visitor),
202
+ undefined, /* can not pass node.ctor here because of mismatching types */
203
+ nodeVisitor(node.super, visitor),
172
204
  nodesVisitor(node.body, visitor),
173
205
  node.modifiers,
174
- classDefinitionFlags(node)
206
+ node.modifierFlags
175
207
  )
176
208
  }
177
209
  if (isMethodDefinition(node)) {
178
210
  return factory.updateMethodDefinition(
179
211
  node,
180
212
  node.kind,
181
- node.id,
182
- factory.createFunctionExpression(
183
- node.id,
184
- nodeVisitor(node.function, visitor)
185
- ),
186
- node.modifiers,
187
- node.isComputed
213
+ nodeVisitor(node.id, visitor),
214
+ nodeVisitor(node.value, visitor),
215
+ node.modifierFlags,
216
+ node.isComputed,
217
+ nodesVisitor(node.overloads, visitor)
188
218
  )
189
219
  }
190
220
  if (isScriptFunction(node)) {
191
221
  return factory.updateScriptFunction(
192
222
  node,
193
223
  nodeVisitor(node.body, visitor),
194
- node.typeParams,
195
- node.params,
196
- node.returnTypeAnnotation,
224
+ nodeVisitor(node.typeParams, visitor),
225
+ nodesVisitor(node.params, visitor),
226
+ nodeVisitor(node.returnTypeAnnotation, visitor),
197
227
  node.hasReceiver,
198
228
  node.flags,
199
- node.modifiers,
200
- node.id,
201
- node.annotations,
229
+ node.modifierFlags,
230
+ nodeVisitor(node.id, visitor),
231
+ nodesVisitor(node.annotations, visitor)
202
232
  )
203
233
  }
204
- if (isETSImportDeclaration(node)) {
205
- return factory.updateETSImportDeclaration(
234
+ if (isETSParameterExpression(node)) {
235
+ if (node.isRestParameter) {
236
+ /** there is no RestParameter node at .idl */
237
+ return node
238
+ }
239
+ return factory.updateETSParameterExpression(
206
240
  node,
207
- factory.createImportSource(
208
- node.source,
209
- node.resolvedSource,
210
- node.hasDecl
211
- ),
212
- nodesVisitor(node.specifiers, visitor),
213
- +node.isTypeKind,
241
+ nodeVisitor(node.ident, visitor),
242
+ node.isOptional,
243
+ nodeVisitor(node.initializer, visitor),
244
+ nodeVisitor(node.typeAnnotation, visitor),
245
+ nodesVisitor(node.annotations, visitor),
214
246
  )
215
247
  }
216
248
  if (isMemberExpression(node)) {
@@ -231,8 +263,7 @@ export function visitEachChild(
231
263
  nodeVisitor(node.typeParams, visitor),
232
264
  nodeVisitor(node.body, visitor),
233
265
  node.isStatic,
234
- // TODO: how do I get it?
235
- true
266
+ node.isFromExternal
236
267
  )
237
268
  }
238
269
  if (isTSInterfaceBody(node)) {
@@ -262,12 +293,13 @@ export function visitEachChild(
262
293
  node,
263
294
  node.kind,
264
295
  nodesVisitor(node.declarators, visitor),
296
+ nodesVisitor(node.annotations, visitor)
265
297
  )
266
298
  }
267
299
  if (isVariableDeclarator(node)) {
268
300
  return factory.updateVariableDeclarator(
269
301
  node,
270
- Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_UNKNOWN,
302
+ node.flag,
271
303
  nodeVisitor(node.id, visitor),
272
304
  nodeVisitor(node.init, visitor),
273
305
  )
@@ -276,6 +308,7 @@ export function visitEachChild(
276
308
  return factory.updateArrowFunctionExpression(
277
309
  node,
278
310
  nodeVisitor(node.function, visitor),
311
+ nodesVisitor(node.annotations, visitor)
279
312
  )
280
313
  }
281
314
  if (isReturnStatement(node)) {
@@ -292,6 +325,106 @@ export function visitEachChild(
292
325
  node.isConst
293
326
  )
294
327
  }
295
- // TODO
328
+ if (isTemplateLiteral(node)) {
329
+ return factory.updateTemplateLiteral(
330
+ node,
331
+ nodesVisitor(node.quasis, visitor),
332
+ nodesVisitor(node.expressions, visitor),
333
+ node.multilineString
334
+ )
335
+ }
336
+ if (isTSTypeAliasDeclaration(node)) {
337
+ return factory.updateTSTypeAliasDeclaration(
338
+ node,
339
+ nodeVisitor(node.id, visitor),
340
+ nodeVisitor(node.typeParams, visitor),
341
+ nodeVisitor(node.typeAnnotation, visitor),
342
+ nodesVisitor(node.annotations, visitor),
343
+ )
344
+ }
345
+ if (isTryStatement(node)) {
346
+ return factory.updateTryStatement(
347
+ node,
348
+ nodeVisitor(node.block, visitor),
349
+ nodesVisitor(node.catchClauses, visitor),
350
+ nodeVisitor(node.finallyBlock, visitor),
351
+ [],
352
+ []
353
+ )
354
+ }
355
+ if (isObjectExpression(node)) {
356
+ return factory.updateObjectExpression(
357
+ node,
358
+ nodesVisitor(node.properties, visitor)
359
+ )
360
+ }
361
+ if (isFunctionExpression(node)) {
362
+ return factory.updateFunctionExpression(
363
+ node,
364
+ nodeVisitor(node.id, visitor),
365
+ nodeVisitor(node.function, visitor)
366
+ )
367
+ }
368
+ if (isArrayExpression(node)) {
369
+ return factory.updateArrayExpression(
370
+ node,
371
+ nodesVisitor(node.elements, visitor)
372
+ )
373
+ }
374
+ if (isAssignmentExpression(node)) {
375
+ return factory.updateAssignmentExpression(
376
+ node,
377
+ nodeVisitor(node.left, visitor),
378
+ nodeVisitor(node.right, visitor),
379
+ node.operatorType,
380
+ )
381
+ }
382
+ if (isETSTuple(node)) {
383
+ return factory.updateETSTuple(
384
+ node,
385
+ nodesVisitor(node.tupleTypeAnnotationsList, visitor)
386
+ )
387
+ }
388
+ if (isETSUnionType(node)) {
389
+ return factory.updateETSUnionType(
390
+ node,
391
+ nodesVisitor(node.types, visitor),
392
+ )
393
+ }
394
+ if (isETSFunctionType(node)) {
395
+ return factory.updateETSFunctionType(
396
+ node,
397
+ nodeVisitor(node.typeParams, visitor),
398
+ nodesVisitor(node.params, visitor),
399
+ nodeVisitor(node.returnType, visitor),
400
+ false, // TODO: how to get it?
401
+ Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW,
402
+ nodesVisitor(node.annotations, visitor),
403
+ )
404
+ }
405
+ if (isClassProperty(node)) {
406
+ return factory.updateClassProperty(
407
+ node,
408
+ nodeVisitor(node.key, visitor),
409
+ nodeVisitor(node.value, visitor),
410
+ nodeVisitor(node.typeAnnotation, visitor),
411
+ node.modifierFlags,
412
+ node.isComputed
413
+ )
414
+ }
415
+ if (isIdentifier(node)) {
416
+ return factory.updateIdentifier(
417
+ node,
418
+ node.name,
419
+ nodeVisitor(node.typeAnnotation, visitor)
420
+ )
421
+ }
422
+ if (isWhileStatement(node)) {
423
+ return factory.updateWhileStatement(
424
+ node,
425
+ nodeVisitor(node.test, visitor),
426
+ nodeVisitor(node.body, visitor),
427
+ )
428
+ }
296
429
  return node
297
430
  }