@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,12 +0,0 @@
1
- import { IRVar } from "../../IRNodes/IRVar.js";
2
- import { iterTree } from "../_internal/iterTree.js";
3
- function hasAtLeastNVarsAtDbn(term, baseDbn = 0) {
4
- let n = 0;
5
- iterTree(term, (node, dbn) => {
6
- if (node instanceof IRVar && node.dbn === baseDbn + dbn)
7
- n++;
8
- }, undefined, // shouldSkipNode
9
- () => n > 1 // shouldExit
10
- );
11
- return n > 1;
12
- }
@@ -1,227 +0,0 @@
1
- import { IRConstr, IRNative } from "../../../IRNodes/index.js";
2
- import { IRApp } from "../../../IRNodes/IRApp.js";
3
- import { IRCase } from "../../../IRNodes/IRCase.js";
4
- import { IRDelayed } from "../../../IRNodes/IRDelayed.js";
5
- import { IRForced } from "../../../IRNodes/IRForced.js";
6
- import { IRFunc } from "../../../IRNodes/IRFunc.js";
7
- import { IRHoisted } from "../../../IRNodes/IRHoisted.js";
8
- import { IRLetted } from "../../../IRNodes/IRLetted.js";
9
- import { IRRecursive } from "../../../IRNodes/IRRecursive.js";
10
- import { IRSelfCall } from "../../../IRNodes/IRSelfCall.js";
11
- import { IRVar } from "../../../IRNodes/IRVar.js";
12
- import { dependsByDbns } from "../../../IRNodes/utils/dependsByDbns.js";
13
- import { mapArrayLike } from "../../../IRNodes/utils/mapArrayLike.js";
14
- import { _modifyChildFromTo } from "../../_internal/_modifyChildFromTo.js";
15
- import { isDebugUplcOptimizations } from "../../CompilerOptions.js";
16
- import { expandFuncsAndReturnRoot, getExpandedIRFunc } from "./expandFuncsAndReturnRoot.js";
17
- export function performUplcOptimizationsAndReturnRoot(root, options) {
18
- const opts = options.uplcOptimizations;
19
- if (isDebugUplcOptimizations(opts))
20
- return root;
21
- const { groupApplications, inlineSingleUse, simplifyWrappedPartialFuncApps, removeForceDelay } = opts;
22
- root = expandFuncsAndReturnRoot(root);
23
- const stack = [[root, 0]];
24
- while (stack.length > 0) {
25
- let [t, dbn] = stack.pop();
26
- if (t instanceof IRApp) {
27
- if (isIdLike(t.fn)) {
28
- if (t.parent)
29
- _modifyChildFromTo(t.parent, t, t.arg);
30
- else
31
- root = t.arg;
32
- stack.push([t.arg, dbn]);
33
- continue;
34
- }
35
- if (!groupApplications) {
36
- stack.push([t.fn, dbn], [t.arg, dbn]);
37
- continue;
38
- }
39
- let args;
40
- let body;
41
- /*
42
- // can't figure how to make it work
43
- [ args, body ] = groupIndipendentLets( t, dbn );
44
-
45
- if( args.length >= 2 )
46
- {
47
- let newNode = body;
48
- for( let i = args.length - 1; i >= 0; i-- )
49
- {
50
- // apply as normal apps, not case/constr
51
- // so we can further group if the body is directly applications
52
- newNode = new IRApp( newNode, args[i] );
53
- }
54
-
55
- // overwrite original
56
- if( t.parent ) _modifyChildFromTo( t.parent, t, newNode );
57
- else root = newNode;
58
-
59
- // reanalyze this new node to group using case/constr
60
- stack.push([ newNode, dbn ]);
61
- continue;
62
- }
63
- //*/
64
- [args, body] = getMultiAppArgsAndBody(t);
65
- if (args.length <= 2) {
66
- stack.push([t.fn, dbn], [t.arg, dbn]);
67
- continue;
68
- }
69
- const newNode = new IRCase(new IRConstr(0, args), [body]);
70
- stack.push([body, dbn]);
71
- if (t.parent)
72
- _modifyChildFromTo(t.parent, t, newNode);
73
- else
74
- root = newNode;
75
- continue;
76
- }
77
- if (t instanceof IRCase) {
78
- stack.push([t.constrTerm, dbn], ...mapArrayLike(t.continuations, (c) => [c, dbn]));
79
- continue;
80
- }
81
- if (t instanceof IRConstr) {
82
- // stack.push( ...t.fields );
83
- stack.push(...mapArrayLike(t.fields, (f) => [f, dbn]));
84
- continue;
85
- }
86
- if (t instanceof IRDelayed) {
87
- stack.push([t.delayed, dbn]);
88
- continue;
89
- }
90
- if (t instanceof IRForced) {
91
- stack.push([t.forced, dbn]);
92
- continue;
93
- }
94
- if (t instanceof IRFunc) {
95
- stack.push([t.body, dbn + t.arity]);
96
- continue;
97
- }
98
- if (t instanceof IRRecursive ||
99
- t instanceof IRHoisted ||
100
- t instanceof IRLetted ||
101
- t instanceof IRSelfCall) {
102
- throw new Error("Unexpected term while performing uplc optimizations");
103
- }
104
- }
105
- return root;
106
- }
107
- function isAppLike(term) {
108
- return (term instanceof IRApp ||
109
- isCaseConstrApp(term));
110
- }
111
- /** @experimental still can't figure how to make it work */
112
- export function groupIndipendentLets(term, dbn) {
113
- let args = [];
114
- let body = term;
115
- //*
116
- const lettedDbns = [];
117
- while (term instanceof IRApp &&
118
- term.fn instanceof IRFunc &&
119
- term.fn.arity === 1) {
120
- // letted terms
121
- // [(lam a [(lam b [(lam c ... ))) c] b] a] :: []
122
- // [(lam b [(lam c ... ))) c] b] :: [a]
123
- // [(lam c ... ) c] :: [a, b]
124
- // ... :: [a, b, c]
125
- // finally expand:
126
- // (lam a (lam b (lam c ... ))) :: [a, b, c]
127
- // console.log({
128
- // arg: prettyIRInline( term.arg ),
129
- // lettedDbns,
130
- // depends: dependsByDbns( term.arg, lettedDbns ),
131
- // currArgsLen: args.length
132
- // });
133
- if (!dependsByDbns(term.arg, lettedDbns)) {
134
- args.push(term.arg);
135
- term = term.fn.body;
136
- // push current dbn
137
- // and increment later
138
- lettedDbns.push(dbn++);
139
- body = term;
140
- continue;
141
- }
142
- else {
143
- term = term.fn.body;
144
- break;
145
- }
146
- continue;
147
- }
148
- return [
149
- args,
150
- getExpandedIRFunc(body, args.length)
151
- ];
152
- //*/
153
- }
154
- function getMultiAppArgsAndBody(term) {
155
- let args = [];
156
- let body = term;
157
- // else we look for consecutive applications or cases
158
- while (term instanceof IRApp) {
159
- /*
160
- consecutive applications look like:
161
- [
162
- [
163
- [
164
- (lam a (lam b (lam c ... )))
165
- a]
166
- b]
167
- c]
168
- but the equivalent IRCase looks like:
169
- (case
170
- (constr 0 a b c)
171
- (lam a (lam b (lam c ... )))
172
- )
173
- so we need to reverse the order of the args
174
- since we start from the outermost application
175
- (in order, we encounter from the top: c => b => a)
176
- */
177
- args.unshift(term.arg);
178
- term = term.fn;
179
- // arity++;
180
- body = term;
181
- }
182
- ;
183
- return [args, body];
184
- // if( args.length === 0 ) return [ args, body ];
185
- // const [ nextArgs, nextBody ] = getMultiAppArgsAndBody( body, dbn );
186
- // return [ args.concat( nextArgs ), nextBody ];
187
- }
188
- function isCaseConstrApp(term) {
189
- return (term instanceof IRCase &&
190
- term.continuations.length === 1 &&
191
- term.constrTerm instanceof IRCase);
192
- }
193
- function isIdLike(term) {
194
- return (term instanceof IRFunc &&
195
- term.arity === 1 &&
196
- term.body instanceof IRVar &&
197
- Number(term.body.dbn) === 0);
198
- }
199
- function getArityOfTerm(term) {
200
- let arity = 0;
201
- while (term instanceof IRApp ||
202
- term instanceof IRFunc ||
203
- term instanceof IRNative ||
204
- term instanceof IRVar ||
205
- term instanceof IRForced ||
206
- term instanceof IRDelayed) {
207
- if (term instanceof IRForced) {
208
- term = term.forced;
209
- continue;
210
- }
211
- if (term instanceof IRDelayed) {
212
- term = term.delayed;
213
- continue;
214
- }
215
- if (term instanceof IRApp) {
216
- arity--;
217
- term = term.fn;
218
- continue;
219
- }
220
- if (term instanceof IRFunc) {
221
- arity += term.arity;
222
- term = term.body;
223
- continue;
224
- }
225
- }
226
- return arity;
227
- }
@@ -1,3 +0,0 @@
1
- import { IRApp } from "../IRNodes/IRApp.js";
2
- import { IRTerm } from "../IRTerm.js";
3
- export declare function _ir_apps(...terms: [IRTerm, IRTerm, ...IRTerm[]]): IRApp;
@@ -1,8 +0,0 @@
1
- import { IRApp } from "../IRNodes/IRApp.js";
2
- export function _ir_apps(...terms) {
3
- let term = new IRApp(terms[0], terms[1]);
4
- for (let i = 2; i < terms.length; i++) {
5
- term = new IRApp(term, terms[i]);
6
- }
7
- return term;
8
- }
@@ -1,5 +0,0 @@
1
- import { TirHoistedExpr } from "../../tir/expressions/TirHoistedExpr.js";
2
- import { TirNativeFunc } from "../../tir/expressions/TirNativeFunc.js";
3
- import { TypedProgram } from "../../tir/program/TypedProgram.js";
4
- import { DepsNode } from "./deps/DepsNode.js";
5
- export declare function _compileHoistedDeps(program: TypedProgram, hoistedMap: Map<string, TirHoistedExpr | TirNativeFunc>, deps: string[], depsStack: DepsNode): void;
@@ -1,37 +0,0 @@
1
- import { TirHoistedExpr } from "../../tir/expressions/TirHoistedExpr.js";
2
- import { ExpressifyCtx } from "../expressify/ExpressifyCtx.js";
3
- import { expressifyVars } from "../expressify/expressifyVars.js";
4
- export function _compileHoistedDeps(program, hoistedMap, deps, depsStack) {
5
- let depName;
6
- if (deps.some(dep => depsStack.includes(dep)))
7
- throw new Error("Circular dependency in hoisted expressions NOT YET IMPLEMENTED");
8
- while (depName = deps.pop()) {
9
- const funcDecl = program.functions.get(depName);
10
- if (funcDecl) {
11
- _compileHoistedDeps(program, hoistedMap, funcDecl.deps(), depsStack.getNext(depName));
12
- /*
13
- const funcExpr = funcDecl instanceof TirInlineClosedIR ? funcDecl : expressify(
14
- funcDecl,
15
- undefined, // loopReplacements
16
- new ExpressifyCtx(
17
- undefined,
18
- funcDecl.returnType,
19
- hoistedMap
20
- )
21
- );
22
- //*/
23
- const hoistedExpr = new TirHoistedExpr(depName, funcDecl);
24
- hoistedMap.set(depName, hoistedExpr);
25
- continue;
26
- }
27
- const constDecl = program.constants.get(depName);
28
- if (constDecl) {
29
- _compileHoistedDeps(program, hoistedMap, constDecl.deps(), depsStack.getNext(depName));
30
- const expr = expressifyVars(new ExpressifyCtx(undefined, constDecl.type, hoistedMap), constDecl);
31
- const hoistedExpr = new TirHoistedExpr(depName, expr);
32
- hoistedMap.set(depName, hoistedExpr);
33
- continue;
34
- }
35
- throw new Error(`Hoisted dependency "${depName}" not found in program`);
36
- }
37
- }