@harmoniclabs/pebble 0.1.0-dev5 → 0.1.0-dev7

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 (321) hide show
  1. package/dist/IR/IRHash.d.ts +3 -3
  2. package/dist/IR/IRHash.js +47 -52
  3. package/dist/IR/IRNodes/IRApp.d.ts +12 -8
  4. package/dist/IR/IRNodes/IRApp.js +34 -20
  5. package/dist/IR/IRNodes/IRCase.d.ts +11 -7
  6. package/dist/IR/IRNodes/IRCase.js +33 -32
  7. package/dist/IR/IRNodes/IRConst.d.ts +7 -5
  8. package/dist/IR/IRNodes/IRConst.js +23 -13
  9. package/dist/IR/IRNodes/IRConstr.d.ts +11 -7
  10. package/dist/IR/IRNodes/IRConstr.js +34 -37
  11. package/dist/IR/IRNodes/IRDelayed.d.ts +12 -9
  12. package/dist/IR/IRNodes/IRDelayed.js +22 -18
  13. package/dist/IR/IRNodes/IRError.d.ts +9 -6
  14. package/dist/IR/IRNodes/IRError.js +12 -5
  15. package/dist/IR/IRNodes/IRForced.d.ts +9 -6
  16. package/dist/IR/IRNodes/IRForced.js +22 -18
  17. package/dist/IR/IRNodes/IRFunc.d.ts +14 -10
  18. package/dist/IR/IRNodes/IRFunc.js +35 -38
  19. package/dist/IR/IRNodes/IRHoisted.d.ts +16 -9
  20. package/dist/IR/IRNodes/IRHoisted.js +36 -18
  21. package/dist/IR/IRNodes/IRLetted.d.ts +14 -34
  22. package/dist/IR/IRNodes/IRLetted.js +65 -297
  23. package/dist/IR/IRNodes/IRNative/IRNativeTag.d.ts +3 -3
  24. package/dist/IR/IRNodes/IRNative/IRNativeTag.js +4 -4
  25. package/dist/IR/IRNodes/IRNative/index.d.ts +10 -8
  26. package/dist/IR/IRNodes/IRNative/index.js +56 -18
  27. package/dist/IR/IRNodes/IRNative/isForcedNative.d.ts +2 -0
  28. package/dist/IR/IRNodes/IRNative/isForcedNative.js +1 -1
  29. package/dist/IR/IRNodes/IRRecursive.d.ts +18 -10
  30. package/dist/IR/IRNodes/IRRecursive.js +36 -44
  31. package/dist/IR/IRNodes/IRSelfCall.d.ts +10 -24
  32. package/dist/IR/IRNodes/IRSelfCall.js +25 -87
  33. package/dist/IR/IRNodes/IRVar.d.ts +11 -19
  34. package/dist/IR/IRNodes/IRVar.js +26 -54
  35. package/dist/IR/IRNodes/utils/dependsByDbns.d.ts +1 -1
  36. package/dist/IR/IRNodes/utils/dependsByDbns.js +5 -11
  37. package/dist/IR/IRNodes/utils/hashVarSym.d.ts +1 -0
  38. package/dist/IR/IRNodes/utils/hashVarSym.js +37 -0
  39. package/dist/IR/IRNodes/utils/makeArrayLikeProxy.d.ts +2 -1
  40. package/dist/IR/IRTerm.d.ts +7 -0
  41. package/dist/IR/toUPLC/CompilerOptions.d.ts +5 -0
  42. package/dist/IR/toUPLC/CompilerOptions.js +10 -1
  43. package/dist/IR/toUPLC/_internal/_modifyChildFromTo.js +3 -0
  44. package/dist/IR/toUPLC/_internal/findAll.js +2 -73
  45. package/dist/IR/toUPLC/_internal/getDebruijnInTerm.js +7 -34
  46. package/dist/IR/toUPLC/_internal/iterTree.js +3 -17
  47. package/dist/IR/toUPLC/common_hoisted.d.ts +2 -0
  48. package/dist/IR/toUPLC/common_hoisted.js +4 -0
  49. package/dist/IR/toUPLC/compileIRToUPLC.d.ts +1 -1
  50. package/dist/IR/toUPLC/compileIRToUPLC.js +91 -14
  51. package/dist/IR/toUPLC/ctx/ToUplcCtx.d.ts +16 -0
  52. package/dist/IR/toUPLC/ctx/ToUplcCtx.js +67 -0
  53. package/dist/IR/toUPLC/subRoutines/_comptimeDropN.d.ts +8 -0
  54. package/dist/IR/toUPLC/subRoutines/_comptimeDropN.js +95 -0
  55. package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.js +7 -54
  56. package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.d.ts +6 -13
  57. package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.js +65 -71
  58. package/dist/IR/toUPLC/subRoutines/handleLetted/index.js +44 -170
  59. package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.js +7 -3
  60. package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.js +3 -2
  61. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.d.ts +22 -0
  62. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.js +59 -0
  63. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.d.ts +0 -0
  64. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.js +217 -0
  65. package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.js +12 -49
  66. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.d.ts +1 -1
  67. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.js +11 -14
  68. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/{index.d.ts → performUplcOptimizationsAndReturnRoot.d.ts} +0 -2
  69. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/performUplcOptimizationsAndReturnRoot.js +151 -0
  70. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.d.ts +11 -0
  71. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.js +46 -0
  72. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.d.ts +2 -0
  73. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.js +80 -0
  74. package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.js +18 -11
  75. package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +45 -0
  76. package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +277 -478
  77. package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.d.ts +2 -0
  78. package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.js +85 -0
  79. package/dist/IR/toUPLC/subRoutines/sanifyTree.js +1 -0
  80. package/dist/IR/toUPLC/utils/getApplicationTerms.d.ts +6 -0
  81. package/dist/IR/toUPLC/utils/getApplicationTerms.js +37 -0
  82. package/dist/IR/tree_utils/_ir_lazyChooseList.d.ts +2 -2
  83. package/dist/IR/tree_utils/_ir_lazyChooseList.js +4 -2
  84. package/dist/IR/tree_utils/_ir_lazyIfThenElse.d.ts +1 -1
  85. package/dist/IR/tree_utils/_ir_lazyIfThenElse.js +4 -2
  86. package/dist/IR/tree_utils/_ir_let.d.ts +2 -1
  87. package/dist/IR/tree_utils/_ir_let.js +6 -2
  88. package/dist/IR/utils/isClosedIRTerm.d.ts +1 -0
  89. package/dist/IR/utils/isClosedIRTerm.js +40 -26
  90. package/dist/IR/utils/positiveIntAsBytes.d.ts +1 -0
  91. package/dist/IR/utils/positiveIntAsBytes.js +4 -4
  92. package/dist/IR/utils/showIR.d.ts +10 -21
  93. package/dist/IR/utils/showIR.js +66 -64
  94. package/dist/ast/nodes/common/Identifier.d.ts +1 -0
  95. package/dist/ast/nodes/common/Identifier.js +3 -0
  96. package/dist/ast/nodes/expr/CaseExpr.d.ts +5 -5
  97. package/dist/ast/nodes/expr/ElemAccessExpr.d.ts +2 -2
  98. package/dist/ast/nodes/expr/ParentesizedExpr.d.ts +1 -1
  99. package/dist/ast/nodes/expr/PebbleExpr.d.ts +2 -1
  100. package/dist/ast/nodes/expr/PropAccessExpr.d.ts +3 -3
  101. package/dist/ast/nodes/expr/TernaryExpr.d.ts +3 -3
  102. package/dist/ast/nodes/expr/TypeConversionExpr.d.ts +2 -1
  103. package/dist/ast/nodes/expr/TypeConversionExpr.js +2 -0
  104. package/dist/ast/nodes/expr/binary/BinaryExpr.d.ts +42 -42
  105. package/dist/ast/nodes/expr/functions/CallExpr.d.ts +1 -1
  106. package/dist/ast/nodes/expr/functions/FuncExpr.d.ts +2 -1
  107. package/dist/ast/nodes/expr/functions/FuncExpr.js +6 -0
  108. package/dist/ast/nodes/expr/litteral/LitContextExpr.d.ts +6 -0
  109. package/dist/ast/nodes/expr/litteral/LitContextExpr.js +6 -0
  110. package/dist/ast/nodes/expr/litteral/LitFailExpr.d.ts +6 -0
  111. package/dist/ast/nodes/expr/litteral/LitFailExpr.js +6 -0
  112. package/dist/ast/nodes/expr/litteral/LitteralExpr.d.ts +3 -1
  113. package/dist/ast/nodes/expr/litteral/LitteralExpr.js +5 -1
  114. package/dist/ast/nodes/statements/AssertStmt.d.ts +2 -2
  115. package/dist/ast/nodes/statements/AssignmentStmt.d.ts +1 -1
  116. package/dist/ast/nodes/statements/BlockStmt.d.ts +1 -1
  117. package/dist/ast/nodes/statements/FailStmt.d.ts +1 -1
  118. package/dist/ast/nodes/statements/ForOfStmt.d.ts +4 -2
  119. package/dist/ast/nodes/statements/ForOfStmt.js +6 -0
  120. package/dist/ast/nodes/statements/ForStmt.d.ts +6 -4
  121. package/dist/ast/nodes/statements/ForStmt.js +6 -0
  122. package/dist/ast/nodes/statements/IfStmt.d.ts +8 -5
  123. package/dist/ast/nodes/statements/IfStmt.js +13 -0
  124. package/dist/ast/nodes/statements/MatchStmt.d.ts +13 -4
  125. package/dist/ast/nodes/statements/MatchStmt.js +22 -1
  126. package/dist/ast/nodes/statements/PebbleStmt.d.ts +2 -1
  127. package/dist/ast/nodes/statements/PebbleStmt.js +3 -1
  128. package/dist/ast/nodes/statements/ReturnStmt.d.ts +1 -1
  129. package/dist/ast/nodes/statements/WhileStmt.d.ts +4 -2
  130. package/dist/ast/nodes/statements/WhileStmt.js +6 -0
  131. package/dist/ast/nodes/statements/declarations/ContractDecl.d.ts +17 -0
  132. package/dist/ast/nodes/statements/declarations/ContractDecl.js +22 -0
  133. package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.d.ts +1 -1
  134. package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.d.ts +1 -1
  135. package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.d.ts +1 -1
  136. package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.d.ts +2 -1
  137. package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.js +6 -0
  138. package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.d.ts +1 -1
  139. package/dist/compiler/AstCompiler/AstCompiler.d.ts +7 -2
  140. package/dist/compiler/AstCompiler/AstCompiler.js +129 -25
  141. package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.d.ts +10 -0
  142. package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.js +777 -0
  143. package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.js +1 -1
  144. package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.js +5 -1
  145. package/dist/compiler/AstCompiler/internal/exprs/_compileFuncExpr.js +7 -4
  146. package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.js +8 -2
  147. package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.js +1 -1
  148. package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.js +2 -1
  149. package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +1 -1
  150. package/dist/compiler/AstCompiler/internal/exprs/_compileVarAccessExpr.js +3 -1
  151. package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +8 -8
  152. package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.d.ts +2 -2
  153. package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.js +48 -24
  154. package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +4 -1
  155. package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.d.ts +2 -1
  156. package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.js +4 -3
  157. package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.js +1 -1
  158. package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.js +4 -1
  159. package/dist/compiler/AstCompiler/scope/AstScope.d.ts +1 -0
  160. package/dist/compiler/AstCompiler/scope/AstScope.js +9 -3
  161. package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +6 -4
  162. package/dist/compiler/Compiler.js +7 -1
  163. package/dist/compiler/TirCompiler/compileTirProgram.js +4 -1
  164. package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +17 -5
  165. package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +79 -49
  166. package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +13 -2
  167. package/dist/compiler/TirCompiler/expressify/expressify.d.ts +2 -1
  168. package/dist/compiler/TirCompiler/expressify/expressify.js +102 -41
  169. package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +2 -1
  170. package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +77 -12
  171. package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +1 -1
  172. package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.d.ts +1 -2
  173. package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +16 -9
  174. package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +6 -8
  175. package/dist/compiler/TirCompiler/expressify/expressifyVars.js +146 -13
  176. package/dist/compiler/TirCompiler/expressify/flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct.js +1 -0
  177. package/dist/compiler/internalVar.d.ts +1 -1
  178. package/dist/compiler/internalVar.js +31 -24
  179. package/dist/compiler/io/CompilerIoApi.d.ts +1 -1
  180. package/dist/compiler/io/IOutputStream.d.ts +1 -0
  181. package/dist/compiler/io/IOutputStream.js +18 -3
  182. package/dist/compiler/path/getAbsolutePath.js +4 -6
  183. package/dist/compiler/tir/expressions/ITirExpr.d.ts +2 -0
  184. package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.d.ts +4 -2
  185. package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.js +16 -2
  186. package/dist/compiler/tir/expressions/TirCallExpr.d.ts +3 -1
  187. package/dist/compiler/tir/expressions/TirCallExpr.js +16 -1
  188. package/dist/compiler/tir/expressions/TirCaseExpr.d.ts +6 -1
  189. package/dist/compiler/tir/expressions/TirCaseExpr.js +105 -60
  190. package/dist/compiler/tir/expressions/TirElemAccessExpr.d.ts +3 -1
  191. package/dist/compiler/tir/expressions/TirElemAccessExpr.js +9 -1
  192. package/dist/compiler/tir/expressions/TirFailExpr.d.ts +3 -1
  193. package/dist/compiler/tir/expressions/TirFailExpr.js +9 -1
  194. package/dist/compiler/tir/expressions/TirFromDataExpr.d.ts +3 -2
  195. package/dist/compiler/tir/expressions/TirFromDataExpr.js +85 -56
  196. package/dist/compiler/tir/expressions/TirFuncExpr.d.ts +4 -10
  197. package/dist/compiler/tir/expressions/TirFuncExpr.js +30 -13
  198. package/dist/compiler/tir/expressions/TirHoistedExpr.d.ts +3 -1
  199. package/dist/compiler/tir/expressions/TirHoistedExpr.js +8 -0
  200. package/dist/compiler/tir/expressions/TirInlineClosedIR.d.ts +4 -1
  201. package/dist/compiler/tir/expressions/TirInlineClosedIR.js +8 -0
  202. package/dist/compiler/tir/expressions/TirLettedExpr.d.ts +6 -3
  203. package/dist/compiler/tir/expressions/TirLettedExpr.js +20 -7
  204. package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +9 -5
  205. package/dist/compiler/tir/expressions/TirNativeFunc.js +58 -22
  206. package/dist/compiler/tir/expressions/TirParentesizedExpr.d.ts +3 -1
  207. package/dist/compiler/tir/expressions/TirParentesizedExpr.js +6 -0
  208. package/dist/compiler/tir/expressions/TirPropAccessExpr.d.ts +3 -1
  209. package/dist/compiler/tir/expressions/TirPropAccessExpr.js +9 -1
  210. package/dist/compiler/tir/expressions/TirTernaryExpr.d.ts +3 -1
  211. package/dist/compiler/tir/expressions/TirTernaryExpr.js +16 -5
  212. package/dist/compiler/tir/expressions/TirToDataExpr.d.ts +3 -1
  213. package/dist/compiler/tir/expressions/TirToDataExpr.js +56 -25
  214. package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.d.ts +3 -1
  215. package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.js +21 -4
  216. package/dist/compiler/tir/expressions/TirTypeConversionExpr.d.ts +3 -1
  217. package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +9 -1
  218. package/dist/compiler/tir/expressions/TirVariableAccessExpr.d.ts +6 -3
  219. package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +22 -8
  220. package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +19 -20
  221. package/dist/compiler/tir/expressions/ToIRTermCtx.js +74 -50
  222. package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +41 -0
  223. package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +180 -4
  224. package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.d.ts +4 -2
  225. package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.js +8 -2
  226. package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.d.ts +17 -0
  227. package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.js +21 -0
  228. package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.d.ts +4 -1
  229. package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.js +4 -0
  230. package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.d.ts +4 -1
  231. package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.js +5 -0
  232. package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.d.ts +4 -1
  233. package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.js +4 -0
  234. package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.d.ts +3 -1
  235. package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.js +5 -0
  236. package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.d.ts +3 -1
  237. package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.js +5 -0
  238. package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.d.ts +4 -1
  239. package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.js +4 -0
  240. package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.d.ts +4 -1
  241. package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.js +7 -3
  242. package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.d.ts +4 -1
  243. package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.js +4 -0
  244. package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.d.ts +4 -1
  245. package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.js +4 -0
  246. package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.d.ts +4 -1
  247. package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.js +4 -0
  248. package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.d.ts +2 -1
  249. package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.js +3 -1
  250. package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.d.ts +4 -2
  251. package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.js +8 -3
  252. package/dist/compiler/tir/expressions/unary/TirUnaryMinus.d.ts +4 -2
  253. package/dist/compiler/tir/expressions/unary/TirUnaryMinus.js +8 -2
  254. package/dist/compiler/tir/expressions/unary/TirUnaryPlus.d.ts +3 -1
  255. package/dist/compiler/tir/expressions/unary/TirUnaryPlus.js +6 -0
  256. package/dist/compiler/tir/expressions/unary/TirUnaryTilde.d.ts +4 -2
  257. package/dist/compiler/tir/expressions/unary/TirUnaryTilde.js +8 -2
  258. package/dist/compiler/tir/program/TypedProgram.d.ts +3 -2
  259. package/dist/compiler/tir/program/TypedProgram.js +9 -0
  260. package/dist/compiler/tir/program/stdScope/stdScope.js +135 -149
  261. package/dist/compiler/tir/statements/TirAssertStmt.d.ts +2 -0
  262. package/dist/compiler/tir/statements/TirAssertStmt.js +10 -0
  263. package/dist/compiler/tir/statements/TirAssignmentStmt.d.ts +2 -0
  264. package/dist/compiler/tir/statements/TirAssignmentStmt.js +8 -0
  265. package/dist/compiler/tir/statements/TirBlockStmt.d.ts +2 -0
  266. package/dist/compiler/tir/statements/TirBlockStmt.js +16 -0
  267. package/dist/compiler/tir/statements/TirBreakStmt.d.ts +2 -0
  268. package/dist/compiler/tir/statements/TirBreakStmt.js +8 -0
  269. package/dist/compiler/tir/statements/TirContinueStmt.d.ts +2 -0
  270. package/dist/compiler/tir/statements/TirContinueStmt.js +8 -0
  271. package/dist/compiler/tir/statements/TirFailStmt.d.ts +2 -0
  272. package/dist/compiler/tir/statements/TirFailStmt.js +8 -0
  273. package/dist/compiler/tir/statements/TirForOfStmt.d.ts +2 -0
  274. package/dist/compiler/tir/statements/TirForOfStmt.js +14 -0
  275. package/dist/compiler/tir/statements/TirForStmt.d.ts +2 -0
  276. package/dist/compiler/tir/statements/TirForStmt.js +21 -0
  277. package/dist/compiler/tir/statements/TirIfStmt.d.ts +2 -0
  278. package/dist/compiler/tir/statements/TirIfStmt.js +16 -0
  279. package/dist/compiler/tir/statements/TirMatchStmt.d.ts +2 -0
  280. package/dist/compiler/tir/statements/TirMatchStmt.js +30 -0
  281. package/dist/compiler/tir/statements/TirReturnStmt.d.ts +2 -0
  282. package/dist/compiler/tir/statements/TirReturnStmt.js +8 -0
  283. package/dist/compiler/tir/statements/TirStmt.d.ts +2 -0
  284. package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.d.ts +2 -0
  285. package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.js +30 -0
  286. package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.d.ts +3 -1
  287. package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js +28 -0
  288. package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.d.ts +3 -0
  289. package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.js +13 -0
  290. package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.d.ts +3 -1
  291. package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js +28 -0
  292. package/dist/compiler/tir/statements/TirWhileStmt.d.ts +2 -0
  293. package/dist/compiler/tir/statements/TirWhileStmt.js +14 -0
  294. package/dist/compiler/tir/types/utils/canAssignTo.js +1 -1
  295. package/dist/diagnostics/DiagnosticEmitter.js +1 -1
  296. package/dist/diagnostics/diagnosticMessages.generated.d.ts +10 -1
  297. package/dist/diagnostics/diagnosticMessages.generated.js +20 -2
  298. package/dist/parser/Parser.d.ts +8 -3
  299. package/dist/parser/Parser.js +180 -32
  300. package/dist/parser/Precedence.js +1 -0
  301. package/dist/tokenizer/Token.d.ts +81 -72
  302. package/dist/tokenizer/Token.js +82 -72
  303. package/dist/tokenizer/utils/tokenFromKeyword.js +32 -10
  304. package/dist/tokenizer/utils/tokenIsAlsoIdentifier.js +10 -0
  305. package/dist/utils/BitUtils/index.js +1 -1
  306. package/dist/utils/UPLCFlatUtils/index.js +1 -1
  307. package/dist/utils/array/keepSortedArrInplace.js +1 -0
  308. package/package.json +3 -1
  309. package/dist/IR/IRNodes/utils/isClosedAtDbn.d.ts +0 -2
  310. package/dist/IR/IRNodes/utils/isClosedAtDbn.js +0 -22
  311. package/dist/IR/toUPLC/_internal/_irToUplc.d.ts +0 -9
  312. package/dist/IR/toUPLC/_internal/_irToUplc.js +0 -156
  313. package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.d.ts +0 -9
  314. package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.js +0 -73
  315. package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.d.ts +0 -1
  316. package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.js +0 -12
  317. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.js +0 -227
  318. package/dist/IR/tree_utils/_ir_apps.d.ts +0 -3
  319. package/dist/IR/tree_utils/_ir_apps.js +0 -8
  320. package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.d.ts +0 -5
  321. package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +0 -37
