@harmoniclabs/pebble 0.1.0-dev5 → 0.1.0-dev6

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 (307) 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 +0 -2
  24. package/dist/IR/IRNodes/IRNative/IRNativeTag.js +0 -4
  25. package/dist/IR/IRNodes/IRNative/index.d.ts +9 -8
  26. package/dist/IR/IRNodes/IRNative/index.js +55 -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/_internal/_modifyChildFromTo.js +3 -0
  42. package/dist/IR/toUPLC/_internal/findAll.js +2 -73
  43. package/dist/IR/toUPLC/_internal/getDebruijnInTerm.js +7 -34
  44. package/dist/IR/toUPLC/_internal/iterTree.js +3 -17
  45. package/dist/IR/toUPLC/common_hoisted.d.ts +2 -0
  46. package/dist/IR/toUPLC/common_hoisted.js +4 -0
  47. package/dist/IR/toUPLC/compileIRToUPLC.d.ts +1 -1
  48. package/dist/IR/toUPLC/compileIRToUPLC.js +91 -14
  49. package/dist/IR/toUPLC/ctx/ToUplcCtx.d.ts +16 -0
  50. package/dist/IR/toUPLC/ctx/ToUplcCtx.js +75 -0
  51. package/dist/IR/toUPLC/subRoutines/_comptimeDropN.d.ts +8 -0
  52. package/dist/IR/toUPLC/subRoutines/_comptimeDropN.js +95 -0
  53. package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.js +7 -54
  54. package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.d.ts +6 -13
  55. package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.js +67 -71
  56. package/dist/IR/toUPLC/subRoutines/handleLetted/index.js +44 -170
  57. package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.js +7 -3
  58. package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.js +3 -2
  59. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.d.ts +22 -0
  60. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.js +59 -0
  61. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.d.ts +0 -0
  62. package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.js +217 -0
  63. package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.js +12 -49
  64. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.d.ts +1 -1
  65. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.js +11 -14
  66. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/{index.d.ts → performUplcOptimizationsAndReturnRoot.d.ts} +0 -2
  67. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/performUplcOptimizationsAndReturnRoot.js +151 -0
  68. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.d.ts +11 -0
  69. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.js +46 -0
  70. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.d.ts +2 -0
  71. package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.js +80 -0
  72. package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.js +18 -11
  73. package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +43 -0
  74. package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +255 -478
  75. package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.d.ts +2 -0
  76. package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.js +85 -0
  77. package/dist/IR/toUPLC/subRoutines/sanifyTree.js +1 -0
  78. package/dist/IR/toUPLC/utils/getApplicationTerms.d.ts +6 -0
  79. package/dist/IR/toUPLC/utils/getApplicationTerms.js +37 -0
  80. package/dist/IR/tree_utils/_ir_lazyChooseList.d.ts +2 -2
  81. package/dist/IR/tree_utils/_ir_lazyChooseList.js +4 -2
  82. package/dist/IR/tree_utils/_ir_lazyIfThenElse.d.ts +1 -1
  83. package/dist/IR/tree_utils/_ir_lazyIfThenElse.js +4 -2
  84. package/dist/IR/tree_utils/_ir_let.d.ts +2 -1
  85. package/dist/IR/tree_utils/_ir_let.js +6 -2
  86. package/dist/IR/utils/isClosedIRTerm.d.ts +1 -0
  87. package/dist/IR/utils/isClosedIRTerm.js +39 -25
  88. package/dist/IR/utils/positiveIntAsBytes.d.ts +1 -0
  89. package/dist/IR/utils/positiveIntAsBytes.js +4 -0
  90. package/dist/IR/utils/showIR.d.ts +10 -21
  91. package/dist/IR/utils/showIR.js +66 -64
  92. package/dist/ast/nodes/common/Identifier.d.ts +1 -0
  93. package/dist/ast/nodes/common/Identifier.js +3 -0
  94. package/dist/ast/nodes/expr/CaseExpr.d.ts +5 -5
  95. package/dist/ast/nodes/expr/ElemAccessExpr.d.ts +2 -2
  96. package/dist/ast/nodes/expr/ParentesizedExpr.d.ts +1 -1
  97. package/dist/ast/nodes/expr/PebbleExpr.d.ts +2 -1
  98. package/dist/ast/nodes/expr/PropAccessExpr.d.ts +3 -3
  99. package/dist/ast/nodes/expr/TernaryExpr.d.ts +3 -3
  100. package/dist/ast/nodes/expr/TypeConversionExpr.d.ts +2 -1
  101. package/dist/ast/nodes/expr/TypeConversionExpr.js +2 -0
  102. package/dist/ast/nodes/expr/binary/BinaryExpr.d.ts +42 -42
  103. package/dist/ast/nodes/expr/functions/CallExpr.d.ts +1 -1
  104. package/dist/ast/nodes/expr/functions/FuncExpr.d.ts +2 -1
  105. package/dist/ast/nodes/expr/functions/FuncExpr.js +6 -0
  106. package/dist/ast/nodes/expr/litteral/LitContextExpr.d.ts +6 -0
  107. package/dist/ast/nodes/expr/litteral/LitContextExpr.js +6 -0
  108. package/dist/ast/nodes/expr/litteral/LitFailExpr.d.ts +6 -0
  109. package/dist/ast/nodes/expr/litteral/LitFailExpr.js +6 -0
  110. package/dist/ast/nodes/expr/litteral/LitteralExpr.d.ts +3 -1
  111. package/dist/ast/nodes/expr/litteral/LitteralExpr.js +5 -1
  112. package/dist/ast/nodes/statements/AssertStmt.d.ts +2 -2
  113. package/dist/ast/nodes/statements/AssignmentStmt.d.ts +1 -1
  114. package/dist/ast/nodes/statements/BlockStmt.d.ts +1 -1
  115. package/dist/ast/nodes/statements/FailStmt.d.ts +1 -1
  116. package/dist/ast/nodes/statements/ForOfStmt.d.ts +4 -2
  117. package/dist/ast/nodes/statements/ForOfStmt.js +6 -0
  118. package/dist/ast/nodes/statements/ForStmt.d.ts +6 -4
  119. package/dist/ast/nodes/statements/ForStmt.js +6 -0
  120. package/dist/ast/nodes/statements/IfStmt.d.ts +8 -5
  121. package/dist/ast/nodes/statements/IfStmt.js +13 -0
  122. package/dist/ast/nodes/statements/MatchStmt.d.ts +13 -4
  123. package/dist/ast/nodes/statements/MatchStmt.js +22 -1
  124. package/dist/ast/nodes/statements/PebbleStmt.d.ts +2 -1
  125. package/dist/ast/nodes/statements/PebbleStmt.js +3 -1
  126. package/dist/ast/nodes/statements/ReturnStmt.d.ts +1 -1
  127. package/dist/ast/nodes/statements/WhileStmt.d.ts +4 -2
  128. package/dist/ast/nodes/statements/WhileStmt.js +6 -0
  129. package/dist/ast/nodes/statements/declarations/ContractDecl.d.ts +17 -0
  130. package/dist/ast/nodes/statements/declarations/ContractDecl.js +22 -0
  131. package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.d.ts +1 -1
  132. package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.d.ts +1 -1
  133. package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.d.ts +1 -1
  134. package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.d.ts +2 -1
  135. package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.js +6 -0
  136. package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.d.ts +1 -1
  137. package/dist/compiler/AstCompiler/AstCompiler.d.ts +6 -2
  138. package/dist/compiler/AstCompiler/AstCompiler.js +91 -24
  139. package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.d.ts +10 -0
  140. package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.js +777 -0
  141. package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.js +1 -1
  142. package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.js +1 -1
  143. package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.js +8 -2
  144. package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.js +1 -1
  145. package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.js +3 -1
  146. package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +1 -1
  147. package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +2 -2
  148. package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.d.ts +2 -2
  149. package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.js +48 -24
  150. package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +4 -1
  151. package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.js +2 -2
  152. package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.js +1 -1
  153. package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.js +4 -1
  154. package/dist/compiler/AstCompiler/scope/AstScope.js +4 -3
  155. package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +6 -4
  156. package/dist/compiler/Compiler.js +3 -1
  157. package/dist/compiler/TirCompiler/compileTirProgram.js +3 -1
  158. package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +13 -3
  159. package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +41 -37
  160. package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +11 -2
  161. package/dist/compiler/TirCompiler/expressify/expressify.d.ts +2 -1
  162. package/dist/compiler/TirCompiler/expressify/expressify.js +82 -36
  163. package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +2 -1
  164. package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +57 -8
  165. package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +1 -1
  166. package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +1 -1
  167. package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +1 -0
  168. package/dist/compiler/TirCompiler/expressify/expressifyVars.js +131 -9
  169. package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +3 -1
  170. package/dist/compiler/io/IOutputStream.d.ts +1 -0
  171. package/dist/compiler/io/IOutputStream.js +18 -3
  172. package/dist/compiler/path/getAbsolutePath.js +4 -6
  173. package/dist/compiler/tir/expressions/ITirExpr.d.ts +2 -0
  174. package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.d.ts +4 -2
  175. package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.js +16 -2
  176. package/dist/compiler/tir/expressions/TirCallExpr.d.ts +3 -1
  177. package/dist/compiler/tir/expressions/TirCallExpr.js +16 -1
  178. package/dist/compiler/tir/expressions/TirCaseExpr.d.ts +6 -1
  179. package/dist/compiler/tir/expressions/TirCaseExpr.js +103 -60
  180. package/dist/compiler/tir/expressions/TirElemAccessExpr.d.ts +3 -1
  181. package/dist/compiler/tir/expressions/TirElemAccessExpr.js +9 -1
  182. package/dist/compiler/tir/expressions/TirFailExpr.d.ts +3 -1
  183. package/dist/compiler/tir/expressions/TirFailExpr.js +9 -1
  184. package/dist/compiler/tir/expressions/TirFromDataExpr.d.ts +3 -2
  185. package/dist/compiler/tir/expressions/TirFromDataExpr.js +85 -56
  186. package/dist/compiler/tir/expressions/TirFuncExpr.d.ts +4 -10
  187. package/dist/compiler/tir/expressions/TirFuncExpr.js +30 -13
  188. package/dist/compiler/tir/expressions/TirHoistedExpr.d.ts +3 -1
  189. package/dist/compiler/tir/expressions/TirHoistedExpr.js +8 -0
  190. package/dist/compiler/tir/expressions/TirInlineClosedIR.d.ts +4 -1
  191. package/dist/compiler/tir/expressions/TirInlineClosedIR.js +8 -0
  192. package/dist/compiler/tir/expressions/TirLettedExpr.d.ts +5 -2
  193. package/dist/compiler/tir/expressions/TirLettedExpr.js +19 -4
  194. package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +8 -5
  195. package/dist/compiler/tir/expressions/TirNativeFunc.js +50 -22
  196. package/dist/compiler/tir/expressions/TirParentesizedExpr.d.ts +3 -1
  197. package/dist/compiler/tir/expressions/TirParentesizedExpr.js +6 -0
  198. package/dist/compiler/tir/expressions/TirPropAccessExpr.d.ts +3 -1
  199. package/dist/compiler/tir/expressions/TirPropAccessExpr.js +9 -0
  200. package/dist/compiler/tir/expressions/TirTernaryExpr.d.ts +3 -1
  201. package/dist/compiler/tir/expressions/TirTernaryExpr.js +16 -5
  202. package/dist/compiler/tir/expressions/TirToDataExpr.d.ts +3 -1
  203. package/dist/compiler/tir/expressions/TirToDataExpr.js +56 -25
  204. package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.d.ts +3 -1
  205. package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.js +21 -4
  206. package/dist/compiler/tir/expressions/TirTypeConversionExpr.d.ts +3 -1
  207. package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +9 -1
  208. package/dist/compiler/tir/expressions/TirVariableAccessExpr.d.ts +7 -3
  209. package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +17 -7
  210. package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +16 -20
  211. package/dist/compiler/tir/expressions/ToIRTermCtx.js +67 -50
  212. package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +40 -0
  213. package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +174 -3
  214. package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.d.ts +4 -2
  215. package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.js +8 -2
  216. package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.d.ts +17 -0
  217. package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.js +21 -0
  218. package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.d.ts +4 -1
  219. package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.js +4 -0
  220. package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.d.ts +4 -1
  221. package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.js +5 -0
  222. package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.d.ts +4 -1
  223. package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.js +4 -0
  224. package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.d.ts +3 -1
  225. package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.js +5 -0
  226. package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.d.ts +3 -1
  227. package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.js +5 -0
  228. package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.d.ts +4 -1
  229. package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.js +4 -0
  230. package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.d.ts +4 -1
  231. package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.js +7 -3
  232. package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.d.ts +4 -1
  233. package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.js +4 -0
  234. package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.d.ts +4 -1
  235. package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.js +4 -0
  236. package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.d.ts +4 -1
  237. package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.js +4 -0
  238. package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.d.ts +2 -1
  239. package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.js +3 -1
  240. package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.d.ts +4 -2
  241. package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.js +8 -3
  242. package/dist/compiler/tir/expressions/unary/TirUnaryMinus.d.ts +4 -2
  243. package/dist/compiler/tir/expressions/unary/TirUnaryMinus.js +8 -2
  244. package/dist/compiler/tir/expressions/unary/TirUnaryPlus.d.ts +3 -1
  245. package/dist/compiler/tir/expressions/unary/TirUnaryPlus.js +6 -0
  246. package/dist/compiler/tir/expressions/unary/TirUnaryTilde.d.ts +4 -2
  247. package/dist/compiler/tir/expressions/unary/TirUnaryTilde.js +8 -2
  248. package/dist/compiler/tir/program/TypedProgram.d.ts +1 -0
  249. package/dist/compiler/tir/program/TypedProgram.js +9 -0
  250. package/dist/compiler/tir/program/stdScope/stdScope.js +126 -126
  251. package/dist/compiler/tir/statements/TirAssertStmt.d.ts +2 -0
  252. package/dist/compiler/tir/statements/TirAssertStmt.js +10 -0
  253. package/dist/compiler/tir/statements/TirAssignmentStmt.d.ts +2 -0
  254. package/dist/compiler/tir/statements/TirAssignmentStmt.js +8 -0
  255. package/dist/compiler/tir/statements/TirBlockStmt.d.ts +2 -0
  256. package/dist/compiler/tir/statements/TirBlockStmt.js +16 -0
  257. package/dist/compiler/tir/statements/TirBreakStmt.d.ts +2 -0
  258. package/dist/compiler/tir/statements/TirBreakStmt.js +8 -0
  259. package/dist/compiler/tir/statements/TirContinueStmt.d.ts +2 -0
  260. package/dist/compiler/tir/statements/TirContinueStmt.js +8 -0
  261. package/dist/compiler/tir/statements/TirFailStmt.d.ts +2 -0
  262. package/dist/compiler/tir/statements/TirFailStmt.js +8 -0
  263. package/dist/compiler/tir/statements/TirForOfStmt.d.ts +2 -0
  264. package/dist/compiler/tir/statements/TirForOfStmt.js +14 -0
  265. package/dist/compiler/tir/statements/TirForStmt.d.ts +2 -0
  266. package/dist/compiler/tir/statements/TirForStmt.js +21 -0
  267. package/dist/compiler/tir/statements/TirIfStmt.d.ts +3 -0
  268. package/dist/compiler/tir/statements/TirIfStmt.js +19 -0
  269. package/dist/compiler/tir/statements/TirMatchStmt.d.ts +2 -0
  270. package/dist/compiler/tir/statements/TirMatchStmt.js +30 -0
  271. package/dist/compiler/tir/statements/TirReturnStmt.d.ts +2 -0
  272. package/dist/compiler/tir/statements/TirReturnStmt.js +8 -0
  273. package/dist/compiler/tir/statements/TirStmt.d.ts +2 -0
  274. package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.d.ts +2 -0
  275. package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.js +30 -0
  276. package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.d.ts +3 -1
  277. package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js +28 -0
  278. package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.d.ts +3 -0
  279. package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.js +13 -0
  280. package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.d.ts +3 -1
  281. package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js +28 -0
  282. package/dist/compiler/tir/statements/TirWhileStmt.d.ts +2 -0
  283. package/dist/compiler/tir/statements/TirWhileStmt.js +14 -0
  284. package/dist/compiler/tir/types/utils/canAssignTo.js +1 -1
  285. package/dist/diagnostics/DiagnosticEmitter.js +1 -1
  286. package/dist/diagnostics/diagnosticMessages.generated.d.ts +10 -1
  287. package/dist/diagnostics/diagnosticMessages.generated.js +20 -2
  288. package/dist/parser/Parser.d.ts +8 -3
  289. package/dist/parser/Parser.js +162 -30
  290. package/dist/tokenizer/Token.d.ts +81 -72
  291. package/dist/tokenizer/Token.js +82 -72
  292. package/dist/tokenizer/utils/tokenFromKeyword.js +32 -10
  293. package/dist/tokenizer/utils/tokenIsAlsoIdentifier.js +10 -0
  294. package/dist/utils/BitUtils/index.js +1 -1
  295. package/dist/utils/UPLCFlatUtils/index.js +1 -1
  296. package/package.json +2 -1
  297. package/dist/IR/IRNodes/utils/isClosedAtDbn.d.ts +0 -2
  298. package/dist/IR/IRNodes/utils/isClosedAtDbn.js +0 -22
  299. package/dist/IR/toUPLC/_internal/_irToUplc.d.ts +0 -9
  300. package/dist/IR/toUPLC/_internal/_irToUplc.js +0 -156
  301. package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.d.ts +0 -9
  302. package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.js +0 -73
  303. package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.d.ts +0 -1
  304. package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.js +0 -12
  305. package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.js +0 -227
  306. package/dist/IR/tree_utils/_ir_apps.d.ts +0 -3
  307. package/dist/IR/tree_utils/_ir_apps.js +0 -8
