@harmoniclabs/pebble 0.1.0-dev2 → 0.1.0-dev4

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 (769) hide show
  1. package/dist/IR/IRHash.d.ts +8 -0
  2. package/dist/IR/IRHash.js +78 -0
  3. package/dist/IR/IRNodeKind.d.ts +17 -0
  4. package/dist/IR/IRNodeKind.js +19 -0
  5. package/dist/IR/IRNodes/BaseIRMetadata.d.ts +3 -0
  6. package/dist/IR/IRNodes/BaseIRMetadata.js +1 -0
  7. package/dist/IR/IRNodes/IRApp.d.ts +36 -0
  8. package/dist/IR/IRNodes/IRApp.js +91 -0
  9. package/dist/IR/IRNodes/IRCase.d.ts +32 -0
  10. package/dist/IR/IRNodes/IRCase.js +91 -0
  11. package/dist/IR/IRNodes/IRConst.d.ts +49 -0
  12. package/dist/IR/IRNodes/IRConst.js +273 -0
  13. package/dist/IR/IRNodes/IRConstr.d.ts +30 -0
  14. package/dist/IR/IRNodes/IRConstr.js +87 -0
  15. package/dist/IR/IRNodes/IRDelayed.d.ts +31 -0
  16. package/dist/IR/IRNodes/IRDelayed.js +68 -0
  17. package/dist/IR/IRNodes/IRError.d.ts +32 -0
  18. package/dist/IR/IRNodes/IRError.js +44 -0
  19. package/dist/IR/IRNodes/IRForced.d.ts +31 -0
  20. package/dist/IR/IRNodes/IRForced.js +69 -0
  21. package/dist/IR/IRNodes/IRFunc.d.ts +33 -0
  22. package/dist/IR/IRNodes/IRFunc.js +91 -0
  23. package/dist/IR/IRNodes/IRHoisted.d.ts +55 -0
  24. package/dist/IR/IRNodes/IRHoisted.js +212 -0
  25. package/dist/IR/IRNodes/IRLetted.d.ts +108 -0
  26. package/dist/IR/IRNodes/IRLetted.js +444 -0
  27. package/dist/IR/IRNodes/IRNative/IRNativeTag.d.ts +138 -0
  28. package/dist/IR/IRNodes/IRNative/IRNativeTag.js +204 -0
  29. package/dist/IR/IRNodes/IRNative/index.d.ts +165 -0
  30. package/dist/IR/IRNodes/IRNative/index.js +240 -0
  31. package/dist/IR/IRNodes/IRNative/isForcedNative.d.ts +3 -0
  32. package/dist/IR/IRNodes/IRNative/isForcedNative.js +18 -0
  33. package/dist/IR/IRNodes/IRRecursive.d.ts +29 -0
  34. package/dist/IR/IRNodes/IRRecursive.js +90 -0
  35. package/dist/IR/IRNodes/IRSelfCall.d.ts +46 -0
  36. package/dist/IR/IRNodes/IRSelfCall.js +127 -0
  37. package/dist/IR/IRNodes/IRVar.d.ts +41 -0
  38. package/dist/IR/IRNodes/IRVar.js +93 -0
  39. package/dist/IR/IRNodes/index.d.ts +12 -0
  40. package/dist/IR/IRNodes/index.js +12 -0
  41. package/dist/IR/IRNodes/utils/dependsByDbns.d.ts +5 -0
  42. package/dist/IR/IRNodes/utils/dependsByDbns.js +29 -0
  43. package/dist/IR/IRNodes/utils/isClosedAtDbn.d.ts +2 -0
  44. package/dist/IR/IRNodes/utils/isClosedAtDbn.js +22 -0
  45. package/dist/IR/IRNodes/utils/makeArrayLikeProxy.d.ts +1 -0
  46. package/dist/IR/IRNodes/utils/makeArrayLikeProxy.js +34 -0
  47. package/dist/IR/IRNodes/utils/mapArrayLike.d.ts +1 -0
  48. package/dist/IR/IRNodes/utils/mapArrayLike.js +8 -0
  49. package/dist/IR/IRTerm.d.ts +15 -0
  50. package/dist/IR/IRTerm.js +1 -0
  51. package/dist/IR/index.d.ts +5 -0
  52. package/dist/IR/index.js +5 -0
  53. package/dist/IR/interfaces/IHash.d.ts +6 -0
  54. package/dist/IR/interfaces/IHash.js +1 -0
  55. package/dist/IR/interfaces/IIRParent.d.ts +4 -0
  56. package/dist/IR/interfaces/IIRParent.js +1 -0
  57. package/dist/IR/interfaces/IRMetadata.d.ts +3 -0
  58. package/dist/IR/interfaces/IRMetadata.js +2 -0
  59. package/dist/IR/interfaces/ToIR.d.ts +5 -0
  60. package/dist/IR/interfaces/ToIR.js +1 -0
  61. package/dist/IR/interfaces/index.d.ts +4 -0
  62. package/dist/IR/interfaces/index.js +4 -0
  63. package/dist/IR/toUPLC/CompilerOptions.d.ts +80 -0
  64. package/dist/IR/toUPLC/CompilerOptions.js +98 -0
  65. package/dist/IR/toUPLC/_internal/_addDepth.d.ts +2 -0
  66. package/dist/IR/toUPLC/_internal/_addDepth.js +58 -0
  67. package/dist/IR/toUPLC/_internal/_irToUplc.d.ts +9 -0
  68. package/dist/IR/toUPLC/_internal/_irToUplc.js +156 -0
  69. package/dist/IR/toUPLC/_internal/_makeAllNegativeNativesHoisted.d.ts +2 -0
  70. package/dist/IR/toUPLC/_internal/_makeAllNegativeNativesHoisted.js +12 -0
  71. package/dist/IR/toUPLC/_internal/_modifyChildFromTo.d.ts +10 -0
  72. package/dist/IR/toUPLC/_internal/_modifyChildFromTo.js +141 -0
  73. package/dist/IR/toUPLC/_internal/depth.d.ts +5 -0
  74. package/dist/IR/toUPLC/_internal/depth.js +8 -0
  75. package/dist/IR/toUPLC/_internal/findAll.d.ts +3 -0
  76. package/dist/IR/toUPLC/_internal/findAll.js +99 -0
  77. package/dist/IR/toUPLC/_internal/getDebruijnInTerm.d.ts +2 -0
  78. package/dist/IR/toUPLC/_internal/getDebruijnInTerm.js +51 -0
  79. package/dist/IR/toUPLC/_internal/getDiffDbn.d.ts +2 -0
  80. package/dist/IR/toUPLC/_internal/getDiffDbn.js +55 -0
  81. package/dist/IR/toUPLC/_internal/includesLettedTerms.d.ts +2 -0
  82. package/dist/IR/toUPLC/_internal/includesLettedTerms.js +50 -0
  83. package/dist/IR/toUPLC/_internal/includesNode.d.ts +2 -0
  84. package/dist/IR/toUPLC/_internal/includesNode.js +54 -0
  85. package/dist/IR/toUPLC/_internal/iterTree.d.ts +2 -0
  86. package/dist/IR/toUPLC/_internal/iterTree.js +93 -0
  87. package/dist/IR/toUPLC/_internal/lowestCommonAncestor.d.ts +3 -0
  88. package/dist/IR/toUPLC/_internal/lowestCommonAncestor.js +41 -0
  89. package/dist/IR/toUPLC/compileIRToUPLC.d.ts +4 -0
  90. package/dist/IR/toUPLC/compileIRToUPLC.js +118 -0
  91. package/dist/IR/toUPLC/index.d.ts +2 -0
  92. package/dist/IR/toUPLC/index.js +2 -0
  93. package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.d.ts +2 -0
  94. package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.js +161 -0
  95. package/dist/IR/toUPLC/subRoutines/handleLetted/findHighestRecursiveParent.d.ts +5 -0
  96. package/dist/IR/toUPLC/subRoutines/handleLetted/findHighestRecursiveParent.js +14 -0
  97. package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.d.ts +20 -0
  98. package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.js +107 -0
  99. package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.d.ts +9 -0
  100. package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.js +73 -0
  101. package/dist/IR/toUPLC/subRoutines/handleLetted/index.d.ts +2 -0
  102. package/dist/IR/toUPLC/subRoutines/handleLetted/index.js +304 -0
  103. package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.d.ts +3 -0
  104. package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.js +32 -0
  105. package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.d.ts +2 -0
  106. package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.js +58 -0
  107. package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.d.ts +1 -0
  108. package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.js +12 -0
  109. package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.d.ts +2 -0
  110. package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.js +82 -0
  111. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.d.ts +4 -0
  112. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.js +68 -0
  113. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.d.ts +5 -0
  114. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.js +227 -0
  115. package/dist/IR/toUPLC/subRoutines/replaceClosedLettedWithHoisted.d.ts +2 -0
  116. package/dist/IR/toUPLC/subRoutines/replaceClosedLettedWithHoisted.js +13 -0
  117. package/dist/IR/toUPLC/subRoutines/replaceForcedNativesWithHoisted.d.ts +2 -0
  118. package/dist/IR/toUPLC/subRoutines/replaceForcedNativesWithHoisted.js +11 -0
  119. package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.d.ts +2 -0
  120. package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.js +16 -0
  121. package/dist/IR/toUPLC/subRoutines/replaceNatives/index.d.ts +2 -0
  122. package/dist/IR/toUPLC/subRoutines/replaceNatives/index.js +16 -0
  123. package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +3 -0
  124. package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +520 -0
  125. package/dist/IR/toUPLC/subRoutines/sanifyTree.d.ts +5 -0
  126. package/dist/IR/toUPLC/subRoutines/sanifyTree.js +84 -0
  127. package/dist/IR/tree_utils/_ir_apps.d.ts +3 -0
  128. package/dist/IR/tree_utils/_ir_apps.js +8 -0
  129. package/dist/IR/tree_utils/_ir_lazyChooseList.d.ts +3 -0
  130. package/dist/IR/tree_utils/_ir_lazyChooseList.js +5 -0
  131. package/dist/IR/tree_utils/_ir_lazyIfThenElse.d.ts +3 -0
  132. package/dist/IR/tree_utils/_ir_lazyIfThenElse.js +5 -0
  133. package/dist/IR/tree_utils/_ir_let.d.ts +3 -0
  134. package/dist/IR/tree_utils/_ir_let.js +4 -0
  135. package/dist/IR/tree_utils/getChildren.d.ts +2 -0
  136. package/dist/IR/tree_utils/getChildren.js +33 -0
  137. package/dist/IR/tree_utils/getRoot.d.ts +2 -0
  138. package/dist/IR/tree_utils/getRoot.js +6 -0
  139. package/dist/IR/utils/MutArrayLike.d.ts +5 -0
  140. package/dist/IR/utils/MutArrayLike.js +1 -0
  141. package/dist/IR/utils/concatUint8Arr.d.ts +1 -0
  142. package/dist/IR/utils/concatUint8Arr.js +11 -0
  143. package/dist/IR/utils/equalIRTerm.d.ts +12 -0
  144. package/dist/IR/utils/equalIRTerm.js +19 -0
  145. package/dist/IR/utils/index.d.ts +3 -0
  146. package/dist/IR/utils/index.js +3 -0
  147. package/dist/IR/utils/isClosedIRTerm.d.ts +2 -0
  148. package/dist/IR/utils/isClosedIRTerm.js +58 -0
  149. package/dist/IR/utils/isIRParentTerm.d.ts +12 -0
  150. package/dist/IR/utils/isIRParentTerm.js +26 -0
  151. package/dist/IR/utils/isIRTerm.d.ts +2 -0
  152. package/dist/IR/utils/isIRTerm.js +30 -0
  153. package/dist/IR/utils/positiveIntAsBytes.d.ts +5 -0
  154. package/dist/IR/utils/positiveIntAsBytes.js +27 -0
  155. package/dist/IR/utils/showIR.d.ts +43 -0
  156. package/dist/IR/utils/showIR.js +372 -0
  157. package/dist/ast/PebbleAst.d.ts +8 -0
  158. package/dist/ast/PebbleAst.js +15 -0
  159. package/dist/ast/Source/Source.d.ts +47 -0
  160. package/dist/ast/Source/Source.js +89 -0
  161. package/dist/ast/Source/SourceRange.d.ts +16 -0
  162. package/dist/ast/Source/SourceRange.js +49 -0
  163. package/dist/ast/nodes/HasSourceRange.d.ts +5 -0
  164. package/dist/ast/nodes/HasSourceRange.js +6 -0
  165. package/dist/ast/nodes/common/Identifier.d.ts +13 -0
  166. package/dist/ast/nodes/common/Identifier.js +20 -0
  167. package/dist/ast/nodes/expr/CaseExpr.d.ts +22 -0
  168. package/dist/ast/nodes/expr/CaseExpr.js +30 -0
  169. package/dist/ast/nodes/expr/ElemAccessExpr.d.ts +12 -0
  170. package/dist/ast/nodes/expr/ElemAccessExpr.js +13 -0
  171. package/dist/ast/nodes/expr/IsExpr.d.ts +1 -0
  172. package/dist/ast/nodes/expr/IsExpr.js +14 -0
  173. package/dist/ast/nodes/expr/ParentesizedExpr.d.ts +8 -0
  174. package/dist/ast/nodes/expr/ParentesizedExpr.js +8 -0
  175. package/dist/ast/nodes/expr/PebbleExpr.d.ts +18 -0
  176. package/dist/ast/nodes/expr/PebbleExpr.js +31 -0
  177. package/dist/ast/nodes/expr/PropAccessExpr.d.ts +28 -0
  178. package/dist/ast/nodes/expr/PropAccessExpr.js +46 -0
  179. package/dist/ast/nodes/expr/TernaryExpr.d.ts +10 -0
  180. package/dist/ast/nodes/expr/TernaryExpr.js +12 -0
  181. package/dist/ast/nodes/expr/TypeConversionExpr.d.ts +10 -0
  182. package/dist/ast/nodes/expr/TypeConversionExpr.js +11 -0
  183. package/dist/ast/nodes/expr/binary/BinaryExpr.d.ts +133 -0
  184. package/dist/ast/nodes/expr/binary/BinaryExpr.js +253 -0
  185. package/dist/ast/nodes/expr/functions/ArrowKind.d.ts +9 -0
  186. package/dist/ast/nodes/expr/functions/ArrowKind.js +11 -0
  187. package/dist/ast/nodes/expr/functions/CallExpr.d.ts +17 -0
  188. package/dist/ast/nodes/expr/functions/CallExpr.js +16 -0
  189. package/dist/ast/nodes/expr/functions/FuncExpr.d.ts +21 -0
  190. package/dist/ast/nodes/expr/functions/FuncExpr.js +21 -0
  191. package/dist/ast/nodes/expr/litteral/LitArrExpr.d.ts +8 -0
  192. package/dist/ast/nodes/expr/litteral/LitArrExpr.js +8 -0
  193. package/dist/ast/nodes/expr/litteral/LitFalseExpr.d.ts +6 -0
  194. package/dist/ast/nodes/expr/litteral/LitFalseExpr.js +6 -0
  195. package/dist/ast/nodes/expr/litteral/LitHexBytesExpr.d.ts +7 -0
  196. package/dist/ast/nodes/expr/litteral/LitHexBytesExpr.js +8 -0
  197. package/dist/ast/nodes/expr/litteral/LitIntExpr.d.ts +7 -0
  198. package/dist/ast/nodes/expr/litteral/LitIntExpr.js +8 -0
  199. package/dist/ast/nodes/expr/litteral/LitNamedObjExpr.d.ts +12 -0
  200. package/dist/ast/nodes/expr/litteral/LitNamedObjExpr.js +12 -0
  201. package/dist/ast/nodes/expr/litteral/LitObjExpr.d.ts +14 -0
  202. package/dist/ast/nodes/expr/litteral/LitObjExpr.js +10 -0
  203. package/dist/ast/nodes/expr/litteral/LitStrExpr.d.ts +7 -0
  204. package/dist/ast/nodes/expr/litteral/LitStrExpr.js +8 -0
  205. package/dist/ast/nodes/expr/litteral/LitThisExpr.d.ts +6 -0
  206. package/dist/ast/nodes/expr/litteral/LitThisExpr.js +6 -0
  207. package/dist/ast/nodes/expr/litteral/LitTrueExpr.d.ts +6 -0
  208. package/dist/ast/nodes/expr/litteral/LitTrueExpr.js +6 -0
  209. package/dist/ast/nodes/expr/litteral/LitUndefExpr.d.ts +6 -0
  210. package/dist/ast/nodes/expr/litteral/LitUndefExpr.js +6 -0
  211. package/dist/ast/nodes/expr/litteral/LitVoidExpr.d.ts +6 -0
  212. package/dist/ast/nodes/expr/litteral/LitVoidExpr.js +6 -0
  213. package/dist/ast/nodes/expr/litteral/LitteralExpr.d.ts +13 -0
  214. package/dist/ast/nodes/expr/litteral/LitteralExpr.js +24 -0
  215. package/dist/ast/nodes/expr/unary/IUnaryExpression.d.ts +4 -0
  216. package/dist/ast/nodes/expr/unary/IUnaryExpression.js +1 -0
  217. package/dist/ast/nodes/expr/unary/NonNullExpr.d.ts +8 -0
  218. package/dist/ast/nodes/expr/unary/NonNullExpr.js +8 -0
  219. package/dist/ast/nodes/expr/unary/UnaryExclamation.d.ts +9 -0
  220. package/dist/ast/nodes/expr/unary/UnaryExclamation.js +8 -0
  221. package/dist/ast/nodes/expr/unary/UnaryMinus.d.ts +9 -0
  222. package/dist/ast/nodes/expr/unary/UnaryMinus.js +8 -0
  223. package/dist/ast/nodes/expr/unary/UnaryPlus.d.ts +9 -0
  224. package/dist/ast/nodes/expr/unary/UnaryPlus.js +8 -0
  225. package/dist/ast/nodes/expr/unary/UnaryPrefixExpr.d.ts +14 -0
  226. package/dist/ast/nodes/expr/unary/UnaryPrefixExpr.js +27 -0
  227. package/dist/ast/nodes/expr/unary/UnaryTilde.d.ts +9 -0
  228. package/dist/ast/nodes/expr/unary/UnaryTilde.js +8 -0
  229. package/dist/ast/nodes/statements/AssertStmt.d.ts +15 -0
  230. package/dist/ast/nodes/statements/AssertStmt.js +14 -0
  231. package/dist/ast/nodes/statements/AssignmentStmt.d.ts +105 -0
  232. package/dist/ast/nodes/statements/AssignmentStmt.js +211 -0
  233. package/dist/ast/nodes/statements/BlockStmt.d.ts +8 -0
  234. package/dist/ast/nodes/statements/BlockStmt.js +8 -0
  235. package/dist/ast/nodes/statements/BreakStmt.d.ts +6 -0
  236. package/dist/ast/nodes/statements/BreakStmt.js +6 -0
  237. package/dist/ast/nodes/statements/ContinueStmt.d.ts +6 -0
  238. package/dist/ast/nodes/statements/ContinueStmt.js +6 -0
  239. package/dist/ast/nodes/statements/DecrStmt.d.ts +11 -0
  240. package/dist/ast/nodes/statements/DecrStmt.js +11 -0
  241. package/dist/ast/nodes/statements/DoWhileStmt.d.ts +10 -0
  242. package/dist/ast/nodes/statements/DoWhileStmt.js +10 -0
  243. package/dist/ast/nodes/statements/EmptyStmt.d.ts +6 -0
  244. package/dist/ast/nodes/statements/EmptyStmt.js +6 -0
  245. package/dist/ast/nodes/statements/ExportImportStmt.d.ts +15 -0
  246. package/dist/ast/nodes/statements/ExportImportStmt.js +15 -0
  247. package/dist/ast/nodes/statements/ExportStarStmt.d.ts +8 -0
  248. package/dist/ast/nodes/statements/ExportStarStmt.js +8 -0
  249. package/dist/ast/nodes/statements/ExportStmt.d.ts +13 -0
  250. package/dist/ast/nodes/statements/ExportStmt.js +13 -0
  251. package/dist/ast/nodes/statements/ExprStmt.d.ts +8 -0
  252. package/dist/ast/nodes/statements/ExprStmt.js +18 -0
  253. package/dist/ast/nodes/statements/FailStmt.d.ts +11 -0
  254. package/dist/ast/nodes/statements/FailStmt.js +10 -0
  255. package/dist/ast/nodes/statements/ForOfStmt.d.ts +16 -0
  256. package/dist/ast/nodes/statements/ForOfStmt.js +15 -0
  257. package/dist/ast/nodes/statements/ForStmt.d.ts +19 -0
  258. package/dist/ast/nodes/statements/ForStmt.js +19 -0
  259. package/dist/ast/nodes/statements/IfStmt.d.ts +11 -0
  260. package/dist/ast/nodes/statements/IfStmt.js +12 -0
  261. package/dist/ast/nodes/statements/ImportStarStmt.d.ts +15 -0
  262. package/dist/ast/nodes/statements/ImportStarStmt.js +15 -0
  263. package/dist/ast/nodes/statements/ImportStmt.d.ts +21 -0
  264. package/dist/ast/nodes/statements/ImportStmt.js +25 -0
  265. package/dist/ast/nodes/statements/IncrStmt.d.ts +8 -0
  266. package/dist/ast/nodes/statements/IncrStmt.js +8 -0
  267. package/dist/ast/nodes/statements/MatchStmt.d.ts +17 -0
  268. package/dist/ast/nodes/statements/MatchStmt.js +20 -0
  269. package/dist/ast/nodes/statements/PebbleStmt.d.ts +29 -0
  270. package/dist/ast/nodes/statements/PebbleStmt.js +62 -0
  271. package/dist/ast/nodes/statements/ReturnStmt.d.ts +8 -0
  272. package/dist/ast/nodes/statements/ReturnStmt.js +8 -0
  273. package/dist/ast/nodes/statements/TestStmt.d.ts +10 -0
  274. package/dist/ast/nodes/statements/TestStmt.js +10 -0
  275. package/dist/ast/nodes/statements/TypeImplementsStmt.d.ts +21 -0
  276. package/dist/ast/nodes/statements/TypeImplementsStmt.js +26 -0
  277. package/dist/ast/nodes/statements/UsingStmt.d.ts +16 -0
  278. package/dist/ast/nodes/statements/UsingStmt.js +20 -0
  279. package/dist/ast/nodes/statements/VarStmt.d.ts +10 -0
  280. package/dist/ast/nodes/statements/VarStmt.js +11 -0
  281. package/dist/ast/nodes/statements/WhileStmt.d.ts +10 -0
  282. package/dist/ast/nodes/statements/WhileStmt.js +10 -0
  283. package/dist/ast/nodes/statements/declarations/EnumDecl.d.ts +18 -0
  284. package/dist/ast/nodes/statements/declarations/EnumDecl.js +22 -0
  285. package/dist/ast/nodes/statements/declarations/FuncDecl.d.ts +8 -0
  286. package/dist/ast/nodes/statements/declarations/FuncDecl.js +9 -0
  287. package/dist/ast/nodes/statements/declarations/InterfaceDecl.d.ts +19 -0
  288. package/dist/ast/nodes/statements/declarations/InterfaceDecl.js +26 -0
  289. package/dist/ast/nodes/statements/declarations/PebbleTypeDecl.d.ts +5 -0
  290. package/dist/ast/nodes/statements/declarations/PebbleTypeDecl.js +8 -0
  291. package/dist/ast/nodes/statements/declarations/StructDecl.d.ts +25 -0
  292. package/dist/ast/nodes/statements/declarations/StructDecl.js +36 -0
  293. package/dist/ast/nodes/statements/declarations/TypeAliasDecl.d.ts +11 -0
  294. package/dist/ast/nodes/statements/declarations/TypeAliasDecl.js +12 -0
  295. package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.d.ts +19 -0
  296. package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.js +19 -0
  297. package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.d.ts +5 -0
  298. package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.js +7 -0
  299. package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.d.ts +24 -0
  300. package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.js +30 -0
  301. package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.d.ts +17 -0
  302. package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.js +21 -0
  303. package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.d.ts +24 -0
  304. package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.js +20 -0
  305. package/dist/ast/nodes/statements/declarations/VarDecl/VarDecl.d.ts +8 -0
  306. package/dist/ast/nodes/statements/declarations/VarDecl/VarDecl.js +13 -0
  307. package/dist/ast/nodes/types/AstNamedTypeExpr.d.ts +14 -0
  308. package/dist/ast/nodes/types/AstNamedTypeExpr.js +14 -0
  309. package/dist/ast/nodes/types/AstNativeTypeExpr.d.ts +52 -0
  310. package/dist/ast/nodes/types/AstNativeTypeExpr.js +82 -0
  311. package/dist/ast/nodes/types/AstTypeExpr.d.ts +4 -0
  312. package/dist/ast/nodes/types/AstTypeExpr.js +7 -0
  313. package/dist/common.d.ts +194 -0
  314. package/dist/common.js +224 -0
  315. package/dist/compiler/AstCompiler/AstCompilationCtx.d.ts +35 -0
  316. package/dist/compiler/AstCompiler/AstCompilationCtx.js +43 -0
  317. package/dist/compiler/AstCompiler/AstCompiler.d.ts +73 -0
  318. package/dist/compiler/AstCompiler/AstCompiler.js +542 -0
  319. package/dist/compiler/AstCompiler/compileAst.d.ts +0 -0
  320. package/dist/compiler/AstCompiler/compileAst.js +0 -0
  321. package/dist/compiler/AstCompiler/index.d.ts +1 -0
  322. package/dist/compiler/AstCompiler/index.js +1 -0
  323. package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.d.ts +5 -0
  324. package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.js +66 -0
  325. package/dist/compiler/AstCompiler/internal/exprs/_compileCallExpr.d.ts +5 -0
  326. package/dist/compiler/AstCompiler/internal/exprs/_compileCallExpr.js +36 -0
  327. package/dist/compiler/AstCompiler/internal/exprs/_compileCaseExpr.d.ts +6 -0
  328. package/dist/compiler/AstCompiler/internal/exprs/_compileCaseExpr.js +47 -0
  329. package/dist/compiler/AstCompiler/internal/exprs/_compileElemAccessExpr.d.ts +5 -0
  330. package/dist/compiler/AstCompiler/internal/exprs/_compileElemAccessExpr.js +23 -0
  331. package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.d.ts +22 -0
  332. package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.js +77 -0
  333. package/dist/compiler/AstCompiler/internal/exprs/_compileFuncExpr.d.ts +26 -0
  334. package/dist/compiler/AstCompiler/internal/exprs/_compileFuncExpr.js +163 -0
  335. package/dist/compiler/AstCompiler/internal/exprs/_compileIsExpr.d.ts +1 -0
  336. package/dist/compiler/AstCompiler/internal/exprs/_compileIsExpr.js +43 -0
  337. package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.d.ts +19 -0
  338. package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.js +202 -0
  339. package/dist/compiler/AstCompiler/internal/exprs/_compileNonNullExpr.d.ts +5 -0
  340. package/dist/compiler/AstCompiler/internal/exprs/_compileNonNullExpr.js +43 -0
  341. package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.d.ts +9 -0
  342. package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.js +102 -0
  343. package/dist/compiler/AstCompiler/internal/exprs/_compileTernaryExpr.d.ts +5 -0
  344. package/dist/compiler/AstCompiler/internal/exprs/_compileTernaryExpr.js +22 -0
  345. package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.d.ts +5 -0
  346. package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.js +25 -0
  347. package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.d.ts +5 -0
  348. package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +54 -0
  349. package/dist/compiler/AstCompiler/internal/exprs/_compileVarAccessExpr.d.ts +5 -0
  350. package/dist/compiler/AstCompiler/internal/exprs/_compileVarAccessExpr.js +9 -0
  351. package/dist/compiler/AstCompiler/internal/exprs/_hasDuplicateTypeParams.d.ts +3 -0
  352. package/dist/compiler/AstCompiler/internal/exprs/_hasDuplicateTypeParams.js +13 -0
  353. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileAddExpr.d.ts +5 -0
  354. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileAddExpr.js +20 -0
  355. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileBitwiseAndExpr.d.ts +5 -0
  356. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileBitwiseAndExpr.js +20 -0
  357. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileBitwiseOrExpr.d.ts +5 -0
  358. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileBitwiseOrExpr.js +20 -0
  359. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileBitwiseXorExpr.d.ts +5 -0
  360. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileBitwiseXorExpr.js +20 -0
  361. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileDivExpr.d.ts +5 -0
  362. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileDivExpr.js +20 -0
  363. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileEqualExpr.d.ts +5 -0
  364. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileEqualExpr.js +18 -0
  365. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileExponentiationExpr.d.ts +5 -0
  366. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileExponentiationExpr.js +20 -0
  367. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileGreaterThanEqualExpr.d.ts +5 -0
  368. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileGreaterThanEqualExpr.js +27 -0
  369. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileGreaterThanExpr.d.ts +5 -0
  370. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileGreaterThanExpr.js +26 -0
  371. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLessThanEqualExpr.d.ts +5 -0
  372. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLessThanEqualExpr.js +25 -0
  373. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLessThanExpr.d.ts +5 -0
  374. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLessThanExpr.js +26 -0
  375. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLogicalAndExpr.d.ts +5 -0
  376. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLogicalAndExpr.js +22 -0
  377. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLogicalOrExpr.d.ts +5 -0
  378. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileLogicalOrExpr.js +22 -0
  379. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileModuloExpr.d.ts +5 -0
  380. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileModuloExpr.js +20 -0
  381. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileMultExpr.d.ts +5 -0
  382. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileMultExpr.js +20 -0
  383. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileNotEqualExpr.d.ts +5 -0
  384. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileNotEqualExpr.js +18 -0
  385. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileOptionalDefaultExpr.d.ts +5 -0
  386. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileOptionalDefaultExpr.js +60 -0
  387. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileShiftLeftExpr.d.ts +5 -0
  388. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileShiftLeftExpr.js +21 -0
  389. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileShiftRightExpr.d.ts +5 -0
  390. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileShiftRightExpr.js +21 -0
  391. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileSubExpr.d.ts +5 -0
  392. package/dist/compiler/AstCompiler/internal/exprs/binary/_compileSubExpr.js +20 -0
  393. package/dist/compiler/AstCompiler/internal/statements/_compileAssertStmt.d.ts +4 -0
  394. package/dist/compiler/AstCompiler/internal/statements/_compileAssertStmt.js +30 -0
  395. package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.d.ts +8 -0
  396. package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +154 -0
  397. package/dist/compiler/AstCompiler/internal/statements/_compileBlockStmt.d.ts +4 -0
  398. package/dist/compiler/AstCompiler/internal/statements/_compileBlockStmt.js +14 -0
  399. package/dist/compiler/AstCompiler/internal/statements/_compileBreakStmt.d.ts +4 -0
  400. package/dist/compiler/AstCompiler/internal/statements/_compileBreakStmt.js +7 -0
  401. package/dist/compiler/AstCompiler/internal/statements/_compileContinueStmt.d.ts +4 -0
  402. package/dist/compiler/AstCompiler/internal/statements/_compileContinueStmt.js +7 -0
  403. package/dist/compiler/AstCompiler/internal/statements/_compileExprStmt.d.ts +1 -0
  404. package/dist/compiler/AstCompiler/internal/statements/_compileExprStmt.js +12 -0
  405. package/dist/compiler/AstCompiler/internal/statements/_compileFailStmt.d.ts +4 -0
  406. package/dist/compiler/AstCompiler/internal/statements/_compileFailStmt.js +18 -0
  407. package/dist/compiler/AstCompiler/internal/statements/_compileForOfStmt.d.ts +4 -0
  408. package/dist/compiler/AstCompiler/internal/statements/_compileForOfStmt.js +30 -0
  409. package/dist/compiler/AstCompiler/internal/statements/_compileForStmt.d.ts +7 -0
  410. package/dist/compiler/AstCompiler/internal/statements/_compileForStmt.js +46 -0
  411. package/dist/compiler/AstCompiler/internal/statements/_compileIfStmt.d.ts +4 -0
  412. package/dist/compiler/AstCompiler/internal/statements/_compileIfStmt.js +27 -0
  413. package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.d.ts +6 -0
  414. package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.js +182 -0
  415. package/dist/compiler/AstCompiler/internal/statements/_compileReturnStmt.d.ts +4 -0
  416. package/dist/compiler/AstCompiler/internal/statements/_compileReturnStmt.js +17 -0
  417. package/dist/compiler/AstCompiler/internal/statements/_compileStatement.d.ts +11 -0
  418. package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +73 -0
  419. package/dist/compiler/AstCompiler/internal/statements/_compileTestStmt.d.ts +1 -0
  420. package/dist/compiler/AstCompiler/internal/statements/_compileTestStmt.js +32 -0
  421. package/dist/compiler/AstCompiler/internal/statements/_compileUsingStmt.d.ts +11 -0
  422. package/dist/compiler/AstCompiler/internal/statements/_compileUsingStmt.js +41 -0
  423. package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.d.ts +34 -0
  424. package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.js +207 -0
  425. package/dist/compiler/AstCompiler/internal/statements/_compileWhileStmt.d.ts +4 -0
  426. package/dist/compiler/AstCompiler/internal/statements/_compileWhileStmt.js +19 -0
  427. package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.d.ts +4 -0
  428. package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.js +61 -0
  429. package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.d.ts +4 -0
  430. package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.js +59 -0
  431. package/dist/compiler/AstCompiler/scope/AstScope.d.ts +102 -0
  432. package/dist/compiler/AstCompiler/scope/AstScope.js +195 -0
  433. package/dist/compiler/AstCompiler/utils/deps/ResolveStackNode.d.ts +14 -0
  434. package/dist/compiler/AstCompiler/utils/deps/ResolveStackNode.js +36 -0
  435. package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.d.ts +4 -0
  436. package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +121 -0
  437. package/dist/compiler/AstCompiler/utils/getTirFuncSigTree/TirFuncSigTree.d.ts +39 -0
  438. package/dist/compiler/AstCompiler/utils/getTirFuncSigTree/TirFuncSigTree.js +129 -0
  439. package/dist/compiler/AstCompiler/utils/getTirFuncSigTree/getTirFuncSigTree.d.ts +4 -0
  440. package/dist/compiler/AstCompiler/utils/getTirFuncSigTree/getTirFuncSigTree.js +49 -0
  441. package/dist/compiler/AstCompiler/utils/wrapManyStatementsOrReturnSame.d.ts +3 -0
  442. package/dist/compiler/AstCompiler/utils/wrapManyStatementsOrReturnSame.js +12 -0
  443. package/dist/compiler/Compiler.d.ts +10 -0
  444. package/dist/compiler/Compiler.js +42 -0
  445. package/dist/compiler/TirCompiler/TirCompilerCtx.d.ts +7 -0
  446. package/dist/compiler/TirCompiler/TirCompilerCtx.js +8 -0
  447. package/dist/compiler/TirCompiler/compileTirProgram.d.ts +9 -0
  448. package/dist/compiler/TirCompiler/compileTirProgram.js +18 -0
  449. package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +72 -0
  450. package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +282 -0
  451. package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.d.ts +27 -0
  452. package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +248 -0
  453. package/dist/compiler/TirCompiler/expressify/expressify.d.ts +15 -0
  454. package/dist/compiler/TirCompiler/expressify/expressify.js +403 -0
  455. package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +8 -0
  456. package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +115 -0
  457. package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.d.ts +6 -0
  458. package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +105 -0
  459. package/dist/compiler/TirCompiler/expressify/expressifyTerminatingIfStmt.d.ts +5 -0
  460. package/dist/compiler/TirCompiler/expressify/expressifyTerminatingIfStmt.js +15 -0
  461. package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.d.ts +4 -0
  462. package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +20 -0
  463. package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.d.ts +3 -0
  464. package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +34 -0
  465. package/dist/compiler/TirCompiler/expressify/expressifyVars.d.ts +10 -0
  466. package/dist/compiler/TirCompiler/expressify/expressifyVars.js +320 -0
  467. package/dist/compiler/TirCompiler/expressify/flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct.d.ts +9 -0
  468. package/dist/compiler/TirCompiler/expressify/flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct.js +59 -0
  469. package/dist/compiler/TirCompiler/expressify/isSingleConstrStruct.d.ts +3 -0
  470. package/dist/compiler/TirCompiler/expressify/isSingleConstrStruct.js +9 -0
  471. package/dist/compiler/TirCompiler/expressify/toNamedDeconstructVarDecl.d.ts +3 -0
  472. package/dist/compiler/TirCompiler/expressify/toNamedDeconstructVarDecl.js +15 -0
  473. package/dist/compiler/TirCompiler/index.d.ts +2 -0
  474. package/dist/compiler/TirCompiler/index.js +2 -0
  475. package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.d.ts +5 -0
  476. package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +37 -0
  477. package/dist/compiler/TirCompiler/internal/deps/DepsNode.d.ts +13 -0
  478. package/dist/compiler/TirCompiler/internal/deps/DepsNode.js +36 -0
  479. package/dist/compiler/index.d.ts +4 -0
  480. package/dist/compiler/index.js +4 -0
  481. package/dist/compiler/internalVar.d.ts +19 -0
  482. package/dist/compiler/internalVar.js +56 -0
  483. package/dist/compiler/io/CompilerIoApi.d.ts +36 -0
  484. package/dist/compiler/io/CompilerIoApi.js +62 -0
  485. package/dist/compiler/io/IOutputStream.d.ts +28 -0
  486. package/dist/compiler/io/IOutputStream.js +45 -0
  487. package/dist/compiler/io/index.d.ts +2 -0
  488. package/dist/compiler/io/index.js +2 -0
  489. package/dist/compiler/path/getAbsolutePath.d.ts +12 -0
  490. package/dist/compiler/path/getAbsolutePath.js +114 -0
  491. package/dist/compiler/path/path.d.ts +5 -0
  492. package/dist/compiler/path/path.js +160 -0
  493. package/dist/compiler/tir/expressions/ITirExpr.d.ts +11 -0
  494. package/dist/compiler/tir/expressions/ITirExpr.js +1 -0
  495. package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.d.ts +19 -0
  496. package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.js +41 -0
  497. package/dist/compiler/tir/expressions/TirCallExpr.d.ts +17 -0
  498. package/dist/compiler/tir/expressions/TirCallExpr.js +28 -0
  499. package/dist/compiler/tir/expressions/TirCaseExpr.d.ts +36 -0
  500. package/dist/compiler/tir/expressions/TirCaseExpr.js +257 -0
  501. package/dist/compiler/tir/expressions/TirElemAccessExpr.d.ts +20 -0
  502. package/dist/compiler/tir/expressions/TirElemAccessExpr.js +43 -0
  503. package/dist/compiler/tir/expressions/TirExpr.d.ts +23 -0
  504. package/dist/compiler/tir/expressions/TirExpr.js +46 -0
  505. package/dist/compiler/tir/expressions/TirFailExpr.d.ts +19 -0
  506. package/dist/compiler/tir/expressions/TirFailExpr.js +28 -0
  507. package/dist/compiler/tir/expressions/TirFromDataExpr.d.ts +22 -0
  508. package/dist/compiler/tir/expressions/TirFromDataExpr.js +196 -0
  509. package/dist/compiler/tir/expressions/TirFuncExpr.d.ts +37 -0
  510. package/dist/compiler/tir/expressions/TirFuncExpr.js +92 -0
  511. package/dist/compiler/tir/expressions/TirHoistedExpr.d.ts +18 -0
  512. package/dist/compiler/tir/expressions/TirHoistedExpr.js +28 -0
  513. package/dist/compiler/tir/expressions/TirInlineClosedIR.d.ts +16 -0
  514. package/dist/compiler/tir/expressions/TirInlineClosedIR.js +25 -0
  515. package/dist/compiler/tir/expressions/TirLettedExpr.d.ts +18 -0
  516. package/dist/compiler/tir/expressions/TirLettedExpr.js +28 -0
  517. package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +104 -0
  518. package/dist/compiler/tir/expressions/TirNativeFunc.js +805 -0
  519. package/dist/compiler/tir/expressions/TirParentesizedExpr.d.ts +17 -0
  520. package/dist/compiler/tir/expressions/TirParentesizedExpr.js +20 -0
  521. package/dist/compiler/tir/expressions/TirPropAccessExpr.d.ts +18 -0
  522. package/dist/compiler/tir/expressions/TirPropAccessExpr.js +29 -0
  523. package/dist/compiler/tir/expressions/TirTernaryExpr.d.ts +18 -0
  524. package/dist/compiler/tir/expressions/TirTernaryExpr.js +36 -0
  525. package/dist/compiler/tir/expressions/TirToDataExpr.d.ts +28 -0
  526. package/dist/compiler/tir/expressions/TirToDataExpr.js +172 -0
  527. package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.d.ts +23 -0
  528. package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.js +32 -0
  529. package/dist/compiler/tir/expressions/TirTypeConversionExpr.d.ts +16 -0
  530. package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +66 -0
  531. package/dist/compiler/tir/expressions/TirVariableAccessExpr.d.ts +18 -0
  532. package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +30 -0
  533. package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +29 -0
  534. package/dist/compiler/tir/expressions/ToIRTermCtx.js +77 -0
  535. package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +221 -0
  536. package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +532 -0
  537. package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.d.ts +16 -0
  538. package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.js +60 -0
  539. package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.d.ts +14 -0
  540. package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.js +17 -0
  541. package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.d.ts +15 -0
  542. package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.js +19 -0
  543. package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.d.ts +15 -0
  544. package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.js +19 -0
  545. package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.d.ts +22 -0
  546. package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.js +105 -0
  547. package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.d.ts +22 -0
  548. package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.js +102 -0
  549. package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.d.ts +15 -0
  550. package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.js +20 -0
  551. package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.d.ts +14 -0
  552. package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.js +20 -0
  553. package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.d.ts +14 -0
  554. package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.js +17 -0
  555. package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.d.ts +18 -0
  556. package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.js +23 -0
  557. package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.d.ts +14 -0
  558. package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.js +17 -0
  559. package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.d.ts +13 -0
  560. package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.js +24 -0
  561. package/dist/compiler/tir/expressions/unary/ITirUnaryExpression.d.ts +4 -0
  562. package/dist/compiler/tir/expressions/unary/ITirUnaryExpression.js +1 -0
  563. package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.d.ts +17 -0
  564. package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.js +23 -0
  565. package/dist/compiler/tir/expressions/unary/TirUnaryMinus.d.ts +17 -0
  566. package/dist/compiler/tir/expressions/unary/TirUnaryMinus.js +22 -0
  567. package/dist/compiler/tir/expressions/unary/TirUnaryPlus.d.ts +15 -0
  568. package/dist/compiler/tir/expressions/unary/TirUnaryPlus.js +20 -0
  569. package/dist/compiler/tir/expressions/unary/TirUnaryPrefixExpr.d.ts +6 -0
  570. package/dist/compiler/tir/expressions/unary/TirUnaryPrefixExpr.js +10 -0
  571. package/dist/compiler/tir/expressions/unary/TirUnaryTilde.d.ts +17 -0
  572. package/dist/compiler/tir/expressions/unary/TirUnaryTilde.js +22 -0
  573. package/dist/compiler/tir/expressions/utils/NamedExpr.d.ts +5 -0
  574. package/dist/compiler/tir/expressions/utils/NamedExpr.js +1 -0
  575. package/dist/compiler/tir/program/TypedProgram.d.ts +44 -0
  576. package/dist/compiler/tir/program/TypedProgram.js +126 -0
  577. package/dist/compiler/tir/program/stdScope/StdTypes.d.ts +34 -0
  578. package/dist/compiler/tir/program/stdScope/StdTypes.js +40 -0
  579. package/dist/compiler/tir/program/stdScope/prelude/preludeTypesSrc.d.ts +0 -0
  580. package/dist/compiler/tir/program/stdScope/prelude/preludeTypesSrc.js +288 -0
  581. package/dist/compiler/tir/program/stdScope/stdScope.d.ts +15 -0
  582. package/dist/compiler/tir/program/stdScope/stdScope.js +730 -0
  583. package/dist/compiler/tir/statements/TirAssertStmt.d.ts +18 -0
  584. package/dist/compiler/tir/statements/TirAssertStmt.js +29 -0
  585. package/dist/compiler/tir/statements/TirAssignmentStmt.d.ts +12 -0
  586. package/dist/compiler/tir/statements/TirAssignmentStmt.js +14 -0
  587. package/dist/compiler/tir/statements/TirBlockStmt.d.ts +9 -0
  588. package/dist/compiler/tir/statements/TirBlockStmt.js +25 -0
  589. package/dist/compiler/tir/statements/TirBreakStmt.d.ts +8 -0
  590. package/dist/compiler/tir/statements/TirBreakStmt.js +11 -0
  591. package/dist/compiler/tir/statements/TirContinueStmt.d.ts +8 -0
  592. package/dist/compiler/tir/statements/TirContinueStmt.js +13 -0
  593. package/dist/compiler/tir/statements/TirFailStmt.d.ts +13 -0
  594. package/dist/compiler/tir/statements/TirFailStmt.js +14 -0
  595. package/dist/compiler/tir/statements/TirForOfStmt.d.ts +16 -0
  596. package/dist/compiler/tir/statements/TirForOfStmt.js +25 -0
  597. package/dist/compiler/tir/statements/TirForStmt.d.ts +19 -0
  598. package/dist/compiler/tir/statements/TirForStmt.js +39 -0
  599. package/dist/compiler/tir/statements/TirIfStmt.d.ts +12 -0
  600. package/dist/compiler/tir/statements/TirIfStmt.js +23 -0
  601. package/dist/compiler/tir/statements/TirMatchStmt.d.ts +27 -0
  602. package/dist/compiler/tir/statements/TirMatchStmt.js +51 -0
  603. package/dist/compiler/tir/statements/TirReturnStmt.d.ts +10 -0
  604. package/dist/compiler/tir/statements/TirReturnStmt.js +12 -0
  605. package/dist/compiler/tir/statements/TirStmt.d.ts +32 -0
  606. package/dist/compiler/tir/statements/TirStmt.js +40 -0
  607. package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.d.ts +17 -0
  608. package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.js +30 -0
  609. package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.d.ts +21 -0
  610. package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js +34 -0
  611. package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.d.ts +17 -0
  612. package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.js +22 -0
  613. package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.d.ts +17 -0
  614. package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js +30 -0
  615. package/dist/compiler/tir/statements/TirVarDecl/TirVarDecl.d.ts +10 -0
  616. package/dist/compiler/tir/statements/TirVarDecl/TirVarDecl.js +11 -0
  617. package/dist/compiler/tir/statements/TirWhileStmt.d.ts +11 -0
  618. package/dist/compiler/tir/statements/TirWhileStmt.js +19 -0
  619. package/dist/compiler/tir/statements/utils/definitelyFails.d.ts +3 -0
  620. package/dist/compiler/tir/statements/utils/definitelyFails.js +52 -0
  621. package/dist/compiler/tir/types/TirAliasType.d.ts +32 -0
  622. package/dist/compiler/tir/types/TirAliasType.js +49 -0
  623. package/dist/compiler/tir/types/TirInterfaceImpl.d.ts +44 -0
  624. package/dist/compiler/tir/types/TirInterfaceImpl.js +32 -0
  625. package/dist/compiler/tir/types/TirInterfaceType.d.ts +28 -0
  626. package/dist/compiler/tir/types/TirInterfaceType.js +36 -0
  627. package/dist/compiler/tir/types/TirNativeType/TirNativeType.d.ts +41 -0
  628. package/dist/compiler/tir/types/TirNativeType/TirNativeType.js +86 -0
  629. package/dist/compiler/tir/types/TirNativeType/index.d.ts +2 -0
  630. package/dist/compiler/tir/types/TirNativeType/index.js +2 -0
  631. package/dist/compiler/tir/types/TirNativeType/native/Optional/data.d.ts +17 -0
  632. package/dist/compiler/tir/types/TirNativeType/native/Optional/data.js +47 -0
  633. package/dist/compiler/tir/types/TirNativeType/native/Optional/index.d.ts +3 -0
  634. package/dist/compiler/tir/types/TirNativeType/native/Optional/index.js +3 -0
  635. package/dist/compiler/tir/types/TirNativeType/native/Optional/isTirOptType.d.ts +4 -0
  636. package/dist/compiler/tir/types/TirNativeType/native/Optional/isTirOptType.js +6 -0
  637. package/dist/compiler/tir/types/TirNativeType/native/Optional/sop.d.ts +17 -0
  638. package/dist/compiler/tir/types/TirNativeType/native/Optional/sop.js +48 -0
  639. package/dist/compiler/tir/types/TirNativeType/native/bool.d.ts +13 -0
  640. package/dist/compiler/tir/types/TirNativeType/native/bool.js +12 -0
  641. package/dist/compiler/tir/types/TirNativeType/native/bytes.d.ts +13 -0
  642. package/dist/compiler/tir/types/TirNativeType/native/bytes.js +12 -0
  643. package/dist/compiler/tir/types/TirNativeType/native/data.d.ts +13 -0
  644. package/dist/compiler/tir/types/TirNativeType/native/data.js +12 -0
  645. package/dist/compiler/tir/types/TirNativeType/native/function.d.ts +16 -0
  646. package/dist/compiler/tir/types/TirNativeType/native/function.js +38 -0
  647. package/dist/compiler/tir/types/TirNativeType/native/index.d.ts +10 -0
  648. package/dist/compiler/tir/types/TirNativeType/native/index.js +10 -0
  649. package/dist/compiler/tir/types/TirNativeType/native/int.d.ts +13 -0
  650. package/dist/compiler/tir/types/TirNativeType/native/int.js +12 -0
  651. package/dist/compiler/tir/types/TirNativeType/native/linearMap.d.ts +17 -0
  652. package/dist/compiler/tir/types/TirNativeType/native/linearMap.js +44 -0
  653. package/dist/compiler/tir/types/TirNativeType/native/list.d.ts +16 -0
  654. package/dist/compiler/tir/types/TirNativeType/native/list.js +38 -0
  655. package/dist/compiler/tir/types/TirNativeType/native/string.d.ts +13 -0
  656. package/dist/compiler/tir/types/TirNativeType/native/string.js +12 -0
  657. package/dist/compiler/tir/types/TirNativeType/native/void.d.ts +13 -0
  658. package/dist/compiler/tir/types/TirNativeType/native/void.js +12 -0
  659. package/dist/compiler/tir/types/TirStructType.d.ts +68 -0
  660. package/dist/compiler/tir/types/TirStructType.js +128 -0
  661. package/dist/compiler/tir/types/TirType.d.ts +34 -0
  662. package/dist/compiler/tir/types/TirType.js +16 -0
  663. package/dist/compiler/tir/types/TirTypeParam.d.ts +18 -0
  664. package/dist/compiler/tir/types/TirTypeParam.js +39 -0
  665. package/dist/compiler/tir/types/utils/canAssignTo.d.ts +24 -0
  666. package/dist/compiler/tir/types/utils/canAssignTo.js +337 -0
  667. package/dist/compiler/tir/types/utils/canCastTo.d.ts +9 -0
  668. package/dist/compiler/tir/types/utils/canCastTo.js +155 -0
  669. package/dist/compiler/tir/types/utils/getDeconstructableType.d.ts +9 -0
  670. package/dist/compiler/tir/types/utils/getDeconstructableType.js +20 -0
  671. package/dist/compiler/tir/types/utils/getListTypeArg.d.ts +2 -0
  672. package/dist/compiler/tir/types/utils/getListTypeArg.js +9 -0
  673. package/dist/compiler/tir/types/utils/getOptTypeArg.d.ts +2 -0
  674. package/dist/compiler/tir/types/utils/getOptTypeArg.js +14 -0
  675. package/dist/compiler/tir/types/utils/getUnaliased.d.ts +3 -0
  676. package/dist/compiler/tir/types/utils/getUnaliased.js +9 -0
  677. package/dist/diagnostics/DiagnosticCategory.d.ts +16 -0
  678. package/dist/diagnostics/DiagnosticCategory.js +39 -0
  679. package/dist/diagnostics/DiagnosticEmitter.d.ts +32 -0
  680. package/dist/diagnostics/DiagnosticEmitter.js +95 -0
  681. package/dist/diagnostics/DiagnosticMessage.d.ts +37 -0
  682. package/dist/diagnostics/DiagnosticMessage.js +229 -0
  683. package/dist/diagnostics/diagnosticMessages.generated.d.ts +275 -0
  684. package/dist/diagnostics/diagnosticMessages.generated.js +551 -0
  685. package/dist/diagnostics/utils/types.d.ts +5 -0
  686. package/dist/diagnostics/utils/types.js +1 -0
  687. package/dist/index.d.ts +12 -0
  688. package/dist/index.js +13 -0
  689. package/dist/parser/Parser.d.ts +150 -0
  690. package/dist/parser/Parser.js +2416 -0
  691. package/dist/parser/Precedence.d.ts +38 -0
  692. package/dist/parser/Precedence.js +98 -0
  693. package/dist/parser/hoistStatementsInplace.d.ts +14 -0
  694. package/dist/parser/hoistStatementsInplace.js +94 -0
  695. package/dist/parser/index.d.ts +1 -0
  696. package/dist/parser/index.js +1 -0
  697. package/dist/parser/parseFile.d.ts +3 -0
  698. package/dist/parser/parseFile.js +8 -0
  699. package/dist/tokenizer/IdentifierHandling.d.ts +5 -0
  700. package/dist/tokenizer/IdentifierHandling.js +6 -0
  701. package/dist/tokenizer/OnNewLine.d.ts +6 -0
  702. package/dist/tokenizer/OnNewLine.js +8 -0
  703. package/dist/tokenizer/Token.d.ts +160 -0
  704. package/dist/tokenizer/Token.js +213 -0
  705. package/dist/tokenizer/Tokenizer.d.ts +129 -0
  706. package/dist/tokenizer/Tokenizer.js +1323 -0
  707. package/dist/tokenizer/TokenizerState.d.ts +17 -0
  708. package/dist/tokenizer/TokenizerState.js +17 -0
  709. package/dist/tokenizer/index.d.ts +2 -0
  710. package/dist/tokenizer/index.js +2 -0
  711. package/dist/tokenizer/utils/isIllegalVariableIdentifier.d.ts +1 -0
  712. package/dist/tokenizer/utils/isIllegalVariableIdentifier.js +12 -0
  713. package/dist/tokenizer/utils/operatorTokenToString.d.ts +2 -0
  714. package/dist/tokenizer/utils/operatorTokenToString.js +57 -0
  715. package/dist/tokenizer/utils/tokenFromKeyword.d.ts +2 -0
  716. package/dist/tokenizer/utils/tokenFromKeyword.js +222 -0
  717. package/dist/tokenizer/utils/tokenIsAlsoIdentifier.d.ts +2 -0
  718. package/dist/tokenizer/utils/tokenIsAlsoIdentifier.js +24 -0
  719. package/dist/utils/BasePlutsError.d.ts +2 -0
  720. package/dist/utils/BasePlutsError.js +2 -0
  721. package/dist/utils/BitUtils/index.d.ts +30 -0
  722. package/dist/utils/BitUtils/index.js +60 -0
  723. package/dist/utils/CharCode.d.ts +125 -0
  724. package/dist/utils/CharCode.js +1 -0
  725. package/dist/utils/Cloneable.d.ts +6 -0
  726. package/dist/utils/Cloneable.js +4 -0
  727. package/dist/utils/InvalidCborFormatError.d.ts +3 -0
  728. package/dist/utils/InvalidCborFormatError.js +5 -0
  729. package/dist/utils/IsSingleKey.d.ts +7 -0
  730. package/dist/utils/IsSingleKey.js +1 -0
  731. package/dist/utils/MaybePromise.d.ts +2 -0
  732. package/dist/utils/MaybePromise.js +4 -0
  733. package/dist/utils/PlutusScriptType.d.ts +12 -0
  734. package/dist/utils/PlutusScriptType.js +1 -0
  735. package/dist/utils/ToJson.d.ts +4 -0
  736. package/dist/utils/ToJson.js +5 -0
  737. package/dist/utils/UPLCFlatUtils/index.d.ts +46 -0
  738. package/dist/utils/UPLCFlatUtils/index.js +124 -0
  739. package/dist/utils/array/filterSortedStrArrInplace.d.ts +7 -0
  740. package/dist/utils/array/filterSortedStrArrInplace.js +46 -0
  741. package/dist/utils/array/keepSortedArrInplace.d.ts +7 -0
  742. package/dist/utils/array/keepSortedArrInplace.js +49 -0
  743. package/dist/utils/array/mergeSortedStrArrInplace.d.ts +6 -0
  744. package/dist/utils/array/mergeSortedStrArrInplace.js +52 -0
  745. package/dist/utils/assert.d.ts +1 -0
  746. package/dist/utils/assert.js +5 -0
  747. package/dist/utils/capitalize.d.ts +1 -0
  748. package/dist/utils/capitalize.js +5 -0
  749. package/dist/utils/combinators.d.ts +37 -0
  750. package/dist/utils/combinators.js +76 -0
  751. package/dist/utils/getCallStackAt/index.d.ts +43 -0
  752. package/dist/utils/getCallStackAt/index.js +295 -0
  753. package/dist/utils/hex.d.ts +1 -0
  754. package/dist/utils/hex.js +6 -0
  755. package/dist/utils/ints.d.ts +4 -0
  756. package/dist/utils/ints.js +19 -0
  757. package/dist/utils/isNonEmpty.d.ts +1 -0
  758. package/dist/utils/isNonEmpty.js +3 -0
  759. package/dist/utils/maybeData.d.ts +4 -0
  760. package/dist/utils/maybeData.js +10 -0
  761. package/dist/utils/stringify.d.ts +2 -0
  762. package/dist/utils/stringify.js +31 -0
  763. package/dist/utils/terminal.d.ts +28 -0
  764. package/dist/utils/terminal.js +38 -0
  765. package/dist/utils/text.d.ts +172 -0
  766. package/dist/utils/text.js +672 -0
  767. package/dist/utils/types.d.ts +12 -0
  768. package/dist/utils/types.js +1 -0
  769. package/package.json +1 -1