@@ -139,7 +139,7 @@ export function populatePreludeScope(program) {
139
139
  return { sop, data };
140
140
  }
141
141
  function defineMultiConstructorStruct(name, constrs, opts, methodsNames = new Map()) {
142
- const { sop, data } = mkMultiConstructorStruct(name, constrs);
142
+ const { sop, data } = mkMultiConstructorStruct(name, constrs, methodsNames);
143
143
  const sop_key = sop.toTirTypeKey();
144
144
  const data_key = data.toTirTypeKey();
145
145
  if (opts.sop)
@@ -166,6 +166,7 @@ export function populatePreludeScope(program) {
166
166
  id: txHash_t,
167
167
  index: int_t
168
168
  }, onlyData);
169
+ const getCredentialHashFuncName = PEBBLE_INTERNAL_IDENTIFIER_PREFIX + "getCredentialHash";
169
170
  const { data: credential_t } = defineMultiConstructorStruct("Credential", {
170
171
  PubKey: {
171
172
  hash: pubKeyHash_t
@@ -173,28 +174,13 @@ export function populatePreludeScope(program) {
173
174
  Script: {
174
175
  hash: scriptHash_t
175
176
  }
176
- }, onlyData);
177
- // TODO:
178
- // understand how to describe function impls
179
- // const credential_t_impl = new TirInterfaceType(
180
- // undefined,
181
- // [],
182
- // []
183
- // )
184
- // credential_t_impl.methods.push(
185
- // new TirInterfaceMethod(
186
- // credential_t_impl,
187
- // "hash",
188
- // [],
189
- // hash28_t
190
- // )
191
- // );
192
- // credential_t.impls.push(
193
- // new TirInterfaceImpl(
194
- // credential_t,
195
- // credential_t_impl
196
- // )
197
- // );
177
+ }, onlyData, new Map([
178
+ [
179
+ "hash",
180
+ getCredentialHashFuncName
181
+ ],
182
+ ]));
183
+ preludeScope.program.functions.set(getCredentialHashFuncName, new TirInlineClosedIR(new TirFuncT([credential_t], hash28_t), (ctx) => IRNative._getCredentialsHash, SourceRange.unknown));
198
184
  const changeParams_t = _defineUnambigousAlias("ChangedParameters", map_int_data_t);