@@ -78,129 +78,139 @@ export var Token;
78
78
  Token[Token["Test"] = 38] = "Test";
79
79
  Token[Token["Fail"] = 39] = "Fail";
80
80
  Token[Token["Assert"] = 40] = "Assert";
81
+ // contract keywords
82
+ Token[Token["Contract"] = 41] = "Contract";
83
+ Token[Token["Param"] = 42] = "Param";
84
+ Token[Token["Spend"] = 43] = "Spend";
85
+ Token[Token["Mint"] = 44] = "Mint";
86
+ Token[Token["Certify"] = 45] = "Certify";
87
+ Token[Token["Withdraw"] = 46] = "Withdraw";
88
+ Token[Token["Propose"] = 47] = "Propose";
89
+ Token[Token["Vote"] = 48] = "Vote";
90
+ Token[Token["Context"] = 49] = "Context";
81
91
  // punctuation
82
92
  /** `{` */
83
- Token[Token["OpenBrace"] = 41] = "OpenBrace";
93
+ Token[Token["OpenBrace"] = 50] = "OpenBrace";
84
94
  /** `}` */
85
- Token[Token["CloseBrace"] = 42] = "CloseBrace";
86
- Token[Token["OpenParen"] = 43] = "OpenParen";
87
- Token[Token["CloseParen"] = 44] = "CloseParen";
95
+ Token[Token["CloseBrace"] = 51] = "CloseBrace";
96
+ Token[Token["OpenParen"] = 52] = "OpenParen";
97
+ Token[Token["CloseParen"] = 53] = "CloseParen";
88
98
  /** `[` */
