@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
@@ -1,49 +1,43 @@
1
1
  import { BasePlutsError } from "../../utils/BasePlutsError.js";
2
2
  import { concatUint8Arr } from "../utils/concatUint8Arr.js";
3
- import { positiveIntAsBytes } from "../utils/positiveIntAsBytes.js";
4
3
  import { isIRParentTerm } from "../utils/isIRParentTerm.js";
5
4
  import { hashIrData, isIRHash } from "../IRHash.js";
6
5
  import { IRNodeKind } from "../IRNodeKind.js";
6
+ import { hashVarSym } from "./utils/hashVarSym.js";
7
+ import { UPLCVar } from "@harmoniclabs/uplc";
7
8
  export class IRVar {
9
+ _creationStack;
10
+ meta;
11
+ name;
12
+ constructor(name, _unsafeHash) {
13
+ if (!(typeof name === "symbol"
14
+ && typeof name.description === "string"
15
+ && name.description.length > 0))
16
+ throw new BasePlutsError("invalid name for IRVar");
17
+ this.name = name;
18
+ this._parent = undefined;
19
+ this.meta = {};
20
+ this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
21
+ this._creationStack = (new Error()).stack ?? "unknown";
22
+ }
23
+ toUPLC(ctx) {
24
+ return new UPLCVar(ctx.getVarAccessDbn(this.name));
25
+ }
8
26
  _hash;
9
27
  get hash() {
10
- if (!isIRHash(this._hash)) {
11
- this._hash = getVarHashAtDbn(this.dbn);
12
- }
28
+ if (isIRHash(this._hash))
29
+ return this._hash;
30
+ this._hash = hashIrData(concatUint8Arr(IRVar.tag, hashVarSym(this.name)));
13
31
  return this._hash;
14
32
  }
15
- /**
16
- * called inside the dbn setter
17
- */
33
+ isHashPresent() { return isIRHash(this._hash); }
18
34
  markHashAsInvalid() {
19
35
  this._hash = undefined;
20
36
  this.parent?.markHashAsInvalid();
21
37
  }
22
- isHashPresent() { return true; }
23
- _dbn;
24
- /**
25
- * the IR DeBruijn index is not necessarly the same of the UPLC
26
- * ( more ofthen than not it won't be the same )
27
- *
28
- * this is because in the IR things like `IRLetted` and `IRHoisted`
29
- * are skipping some DeBruijin levels that are instead present
30
- * in the final UPLC
31
- **/
32
- get dbn() { return this._dbn; }
33
- set dbn(newDbn) {
34
- if (!(Number.isSafeInteger(newDbn) && newDbn >= 0)) {
35
- // console.log( e.stack );
36
- throw new BasePlutsError("invalid index for an `IRVar` instance; new DeBruijn was: " + newDbn);
37
- }
38
- if (newDbn === this._dbn)
39
- return; // everything ok
40
- this.markHashAsInvalid();
41
- this._dbn = newDbn;
42
- }
43
38
  static get kind() { return IRNodeKind.Var; }
44
39
  get kind() { return IRVar.kind; }
45
40
  static get tag() { return new Uint8Array([IRVar.kind]); }
46
- meta;
47
41
  _parent;
48
42
  get parent() { return this._parent; }
49
43
  set parent(newParent) {
@@ -57,37 +51,15 @@ export class IRVar {
57
51
  // change parent
58
52
  this._parent = newParent;
59
53
  }
60
- constructor(DeBruijn) {
61
- Object.defineProperty(this, "meta", {
62
- value: {},
63
- writable: false,
64
- enumerable: true,
65
- configurable: false
66
- });
67
- this._hash = undefined;
68
- DeBruijn = typeof DeBruijn === "number" ? DeBruijn : Number(DeBruijn);
69
- this._dbn = DeBruijn;
70
- // call setter to check for validity
71
- this.dbn = DeBruijn;
72
- this._parent = undefined;
73
- }
54
+ children() { return []; }
74
55
  clone() {
75
- return new IRVar(this.dbn);
56
+ return new IRVar(this.name, this._hash);
76
57
  }
77
58
  toJSON() { return this.toJson(); }
78
59
  toJson() {
79
60
  return {
80
61
  type: "IRVar",
81
- dbn: this.dbn
62
+ name: this.name
82
63
  };
83
64
  }
84
65
  }
85
- const _bdnVarHashCache = new Map();
86
- function getVarHashAtDbn(dbn) {
87
- const cached = _bdnVarHashCache.get(dbn)?.deref();
88
- if (isIRHash(cached))
89
- return cached;
90
- const hash = hashIrData(concatUint8Arr(IRVar.tag, positiveIntAsBytes(dbn)));
91
- _bdnVarHashCache.set(dbn, new WeakRef(hash));
92
- return hash;
93
- }
@@ -2,4 +2,4 @@ import { IRTerm } from "../../IRTerm.js";
2
2
  /**
3
3
  * returns true if the term depends on *ANY* of the deBrujin indices specified
4
4
  */
5
- export declare function dependsByDbns(term: IRTerm, depsDbns: readonly number[]): boolean;
5
+ export declare function dependsByVars(term: IRTerm, depsVars: readonly symbol[]): boolean;
@@ -4,20 +4,14 @@ import { IRVar } from "../IRVar.js";
4
4
  /**
5
5
  * returns true if the term depends on *ANY* of the deBrujin indices specified
6
6
  */
7
- export function dependsByDbns(term, depsDbns) {
8
- if (depsDbns.length === 0)
7
+ export function dependsByVars(term, depsVars) {
8
+ if (depsVars.length === 0)
9
9
  return false;
10
10
  let doesDepend = false;
11
11
  iterTree(term, (node, diff) => {
12
- if (node instanceof IRVar ||
13
- node instanceof IRSelfCall) {
14
- doesDepend = doesDepend || depsDbns.some(dbn => {
15
- const realDbn = dbn + diff;
16
- // realDbn === 0 implies no variables are in scope
17
- // so if node.dbn === 0 and realDbn === 1 then the
18
- // variable is pointing to that definition
19
- return node.dbn === realDbn;
20
- });
12
+ if (node instanceof IRVar
13
+ || node instanceof IRSelfCall) {
14
+ doesDepend = doesDepend || depsVars.some(sym => node.name === sym);
21
15
  }
22
16
  },
23
17
  // shouldSkipNode
@@ -0,0 +1 @@
1
+ export declare function hashVarSym(s: symbol): Uint8Array;
@@ -0,0 +1,37 @@
1
+ // HASH GENERATOR
2
+ import { fromHex } from "@harmoniclabs/uint8array-utils";
3
+ const MAX_SAFE_INTEGER = Number(globalThis.Number?.MAX_SAFE_INTEGER ?? ((2 ** 53) - 1));
4
+ const MIN_SAFE_INTEGER = Number(globalThis.Number?.MIN_SAFE_INTEGER ?? -MAX_SAFE_INTEGER);
5
+ /// @ts-ignore Type 'symbol' does not satisfy the constraint 'object'.
6
+ const _sym_to_hash = new WeakMap();
7
+ // we cannot store the symbol itself as it would prevent garbage collection
8
+ /// @ts-ignore Type 'symbol' does not satisfy the constraint 'object'.
9
+ const _hash_to_sym = new Map();
10
+ let _next_hash = MIN_SAFE_INTEGER;
11
+ const unusedHashes = [];
12
+ function _collectUnusedHashes() {
13
+ for (const [h, s] of _hash_to_sym) {
14
+ const newSymbol = s.deref();
15
+ if (!newSymbol
16
+ || !_sym_to_hash.has(newSymbol)) {
17
+ _hash_to_sym.delete(h);
18
+ unusedHashes.push(h);
19
+ }
20
+ }
21
+ }
22
+ export function hashVarSym(s) {
23
+ const limitReached = _next_hash >= MAX_SAFE_INTEGER;
24
+ if (_next_hash % 0xffff === 0
25
+ || limitReached)
26
+ _collectUnusedHashes();
27
+ if (limitReached
28
+ && unusedHashes.length <= 0)
29
+ throw new Error("ran out of IR hashes");
30
+ const result_hash = unusedHashes.shift() ?? _next_hash++;
31
+ _sym_to_hash.set(s, result_hash);
32
+ /// @ts-ignore Argument of type 'WeakRef<object>' is not assignable to parameter of type 'WeakRef<symbol>'
33
+ _hash_to_sym.set(result_hash, new WeakRef(s));
34
+ return fromHex((BigInt(result_hash) + BigInt(MAX_SAFE_INTEGER))
35
+ .toString(16)
36
+ .padStart(16, "0"));
37
+ }
@@ -1 +1,2 @@
1
- export declare function makeArrayLikeProxy<T>(arr: ArrayLike<T>, isValidElem: (elem: T) => boolean, initModifyElem: (elem: T) => T, modifyElem: (elem: T, oldElem: T) => T): ArrayLike<T>;
1
+ import { MutArrayLike } from "../../utils/MutArrayLike.js";
2
+ export declare function makeArrayLikeProxy<T>(arr: ArrayLike<T>, isValidElem: (elem: T) => boolean, initModifyElem: (elem: T) => T, modifyElem: (elem: T, oldElem: T) => T): MutArrayLike<T>;
@@ -12,4 +12,11 @@ import { IRConstr } from "./IRNodes/IRConstr.js";
12
12
  import { IRCase } from "./IRNodes/IRCase.js";
13
13
  import { IRRecursive } from "./IRNodes/IRRecursive.js";
14
14
  import { IRSelfCall } from "./IRNodes/IRSelfCall.js";
15
+ import { IHash } from "./interfaces/index.js";
16
+ import { UPLCTerm } from "@harmoniclabs/uplc";
17
+ import { ToUplcCtx } from "./toUPLC/ctx/ToUplcCtx.js";
15
18
  export type IRTerm = IRVar | IRFunc | IRApp | IRConst | IRNative | IRLetted | IRHoisted | IRError | IRForced | IRDelayed | IRConstr | IRCase | IRRecursive | IRSelfCall;
19
+ export interface IIRTerm extends IHash {
20
+ children(): IRTerm[];
21
+ toUPLC(ctx: ToUplcCtx): UPLCTerm;
22
+ }
@@ -33,6 +33,10 @@ export interface CompilerOptions {
33
33
  * path to the output directory
34
34
  */
35
35
  readonly outDir: string;
36
+ /**
37
+ * if `true` silences all compiler output
38
+ */
39
+ readonly silent: boolean;
36
40
  /**
37
41
  * uplc version (encoded in the script)
38
42
  */
@@ -76,5 +80,6 @@ export declare const extremeOptions: CompilerOptions;
76
80
  export declare const productionOptions: CompilerOptions;
77
81
  export declare const debugOptions: CompilerOptions;
78
82
  export declare const defaultOptions: CompilerOptions;
83
+ export declare const testOptions: CompilerOptions;
79
84
  export declare const defulatCompilerOptions: CompilerOptions;
80
85
  export declare function completeCompilerOptions(options: Partial<CompilerOptions>, complete?: CompilerOptions): CompilerOptions;
@@ -36,6 +36,7 @@ export const extremeOptions = Object.freeze({
36
36
  entry: "./src/index.pebble",
37
37
  root: ".",
38
38
  outDir: "./out",
39
+ silent: false,
39
40
  targetUplcVersion: defaultUplcVersion,
40
41
  removeTraces: true,
41
42
  delayHoists: true,
@@ -46,6 +47,7 @@ export const productionOptions = Object.freeze({
46
47
  entry: "./src/index.pebble",
47
48
  root: ".",
48
49
  outDir: "./out",
50
+ silent: false,
49
51
  targetUplcVersion: defaultUplcVersion,
50
52
  removeTraces: true,
51
53
  delayHoists: true,
@@ -56,13 +58,20 @@ export const debugOptions = Object.freeze({
56
58
  entry: "./src/index.pebble",
57
59
  root: ".",
58
60
  outDir: "./out",
61
+ silent: false,
59
62
  targetUplcVersion: defaultUplcVersion,
60
63
  removeTraces: false,
61
64
  delayHoists: false,
62
65
  uplcOptimizations: debugUplcOptimizations,
63
66
  addMarker: false
64
67
  });
65
- export const defaultOptions = productionOptions;
68
+ export const defaultOptions = Object.freeze({
69
+ ...productionOptions,
70
+ });
71
+ export const testOptions = Object.freeze({
72
+ ...debugOptions,
73
+ silent: true
74
+ });
66
75
  export const defulatCompilerOptions = defaultOptions;
67
76
  export function completeCompilerOptions(options, complete = defaultOptions) {
68
77
  let targetUplcVersion = options.targetUplcVersion instanceof UPLCVersion ? complete.targetUplcVersion : defaultUplcVersion;
@@ -138,4 +138,7 @@ export function _modifyChildFromTo(parent, currentChild, newChild) {
138
138
  parent.value = newChild;
139
139
  return;
140
140
  }
141
+ const tsEnsureExhaustiveCheck = parent;
142
+ throw new Error("unknown parent type in '_modifyChildFromTo': " +
143
+ parent.constructor?.name);
141
144
  }
@@ -1,11 +1,4 @@
1
- import { IRCase, IRConstr } from "../../IRNodes/index.js";
2
- import { IRApp } from "../../IRNodes/IRApp.js";
3
- import { IRDelayed } from "../../IRNodes/IRDelayed.js";
4
- import { IRForced } from "../../IRNodes/IRForced.js";
5
- import { IRFunc } from "../../IRNodes/IRFunc.js";
6
1
  import { IRHoisted } from "../../IRNodes/IRHoisted.js";
7
- import { IRLetted } from "../../IRNodes/IRLetted.js";
8
- import { IRRecursive } from "../../IRNodes/IRRecursive.js";
9
2
  export function findAll(term, predicate) {
10
3
  const stack = [term];
11
4
  const result = [];
@@ -13,37 +6,7 @@ export function findAll(term, predicate) {
13
6
  const t = stack.pop();
14
7
  if (predicate(t))
15
8
  result.push(t);
16
- if (t instanceof IRApp) {
17
- stack.push(t.fn, t.arg);
18
- continue;
19
- }
20
- if (t instanceof IRDelayed) {
21
- stack.push(t.delayed);
22
- continue;
23
- }
24
- if (t instanceof IRForced) {
25
- stack.push(t.forced);
26
- continue;
27
- }
28
- if (t instanceof IRFunc) {
29
- stack.push(t.body);
30
- continue;
31
- }
32
- if (t instanceof IRRecursive) {
33
- stack.push(t.body);
34
- continue;
35
- }
36
- if (t instanceof IRHoisted) {
37
- stack.push(t.hoisted);
38
- continue;
39
- }
40
- if (t instanceof IRLetted) {
41
- // same stuff as the hoisted terms
42
- // the only difference is that depth is then incremented
43
- // once the letted term reaches its final position
44
- stack.push(t.value);
45
- continue;
46
- }
9
+ stack.push(...t.children());
47
10
  }
48
11
  return result;
49
12
  }
@@ -54,46 +17,12 @@ export function findAllNoHoisted(term, predicate) {
54
17
  const t = stack.pop();
55
18
  if (predicate(t))
56
19
  result.push(t);
57
- if (t instanceof IRApp) {
58
- stack.push(t.fn, t.arg);
59
- continue;
60
- }
61
- if (t instanceof IRCase) {
62
- stack.push(t.constrTerm, ...t.continuations);
63
- continue;
64
- }
65
- if (t instanceof IRConstr) {
66
- stack.push(...t.fields);
67
- continue;
68
- }
69
- if (t instanceof IRDelayed) {
70
- stack.push(t.delayed);
71
- continue;
72
- }
73
- if (t instanceof IRForced) {
74
- stack.push(t.forced);
75
- continue;
76
- }
77
- if (t instanceof IRFunc) {
78
- stack.push(t.body);
79
- continue;
80
- }
81
- if (t instanceof IRRecursive) {
82
- stack.push(t.body);
83
- continue;
84
- }
85
20
  if (t instanceof IRHoisted) {
86
21
  // this is `findAllNoHoisted` remember?
87
22
  // stack.push( t.hoisted );
88
23
  continue;
89
24
  }
90
- if (t instanceof IRLetted) {
91
- // same stuff as the hoisted terms
92
- // the only difference is that depth is then incremented
93
- // once the letted term reaches its final position
94
- stack.push(t.value);
95
- continue;
96
- }
25
+ stack.push(...t.children());
97
26
  }
98
27
  return result;
99
28
  }
@@ -1,12 +1,7 @@
1
1
  import { equalIrHash } from "../../IRHash.js";
2
- import { IRCase, IRConstr } from "../../IRNodes/index.js";
3
- import { IRApp } from "../../IRNodes/IRApp.js";
4
- import { IRDelayed } from "../../IRNodes/IRDelayed.js";
5
- import { IRForced } from "../../IRNodes/IRForced.js";
2
+ import { IRHoisted } from "../../IRNodes/index.js";
6
3
  import { IRFunc } from "../../IRNodes/IRFunc.js";
7
- import { IRLetted } from "../../IRNodes/IRLetted.js";
8
4
  import { IRRecursive } from "../../IRNodes/IRRecursive.js";
9
- import { mapArrayLike } from "../../IRNodes/utils/mapArrayLike.js";
10
5
  export function getDebruijnInTerm(root, termToFind) {
11
6
  const termTofindHash = termToFind.hash;
12
7
  const stack = [{ term: root, dbn: 0 }];
@@ -14,38 +9,16 @@ export function getDebruijnInTerm(root, termToFind) {
14
9
  const { term, dbn } = stack.pop();
15
10
  if (term === termToFind || equalIrHash(term.hash, termTofindHash))
16
11
  return dbn;
17
- if (term instanceof IRApp) {
18
- stack.push({ term: term.fn, dbn }, { term: term.arg, dbn });
19
- continue;
20
- }
21
- if (term instanceof IRCase) {
22
- stack.push({ term: term.constrTerm, dbn }, ...mapArrayLike(term.continuations, (continuation) => ({ term: continuation, dbn })));
23
- continue;
24
- }
25
- if (term instanceof IRConstr) {
26
- stack.push(...mapArrayLike(term.fields, (field) => ({ term: field, dbn })));
27
- continue;
28
- }
29
- if (term instanceof IRDelayed) {
30
- stack.push({ term: term.delayed, dbn });
31
- continue;
32
- }
33
- if (term instanceof IRForced) {
34
- stack.push({ term: term.forced, dbn });
35
- continue;
36
- }
37
- if (term instanceof IRFunc) {
12
+ if (term instanceof IRFunc
13
+ || term instanceof IRRecursive) {
14
+ // new variable in scope
38
15
  stack.push({ term: term.body, dbn: dbn + term.arity });
39
16
  continue;
40
17
  }
41
- if (term instanceof IRRecursive) {
42
- stack.push({ term: term.body, dbn: dbn + term.arity });
18
+ if (term instanceof IRHoisted) {
43
19
  continue;
44
- }
45
- if (term instanceof IRLetted) {
46
- stack.push({ term: term.value, dbn });
47
- continue;
48
- }
20
+ } // skip hoisted since closed
21
+ stack.push(...term.children().map(t => ({ term: t, dbn })));
49
22
  }
50
23
  return -1;
51
24
  }
@@ -7,6 +7,7 @@ import { IRFunc } from "../../IRNodes/IRFunc.js";
7
7
  import { IRHoisted } from "../../IRNodes/IRHoisted.js";
8
8
  import { IRLetted } from "../../IRNodes/IRLetted.js";
9
9
  import { IRRecursive } from "../../IRNodes/IRRecursive.js";
10
+ import { sanifyTree } from "../subRoutines/sanifyTree.js";
10
11
  export function iterTree(_term, fn,
11
12
  // necessary for letted hash calculation (exclude hoisted)
12
13
  shouldSkipNode, shouldExit) {
@@ -32,31 +33,14 @@ shouldSkipNode, shouldExit) {
32
33
  continue;
33
34
  }
34
35
  if (t instanceof IRApp) {
35
- // sanifyTree as we go
36
- if (t.fn.parent !== t)
37
- t.fn = t.fn.clone();
38
- if (t.arg.parent !== t)
39
- t.arg = t.arg.clone();
40
36
  stack.push({ term: t.fn, dbn }, { term: t.arg, dbn, shouldPopIfParentIsModified: true });
41
37
  continue;
42
38
  }
43
39
  if (t instanceof IRCase) {
44
- // sanifyTree as we go
45
- if (t.constrTerm.parent !== t)
46
- t.constrTerm = t.constrTerm.clone();
47
- for (let i = 0; i < t.continuations.length; i++) {
48
- if (t.continuations[i].parent !== t)
49
- t.continuations[i] = t.continuations[i].clone();
50
- }
51
40
  stack.push({ term: t.constrTerm, dbn }, ...Array.from(t.continuations).map(cont => ({ term: cont, dbn, shouldPopIfParentIsModified: true })));
52
41
  continue;
53
42
  }
54
43
  if (t instanceof IRConstr) {
55
- // sanifyTree as we go
56
- for (let i = 0; i < t.fields.length; i++) {
57
- if (t.fields[i].parent !== t)
58
- t.fields[i] = t.fields[i].clone();
59
- }
60
44
  stack.push(...Array.from(t.fields).map((f, i) => ({ term: f, dbn, shouldPopIfParentIsModified: i !== 0 })));
61
45
  continue;
62
46
  }
@@ -89,5 +73,7 @@ shouldSkipNode, shouldExit) {
89
73
  stack.push({ term: t.value, dbn });
90
74
  continue;
91
75
  }
76
+ stack.push(...t.children().map(c => ({ term: c, dbn })));
92
77
  }
78
+ sanifyTree(_term);
93
79
  }
@@ -0,0 +1,2 @@
1
+ import { IRHoisted } from "../IRNodes/IRHoisted.js";
2
+ export declare const hoisted_constr1_empty: IRHoisted;
@@ -0,0 +1,4 @@
1
+ import { DataConstr } from "@harmoniclabs/plutus-data";
2
+ import { IRHoisted } from "../IRNodes/IRHoisted.js";
3
+ import { IRConst } from "../IRNodes/IRConst.js";
4
+ export const hoisted_constr1_empty = new IRHoisted(IRConst.data(new DataConstr(1, [])));
@@ -1,4 +1,4 @@
1
- import type { UPLCTerm } from "@harmoniclabs/uplc";
1
+ import { type UPLCTerm } from "@harmoniclabs/uplc";
2
2
  import type { IRTerm } from "../IRTerm.js";
3
3
  import { CompilerOptions } from "./CompilerOptions.js";
4
4
  export declare function compileIRToUPLC(term: IRTerm, paritalOptions?: Partial<CompilerOptions>): UPLCTerm;