199
185
  const { data: rational_t } = defineSingleConstructorStruct("Rational", {
200
186
  numerator: int_t,
@@ -354,6 +340,127 @@ export function populatePreludeScope(program) {
354
340
  proposal: proposalProcedure_t
355
341
  }
356
342
  }, onlyData);
343
+ // struct Vote {
344
+ // No {}
345
+ // Yes {}
346
+ // Abstain {}
347
+ // }
348
+ const { data: vote_t } = defineMultiConstructorStruct("Vote", {
349
+ No: {},
350
+ Yes: {},
351
+ Abstain: {}
352
+ }, onlyData);
353
+ // struct Delegatee {
354
+ // StakePool { poolKeyHash: PubKeyHash }
355
+ // DRep { drep: Credential }
356
+ // PoolAndDRep {
357
+ // poolKeyHash: PubKeyHash,
358
+ // drep: Credential
359
+ // }
360
+ // }
361
+ const { data: delegatee_t } = defineMultiConstructorStruct("Delegatee", {
362
+ StakePool: {
363
+ poolKeyHash: pubKeyHash_t
364
+ },
365
+ DRep: {
366
+ drep: credential_t
367
+ },
368
+ PoolAndDRep: {
369
+ poolKeyHash: pubKeyHash_t,
370
+ drep: credential_t
371
+ }
372
+ }, onlyData);
373
+ // struct Certificate {
374
+ // StakeRegistration {
375
+ // stakeKey: Credential,
376
+ // deposit: Optional<int>
377
+ // }
378
+ // StakeDeRegistration {
379
+ // stakeKey: Credential,
380
+ // refund: Optional<int>
381
+ // }
382
+ // Delegation {
383
+ // delegator: Credential,
384
+ // delegatee: Delegatee
385
+ // }
386
+ // RegistrationAndDelegation {
387
+ // delegator: Credential,
388
+ // delegatee: Delegatee,
389
+ // lovelacesDeposit: int
390
+ // }
391
+ // DRepRegistration {
392
+ // drep: Credential,
393
+ // lovelacesDeposit: int
394
+ // }
395
+ // DRepUpdate {
396
+ // drep: Credential
397
+ // }
398
+ // DRepDeRegistration {
399
+ // drep: Credential,
400
+ // refund: int
401
+ // }
402
+ // PoolRegistration {
403
+ // poolId: PubKeyHash,
404
+ // poolVRF: PubKeyHash
405
+ // }
406
+ // PoolRetire {
407
+ // poolId: PubKeyHash,
408
+ // epoch: int
409
+ // }
410
+ // CommitteeHotAuthorization {
411
+ // cold: Credential,
412
+ // hot: Credential
413
+ // }
414
+ // CommitteeResignation {
415
+ // cold: Credential
416
+ // }
417
+ // }
418
+ const opt_int_t = program.getAppliedGeneric(TirDataOptT.toTirTypeKey(), [int_t]);
419
+ if (!opt_int_t)
420
+ throw new Error("expected opt_int_t");
421
+ const { data: certificate_t } = defineMultiConstructorStruct("Certificate", {
422
+ StakeRegistration: {
423
+ stakeKey: credential_t,
424
+ deposit: opt_int_t
425
+ },
426
+ StakeDeRegistration: {
427
+ stakeKey: credential_t,
428
+ refund: opt_int_t
429
+ },
430
+ Delegation: {
431
+ delegator: credential_t,
432
+ delegatee: delegatee_t
433
+ },
434
+ RegistrationAndDelegation: {
435
+ delegator: credential_t,
436
+ delegatee: delegatee_t,
437
+ lovelacesDeposit: int_t
438
+ },
439
+ DRepRegistration: {
440
+ drep: credential_t,
441
+ lovelacesDeposit: int_t
442
+ },
443
+ DRepUpdate: {
444
+ drep: credential_t
445
+ },
446
+ DRepDeRegistration: {
447
+ drep: credential_t,
448
+ refund: int_t
449
+ },
450
+ PoolRegistration: {
451
+ poolId: pubKeyHash_t,
452
+ poolVRF: bytes_t
453
+ },
454
+ PoolRetire: {
455
+ poolId: pubKeyHash_t,
456
+ epoch: int_t
457
+ },
458
+ CommitteeHotAuthorization: {
459
+ cold: credential_t,
460
+ hot: credential_t
461
+ },
462
+ CommitteeResignation: { cold: credential_t }
463
+ }, onlyData);
357
464
  // struct ScriptInfo {