89
- Token[Token["OpenBracket"] = 45] = "OpenBracket";
99
+ Token[Token["OpenBracket"] = 54] = "OpenBracket";
90
100
  /** `]` */
91
- Token[Token["CloseBracket"] = 46] = "CloseBracket";
101
+ Token[Token["CloseBracket"] = 55] = "CloseBracket";
92
102
  /** `.` */
93
- Token[Token["Dot"] = 47] = "Dot";
103
+ Token[Token["Dot"] = 56] = "Dot";
94
104
  /** `...` */
95
- Token[Token["Dot_Dot_Dot"] = 48] = "Dot_Dot_Dot";
105
+ Token[Token["Dot_Dot_Dot"] = 57] = "Dot_Dot_Dot";
96
106
  /** `;` */
97
- Token[Token["Semicolon"] = 49] = "Semicolon";
107
+ Token[Token["Semicolon"] = 58] = "Semicolon";
98
108
  /** `,` */
99
- Token[Token["Comma"] = 50] = "Comma";
109
+ Token[Token["Comma"] = 59] = "Comma";
100
110
  /** `<` */
101
- Token[Token["LessThan"] = 51] = "LessThan";
111
+ Token[Token["LessThan"] = 60] = "LessThan";
102
112
  /** `>` */
103
- Token[Token["GreaterThan"] = 52] = "GreaterThan";
113
+ Token[Token["GreaterThan"] = 61] = "GreaterThan";
104
114
  /** `<=` */