@@ -0,0 +1,403 @@
1
+ import { SourceRange } from "../../../ast/Source/SourceRange.js";
2
+ import { getUniqueInternalName } from "../../internalVar.js";
3
+ import { TirLitVoidExpr } from "../../tir/expressions/litteral/TirLitVoidExpr.js";
4
+ import { TirCaseExpr, TirCaseMatcher, TirWildcardCaseMatcher } from "../../tir/expressions/TirCaseExpr.js";
5
+ import { TirFailExpr } from "../../tir/expressions/TirFailExpr.js";
6
+ import { TirLettedExpr } from "../../tir/expressions/TirLettedExpr.js";
7
+ import { TirVariableAccessExpr } from "../../tir/expressions/TirVariableAccessExpr.js";
8
+ import { TirAssertStmt } from "../../tir/statements/TirAssertStmt.js";
9
+ import { TirAssignmentStmt } from "../../tir/statements/TirAssignmentStmt.js";
10
+ import { TirBlockStmt } from "../../tir/statements/TirBlockStmt.js";
11
+ import { TirBreakStmt } from "../../tir/statements/TirBreakStmt.js";
12
+ import { TirContinueStmt } from "../../tir/statements/TirContinueStmt.js";
13
+ import { TirFailStmt } from "../../tir/statements/TirFailStmt.js";
14
+ import { TirForOfStmt } from "../../tir/statements/TirForOfStmt.js";
15
+ import { TirForStmt } from "../../tir/statements/TirForStmt.js";
16
+ import { TirIfStmt } from "../../tir/statements/TirIfStmt.js";
17
+ import { TirMatchStmt } from "../../tir/statements/TirMatchStmt.js";
18
+ import { TirReturnStmt } from "../../tir/statements/TirReturnStmt.js";
19
+ import { TirArrayLikeDeconstr } from "../../tir/statements/TirVarDecl/TirArrayLikeDeconstr.js";
20
+ import { TirNamedDeconstructVarDecl } from "../../tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js";
21
+ import { TirSimpleVarDecl } from "../../tir/statements/TirVarDecl/TirSimpleVarDecl.js";
22
+ import { TirSingleDeconstructVarDecl } from "../../tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js";
23
+ import { TirWhileStmt } from "../../tir/statements/TirWhileStmt.js";
24
+ import { TirDataStructType, TirSoPStructType } from "../../tir/types/TirStructType.js";
25
+ import { ExpressifyCtx } from "./ExpressifyCtx.js";
26
+ import { expressifyVarAssignmentStmt } from "./expressifyVarAssignmentStmt.js";
27
+ import { isSingleConstrStruct } from "./isSingleConstrStruct.js";
28
+ import { expressifyVars } from "./expressifyVars.js";
29
+ import { toNamedDeconstructVarDecl } from "./toNamedDeconstructVarDecl.js";
30
+ import { flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct } from "./flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct.js";
31
+ import { TirAssertAndContinueExpr } from "../../tir/expressions/TirAssertAndContinueExpr.js";
32
+ import { expressifyTerminatingIfStmt } from "./expressifyTerminatingIfStmt.js";
33
+ import { determineReassignedVariablesAndFlowInfos, determineReassignedVariablesAndReturn, getBodyStateType, getBranchStmtReturnType } from "./determineReassignedVariablesAndReturn.js";
34
+ import { TirTernaryExpr } from "../../tir/expressions/TirTernaryExpr.js";
35
+ import { expressifyIfBranch } from "./expressifyIfBranch.js";
36
+ import { expressifyForStmt, whileToFor } from "./expressifyForStmt.js";
37
+ import { getListTypeArg } from "../../tir/types/utils/getListTypeArg.js";
38
+ import { TirElemAccessExpr } from "../../tir/expressions/TirElemAccessExpr.js";
39
+ import { TirLitIntExpr } from "../../tir/expressions/litteral/TirLitIntExpr.js";
40
+ import { TirCallExpr } from "../../tir/expressions/TirCallExpr.js";
41
+ import { TirNativeFunc } from "../../tir/expressions/TirNativeFunc.js";
42
+ export function expressify(func, loopReplacements, parentCtx = undefined) {
43
+ const ctx = new ExpressifyCtx(parentCtx, func.returnType);
44
+ ctx.introduceFuncParams(func.params);
45
+ func.body.stmts = [
46
+ new TirReturnStmt(expressifyFuncBody(ctx, func.body.stmts, loopReplacements), func.body.range)
47
+ ];
48
+ }
49
+ export function expressifyFuncBody(ctx, bodyStmts,
50
+ // passed when compiling loops
51
+ loopReplacements, assertions = []) {
52
+ bodyStmts = bodyStmts.slice();
53
+ let stmt;
54
+ while (stmt = bodyStmts.shift()) {
55
+ if (stmt instanceof TirBreakStmt) {
56
+ if (typeof loopReplacements?.compileBreak !== "function")
57
+ throw new Error("break statement in function body.");
58
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, loopReplacements.compileBreak(ctx, stmt));
59
+ }
60
+ else if (stmt instanceof TirContinueStmt) {
61
+ if (typeof loopReplacements?.compileContinue !== "function")
62
+ throw new Error("continue statement in function body.");
63
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, loopReplacements.compileContinue(ctx, stmt));
64
+ }
65
+ else if (stmt instanceof TirReturnStmt) {
66
+ if (stmt.value) {
67
+ let modifiedExpr = expressifyVars(ctx, stmt.value);
68
+ if (typeof loopReplacements?.replaceReturnValue === "function") {
69
+ modifiedExpr = loopReplacements.replaceReturnValue(ctx, stmt);
70
+ }
71
+ stmt.value = modifiedExpr;
72
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, modifiedExpr);
73
+ }
74
+ else
75
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, new TirLitVoidExpr(stmt.range));
76
+ }
77
+ // if( isTirVarDecl( stmt ) ) expressifyVarDecl( ctx, stmt );
78
+ else if (stmt instanceof TirSimpleVarDecl) {
79
+ if (!stmt.initExpr)
80
+ throw new Error("simple var decl without init expr");
81
+ const initExpr = expressifyVars(ctx, stmt.initExpr);
82
+ stmt.initExpr = initExpr;
83
+ const lettedExpr = ctx.introduceLettedConstant(stmt.name, initExpr, stmt.range);
84
+ if (!isSingleConstrStruct(stmt.type))
85
+ continue;
86
+ if ((initExpr instanceof TirVariableAccessExpr || initExpr instanceof TirLettedExpr)
87
+ && ctx.properties.has(initExpr.varName))
88
+ continue; // field extraction was already done
89
+ if (stmt.type instanceof TirSoPStructType) {
90
+ const pattern = getConstrDestructPattern(stmt.type, stmt.range, undefined, // no init expr (pattern is used as case matcher)
91
+ 0);
92
+ ctx.introduceSopConstrFieldsAsProperties(stmt.name, pattern);
93
+ // nested single constr structs
94
+ // are added as destructed variables in the matcher body
95
+ // using `getNestedDestructsInSingleSopDestructPattern`
96
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, new TirCaseExpr(lettedExpr, [new TirCaseMatcher(pattern, expressifyFuncBody(ctx, getNestedDestructsInSingleSopDestructPattern(pattern)
97
+ .concat(bodyStmts), loopReplacements), stmt.range)], undefined, // no wildcard case
98
+ ctx.returnType, stmt.range));
99
+ }
100
+ else if (stmt.type instanceof TirDataStructType) {
101
+ ctx.introduceSingleConstrDataLettedFields(stmt.name, stmt.initExpr, stmt.type);
102
+ continue;
103
+ }
104
+ continue;
105
+ }
106
+ else if (stmt instanceof TirSingleDeconstructVarDecl
107
+ || stmt instanceof TirNamedDeconstructVarDecl) {
108
+ stmt = toNamedDeconstructVarDecl(stmt);
109
+ // for some reason typescript goes crazy with types here
110
+ if (stmt instanceof TirBreakStmt)
111
+ throw new Error("unreachable");
112
+ else if (stmt instanceof TirContinueStmt)
113
+ throw new Error("unreachable");
114
+ else if (stmt instanceof TirSingleDeconstructVarDecl)
115
+ throw new Error("unreachable");
116
+ if (!stmt.initExpr)
117
+ throw new Error("simple var decl without init expr");
118
+ const initExpr = expressifyVars(ctx, stmt.initExpr);
119
+ stmt.initExpr = initExpr;
120
+ const lettedName = getUniqueInternalName(stmt.type.toString().toLowerCase());
121
+ const lettedExpr = ctx.introduceLettedConstant(lettedName, initExpr, stmt.range);
122
+ if (stmt.type instanceof TirSoPStructType) {
123
+ const nestedDeconstructs = flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct(stmt, ctx);
124
+ // nested single constr structs
125
+ // are added as destructed variables in the matcher body
126
+ // using `getNestedDestructsInSingleSopDestructPattern`
127
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, new TirCaseExpr(lettedExpr, [new TirCaseMatcher(stmt, expressifyFuncBody(ctx, nestedDeconstructs
128
+ .concat(bodyStmts), loopReplacements), stmt.range)], new TirWildcardCaseMatcher(new TirFailExpr(undefined, ctx.returnType, stmt.range), stmt.range), ctx.returnType, stmt.range));
129
+ }
130
+ else if (stmt.type instanceof TirDataStructType) {
131
+ assertions.push(...ctx.introduceDeconstrDataLettedFields(toNamedDeconstructVarDecl(stmt)));
132
+ continue;
133
+ }
134
+ }
135
+ else if (stmt instanceof TirArrayLikeDeconstr) {
136
+ if (!stmt.initExpr)
137
+ throw new Error("array-like deconstruction with init expr is not supported");
138
+ const listType = stmt.type;
139
+ const elemType = getListTypeArg(stmt.type);
140
+ if (!elemType)
141
+ throw new Error("array-like deconstruction without element type is not supported");
142
+ const uniqueArrName = getUniqueInternalName("deconstructed_list_0");
143
+ let lettedArr = ctx.introduceLettedConstant(uniqueArrName, expressifyVars(ctx, stmt.initExpr), stmt.range);
144
+ const modTails = 3;
145
+ const nextDeclarations = [];
146
+ for (let i = 0; i < stmt.elements.length; i++) {
147
+ const elem = stmt.elements[i];
148
+ const uniqueVarName = getUniqueInternalName("elem_" + i.toString());
149
+ const nTails = i % modTails; // every 3 we hoist the intermediate list
150
+ let lettedElem;
151
+ if (nTails === 0 && i > 0) {
152
+ // hoist the list
153
+ lettedArr = ctx.introduceLettedConstant(uniqueArrName, new TirElemAccessExpr(lettedArr, new TirLitIntExpr(BigInt(modTails), elem.range), listType, elem.range), stmt.range);
154
+ lettedElem = ctx.introduceLettedConstant(uniqueVarName, new TirElemAccessExpr(lettedArr, new TirLitIntExpr(BigInt(0), elem.range), elemType, elem.range), elem.range);
155
+ }
156
+ else {
157
+ lettedElem = ctx.introduceLettedConstant(uniqueVarName, new TirElemAccessExpr(lettedArr, new TirLitIntExpr(BigInt(nTails), elem.range), elemType, elem.range), elem.range);
158
+ }
159
+ if (elem instanceof TirSimpleVarDecl) {
160
+ ctx.setNewVariableName(elem.name, uniqueVarName);
161
+ }
162
+ else {
163
+ elem.initExpr = lettedElem;
164
+ nextDeclarations.push(elem);
165
+ }
166
+ }
167
+ if (stmt.rest) {
168
+ const uniqueRestName = getUniqueInternalName(stmt.rest);
169
+ const restLetted = ctx.introduceLettedConstant(uniqueRestName, new TirCallExpr(TirNativeFunc._dropList(elemType), [
170
+ new TirLitIntExpr(BigInt(stmt.elements.length % modTails), stmt.range),
171
+ lettedArr
172
+ ], listType, stmt.range), stmt.range);
173
+ ctx.setNewVariableName(stmt.rest, uniqueRestName);
174
+ }
175
+ bodyStmts.push(...nextDeclarations);
176
+ continue;
177
+ }
178
+ else if (stmt instanceof TirAssignmentStmt)
179
+ bodyStmts.unshift(expressifyVarAssignmentStmt(ctx, stmt));
180
+ else if (stmt instanceof TirBlockStmt) {
181
+ // inline the block
182
+ bodyStmts = stmt.stmts.concat(bodyStmts);
183
+ continue;
184
+ }
185
+ else if (stmt instanceof TirFailStmt) {
186
+ if (stmt.failMsgExpr) {
187
+ const modifiedExpr = expressifyVars(ctx, stmt.failMsgExpr);
188
+ stmt.failMsgExpr = modifiedExpr;
189
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, new TirFailExpr(modifiedExpr, ctx.returnType, stmt.range));
190
+ }
191
+ else
192
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, new TirFailExpr(undefined, ctx.returnType, stmt.range));
193
+ }
194
+ else if (stmt instanceof TirAssertStmt) {
195
+ const condition = expressifyVars(ctx, stmt.condition);
196
+ stmt.condition = condition;
197
+ if (stmt.elseExpr) {
198
+ const elseExpr = expressifyVars(ctx, stmt.elseExpr);
199
+ stmt.elseExpr = elseExpr;
200
+ }
201
+ assertions.push(stmt);
202
+ continue;
203
+ }
204
+ else if (stmt instanceof TirIfStmt) {
205
+ if (stmt.thenBranch.definitelyTerminates()) {
206
+ const elseBranchStmts = [];
207
+ if (stmt.elseBranch) {
208
+ if (stmt.elseBranch instanceof TirBlockStmt) {
209
+ elseBranchStmts.push(...stmt.elseBranch.stmts);
210
+ }
211
+ else {
212
+ elseBranchStmts.push(stmt.elseBranch);
213
+ }
214
+ }
215
+ // move the rest of the body into the else branch
216
+ elseBranchStmts.push(...bodyStmts);
217
+ stmt.elseBranch = new TirBlockStmt(elseBranchStmts, stmt.elseBranch?.range ?? stmt.thenBranch.range);
218
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, expressifyTerminatingIfStmt(ctx, stmt, loopReplacements));
219
+ }
220
+ else if (stmt.elseBranch && stmt.elseBranch.definitelyTerminates()) {
221
+ const thenBranchStmts = [];
222
+ if (stmt.thenBranch instanceof TirBlockStmt) {
223
+ thenBranchStmts.push(...stmt.thenBranch.stmts);
224
+ }
225
+ else {
226
+ thenBranchStmts.push(stmt.thenBranch);
227
+ }
228
+ // move the rest of the body into the then branch
229
+ thenBranchStmts.push(...bodyStmts);
230
+ stmt.thenBranch = new TirBlockStmt(thenBranchStmts, stmt.thenBranch.range);
231
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, expressifyTerminatingIfStmt(ctx, stmt, loopReplacements));
232
+ }
233
+ // determine affected variables
234
+ // determine if we have an early return
235
+ const reassignsAndReturns = determineReassignedVariablesAndReturn(stmt);
236
+ // build a SoP type to return
237
+ const { sop, initState } = getBranchStmtReturnType(reassignsAndReturns, ctx, stmt.range);
238
+ const condition = expressifyVars(ctx, stmt.condition);
239
+ const stmtExpr = new TirTernaryExpr(condition, expressifyIfBranch(ctx.newChild(), stmt.thenBranch, reassignsAndReturns.reassigned, sop, loopReplacements), stmt.elseBranch ? expressifyIfBranch(ctx.newChild(), stmt.elseBranch, reassignsAndReturns.reassigned, sop, loopReplacements) : initState, // no else branch means the variables stay unchanged
240
+ sop, stmt.range);
241
+ // expressify as ternary that returns the SoP type
242
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, getFinalStmtCaseExpr(stmtExpr, sop, ctx, stmt.range, reassignsAndReturns, bodyStmts, loopReplacements));
243
+ }
244
+ else if (stmt instanceof TirMatchStmt) {
245
+ /**
246
+ * index of the **only** case that does not terminate
247
+ *
248
+ * if it is undefined, then all cases terminate
249
+ * if it is negative, then more than one case does not terminate
250
+ * if it is positive, then only one case does not terminate and this is the index
251
+ **/
252
+ let doesNotTerminateIdx = undefined;
253
+ for (let i = 0; i < stmt.cases.length; i++) {
254
+ const _case = stmt.cases[i];
255
+ if (_case.body.definitelyTerminates())
256
+ continue;
257
+ if (typeof doesNotTerminateIdx !== "number")
258
+ doesNotTerminateIdx = i;
259
+ else {
260
+ doesNotTerminateIdx = -1; // more than one case does not terminate
261
+ break;
262
+ }
263
+ }
264
+ const onlyOneCaseDoesNotTerminate = typeof doesNotTerminateIdx === "number" && doesNotTerminateIdx >= 0;
265
+ if (onlyOneCaseDoesNotTerminate) {
266
+ const theDude = stmt.cases[doesNotTerminateIdx];
267
+ theDude.body = theDude.body instanceof TirBlockStmt ? theDude.body : new TirBlockStmt([theDude.body], theDude.body.range);
268
+ theDude.body.stmts.push(...bodyStmts);
269
+ }
270
+ const isDirectReturn = typeof doesNotTerminateIdx !== "number" // all cases terminate
271
+ || onlyOneCaseDoesNotTerminate;
272
+ const reassignsAndReturns = determineReassignedVariablesAndReturn(stmt);
273
+ if (isDirectReturn) {
274
+ // build a SoP type to return
275
+ const { sop, initState } = getBranchStmtReturnType(reassignsAndReturns, ctx, stmt.range);
276
+ // expressify as ternary that returns the SoP type
277
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, getFinalStmtCaseExpr(new TirCaseExpr(expressifyVars(ctx, stmt.matchExpr), stmt.cases.map(_case => {
278
+ if (_case.pattern instanceof TirArrayLikeDeconstr)
279
+ throw new Error("array-like deconstruction in match statement is not supported");
280
+ _case.pattern = toNamedDeconstructVarDecl(_case.pattern);
281
+ const caseCtx = ctx.newChild();
282
+ flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct(_case.pattern, caseCtx);
283
+ const caseBody = expressifyFuncBody(caseCtx, _case.body instanceof TirBlockStmt
284
+ ? _case.body.stmts
285
+ : [_case.body], loopReplacements, assertions);
286
+ return new TirCaseMatcher(_case.pattern, caseBody, _case.range);
287
+ }), stmt.wildcardCase ? new TirWildcardCaseMatcher(expressifyFuncBody(ctx.newChild(), stmt.wildcardCase.body instanceof TirBlockStmt
288
+ ? stmt.wildcardCase.body.stmts
289
+ : [stmt.wildcardCase.body], loopReplacements, []), stmt.wildcardCase.range) : undefined, ctx.returnType, stmt.range), sop, ctx, stmt.range, reassignsAndReturns, bodyStmts, loopReplacements));
290
+ }
291
+ }
292
+ else if (stmt instanceof TirForOfStmt) {
293
+ // determine affected variables
294
+ // determine if we may have an early return
295
+ // determine if we can break or continue
296
+ const reassignedAndFlow = determineReassignedVariablesAndFlowInfos(stmt);
297
+ const { reassigned, returns, canBreak, canContinue } = reassignedAndFlow;
298
+ const { sop, initState } = getBranchStmtReturnType(reassignedAndFlow, ctx, stmt.range);
299
+ if (!returns
300
+ && !canBreak
301
+ // && !canContinue
302
+ ) {
303
+ // **only for...of** can be optimized as a simple `.reduce`
304
+ // producing the new state in this case
305
+ // (`.reduce` has no way to break or early return (efficiently))
306
+ // continue is ok, because we only need to pass the state up to that point
307
+ }
308
+ }
309
+ else if (stmt instanceof TirForStmt
310
+ || stmt instanceof TirWhileStmt) {
311
+ const reassignedAndFlow = determineReassignedVariablesAndFlowInfos(stmt);
312
+ const returnTypeAndInvalidInit = getBranchStmtReturnType(reassignedAndFlow, ctx, stmt.range);
313
+ const forStmt = whileToFor(stmt);
314
+ const { bodyStateType, initState } = getBodyStateType(returnTypeAndInvalidInit, forStmt);
315
+ const loopExpr = expressifyForStmt(ctx.newChild(), forStmt, returnTypeAndInvalidInit.sop, bodyStateType, initState);
316
+ }
317
+ else {
318
+ const tsEnsureExsautstiveCheck = stmt;
319
+ console.error(stmt);
320
+ throw new Error("unreachable::expressify::stmt");
321
+ }
322
+ }
323
+ return TirAssertAndContinueExpr.fromStmtsAndContinuation(assertions, new TirLitVoidExpr(SourceRange.mock));
324
+ }
325
+ function getConstrDestructPattern(type, range, initExpr, constrIndex) {
326
+ const constr = type.constructors[constrIndex];
327
+ if (!constr)
328
+ throw new Error("no constructor in single constr struct type");
329
+ const deconstructedFields = new Map();
330
+ for (const field of constr.fields) {
331
+ const uniqueName = getUniqueInternalName(field.name);
332
+ deconstructedFields.set(field.name, new TirSimpleVarDecl(uniqueName, field.type, initExpr, false, // not a constant (reassigned if deconstruction statement already exists later)
333
+ range));
334
+ }
335
+ return new TirNamedDeconstructVarDecl(constr.name, deconstructedFields, undefined, type, undefined, false, // not a constant
336
+ range);
337
+ }
338
+ function getNestedDestructsInSingleSopDestructPattern(pattern) {
339
+ const result = [];
340
+ for (const [fName, varDecl] of pattern.fields) {
341
+ if (!(varDecl instanceof TirSimpleVarDecl))
342
+ throw new Error("expected simple var decl in single destruct pattern");
343
+ if (!(varDecl.type instanceof TirSoPStructType))
344
+ continue;
345
+ result.push(getConstrDestructPattern(varDecl.type, varDecl.range,
346
+ // init expr
347
+ new TirVariableAccessExpr({
348
+ variableInfos: {
349
+ name: varDecl.name,
350
+ type: varDecl.type,
351
+ isConstant: true,
352
+ },
353
+ isDefinedOutsideFuncScope: false,
354
+ }, varDecl.range), 0));
355
+ }
356
+ return result;
357
+ }
358
+ function getFinalStmtCaseExpr(finalStmtExpr, sop, ctx, stmtRange, reassignsAndReturns, nextBodyStmts, loopReplacements) {
359
+ const continuations = [];
360
+ const contBranchCtx = ctx.newChild();
361
+ const contConstr = sop.constructors[0];
362
+ const contFields = contConstr.fields;
363
+ const contPattern = new TirNamedDeconstructVarDecl(sop.constructors[0].name, new Map(contFields.map((f, i) => [
364
+ f.name,
365
+ new TirSimpleVarDecl(getUniqueInternalName(f.name), f.type, undefined, // no init expr (pattern is used as case matcher)
366
+ false, // not a constant
367
+ stmtRange)
368
+ ])), undefined, // no rest
369
+ sop, undefined, // no init expr
370
+ false, // not a constant
371
+ stmtRange);
372
+ const nestedDeconstructs = flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct(contPattern, contBranchCtx);
373
+ continuations.push(new TirCaseMatcher(contPattern, expressifyFuncBody(contBranchCtx, nestedDeconstructs
374
+ .concat(nextBodyStmts), loopReplacements, [] // assertions are added before if statement exectution
375
+ ), stmtRange));
376
+ if (reassignsAndReturns.returns) {
377
+ const earlyRetConstr = sop.constructors[1];
378
+ const earlyRetField = earlyRetConstr.fields[0];
379
+ const uniqueFieldName = getUniqueInternalName(earlyRetField.name);
380
+ const earlyRetPattern = new TirNamedDeconstructVarDecl(earlyRetConstr.name, new Map([
381
+ [
382
+ earlyRetField.name,
383
+ new TirSimpleVarDecl(uniqueFieldName, earlyRetField.type, undefined, // no init expr (pattern is used as case matcher)
384
+ false, // not a constant
385
+ stmtRange)
386
+ ]
387
+ ]), undefined, // no rest
388
+ sop, undefined, // no init expr
389
+ false, // not a constant
390
+ stmtRange);
391
+ continuations.push(new TirCaseMatcher(earlyRetPattern, new TirVariableAccessExpr({
392
+ variableInfos: {
393
+ name: uniqueFieldName,
394
+ type: earlyRetField.type,
395
+ isConstant: true,
396
+ },
397
+ isDefinedOutsideFuncScope: false,
398
+ }, stmtRange), stmtRange));
399
+ }
400
+ // expressify as ternary that returns the SoP type
401
+ return new TirCaseExpr(finalStmtExpr, continuations, undefined, // no wildcard case
402
+ ctx.returnType, stmtRange);
403
+ }
@@ -0,0 +1,8 @@
1
+ import { TirLitNamedObjExpr } from "../../tir/expressions/litteral/TirLitNamedObjExpr.js";
2
+ import { TirCallExpr } from "../../tir/expressions/TirCallExpr.js";
3
+ import { TirForStmt } from "../../tir/statements/TirForStmt.js";
4
+ import { TirWhileStmt } from "../../tir/statements/TirWhileStmt.js";
5
+ import { TirSoPStructType } from "../../tir/types/TirStructType.js";
6
+ import { ExpressifyCtx } from "./ExpressifyCtx.js";
7
+ export declare function whileToFor(stmt: TirWhileStmt | TirForStmt): TirForStmt;
8
+ export declare function expressifyForStmt(ctx: ExpressifyCtx, stmt: TirForStmt, returnType: TirSoPStructType, bodyStateType: TirSoPStructType, initState: TirLitNamedObjExpr): TirCallExpr;
@@ -0,0 +1,115 @@
1
+ import { Identifier } from "../../../ast/nodes/common/Identifier.js";
2
+ import { getUniqueInternalName } from "../../internalVar.js";
3
+ import { TirLitNamedObjExpr } from "../../tir/expressions/litteral/TirLitNamedObjExpr.js";
4
+ import { TirCallExpr } from "../../tir/expressions/TirCallExpr.js";
5
+ import { TirFuncExpr } from "../../tir/expressions/TirFuncExpr.js";
6
+ import { TirVariableAccessExpr } from "../../tir/expressions/TirVariableAccessExpr.js";
7
+ import { TirBlockStmt } from "../../tir/statements/TirBlockStmt.js";
8
+ import { TirBreakStmt } from "../../tir/statements/TirBreakStmt.js";
9
+ import { TirContinueStmt } from "../../tir/statements/TirContinueStmt.js";
10
+ import { TirForStmt } from "../../tir/statements/TirForStmt.js";
11
+ import { TirIfStmt } from "../../tir/statements/TirIfStmt.js";
12
+ import { TirReturnStmt } from "../../tir/statements/TirReturnStmt.js";
13
+ import { TirSimpleVarDecl } from "../../tir/statements/TirVarDecl/TirSimpleVarDecl.js";
14
+ import { TirFuncT } from "../../tir/types/TirNativeType/native/function.js";
15
+ import { expressifyFuncBody } from "./expressify.js";
16
+ import { isExpressifyFuncParam } from "./ExpressifyCtx.js";
17
+ export function whileToFor(stmt) {
18
+ if (stmt instanceof TirForStmt)
19
+ return stmt;
20
+ // convert while to for
21
+ return new TirForStmt([], // no init
22
+ stmt.condition, // condition
23
+ [], // no update
24
+ stmt.body, // loopBody
25
+ stmt.range);
26
+ }
27
+ export function expressifyForStmt(ctx, stmt, returnType, bodyStateType, initState) {
28
+ const loopBody = stmt.body instanceof TirBlockStmt ? stmt.body : new TirBlockStmt([stmt.body], stmt.range);
29
+ if (stmt.condition)
30
+ loopBody.stmts.unshift(new TirIfStmt(stmt.condition,
31
+ // then
32
+ loopBody,
33
+ // else
34
+ new TirBlockStmt([new TirBreakStmt(stmt.condition.range)], stmt.condition.range), stmt.condition.range));
35
+ loopBody.stmts.push(new TirContinueStmt(loopBody.range.atEnd()));
36
+ const loopFuncName = getUniqueInternalName("loop");
37
+ const loopFuncType = new TirFuncT(bodyStateType.constructors[0].fields.map(f => f.type), returnType);
38
+ const loopReplacements = {
39
+ compileBreak(ctx, stmt) {
40
+ // return first constructor of the return type
41
+ const ctor = returnType.constructors[0];
42
+ return new TirLitNamedObjExpr(new Identifier(ctor.name, stmt.range), ctor.fields.map(f => new Identifier(f.name, stmt.range)), bodyStateType.constructors[0].fields
43
+ .slice(0, ctor.fields.length)
44
+ .map(f => {
45
+ const resolved = ctx.getVariable(f.name);
46
+ if (isExpressifyFuncParam(resolved)) {
47
+ return new TirVariableAccessExpr({
48
+ variableInfos: {
49
+ name: resolved.name,
50
+ type: resolved.type,
51
+ isConstant: false
52
+ },
53
+ isDefinedOutsideFuncScope: false
54
+ }, stmt.range);
55
+ }
56
+ return resolved;
57
+ }), returnType, stmt.range);
58
+ },
59
+ replaceReturnValue(ctx, stmt) {
60
+ // return second constructor of the return type
61
+ const ctor = returnType.constructors[1];
62
+ if (!ctor) {
63
+ throw new Error("No return constructor found in return type");
64
+ }
65
+ return new TirLitNamedObjExpr(new Identifier(ctor.name, stmt.range), [new Identifier(ctor.fields[0].name, stmt.range)], [stmt.value], returnType, stmt.range);
66
+ },
67
+ compileContinue(ctx, stmt) {
68
+ // return recursive call
69
+ const resolvedSelfResult = ctx.getVariable(loopFuncName);
70
+ let resolvedSelf;
71
+ if (isExpressifyFuncParam(resolvedSelfResult)) {
72
+ resolvedSelf = new TirVariableAccessExpr({
73
+ variableInfos: {
74
+ name: resolvedSelfResult.name,
75
+ type: resolvedSelfResult.type,
76
+ isConstant: false
77
+ },
78
+ isDefinedOutsideFuncScope: false
79
+ }, stmt.range);
80
+ }
81
+ else {
82
+ resolvedSelf = resolvedSelfResult;
83
+ }
84
+ return new TirCallExpr(resolvedSelf, bodyStateType.constructors[0].fields
85
+ .map(f => {
86
+ const resolved = ctx.getVariable(f.name);
87
+ if (isExpressifyFuncParam(resolved)) {
88
+ return new TirVariableAccessExpr({
89
+ variableInfos: {
90
+ name: resolved.name,
91
+ type: resolved.type,
92
+ isConstant: false
93
+ },
94
+ isDefinedOutsideFuncScope: false
95
+ }, stmt.range);
96
+ }
97
+ return resolved;
98
+ }), returnType, stmt.range);
99
+ },
100
+ };
101
+ const loopCompilationCtx = ctx.newChild();
102
+ // define loop function for recursion
103
+ loopCompilationCtx.setFuncParam(loopFuncName, loopFuncType);
104
+ // define loop function parameters
105
+ for (const { name, type } of bodyStateType.constructors[0].fields) {
106
+ loopCompilationCtx.setFuncParam(name, type);
107
+ }
108
+ return new TirCallExpr(new TirFuncExpr(loopFuncName, bodyStateType.constructors[0].fields.map(f => new TirSimpleVarDecl(f.name, f.type, undefined, // no initial value
109
+ false, // is constant
110
+ stmt.range)), returnType, new TirBlockStmt([
111
+ new TirReturnStmt(expressifyFuncBody(loopCompilationCtx, loopBody.stmts, loopReplacements, [] // assertions
112
+ ), stmt.range)
113
+ ], stmt.range), stmt.range, true // is loop
114
+ ), initState.values, returnType, stmt.range);
115
+ }
@@ -0,0 +1,6 @@
1
+ import { TirExpr } from "../../tir/expressions/TirExpr.js";
2
+ import { TirStmt } from "../../tir/statements/TirStmt.js";
3
+ import { TirSoPStructType } from "../../tir/types/TirStructType.js";
4
+ import { LoopReplacements } from "./expressify.js";
5
+ import { ExpressifyCtx } from "./ExpressifyCtx.js";
6
+ export declare function expressifyIfBranch(ctx: ExpressifyCtx, branch: TirStmt, reassignedNames: string[], sop: TirSoPStructType, loopReplacements: LoopReplacements | undefined): TirExpr;
@@ -0,0 +1,105 @@
1
+ import { Identifier } from "../../../ast/nodes/common/Identifier.js";
2
+ import { TirLitNamedObjExpr } from "../../tir/expressions/litteral/TirLitNamedObjExpr.js";
3
+ import { TirLitVoidExpr } from "../../tir/expressions/litteral/TirLitVoidExpr.js";
4
+ import { TirVariableAccessExpr } from "../../tir/expressions/TirVariableAccessExpr.js";
5
+ import { TirAssertStmt } from "../../tir/statements/TirAssertStmt.js";
6
+ import { TirAssignmentStmt } from "../../tir/statements/TirAssignmentStmt.js";
7
+ import { TirBlockStmt } from "../../tir/statements/TirBlockStmt.js";
8
+ import { TirBreakStmt } from "../../tir/statements/TirBreakStmt.js";
9
+ import { TirContinueStmt } from "../../tir/statements/TirContinueStmt.js";
10
+ import { TirFailStmt } from "../../tir/statements/TirFailStmt.js";
11
+ import { TirForOfStmt } from "../../tir/statements/TirForOfStmt.js";
12
+ import { TirForStmt } from "../../tir/statements/TirForStmt.js";
13
+ import { TirIfStmt } from "../../tir/statements/TirIfStmt.js";
14
+ import { TirMatchStmt } from "../../tir/statements/TirMatchStmt.js";
15
+ import { TirReturnStmt } from "../../tir/statements/TirReturnStmt.js";
16
+ import { isTirVarDecl } from "../../tir/statements/TirVarDecl/TirVarDecl.js";
17
+ import { TirWhileStmt } from "../../tir/statements/TirWhileStmt.js";
18
+ import { expressifyFuncBody } from "./expressify.js";
19
+ export function expressifyIfBranch(ctx, branch, reassignedNames, sop, loopReplacements) {
20
+ ctx.returnType = sop;
21
+ const body = branch instanceof TirBlockStmt ? branch.stmts : [branch];
22
+ const earlyReturnConstr = sop.constructors[1];
23
+ const wrapReturnExpr = !earlyReturnConstr ? undefined :
24
+ (expr) => new TirLitNamedObjExpr(new Identifier(earlyReturnConstr.name, expr.range), [new Identifier(earlyReturnConstr.fields[0].name, expr.range)], [expr], sop, expr.range);
25
+ // replace explicit return statements wrapping the return value in the second constr
26
+ replaceReturnStatements(body, wrapReturnExpr, sop);
27
+ // add a final return statement (if it doesn't end with one)
28
+ // returning the first constr, with the modified variables
29
+ const lastIdx = body.length - 1;
30
+ if (body.length === 0 ||
31
+ !(body[lastIdx] instanceof TirReturnStmt)) {
32
+ const fstConstr = sop.constructors[0];
33
+ const fields = fstConstr.fields;
34
+ body.push(new TirReturnStmt(new TirLitNamedObjExpr(new Identifier(fstConstr.name, branch.range), fields.map(f => new Identifier(f.name, branch.range)), fields.map((f, i) => new TirVariableAccessExpr({
35
+ variableInfos: {
36
+ name: reassignedNames[i],
37
+ type: f.type,
38
+ isConstant: false
39
+ },
40
+ isDefinedOutsideFuncScope: false,
41
+ }, branch.range)), sop, branch.range), branch.range));
42
+ }
43
+ // finally expressify as normal function body, but with `sop` as return type
44
+ return expressifyFuncBody(ctx, body, loopReplacements);
45
+ }
46
+ function replaceReturnStatements(body, wrapReturnExpr, sopType) {
47
+ const hasEarlyReturn = typeof wrapReturnExpr === "function";
48
+ for (let i = 0; i < body.length; i++) {
49
+ const stmt = body[i];
50
+ // replace the return statement with a new one
51
+ // that returns the first constr, with the modified variables
52
+ if (stmt instanceof TirReturnStmt) {
53
+ if (!hasEarlyReturn)
54
+ throw new Error("unexpected early return statement.");
55
+ stmt.value = wrapReturnExpr(stmt.value ?? new TirLitVoidExpr(stmt.range));
56
+ body[i] = stmt;
57
+ continue;
58
+ }
59
+ if (isTirVarDecl(stmt)
60
+ || stmt instanceof TirBreakStmt
61
+ || stmt instanceof TirContinueStmt
62
+ || stmt instanceof TirFailStmt
63
+ || stmt instanceof TirAssertStmt
64
+ || stmt instanceof TirAssignmentStmt)
65
+ continue;
66
+ if (stmt instanceof TirBlockStmt) {
67
+ replaceReturnStatements(stmt.stmts, wrapReturnExpr, sopType);
68
+ continue;
69
+ }
70
+ if (stmt instanceof TirIfStmt) {
71
+ stmt.thenBranch = stmt.thenBranch instanceof TirBlockStmt ?
72
+ stmt.thenBranch :
73
+ new TirBlockStmt([stmt.thenBranch], stmt.range);
74
+ replaceReturnStatements(stmt.thenBranch.stmts, wrapReturnExpr, sopType);
75
+ if (stmt.elseBranch) {
76
+ stmt.elseBranch = stmt.elseBranch instanceof TirBlockStmt ?
77
+ stmt.elseBranch :
78
+ new TirBlockStmt([stmt.elseBranch], stmt.range);
79
+ replaceReturnStatements(stmt.elseBranch.stmts, wrapReturnExpr, sopType);
80
+ }
81
+ continue;
82
+ }
83
+ if (stmt instanceof TirMatchStmt) {
84
+ for (let i = 0; i < stmt.cases.length; i++) {
85
+ const matchCase = stmt.cases[i];
86
+ matchCase.body = matchCase.body instanceof TirBlockStmt ?
87
+ matchCase.body :
88
+ new TirBlockStmt([matchCase.body], matchCase.range);
89
+ replaceReturnStatements(matchCase.body.stmts, wrapReturnExpr, sopType);
90
+ }
91
+ // TODO: do wildcard
92
+ continue;
93
+ }
94
+ if (stmt instanceof TirForStmt
95
+ || stmt instanceof TirForOfStmt
96
+ || stmt instanceof TirWhileStmt) {
97
+ stmt.body = stmt.body instanceof TirBlockStmt ?
98
+ stmt.body :
99
+ new TirBlockStmt([stmt.body], stmt.range);
100
+ replaceReturnStatements(stmt.body.stmts, wrapReturnExpr, sopType);
101
+ continue;
102
+ }
103
+ const tsEnsureExsautstiveCheck = stmt;
104
+ }
105
+ }
@@ -0,0 +1,5 @@
1
+ import { TirExpr } from "../../tir/expressions/TirExpr.js";
2
+ import { TirIfStmt } from "../../tir/statements/TirIfStmt.js";
3
+ import { LoopReplacements } from "./expressify.js";
4
+ import { ExpressifyCtx } from "./ExpressifyCtx.js";
5
+ export declare function expressifyTerminatingIfStmt(parentCtx: ExpressifyCtx, stmt: TirIfStmt, loopReplacements: LoopReplacements | undefined): TirExpr;