358
465
  // Mint { policy: PolicyId }
359
466
  // Spend {
@@ -390,14 +497,14 @@ export function populatePreludeScope(program) {
390
497
  credential: credential_t
391
498
  },
392
499
  Certificate: {
393
- index: int_t,
394
- certificate: credential_t
500
+ certificateIndex: int_t,
501
+ certificate: certificate_t
395
502
  },
396
503
  Vote: {
397
504
  voter: voter_t
398
505
  },
399
506
  Propose: {
400
- index: int_t,
507
+ proposalIndex: int_t,
401
508
  proposal: proposalProcedure_t
402
509
  }
403
510
  }, onlyData);
@@ -501,7 +608,7 @@ export function populatePreludeScope(program) {
501
608
  // resolved: TxOut
502
609
  // }
503
610
  const { data: txIn_t } = defineSingleConstructorStruct("TxIn", {
504
- txOutRef: txOutRef_t,
611
+ ref: txOutRef_t,
505
612
  resolved: txOut_t
506
613
  }, onlyData);
507
614
  // struct ExtendedInteger {
@@ -532,127 +639,6 @@ export function populatePreludeScope(program) {
532
639
  from: intervalBoundary_t,
533
640
  to: intervalBoundary_t
534
641
  }, onlyData);
535
- // struct Vote {
536
- // No {}
537
- // Yes {}
538
- // Abstain {}
539
- // }
540
- const { data: vote_t } = defineMultiConstructorStruct("Vote", {
541
- No: {},
542
- Yes: {},
543
- Abstain: {}
544
- }, onlyData);
545
- // struct Delegatee {
546
- // StakePool { poolKeyHash: PubKeyHash }
547
- // DRep { drep: Credential }
548
- // PoolAndDRep {
549
- // poolKeyHash: PubKeyHash,
550
- // drep: Credential
551
- // }
552
- // }
553
- const { data: delegatee_t } = defineMultiConstructorStruct("Delegatee", {
554
- StakePool: {
555
- poolKeyHash: pubKeyHash_t
556
- },
557
- DRep: {
558
- drep: credential_t
559
- },
560
- PoolAndDRep: {
561
- poolKeyHash: pubKeyHash_t,
562
- drep: credential_t
563
- }
564
- }, onlyData);
565
- // struct Certificate {
566
- // StakeRegistration {
567
- // stakeKey: Credential,
568
- // deposit: Optional<int>
569
- // }
570
- // StakeDeRegistration {
571
- // stakeKey: Credential,
572
- // refund: Optional<int>
573
- // }
574
- // Delegation {
575
- // delegator: Credential,
576
- // delegatee: Delegatee
577
- // }
578
- // RegistrationAndDelegation {
579
- // delegator: Credential,
580
- // delegatee: Delegatee,
581
- // lovelacesDeposit: int
582
- // }
583
- // DRepRegistration {
584
- // drep: Credential,
585
- // lovelacesDeposit: int
586
- // }
587
- // DRepUpdate {
588
- // drep: Credential
589
- // }
590
- // DRepDeRegistration {
591
- // drep: Credential,
592
- // refund: int
593
- // }
594
- // PoolRegistration {
595
- // poolId: PubKeyHash,
596
- // poolVRF: PubKeyHash
597
- // }
598
- // PoolRetire {
599
- // poolId: PubKeyHash,
600
- // epoch: int
601
- // }
602
- // CommitteeHotAuthorization {
603
- // cold: Credential,
604
- // hot: Credential
605
- // }
606
- // CommitteeResignation {
607
- // cold: Credential
608
- // }
609
- // }
610
- const opt_int_t = program.getAppliedGeneric(TirDataOptT.toTirTypeKey(), [int_t]);
611
- if (!opt_int_t)
612
- throw new Error("expected opt_int_t");
613
- const { data: certificate_t } = defineMultiConstructorStruct("Certificate", {
614
- StakeRegistration: {
615
- stakeKey: credential_t,
616
- deposit: opt_int_t
617
- },
618
- StakeDeRegistration: {
619
- stakeKey: credential_t,
620
- refund: opt_int_t
621
- },
622
- Delegation: {
623
- delegator: credential_t,
624
- delegatee: delegatee_t
625
- },
626
- RegistrationAndDelegation: {
627
- delegator: credential_t,
628
- delegatee: delegatee_t,
629
- lovelacesDeposit: int_t
630
- },
631
- DRepRegistration: {
632
- drep: credential_t,
633
- lovelacesDeposit: int_t
634
- },
635
- DRepUpdate: {
636
- drep: credential_t
637
- },
638
- DRepDeRegistration: {
639
- drep: credential_t,
640
- refund: int_t
641
- },
642
- PoolRegistration: {
643
- poolId: pubKeyHash_t,
644
- poolVRF: bytes_t
645
- },
646
- PoolRetire: {
647
- poolId: pubKeyHash_t,
648
- epoch: int_t
649
- },
650
- CommitteeHotAuthorization: {
651
- cold: credential_t,
652
- hot: credential_t
653
- },
654
- CommitteeResignation: { cold: credential_t }
655
- }, onlyData);
656
642
  // struct Tx {