105
- Token[Token["LessThan_Equals"] = 53] = "LessThan_Equals";
115
+ Token[Token["LessThan_Equals"] = 62] = "LessThan_Equals";
106
116
  /** `>=` */
107
- Token[Token["GreaterThan_Equals"] = 54] = "GreaterThan_Equals";
117
+ Token[Token["GreaterThan_Equals"] = 63] = "GreaterThan_Equals";
108
118
  /** `==` */
109
- Token[Token["Equals_Equals"] = 55] = "Equals_Equals";
119
+ Token[Token["Equals_Equals"] = 64] = "Equals_Equals";
110
120
  /** `!=` */
111
- Token[Token["Exclamation_Equals"] = 56] = "Exclamation_Equals";
121
+ Token[Token["Exclamation_Equals"] = 65] = "Exclamation_Equals";
112
122
  /** `===` */
113
- Token[Token["Equals_Equals_Equals"] = 57] = "Equals_Equals_Equals";
123
+ Token[Token["Equals_Equals_Equals"] = 66] = "Equals_Equals_Equals";
114
124
  /** `!==` */
115
- Token[Token["Exclamation_Equals_Equals"] = 58] = "Exclamation_Equals_Equals";
125
+ Token[Token["Exclamation_Equals_Equals"] = 67] = "Exclamation_Equals_Equals";
116
126
  /** `=>` */
117
- Token[Token["FatArrow"] = 59] = "FatArrow";
127
+ Token[Token["FatArrow"] = 68] = "FatArrow";
118
128
  /** `+` */
119
- Token[Token["Plus"] = 60] = "Plus";
129
+ Token[Token["Plus"] = 69] = "Plus";
120
130
  /** `-` */
121
- Token[Token["Minus"] = 61] = "Minus";
131
+ Token[Token["Minus"] = 70] = "Minus";
122
132
  /** `**` */
123
- Token[Token["Asterisk_Asterisk"] = 62] = "Asterisk_Asterisk";
133
+ Token[Token["Asterisk_Asterisk"] = 71] = "Asterisk_Asterisk";
124
134
  /** `*` */
125
- Token[Token["Asterisk"] = 63] = "Asterisk";
135
+ Token[Token["Asterisk"] = 72] = "Asterisk";
126
136
  /** `/` */
127
- Token[Token["Slash"] = 64] = "Slash";
137
+ Token[Token["Slash"] = 73] = "Slash";
128
138
  /** `%` */
129
- Token[Token["Percent"] = 65] = "Percent";
139
+ Token[Token["Percent"] = 74] = "Percent";
130
140
  /** `++` */
131
- Token[Token["Plus_Plus"] = 66] = "Plus_Plus";
141
+ Token[Token["Plus_Plus"] = 75] = "Plus_Plus";
132
142
  /** `--` */
133
- Token[Token["Minus_Minus"] = 67] = "Minus_Minus";
143
+ Token[Token["Minus_Minus"] = 76] = "Minus_Minus";
134
144
  /** `<<` */
135
- Token[Token["LessThan_LessThan"] = 68] = "LessThan_LessThan";
145
+ Token[Token["LessThan_LessThan"] = 77] = "LessThan_LessThan";
136
146
  /** `>>` */
137
- Token[Token["GreaterThan_GreaterThan"] = 69] = "GreaterThan_GreaterThan";
147
+ Token[Token["GreaterThan_GreaterThan"] = 78] = "GreaterThan_GreaterThan";
138
148
  /** `>>>` */
139
- Token[Token["GreaterThan_GreaterThan_GreaterThan"] = 70] = "GreaterThan_GreaterThan_GreaterThan";
149
+ Token[Token["GreaterThan_GreaterThan_GreaterThan"] = 79] = "GreaterThan_GreaterThan_GreaterThan";
140
150
  /** `+` */
141
- Token[Token["Ampersand"] = 71] = "Ampersand";
151
+ Token[Token["Ampersand"] = 80] = "Ampersand";
142
152
  /** `|` */
143
- Token[Token["Bar"] = 72] = "Bar";
153
+ Token[Token["Bar"] = 81] = "Bar";
144
154
  /** `^` */
145
- Token[Token["Caret"] = 73] = "Caret";
155
+ Token[Token["Caret"] = 82] = "Caret";
146
156
  /** `!` */
147
- Token[Token["Exclamation"] = 74] = "Exclamation";
157
+ Token[Token["Exclamation"] = 83] = "Exclamation";
148
158
  /** `~` */
149
- Token[Token["Tilde"] = 75] = "Tilde";
159
+ Token[Token["Tilde"] = 84] = "Tilde";
150
160
  /** `&&` */
151
- Token[Token["Ampersand_Ampersand"] = 76] = "Ampersand_Ampersand";
161
+ Token[Token["Ampersand_Ampersand"] = 85] = "Ampersand_Ampersand";
152
162
  /** `||` */
153
- Token[Token["Bar_Bar"] = 77] = "Bar_Bar";
163
+ Token[Token["Bar_Bar"] = 86] = "Bar_Bar";
154
164
  /** `?` */
155
- Token[Token["Question"] = 78] = "Question";
165
+ Token[Token["Question"] = 87] = "Question";
156
166
  /** `:` */
157
- Token[Token["Colon"] = 79] = "Colon";
167
+ Token[Token["Colon"] = 88] = "Colon";
158
168
  /** `=` */
159
- Token[Token["Equals"] = 80] = "Equals";
160
- Token[Token["Plus_Equals"] = 81] = "Plus_Equals";
161
- Token[Token["Minus_Equals"] = 82] = "Minus_Equals";
162
- Token[Token["Asterisk_Equals"] = 83] = "Asterisk_Equals";
163
- Token[Token["Asterisk_Asterisk_Equals"] = 84] = "Asterisk_Asterisk_Equals";
164
- Token[Token["Slash_Equals"] = 85] = "Slash_Equals";
165
- Token[Token["Percent_Equals"] = 86] = "Percent_Equals";
166
- Token[Token["LessThan_LessThan_Equals"] = 87] = "LessThan_LessThan_Equals";
167
- Token[Token["GreaterThan_GreaterThan_Equals"] = 88] = "GreaterThan_GreaterThan_Equals";
168
- Token[Token["GreaterThan_GreaterThan_GreaterThan_Equals"] = 89] = "GreaterThan_GreaterThan_GreaterThan_Equals";
169
- Token[Token["Ampersand_Equals"] = 90] = "Ampersand_Equals";
170
- Token[Token["Bar_Equals"] = 91] = "Bar_Equals";
171
- Token[Token["Caret_Equals"] = 92] = "Caret_Equals";
172
- Token[Token["At"] = 93] = "At";
169
+ Token[Token["Equals"] = 89] = "Equals";
170
+ Token[Token["Plus_Equals"] = 90] = "Plus_Equals";
171
+ Token[Token["Minus_Equals"] = 91] = "Minus_Equals";
172
+ Token[Token["Asterisk_Equals"] = 92] = "Asterisk_Equals";
173
+ Token[Token["Asterisk_Asterisk_Equals"] = 93] = "Asterisk_Asterisk_Equals";
174
+ Token[Token["Slash_Equals"] = 94] = "Slash_Equals";
175
+ Token[Token["Percent_Equals"] = 95] = "Percent_Equals";
176
+ Token[Token["LessThan_LessThan_Equals"] = 96] = "LessThan_LessThan_Equals";
177
+ Token[Token["GreaterThan_GreaterThan_Equals"] = 97] = "GreaterThan_GreaterThan_Equals";
178
+ Token[Token["GreaterThan_GreaterThan_GreaterThan_Equals"] = 98] = "GreaterThan_GreaterThan_GreaterThan_Equals";
179
+ Token[Token["Ampersand_Equals"] = 99] = "Ampersand_Equals";
180
+ Token[Token["Bar_Equals"] = 100] = "Bar_Equals";
181
+ Token[Token["Caret_Equals"] = 101] = "Caret_Equals";
182
+ Token[Token["At"] = 102] = "At";
173
183
  /** `??=` */
174
- Token[Token["Question_Question_Equals"] = 94] = "Question_Question_Equals";
184
+ Token[Token["Question_Question_Equals"] = 103] = "Question_Question_Equals";
175
185
  /** `||=` */
176
- Token[Token["Bar_Bar_Equals"] = 95] = "Bar_Bar_Equals";
186
+ Token[Token["Bar_Bar_Equals"] = 104] = "Bar_Bar_Equals";
177
187
  /** `&&=` */
178
- Token[Token["Ampersand_Ampersand_Equals"] = 96] = "Ampersand_Ampersand_Equals";
188
+ Token[Token["Ampersand_Ampersand_Equals"] = 105] = "Ampersand_Ampersand_Equals";
179
189
  /** `??` */
180
- Token[Token["Question_Question"] = 97] = "Question_Question";
190
+ Token[Token["Question_Question"] = 106] = "Question_Question";
181
191
  /** `?.` */
182
- Token[Token["Question_Dot"] = 98] = "Question_Dot";
192
+ Token[Token["Question_Dot"] = 107] = "Question_Dot";
183
193
  /** `!.` */
184
- Token[Token["Exclamation_Dot"] = 99] = "Exclamation_Dot";
194
+ Token[Token["Exclamation_Dot"] = 108] = "Exclamation_Dot";
185
195
  // custom native types for pebble
186
- Token[Token["Data"] = 100] = "Data";
187
- Token[Token["Bytes"] = 101] = "Bytes";
188
- Token[Token["Optional"] = 102] = "Optional";
189
- Token[Token["List"] = 103] = "List";
190
- Token[Token["LinearMap"] = 104] = "LinearMap";
196
+ Token[Token["Data"] = 109] = "Data";
197
+ Token[Token["Bytes"] = 110] = "Bytes";
198
+ Token[Token["Optional"] = 111] = "Optional";
199
+ Token[Token["List"] = 112] = "List";
200
+ Token[Token["LinearMap"] = 113] = "LinearMap";
191
201
  // struct decl modifiers
192
202
  // taggedModifier, // `tagged` data struct
193
- Token[Token["Runtime"] = 105] = "Runtime";
203
+ Token[Token["Runtime"] = 114] = "Runtime";
194
204
  // literals
195
- Token[Token["Identifier"] = 106] = "Identifier";
196
- Token[Token["StringLiteral"] = 107] = "StringLiteral";
197
- Token[Token["HexBytesLiteral"] = 108] = "HexBytesLiteral";
198
- Token[Token["IntegerLiteral"] = 109] = "IntegerLiteral";
205
+ Token[Token["Identifier"] = 115] = "Identifier";
206
+ Token[Token["StringLiteral"] = 116] = "StringLiteral";
207
+ Token[Token["HexBytesLiteral"] = 117] = "HexBytesLiteral";
208
+ Token[Token["IntegerLiteral"] = 118] = "IntegerLiteral";
199
209
  // FloatLiteral,