657
643
  // inputs: List<TxIn>,
658
644
  // refInputs: List<TxIn>,
@@ -726,5 +712,5 @@ export function populatePreludeScope(program) {
726
712
  redeemer: data_t,
727
713
  purpose: scriptInfo_t
728
714
  }, onlyData);
729
- preludeScope.readonly();
715
+ // preludeScope.readonly();
730
716
  }
@@ -12,6 +12,8 @@ export declare class TirAssertStmt implements ITirStmt {
12
12
  condition: TirExpr,
13
13
  /** must be string */
14
14
  elseExpr: TirExpr | undefined, range: SourceRange);
15
+ toString(): string;
16
+ pretty(indent: number): string;
15
17
  definitelyTerminates(): boolean;
16
18
  deps(): string[];
17
19
  toSafeCondition(): TirExpr;
@@ -13,6 +13,16 @@ export class TirAssertStmt {
13
13
  this.elseExpr = elseExpr;
14
14
  this.range = range;
15
15
  }
16
+ toString() {
17
+ return (`assert ${this.condition.toString()}` +
18
+ (this.elseExpr ? ` else ${this.elseExpr.toString()}` : ""));
19
+ }
20
+ pretty(indent) {
21
+ const singleIndent = " ";
22
+ const indent_base = singleIndent.repeat(indent);
23
+ return (`assert ${this.condition.pretty(indent)}` +
24
+ (this.elseExpr ? ` else ${this.elseExpr.pretty(indent)}` : ""));
25
+ }
16
26
  definitelyTerminates() { return false; }