200
- Token[Token["StringTemplateLiteralQuote"] = 110] = "StringTemplateLiteralQuote";
210
+ Token[Token["StringTemplateLiteralQuote"] = 119] = "StringTemplateLiteralQuote";
201
211
  // meta
202
- Token[Token["Invalid"] = 111] = "Invalid";
203
- Token[Token["EndOfFile"] = 112] = "EndOfFile";
212
+ Token[Token["Invalid"] = 120] = "Invalid";
213
+ Token[Token["EndOfFile"] = 121] = "EndOfFile";
204
214
  })(Token || (Token = {}));
205
215
  Object.freeze(Token);
206
216
  /*
@@ -31,6 +31,12 @@ export function tokenFromKeyword(text) {
31
31
  return Token.Const;
32
32
  if (text === "continue")
33
33
  return Token.Continue;
34
+ if (text === "contract")
35
+ return Token.Contract;
36
+ if (text === "certify")
37
+ return Token.Certify;
38
+ if (text === "context")
39
+ return Token.Context;
34
40
  // if (text === "constructor") return Token.Constructor;
35
41
  break;
36
42
  }
@@ -44,6 +50,8 @@ export function tokenFromKeyword(text) {
44
50
  // if (text === "delete") return Token.Delete;
45
51
  if (text === "debugger")
46
52
  return Token.Debugger;
53
+ if (text === "data")
54
+ return Token.Data;
47
55
  break;
48
56
  }
49
57
  case 101 /* CharCode.e */: {
@@ -129,6 +137,8 @@ export function tokenFromKeyword(text) {
129
137
  // if (text === "module") return Token.Module;
130
138
  if (text === "match")
131
139
  return Token.Match;
140
+ if (text === "mint")
141
+ return Token.Mint;
132
142
  break;
133
143
  }
134
144
  case 110 /* CharCode.n */: {
@@ -145,21 +155,27 @@ export function tokenFromKeyword(text) {
145
155
  // if (text === "override") return Token.Override;
146
156
  break;
147
157
  }
148
- // case CharCode.p: {
149
- // if (len === 7) {
150
- // if (text === "private") return Token.Private;
151
- // if (text === "package") return Token.Package;
152
- // break;
153
- // }
154
- // if (text === "public") return Token.Public;
155
- // if (text === "protected") return Token.Protected;
156
- // break;
157
- // }
158
+ case 112 /* CharCode.p */: {
159
+ // if (len === 7) {
160
+ // if (text === "private") return Token.Private;
161
+ // if (text === "package") return Token.Package;
162
+ // break;
163
+ // }
164
+ // if (text === "public") return Token.Public;
165
+ // if (text === "protected") return Token.Protected;
166
+ if (text === "param")
167
+ return Token.Param;
168
+ if (text === "propose")
169
+ return Token.Propose;
170
+ break;
171
+ }
158
172
  case 114 /* CharCode.r */: {
159
173
  if (text === "return")
160
174
  return Token.Return;
161
175
  if (text === "readonly")
162
176
  return Token.Readonly;
177
+ if (text === "runtime")
178
+ return Token.Runtime;
163
179
  break;
164
180
  }
165
181
  case 115 /* CharCode.s */: {
@@ -171,6 +187,8 @@ export function tokenFromKeyword(text) {
171
187
  return Token.Struct;
172
188
  break;
173
189
  }
190
+ if (text === "spend")
191
+ return Token.Spend;
174
192
  // if (text === "set") return Token.Set;
175
193
  // if (text === "super") return Token.Super;
176
194
  break;
@@ -202,6 +220,8 @@ export function tokenFromKeyword(text) {
202
220
  return Token.Var;
203
221
  if (text === "void")
204
222
  return Token.Void;
223
+ if (text === "vote")
224
+ return Token.Vote;
205
225
  break;
206
226
  }
207
227
  case 119 /* CharCode.w */: {
@@ -210,6 +230,8 @@ export function tokenFromKeyword(text) {
210
230
  if (text === "when")
211
231
  return Token.When;
212
232
  // if (text === "with") return Token.With;
233
+ if (text === "withdraw")
234
+ return Token.Withdraw;
213
235
  break;
214
236
  }
215
237
  // case CharCode.y: {
@@ -17,6 +17,16 @@ export function tokenIsAlsoIdentifier(token) {
17
17
  // case Token.Namespace:
18
18
  // case Token.Null:
19
19
  case Token.Readonly:
20
+ // all the contract keywords are also identifiers (except 'context')
21
+ case Token.Contract:
22
+ case Token.Param:
23
+ case Token.Spend:
24
+ case Token.Mint:
25
+ case Token.Certify:
26
+ case Token.Withdraw:
27
+ case Token.Propose:
28
+ case Token.Vote:
29
+ // case Token.Context:
20
30
  // case Token.Type: // we don't allow it in pebble
21
31
  case Token.Void: return true;
22
32
  default: return false;
@@ -48,7 +48,7 @@ export default class BitUtils {
48
48
  static minBytesRequired(bigint) {
49
49
  if (bigint < BigInt(0))
50
50
  throw new Error("BitUtils.minBytesRequired works for positives integers only");
51
- const fullByteOnes = BigInt(255);
51
+ const fullByteOnes = BigInt(0b1111_1111);
52
52
  let mask = fullByteOnes;
53
53
  let bytesRequired = 1;
54
54
  while (bigint !== (bigint & mask)) {
@@ -45,7 +45,7 @@ export default class UPLCFlatUtils {
45
45
  assert(integer > BigInt(0), "'UPLCFlatUtils.encodeBigIntAsVariableLengthBitStream' can only encode non-negative integers; the given input was: " + integer.toString());
46
46
  // store binary string for easy BitStream creation
47
47
  const chunks = [];
48
- let mask = BigInt(127);
48
+ let mask = BigInt(0b0111_1111);
49
49
  // 1. Converting to binary
50
50
  const nBits = BitUtils.getNOfUsedBits(integer);
51
51
  for (let nAddedBits = 0; nAddedBits < nBits; nAddedBits += 7) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harmoniclabs/pebble",
3
- "version": "0.1.0-dev5",
3
+ "version": "0.1.0-dev6",
4
4
  "description": "A simple, yet rock solid, functional language with an imperative bias, targeting UPLC",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "buidl": "npm run build",
18
18
  "build": "rm -rf ./dist && npm run build:light",
19
19
  "build:light": "npm run genDiagnosticMessages && tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json",
20
+ "build-and-replace": "npm run build && cp -r ./dist ../pebble-cli/node_modules/@harmoniclabs/pebble",
20
21
  "genDiagnosticMessages": "node ./scripts/genDiagnosticMessages.js",
21
22
  "test": "jest",
22
23
  "test:debug": "node --nolazy --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --colors --verbose",
@@ -1,2 +0,0 @@
1
- import { IRTerm } from "../../IRTerm.js";
2
- export declare function isClosedAtDbn(term: IRTerm, dbn?: number): boolean;
@@ -1,22 +0,0 @@
1
- import { iterTree } from "../../toUPLC/_internal/iterTree.js";
2
- import { IRSelfCall } from "../IRSelfCall.js";
3
- import { IRVar } from "../IRVar.js";
4
- export function isClosedAtDbn(term, dbn = 0) {
5
- let isClosed = true;
6
- iterTree(term, (node, diff) => {
7
- const realDbn = dbn + diff;
8
- if (node instanceof IRVar ||
9
- node instanceof IRSelfCall) {
10
- // realDbn === 0 implies no variables are in scope
11
- // so if node.dbn === 0 and realDbn === 0 then the variable is open
12
- // and is pointing outside of the scope
13
- isClosed = isClosed || node.dbn < realDbn;
14
- }
15
- },
16
- // shouldSkipNode
17
- undefined,
18
- // shouldStop
19
- () => !isClosed // exit early
20
- );
21
- return isClosed;
22
- }
@@ -1,9 +0,0 @@
1
- import { IRTerm } from "../../IRTerm.js";
2
- import { UPLCTerm } from "@harmoniclabs/uplc";
3
- export type RawSrcMap = {
4
- [node_index: number]: string;
5
- };
6
- export declare function _irToUplc(ir: IRTerm, srcmap?: RawSrcMap | undefined, node_index?: number): {
7
- term: UPLCTerm;
8
- max_idx: number;
9
- };
@@ -1,156 +0,0 @@
1
- import { IRApp } from "../../IRNodes/IRApp.js";
2
- import { IRConst } from "../../IRNodes/IRConst.js";
3
- import { IRFunc } from "../../IRNodes/IRFunc.js";
4
- import { IRHoisted } from "../../IRNodes/IRHoisted.js";
5
- import { IRLetted } from "../../IRNodes/IRLetted.js";
6
- import { IRNative } from "../../IRNodes/IRNative/index.js";
7
- import { nativeTagToString } from "../../IRNodes/IRNative/IRNativeTag.js";
8
- import { IRVar } from "../../IRNodes/IRVar.js";
9
- import { showIR } from "../../utils/showIR.js";
10
- import { IRError } from "../../IRNodes/IRError.js";
11
- import { IRForced } from "../../IRNodes/IRForced.js";
12
- import { IRDelayed } from "../../IRNodes/IRDelayed.js";
13
- import { UPLCVar, Lambda, Application, Builtin, ErrorUPLC, Force, Delay, Constr, Case } from "@harmoniclabs/uplc";
14
- import { IRConstr } from "../../IRNodes/IRConstr.js";
15
- import { IRCase } from "../../IRNodes/IRCase.js";
16
- import { irHashToHex } from "../../IRHash.js";
17
- import { IRRecursive } from "../../IRNodes/IRRecursive.js";
18
- import { IRSelfCall } from "../../IRNodes/IRSelfCall.js";
19
- export function _irToUplc(ir, srcmap = undefined, node_index = 0) {
20
- if (!(ir instanceof IRConst)) {
21
- // console.log("_irToUplc", ir, node_index, Date.now());
22
- }
23
- else {
24
- // if( ir.parent )
25
- // {
26
- // console.log(ir.parent ? Object.getPrototypeOf( ir.parent ).constructor.name : undefined, Date.now() );
27
- // }
28
- // else
29
- // {
30
- // console.log( Error().stack );
31
- // }
32
- }
33
- if (ir instanceof IRConst) {
34
- return {
35
- term: ir.toUPLC(),
36
- max_idx: node_index
37
- };
38
- }
39
- if (ir instanceof IRVar)
40
- return {
41
- term: new UPLCVar(ir.dbn),
42
- max_idx: node_index
43
- };
44
- if (ir instanceof IRFunc) {
45
- const { term: body, max_idx } = _irToUplc(ir.body, srcmap, node_index);
46
- let lam = new Lambda(body);
47
- for (let i = 1; i < ir.arity; i++) {
48
- lam = new Lambda(lam);
49
- }
50
- return {
51
- term: lam,
52
- max_idx
53
- };
54
- }
55
- if (ir instanceof IRRecursive) {
56
- throw new Error("Can't convert 'IRRecursive' to valid UPLC;" +
57
- "IRRecursive are expected to be converted before calling '_irToUplc'");
58
- }
59
- if (ir instanceof IRSelfCall) {
60
- throw new Error("Can't convert 'IRSelfCall' to valid UPLC;" +
61
- "IRSelfCall are expected to be converted before calling '_irToUplc'");
62
- }
63
- if (ir instanceof IRApp) {
64
- const { term: fn, max_idx: fn_max_idx } = _irToUplc(ir.fn, srcmap, node_index + 1);
65
- const { term: arg, max_idx: arg_max_idx } = _irToUplc(ir.arg, srcmap, fn_max_idx + 1);
66
- let src = ir.meta.__src__;
67
- if (srcmap && typeof src === "string") {
68
- srcmap[node_index] = adaptSrcString(src);
69
- }
70
- return {
71
- term: new Application(fn, arg),
72
- max_idx: arg_max_idx
73
- };
74
- }
75
- if (ir instanceof IRNative) {
76
- if (ir.tag < 0)
77
- throw new Error("Can't translate '" + nativeTagToString(ir.tag) + "' 'IRNative' to 'UPLCBuiltin'");
78
- return {
79
- term: new Builtin(ir.tag),
80
- max_idx: node_index
81
- };
82
- }
83
- if (ir instanceof IRLetted) {
84
- throw new Error("Can't convert 'IRLetted' to valid UPLC");
85
- }
86
- if (ir instanceof IRHoisted) {
87
- // return this.hoisted.toUPLC();
88
- throw new Error("Can't convert 'IRHoisted' to valid UPLC;" +
89
- "\nhoisted hash was: " + irHashToHex(ir.hash) +
90
- "\nhoisted term was: " + showIR(ir.hoisted).text);
91
- }
92
- if (ir instanceof IRError) {
93
- if (typeof ir.addInfos.__src__ === "string" && srcmap) {
94
- srcmap[node_index] = adaptSrcString(ir.addInfos.__src__);
95
- }
96
- return {
97
- term: new ErrorUPLC(ir.msg, ir.addInfos),
98
- max_idx: node_index
99
- };
100
- }
101
- if (ir instanceof IRForced) {
102
- const { term: toForce, max_idx } = _irToUplc(ir.forced, srcmap, node_index);
103
- return {
104
- term: new Force(toForce),
105
- max_idx
106
- };
107
- }
108
- if (ir instanceof IRDelayed) {
109
- const { term: toDelay, max_idx } = _irToUplc(ir.delayed, srcmap, node_index);
110
- return {
111
- term: new Delay(toDelay),
112
- max_idx
113
- };
114
- }
115
- if (ir instanceof IRConstr) {
116
- if (ir.fields.length === 0) {
117
- return {
118
- term: new Constr(ir.index, []),
119
- max_idx: node_index + 1
120
- };
121
- }
122
- const fields = Array.from(ir.fields)
123
- .slice(1)
124
- .reduce((accum, field, i) => {
125
- accum.push(_irToUplc(field, srcmap, accum[i].max_idx + 1));
126
- return accum;
127
- }, [_irToUplc(ir.fields[0], srcmap, node_index)]);
128
- return {
129
- term: new Constr(ir.index, fields.map(({ term }) => term)),
130
- max_idx: fields[fields.length - 1].max_idx
131
- };
132
- }
133
- if (ir instanceof IRCase) {
134
- const { term: constrTerm, max_idx } = _irToUplc(ir.constrTerm, srcmap, node_index);
135
- const conts = Array.from(ir.continuations)
136
- .slice(1)
137
- .reduce((accum, cont, i) => {
138
- accum.push(_irToUplc(cont, srcmap, accum[i].max_idx + 1));
139
- return accum;
140
- }, [_irToUplc(ir.continuations[0], srcmap, max_idx + 1)]);
141
- return {
142
- term: new Case(constrTerm, conts.map(({ term }) => term)),
143
- max_idx: conts[conts.length - 1].max_idx
144
- };
145
- }
146
- throw new Error("unknown IR term calling '_irToUplc'");
147
- }
148
- function adaptSrcString(src) {
149
- // " at $ (some/path/to/src.ts:line:column)" -> "some/path/to/src.ts:line:column"
150
- let idx = src.indexOf("(");
151
- src = idx >= 0 ? src.slice(idx + 1, src.length - 1) : src;
152
- // " at some/path/to/src.ts:line:column" -> "some/path/to/src.ts:line:column"
153
- idx = src.indexOf("at ");
154
- src = idx >= 0 ? src.slice(idx + 3) : src;
155
- return src;
156
- }
@@ -1,9 +0,0 @@
1
- import { IRTerm } from "../../../IRTerm.js";
2
- import { IRLetted } from "../../../IRNodes/IRLetted.js";
3
- /**
4
- * add 1 to every var's DeBruijn that accesses stuff outside the parent node
5
- * not including the `parentNode` node
6
- * since the new function introdcued substituting the letted term
7
- * is added inside the `parentNode` node
8
- **/
9
- export declare function incrementUnboundDbns(theTerm: IRTerm, shouldNotModifyLetted: (letted: IRLetted, dbn: number) => boolean): void;
@@ -1,73 +0,0 @@
1
- import { IRVar } from "../../../IRNodes/IRVar.js";
2
- import { IRLetted } from "../../../IRNodes/IRLetted.js";
3
- import { IRApp } from "../../../IRNodes/IRApp.js";
4
- import { IRDelayed } from "../../../IRNodes/IRDelayed.js";
5
- import { IRForced } from "../../../IRNodes/IRForced.js";
6
- import { IRFunc } from "../../../IRNodes/IRFunc.js";
7
- import { IRCase } from "../../../IRNodes/IRCase.js";
8
- import { mapArrayLike } from "../../../IRNodes/utils/mapArrayLike.js";
9
- import { IRConstr } from "../../../IRNodes/IRConstr.js";
10
- import { IRRecursive } from "../../../IRNodes/IRRecursive.js";
11
- import { IRSelfCall } from "../../../IRNodes/IRSelfCall.js";
12
- /**
13
- * add 1 to every var's DeBruijn that accesses stuff outside the parent node
14
- * not including the `parentNode` node
15
- * since the new function introdcued substituting the letted term
16
- * is added inside the `parentNode` node
17
- **/
18
- export function incrementUnboundDbns(theTerm, shouldNotModifyLetted) {
19
- const stack = [{ term: theTerm, dbn: 0 }];
20
- while (stack.length > 0) {
21
- const { term: t, dbn } = stack.pop();
22
- if ((t instanceof IRVar ||
23
- t instanceof IRSelfCall) &&
24
- t.dbn >= dbn) {
25
- // there's a new variable in scope
26
- t.dbn++;
27
- continue;
28
- }
29
- if (t instanceof IRLetted) {
30
- if (shouldNotModifyLetted(t, dbn)) {
31
- // don't modify letted to be hoisted
32
- continue;
33
- }
34
- else // other letted to be handled in one of the next cycles
35
- {
36
- // `IRLambdas` DeBruijn are tracking the level of instantiation
37
- // we add a new variable so the dbn of instantiation increments
38
- t.dbn += 1;
39
- stack.push({ term: t.value, dbn });
40
- }
41
- continue;
42
- }
43
- if (t instanceof IRApp) {
44
- stack.push({ term: t.arg, dbn }, { term: t.fn, dbn });
45
- continue;
46
- }
47
- if (t instanceof IRCase) {
48
- stack.push({ term: t.constrTerm, dbn }, ...mapArrayLike(t.continuations, continuation => ({ term: continuation, dbn })));
49
- continue;
50
- }
51
- if (t instanceof IRConstr) {
52
- stack.push(...mapArrayLike(t.fields, field => ({ term: field, dbn })));
53
- continue;
54
- }
55
- if (t instanceof IRDelayed) {
56
- stack.push({ term: t.delayed, dbn });
57
- continue;
58
- }
59
- if (t instanceof IRForced) {
60
- stack.push({ term: t.forced, dbn });
61
- continue;
62
- }
63
- if (t instanceof IRFunc) {
64
- stack.push({ term: t.body, dbn: dbn + t.arity });
65
- continue;
66
- }
67
- if (t instanceof IRRecursive) {
68
- stack.push({ term: t.body, dbn: dbn + t.arity });
69
- continue;
70
- }
71
- // skip hoisted since closed
72
- }
73
- }