17
27
  deps() {
18
28
  const deps = this.condition.deps();
@@ -7,6 +7,8 @@ export declare class TirAssignmentStmt implements ITirStmt {
7
7
  readonly assignedExpr: TirExpr;
8
8
  readonly range: SourceRange;
9
9
  constructor(varIdentifier: TirVariableAccessExpr, assignedExpr: TirExpr, range: SourceRange);
10
+ toString(): string;
11
+ pretty(indent: number): string;
10
12
  definitelyTerminates(): boolean;
11
13
  deps(): string[];
12
14
  }
@@ -7,6 +7,14 @@ export class TirAssignmentStmt {
7
7
  this.assignedExpr = assignedExpr;
8
8
  this.range = range;
9
9
  }
10
+ toString() {
11
+ return `${this.varIdentifier.toString()} = ${this.assignedExpr.toString()};`;
12
+ }
13
+ pretty(indent) {
14
+ const singleIndent = " ";
15
+ const indent_base = singleIndent.repeat(indent);
16
+ return `${this.varIdentifier.pretty(indent)} = ${this.assignedExpr.pretty(indent)}`;
17
+ }
10
18
  definitelyTerminates() { return false; }
11
19
  deps() {
12
20
  return this.varIdentifier.deps();
@@ -4,6 +4,8 @@ export declare class TirBlockStmt implements ITirStmt {
4
4
  stmts: TirStmt[];
5
5
  readonly range: SourceRange;
6
6
  constructor(stmts: TirStmt[], range: SourceRange);
7
+ toString(): string;
8
+ pretty(indent: number): string;
7
9
  definitelyTerminates(): boolean;
8
10
  deps(): string[];
9
11
  }
@@ -8,6 +8,22 @@ export class TirBlockStmt {
8
8
  this.stmts = stmts;
9
9
  this.range = range;
10
10
  }
11
+ toString() {
12
+ return (`{ ` +
13
+ this.stmts.map(s => s.toString()).join("; ") +
14
+ `}`);
15
+ }
16
+ pretty(indent) {
17
+ const singleIndent = " ";
18
+ const indent_base = singleIndent.repeat(indent);
19
+ const indent_0 = "\n" + indent_base;
20
+ const indent_1 = indent_0 + singleIndent;
21
+ if (this.stmts.length === 0)
22
+ return `${indent_0}{ }`;
23
+ return (`{` +
24
+ "\n" + indent_1 + this.stmts.map(s => s.pretty(indent + 1)).join(`;${indent_1}`) +
25
+ `${indent_0}}`);
26
+ }
11
27
  definitelyTerminates() {
12
28
  return this.stmts.some(stmt => stmt.definitelyTerminates());
13
29
  }
@@ -3,6 +3,8 @@ import { ITirStmt } from "./TirStmt.js";
3
3
  export declare class TirBreakStmt implements ITirStmt {
4
4
  readonly range: SourceRange;
5
5
  constructor(range: SourceRange);
6
+ toString(): string;
7
+ pretty(indent: number): string;
6
8
  definitelyTerminates(): boolean;
7
9
  deps(): string[];
8
10
  }
@@ -3,6 +3,14 @@ export class TirBreakStmt {
3
3
  constructor(range) {
4
4
  this.range = range;
5
5
  }
6
+ toString() {
7
+ return `break`;
8
+ }
9
+ pretty(indent) {
10
+ const singleIndent = " ";
11
+ const indent_base = singleIndent.repeat(indent);
12
+ return `break`;
13
+ }
6
14
  // loops are transoformed into recursive functions
7
15
  // and break statements are transformed into return statements
8
16
  // so this statement does terminate the function
@@ -3,6 +3,8 @@ import { ITirStmt } from "./TirStmt.js";
3
3
  export declare class TirContinueStmt implements ITirStmt {
4
4
  readonly range: SourceRange;
5
5
  constructor(range: SourceRange);
6
+ toString(): string;
7
+ pretty(indent: number): string;
6
8
  definitelyTerminates(): boolean;
7
9
  deps(): string[];
8
10
  }
@@ -3,6 +3,14 @@ export class TirContinueStmt {
3
3
  constructor(range) {
4
4
  this.range = range;
5
5
  }
6
+ toString() {
7
+ return `continue`;
8
+ }
9
+ pretty(indent) {
10
+ const singleIndent = " ";
11
+ const indent_base = singleIndent.repeat(indent);
12
+ return `continue`;
13
+ }
6
14
  // loops are transoformed into recursive functions
7
15
  // and continue statements are transformed into return statements
8
16
  // so this statement does terminate the function
@@ -8,6 +8,8 @@ export declare class TirFailStmt implements ITirStmt {
8
8
  constructor(
9
9
  /** must be string (or utf8 bytes) */
10
10
  failMsgExpr: TirExpr | undefined, range: SourceRange);
11
+ toString(): string;
12
+ pretty(indent: number): string;
11
13
  definitelyTerminates(): boolean;
12
14
  deps(): string[];
13
15
  }
@@ -7,6 +7,14 @@ export class TirFailStmt {
7
7
  this.failMsgExpr = failMsgExpr;
8
8
  this.range = range;
9
9
  }
10
+ toString() {
11
+ return `fail${this.failMsgExpr ? ` ${this.failMsgExpr.toString()}` : ""}`;
12
+ }
13
+ pretty(indent) {
14
+ const singleIndent = " ";
15
+ const indent_base = singleIndent.repeat(indent);
16
+ return `fail${this.failMsgExpr ? ` ${this.failMsgExpr.pretty(indent)}` : ""}`;
17
+ }
10
18
  definitelyTerminates() { return true; }
11
19
  deps() {
12
20
  return this.failMsgExpr?.deps() ?? [];
@@ -11,6 +11,8 @@ export declare class TirForOfStmt implements ITirStmt {
11
11
  body: TirStmt;
12
12
  readonly range: SourceRange;
13
13
  constructor(elemDeclaration: TirVarDecl, iterable: TirExpr, body: TirStmt, range: SourceRange);
14
+ toString(): string;
15
+ pretty(indent: number): string;
14
16
  definitelyTerminates(): boolean;
15
17
  deps(): string[];
16
18
  }
@@ -14,6 +14,20 @@ export class TirForOfStmt {
14
14
  this.body = body;
15
15
  this.range = range;
16
16
  }
17
+ toString() {
18
+ return (`for( ${this.elemDeclaration.toString()} of ${this.iterable.toString()} ) ` +
19
+ this.body.toString());
20
+ }
21
+ pretty(indent) {
22
+ const singleIndent = " ";
23
+ const indent_base = singleIndent.repeat(indent);
24
+ const indent_0 = "\n" + indent_base;
25
+ const indent_1 = indent_0 + singleIndent;
26
+ return (`for(` +
27
+ indent_1 + this.elemDeclaration.pretty(indent + 1) + ` of ` + this.iterable.pretty(indent + 1) +
28
+ `${indent_0}) ` +
29
+ this.body.pretty(indent));
30
+ }
17
31
  definitelyTerminates() {
18
32
  return this.body.definitelyTerminates();
19
33
  }
@@ -14,6 +14,8 @@ export declare class TirForStmt implements ITirStmt {
14
14
  body: TirStmt;
15
15
  readonly range: SourceRange;
16
16
  constructor(init: TirSimpleVarDecl[], condition: TirExpr | undefined, update: TirStmt[] | undefined, body: TirStmt, range: SourceRange);
17
+ toString(): string;
18
+ pretty(indent: number): string;
17
19
  definitelyTerminates(): boolean;
18
20
  deps(): string[];
19
21
  }
@@ -18,6 +18,27 @@ export class TirForStmt {
18
18
  this.body = body;
19
19
  this.range = range;
20
20
  }
21
+ toString() {
22
+ return (`for( ${this.init.map(v => v.toString()).join(", ")}; ` +
23
+ `${this.condition?.toString() ?? ""}; ` +
24
+ `${this.update?.map(s => s.toString()).join(", ") ?? ""} ) ` +
25
+ `${this.body.toString()}`);
26
+ }
27
+ pretty(indent) {
28
+ const singleIndent = " ";
29
+ const indent_base = singleIndent.repeat(indent);
30
+ const indent_0 = "\n" + indent_base;
31
+ const indent_1 = indent_0 + singleIndent;
32
+ const initPart = this.init.map(v => v.pretty(indent + 1)).join(`,${indent_1}`);
33
+ const condPart = this.condition ? this.condition.pretty(indent + 1) : "";
34
+ const updatePart = (this.update ?? []).map(s => s.pretty(indent + 1)).join(`,${indent_1}`);
35
+ return (`for(` +
36
+ indent_1 + initPart + `;` +
37
+ indent_1 + condPart + `;` +
38
+ indent_1 + updatePart +
39
+ `${indent_0}) ` +
40
+ this.body.pretty(indent));
41
+ }
21
42
  definitelyTerminates() {
22
43
  return this.body.definitelyTerminates() || (this.update?.some(stmt => stmt.definitelyTerminates()) ?? false);
23
44
  }
@@ -7,6 +7,8 @@ export declare class TirIfStmt implements ITirStmt {
7
7
  elseBranch: TirStmt | undefined;
8
8
  readonly range: SourceRange;
9
9
  constructor(condition: TirExpr, thenBranch: TirStmt, elseBranch: TirStmt | undefined, range: SourceRange);
10
+ toString(): string;
11
+ pretty(indent: number): string;
10
12
  definitelyTerminates(): boolean;
11
13
  deps(): string[];
12
14
  }
@@ -10,6 +10,22 @@ export class TirIfStmt {
10
10
  this.elseBranch = elseBranch;
11
11
  this.range = range;
12
12
  }
13
+ toString() {
14
+ return (`if( ${this.condition.toString()} ) ` +
15
+ this.thenBranch.toString() +
16
+ (this.elseBranch ? ` else ${this.elseBranch.toString()}` : ``));
17
+ }
18
+ pretty(indent) {
19
+ const singleIndent = " ";
20
+ const indent_base = singleIndent.repeat(indent);
21
+ const indent_0 = "\n" + indent_base;
22
+ const indent_1 = indent_0 + singleIndent;
23
+ return (`if(` +
24
+ indent_1 + this.condition.pretty(indent + 1) +
25
+ `${indent_0}) ` +
26
+ this.thenBranch.pretty(indent) +
27
+ (this.elseBranch ? ` else ${this.elseBranch.pretty(indent)}` : ""));
28
+ }
13
29
  definitelyTerminates() {
14
30
  return (this.thenBranch.definitelyTerminates()
15
31
  && (this.elseBranch?.definitelyTerminates() ?? false));
@@ -9,6 +9,8 @@ export declare class TirMatchStmt implements ITirStmt {
9
9
  wildcardCase: TirMatchStmtWildcardCase | undefined;
10
10
  readonly range: SourceRange;
11
11
  constructor(matchExpr: TirExpr, cases: TirMatchStmtCase[], wildcardCase: TirMatchStmtWildcardCase | undefined, range: SourceRange);
12
+ toString(): string;
13
+ pretty(indent: number): string;
12
14
  definitelyTerminates(): boolean;
13
15
  deps(): string[];
14
16
  }
@@ -11,6 +11,36 @@ export class TirMatchStmt {
11
11
  this.wildcardCase = wildcardCase;
12
12
  this.range = range;
13
13
  }
14
+ toString() {
15
+ return (`match ( ${this.matchExpr.toString()} ) { ` +
16
+ this.cases.map(c => `when ${c.pattern.toString()}: ${c.body.toString()};`).join(" ") +
17
+ (this.wildcardCase ? ` else ${this.wildcardCase.body.toString()};` : "") +
18
+ ` }`);
19
+ }
20
+ pretty(indent) {
21
+ const singleIndent = " ";
22
+ const indent_base = singleIndent.repeat(indent);
23
+ const indent_0 = "\n" + indent_base;
24
+ const indent_1 = indent_0 + singleIndent;
25
+ const caseParts = this.cases.map(c => `when ${c.pattern.pretty(indent + 1)}: ${c.body.pretty(indent + 1)}`);
26
+ const casesPart = caseParts.length > 0
27
+ ? indent_1 + caseParts.join(`;${indent_1}`) + ";"
28
+ : "";
29
+ const wildcardPart = this.wildcardCase
30
+ ? indent_1 + `else ${this.wildcardCase.body.pretty(indent + 1)};`
31
+ : "";
32
+ if (caseParts.length === 0 && !this.wildcardCase) {
33
+ return (`match (` +
34
+ indent_1 + this.matchExpr.pretty(indent + 1) +
35
+ `${indent_0}) { }`);
36
+ }
37
+ return (`match (` +
38
+ indent_1 + this.matchExpr.pretty(indent + 1) +
39
+ `${indent_0}) {` +
40
+ casesPart +
41
+ wildcardPart +
42
+ `${indent_0}}`);
43
+ }
14
44
  definitelyTerminates() {
15
45
  return this.cases.every(({ body }) => body.definitelyTerminates());
16
46
  }
@@ -5,6 +5,8 @@ export declare class TirReturnStmt implements ITirStmt {
5
5
  value: TirExpr;
6
6
  readonly range: SourceRange;
7
7
  constructor(value: TirExpr, range: SourceRange);
8
+ toString(): string;
9
+ pretty(indent: number): string;
8
10
  definitelyTerminates(): boolean;
9
11
  deps(): string[];
10
12
  }