@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.
- package/dist/IR/IRHash.d.ts +3 -3
- package/dist/IR/IRHash.js +47 -52
- package/dist/IR/IRNodes/IRApp.d.ts +12 -8
- package/dist/IR/IRNodes/IRApp.js +34 -20
- package/dist/IR/IRNodes/IRCase.d.ts +11 -7
- package/dist/IR/IRNodes/IRCase.js +33 -32
- package/dist/IR/IRNodes/IRConst.d.ts +7 -5
- package/dist/IR/IRNodes/IRConst.js +23 -13
- package/dist/IR/IRNodes/IRConstr.d.ts +11 -7
- package/dist/IR/IRNodes/IRConstr.js +34 -37
- package/dist/IR/IRNodes/IRDelayed.d.ts +12 -9
- package/dist/IR/IRNodes/IRDelayed.js +22 -18
- package/dist/IR/IRNodes/IRError.d.ts +9 -6
- package/dist/IR/IRNodes/IRError.js +12 -5
- package/dist/IR/IRNodes/IRForced.d.ts +9 -6
- package/dist/IR/IRNodes/IRForced.js +22 -18
- package/dist/IR/IRNodes/IRFunc.d.ts +14 -10
- package/dist/IR/IRNodes/IRFunc.js +35 -38
- package/dist/IR/IRNodes/IRHoisted.d.ts +16 -9
- package/dist/IR/IRNodes/IRHoisted.js +36 -18
- package/dist/IR/IRNodes/IRLetted.d.ts +14 -34
- package/dist/IR/IRNodes/IRLetted.js +65 -297
- package/dist/IR/IRNodes/IRNative/IRNativeTag.d.ts +3 -3
- package/dist/IR/IRNodes/IRNative/IRNativeTag.js +4 -4
- package/dist/IR/IRNodes/IRNative/index.d.ts +10 -8
- package/dist/IR/IRNodes/IRNative/index.js +56 -18
- package/dist/IR/IRNodes/IRNative/isForcedNative.d.ts +2 -0
- package/dist/IR/IRNodes/IRNative/isForcedNative.js +1 -1
- package/dist/IR/IRNodes/IRRecursive.d.ts +18 -10
- package/dist/IR/IRNodes/IRRecursive.js +36 -44
- package/dist/IR/IRNodes/IRSelfCall.d.ts +10 -24
- package/dist/IR/IRNodes/IRSelfCall.js +25 -87
- package/dist/IR/IRNodes/IRVar.d.ts +11 -19
- package/dist/IR/IRNodes/IRVar.js +26 -54
- package/dist/IR/IRNodes/utils/dependsByDbns.d.ts +1 -1
- package/dist/IR/IRNodes/utils/dependsByDbns.js +5 -11
- package/dist/IR/IRNodes/utils/hashVarSym.d.ts +1 -0
- package/dist/IR/IRNodes/utils/hashVarSym.js +37 -0
- package/dist/IR/IRNodes/utils/makeArrayLikeProxy.d.ts +2 -1
- package/dist/IR/IRTerm.d.ts +7 -0
- package/dist/IR/toUPLC/CompilerOptions.d.ts +5 -0
- package/dist/IR/toUPLC/CompilerOptions.js +10 -1
- package/dist/IR/toUPLC/_internal/_modifyChildFromTo.js +3 -0
- package/dist/IR/toUPLC/_internal/findAll.js +2 -73
- package/dist/IR/toUPLC/_internal/getDebruijnInTerm.js +7 -34
- package/dist/IR/toUPLC/_internal/iterTree.js +3 -17
- package/dist/IR/toUPLC/common_hoisted.d.ts +2 -0
- package/dist/IR/toUPLC/common_hoisted.js +4 -0
- package/dist/IR/toUPLC/compileIRToUPLC.d.ts +1 -1
- package/dist/IR/toUPLC/compileIRToUPLC.js +91 -14
- package/dist/IR/toUPLC/ctx/ToUplcCtx.d.ts +16 -0
- package/dist/IR/toUPLC/ctx/ToUplcCtx.js +67 -0
- package/dist/IR/toUPLC/subRoutines/_comptimeDropN.d.ts +8 -0
- package/dist/IR/toUPLC/subRoutines/_comptimeDropN.js +95 -0
- package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.js +7 -54
- package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.d.ts +6 -13
- package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.js +65 -71
- package/dist/IR/toUPLC/subRoutines/handleLetted/index.js +44 -170
- package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.js +7 -3
- package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.js +3 -2
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.d.ts +22 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.js +59 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.d.ts +0 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.js +217 -0
- package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.js +12 -49
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.d.ts +1 -1
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.js +11 -14
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/{index.d.ts → performUplcOptimizationsAndReturnRoot.d.ts} +0 -2
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/performUplcOptimizationsAndReturnRoot.js +151 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.d.ts +11 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.js +46 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.d.ts +2 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.js +80 -0
- package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.js +18 -11
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +45 -0
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +277 -478
- package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.d.ts +2 -0
- package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.js +85 -0
- package/dist/IR/toUPLC/subRoutines/sanifyTree.js +1 -0
- package/dist/IR/toUPLC/utils/getApplicationTerms.d.ts +6 -0
- package/dist/IR/toUPLC/utils/getApplicationTerms.js +37 -0
- package/dist/IR/tree_utils/_ir_lazyChooseList.d.ts +2 -2
- package/dist/IR/tree_utils/_ir_lazyChooseList.js +4 -2
- package/dist/IR/tree_utils/_ir_lazyIfThenElse.d.ts +1 -1
- package/dist/IR/tree_utils/_ir_lazyIfThenElse.js +4 -2
- package/dist/IR/tree_utils/_ir_let.d.ts +2 -1
- package/dist/IR/tree_utils/_ir_let.js +6 -2
- package/dist/IR/utils/isClosedIRTerm.d.ts +1 -0
- package/dist/IR/utils/isClosedIRTerm.js +40 -26
- package/dist/IR/utils/positiveIntAsBytes.d.ts +1 -0
- package/dist/IR/utils/positiveIntAsBytes.js +4 -4
- package/dist/IR/utils/showIR.d.ts +10 -21
- package/dist/IR/utils/showIR.js +66 -64
- package/dist/ast/nodes/common/Identifier.d.ts +1 -0
- package/dist/ast/nodes/common/Identifier.js +3 -0
- package/dist/ast/nodes/expr/CaseExpr.d.ts +5 -5
- package/dist/ast/nodes/expr/ElemAccessExpr.d.ts +2 -2
- package/dist/ast/nodes/expr/ParentesizedExpr.d.ts +1 -1
- package/dist/ast/nodes/expr/PebbleExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/PropAccessExpr.d.ts +3 -3
- package/dist/ast/nodes/expr/TernaryExpr.d.ts +3 -3
- package/dist/ast/nodes/expr/TypeConversionExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/TypeConversionExpr.js +2 -0
- package/dist/ast/nodes/expr/binary/BinaryExpr.d.ts +42 -42
- package/dist/ast/nodes/expr/functions/CallExpr.d.ts +1 -1
- package/dist/ast/nodes/expr/functions/FuncExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/functions/FuncExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitContextExpr.d.ts +6 -0
- package/dist/ast/nodes/expr/litteral/LitContextExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitFailExpr.d.ts +6 -0
- package/dist/ast/nodes/expr/litteral/LitFailExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitteralExpr.d.ts +3 -1
- package/dist/ast/nodes/expr/litteral/LitteralExpr.js +5 -1
- package/dist/ast/nodes/statements/AssertStmt.d.ts +2 -2
- package/dist/ast/nodes/statements/AssignmentStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/BlockStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/FailStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/ForOfStmt.d.ts +4 -2
- package/dist/ast/nodes/statements/ForOfStmt.js +6 -0
- package/dist/ast/nodes/statements/ForStmt.d.ts +6 -4
- package/dist/ast/nodes/statements/ForStmt.js +6 -0
- package/dist/ast/nodes/statements/IfStmt.d.ts +8 -5
- package/dist/ast/nodes/statements/IfStmt.js +13 -0
- package/dist/ast/nodes/statements/MatchStmt.d.ts +13 -4
- package/dist/ast/nodes/statements/MatchStmt.js +22 -1
- package/dist/ast/nodes/statements/PebbleStmt.d.ts +2 -1
- package/dist/ast/nodes/statements/PebbleStmt.js +3 -1
- package/dist/ast/nodes/statements/ReturnStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/WhileStmt.d.ts +4 -2
- package/dist/ast/nodes/statements/WhileStmt.js +6 -0
- package/dist/ast/nodes/statements/declarations/ContractDecl.d.ts +17 -0
- package/dist/ast/nodes/statements/declarations/ContractDecl.js +22 -0
- package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.d.ts +2 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.js +6 -0
- package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.d.ts +1 -1
- package/dist/compiler/AstCompiler/AstCompiler.d.ts +7 -2
- package/dist/compiler/AstCompiler/AstCompiler.js +129 -25
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.d.ts +10 -0
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.js +777 -0
- package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.js +5 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileFuncExpr.js +7 -4
- package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.js +8 -2
- package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.js +2 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileVarAccessExpr.js +3 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +8 -8
- package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.d.ts +2 -2
- package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.js +48 -24
- package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +4 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.d.ts +2 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.js +4 -3
- package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.js +1 -1
- package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.js +4 -1
- package/dist/compiler/AstCompiler/scope/AstScope.d.ts +1 -0
- package/dist/compiler/AstCompiler/scope/AstScope.js +9 -3
- package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +6 -4
- package/dist/compiler/Compiler.js +7 -1
- package/dist/compiler/TirCompiler/compileTirProgram.js +4 -1
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +17 -5
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +79 -49
- package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +13 -2
- package/dist/compiler/TirCompiler/expressify/expressify.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressify.js +102 -41
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +77 -12
- package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +1 -1
- package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.d.ts +1 -2
- package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +16 -9
- package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +6 -8
- package/dist/compiler/TirCompiler/expressify/expressifyVars.js +146 -13
- package/dist/compiler/TirCompiler/expressify/flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct.js +1 -0
- package/dist/compiler/internalVar.d.ts +1 -1
- package/dist/compiler/internalVar.js +31 -24
- package/dist/compiler/io/CompilerIoApi.d.ts +1 -1
- package/dist/compiler/io/IOutputStream.d.ts +1 -0
- package/dist/compiler/io/IOutputStream.js +18 -3
- package/dist/compiler/path/getAbsolutePath.js +4 -6
- package/dist/compiler/tir/expressions/ITirExpr.d.ts +2 -0
- package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.d.ts +4 -2
- package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.js +16 -2
- package/dist/compiler/tir/expressions/TirCallExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirCallExpr.js +16 -1
- package/dist/compiler/tir/expressions/TirCaseExpr.d.ts +6 -1
- package/dist/compiler/tir/expressions/TirCaseExpr.js +105 -60
- package/dist/compiler/tir/expressions/TirElemAccessExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirElemAccessExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirFailExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirFailExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirFromDataExpr.d.ts +3 -2
- package/dist/compiler/tir/expressions/TirFromDataExpr.js +85 -56
- package/dist/compiler/tir/expressions/TirFuncExpr.d.ts +4 -10
- package/dist/compiler/tir/expressions/TirFuncExpr.js +30 -13
- package/dist/compiler/tir/expressions/TirHoistedExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirHoistedExpr.js +8 -0
- package/dist/compiler/tir/expressions/TirInlineClosedIR.d.ts +4 -1
- package/dist/compiler/tir/expressions/TirInlineClosedIR.js +8 -0
- package/dist/compiler/tir/expressions/TirLettedExpr.d.ts +6 -3
- package/dist/compiler/tir/expressions/TirLettedExpr.js +20 -7
- package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +9 -5
- package/dist/compiler/tir/expressions/TirNativeFunc.js +58 -22
- package/dist/compiler/tir/expressions/TirParentesizedExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirParentesizedExpr.js +6 -0
- package/dist/compiler/tir/expressions/TirPropAccessExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirPropAccessExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirTernaryExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTernaryExpr.js +16 -5
- package/dist/compiler/tir/expressions/TirToDataExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirToDataExpr.js +56 -25
- package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.js +21 -4
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.d.ts +6 -3
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +22 -8
- package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +19 -20
- package/dist/compiler/tir/expressions/ToIRTermCtx.js +74 -50
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +41 -0
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +180 -4
- package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.d.ts +4 -2
- package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.js +8 -2
- package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.d.ts +17 -0
- package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.js +21 -0
- package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.js +7 -3
- package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.d.ts +2 -1
- package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.js +3 -1
- package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.js +8 -3
- package/dist/compiler/tir/expressions/unary/TirUnaryMinus.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryMinus.js +8 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryPlus.d.ts +3 -1
- package/dist/compiler/tir/expressions/unary/TirUnaryPlus.js +6 -0
- package/dist/compiler/tir/expressions/unary/TirUnaryTilde.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryTilde.js +8 -2
- package/dist/compiler/tir/program/TypedProgram.d.ts +3 -2
- package/dist/compiler/tir/program/TypedProgram.js +9 -0
- package/dist/compiler/tir/program/stdScope/stdScope.js +135 -149
- package/dist/compiler/tir/statements/TirAssertStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirAssertStmt.js +10 -0
- package/dist/compiler/tir/statements/TirAssignmentStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirAssignmentStmt.js +8 -0
- package/dist/compiler/tir/statements/TirBlockStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirBlockStmt.js +16 -0
- package/dist/compiler/tir/statements/TirBreakStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirBreakStmt.js +8 -0
- package/dist/compiler/tir/statements/TirContinueStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirContinueStmt.js +8 -0
- package/dist/compiler/tir/statements/TirFailStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirFailStmt.js +8 -0
- package/dist/compiler/tir/statements/TirForOfStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirForOfStmt.js +14 -0
- package/dist/compiler/tir/statements/TirForStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirForStmt.js +21 -0
- package/dist/compiler/tir/statements/TirIfStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirIfStmt.js +16 -0
- package/dist/compiler/tir/statements/TirMatchStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirMatchStmt.js +30 -0
- package/dist/compiler/tir/statements/TirReturnStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirReturnStmt.js +8 -0
- package/dist/compiler/tir/statements/TirStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.d.ts +2 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.js +30 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.d.ts +3 -1
- package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js +28 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.d.ts +3 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.js +13 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.d.ts +3 -1
- package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js +28 -0
- package/dist/compiler/tir/statements/TirWhileStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirWhileStmt.js +14 -0
- package/dist/compiler/tir/types/utils/canAssignTo.js +1 -1
- package/dist/diagnostics/DiagnosticEmitter.js +1 -1
- package/dist/diagnostics/diagnosticMessages.generated.d.ts +10 -1
- package/dist/diagnostics/diagnosticMessages.generated.js +20 -2
- package/dist/parser/Parser.d.ts +8 -3
- package/dist/parser/Parser.js +180 -32
- package/dist/parser/Precedence.js +1 -0
- package/dist/tokenizer/Token.d.ts +81 -72
- package/dist/tokenizer/Token.js +82 -72
- package/dist/tokenizer/utils/tokenFromKeyword.js +32 -10
- package/dist/tokenizer/utils/tokenIsAlsoIdentifier.js +10 -0
- package/dist/utils/BitUtils/index.js +1 -1
- package/dist/utils/UPLCFlatUtils/index.js +1 -1
- package/dist/utils/array/keepSortedArrInplace.js +1 -0
- package/package.json +3 -1
- package/dist/IR/IRNodes/utils/isClosedAtDbn.d.ts +0 -2
- package/dist/IR/IRNodes/utils/isClosedAtDbn.js +0 -22
- package/dist/IR/toUPLC/_internal/_irToUplc.d.ts +0 -9
- package/dist/IR/toUPLC/_internal/_irToUplc.js +0 -156
- package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.d.ts +0 -9
- package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.js +0 -73
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.d.ts +0 -1
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.js +0 -12
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.js +0 -227
- package/dist/IR/tree_utils/_ir_apps.d.ts +0 -3
- package/dist/IR/tree_utils/_ir_apps.js +0 -8
- package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.d.ts +0 -5
- package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +0 -37
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { forceBigUInt } from "../../utils/ints.js";
|
|
2
|
-
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
3
2
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
4
|
-
import { positiveIntAsBytes } from "../utils/positiveIntAsBytes.js";
|
|
5
3
|
import { mapArrayLike } from "./utils/mapArrayLike.js";
|
|
6
4
|
import { makeArrayLikeProxy } from "./utils/makeArrayLikeProxy.js";
|
|
7
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
8
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
9
5
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
10
6
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
7
|
+
import { hashIrData, irHashToBytes, isIRHash } from "../IRHash.js";
|
|
8
|
+
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
9
|
+
import { positiveIntAsBytes } from "../utils/positiveIntAsBytes.js";
|
|
10
|
+
import { Constr } from "@harmoniclabs/uplc";
|
|
11
11
|
export class IRConstr {
|
|
12
12
|
index;
|
|
13
13
|
fields;
|
|
@@ -19,49 +19,46 @@ export class IRConstr {
|
|
|
19
19
|
const self = this;
|
|
20
20
|
this.meta = meta;
|
|
21
21
|
this._parent = undefined;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// modifyElem
|
|
38
|
-
// called before setting the new value
|
|
39
|
-
// the return value is the value that will be set
|
|
40
|
-
(newElem, oldElem) => {
|
|
41
|
-
if (!shallowEqualIRTermHash(oldElem, newElem))
|
|
42
|
-
self.markHashAsInvalid();
|
|
43
|
-
newElem.parent = self;
|
|
44
|
-
return newElem;
|
|
45
|
-
}),
|
|
46
|
-
writable: false,
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: false
|
|
22
|
+
this.index = forceBigUInt(index);
|
|
23
|
+
this.fields = makeArrayLikeProxy(fields, isIRTerm,
|
|
24
|
+
// initModifyElem
|
|
25
|
+
newElem => {
|
|
26
|
+
// newElem = newElem.clone();
|
|
27
|
+
newElem.parent = self;
|
|
28
|
+
// self.markHashAsInvalid()
|
|
29
|
+
return newElem;
|
|
30
|
+
},
|
|
31
|
+
// modifyElem
|
|
32
|
+
// called before setting the new value
|
|
33
|
+
// the return value is the value that will be set
|
|
34
|
+
(newElem, oldElem) => {
|
|
35
|
+
newElem.parent = self;
|
|
36
|
+
return newElem;
|
|
49
37
|
});
|
|
50
38
|
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
51
39
|
}
|
|
40
|
+
toUPLC(ctx) {
|
|
41
|
+
if (this.fields.length <= 0) {
|
|
42
|
+
return new Constr(this.index, []);
|
|
43
|
+
}
|
|
44
|
+
const fields = mapArrayLike(this.fields, f => f.toUPLC(ctx));
|
|
45
|
+
return new Constr(this.index, fields);
|
|
46
|
+
}
|
|
52
47
|
_hash;
|
|
53
48
|
get hash() {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
49
|
+
if (isIRHash(this._hash))
|
|
50
|
+
return this._hash;
|
|
51
|
+
this._hash = hashIrData(concatUint8Arr(IRConstr.tag, positiveIntAsBytes(this.index), ...mapArrayLike(this.fields, f => irHashToBytes(f.hash))));
|
|
58
52
|
return this._hash;
|
|
59
53
|
}
|
|
54
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
60
55
|
markHashAsInvalid() {
|
|
61
56
|
this._hash = undefined;
|
|
62
57
|
this.parent?.markHashAsInvalid();
|
|
63
58
|
}
|
|
64
|
-
|
|
59
|
+
children() {
|
|
60
|
+
return Array.from(this.fields);
|
|
61
|
+
}
|
|
65
62
|
_parent;
|
|
66
63
|
get parent() { return this._parent; }
|
|
67
64
|
set parent(newParent) {
|
|
@@ -75,7 +72,7 @@ export class IRConstr {
|
|
|
75
72
|
this._parent = newParent;
|
|
76
73
|
}
|
|
77
74
|
clone() {
|
|
78
|
-
return new IRConstr(this.index, mapArrayLike(this.fields, f => f.clone()), { ...this.meta }, this.
|
|
75
|
+
return new IRConstr(this.index, mapArrayLike(this.fields, f => f.clone()), { ...this.meta }, this._hash);
|
|
79
76
|
}
|
|
80
77
|
toJSON() { return this.toJson(); }
|
|
81
78
|
toJson() {
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
2
2
|
import { ToJson } from "../../utils/ToJson.js";
|
|
3
|
-
import { IRTerm } from "../IRTerm.js";
|
|
4
|
-
import { IHash } from "../interfaces/IHash.js";
|
|
3
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
5
4
|
import { IIRParent } from "../interfaces/IIRParent.js";
|
|
6
5
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
7
6
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
8
|
-
import { IRHash } from "../IRHash.js";
|
|
9
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
8
|
+
import { IRHash } from "../IRHash.js";
|
|
9
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
10
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
10
11
|
export interface IRDelayedMetadata extends BaseIRMetadata {
|
|
11
12
|
}
|
|
12
|
-
export declare class IRDelayed implements Cloneable<IRDelayed>,
|
|
13
|
+
export declare class IRDelayed implements IIRTerm, Cloneable<IRDelayed>, IIRParent, ToJson {
|
|
13
14
|
readonly meta: IRDelayedMetadata;
|
|
14
|
-
constructor(delayed: IRTerm, _unsafeHash?: IRHash);
|
|
15
|
+
constructor(delayed: IRTerm, _unsafeHash?: IRHash | undefined);
|
|
16
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
17
|
+
private _hash;
|
|
18
|
+
get hash(): IRHash;
|
|
19
|
+
isHashPresent(): boolean;
|
|
20
|
+
markHashAsInvalid(): void;
|
|
21
|
+
children(): IRTerm[];
|
|
15
22
|
static get kind(): IRNodeKind.Delayed;
|
|
16
23
|
get kind(): IRNodeKind.Delayed;
|
|
17
24
|
static get tag(): Uint8Array;
|
|
18
25
|
private _delayed;
|
|
19
26
|
get delayed(): IRTerm;
|
|
20
27
|
set delayed(newDelayed: IRTerm | undefined);
|
|
21
|
-
private _hash;
|
|
22
|
-
get hash(): IRHash;
|
|
23
28
|
private _parent;
|
|
24
29
|
get parent(): IRParentTerm | undefined;
|
|
25
30
|
set parent(newParent: IRParentTerm | undefined);
|
|
26
|
-
isHashPresent(): boolean;
|
|
27
|
-
markHashAsInvalid(): void;
|
|
28
31
|
clone(): IRDelayed;
|
|
29
32
|
toJSON(): any;
|
|
30
33
|
toJson(): any;
|
|
@@ -2,9 +2,9 @@ import { BasePlutsError } from "../../utils/BasePlutsError.js";
|
|
|
2
2
|
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
3
3
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
4
4
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
5
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
6
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
7
5
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
6
|
+
import { isIRHash, hashIrData, irHashToBytes } from "../IRHash.js";
|
|
7
|
+
import { Delay } from "@harmoniclabs/uplc";
|
|
8
8
|
export class IRDelayed {
|
|
9
9
|
meta = {};
|
|
10
10
|
constructor(delayed, _unsafeHash) {
|
|
@@ -12,8 +12,26 @@ export class IRDelayed {
|
|
|
12
12
|
throw new Error("IRDelayed argument was not an IRTerm");
|
|
13
13
|
this._delayed = delayed;
|
|
14
14
|
this._delayed.parent = this;
|
|
15
|
-
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
16
15
|
this._parent = undefined;
|
|
16
|
+
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
17
|
+
}
|
|
18
|
+
toUPLC(ctx) {
|
|
19
|
+
return new Delay(this.delayed.toUPLC(ctx));
|
|
20
|
+
}
|
|
21
|
+
_hash;
|
|
22
|
+
get hash() {
|
|
23
|
+
if (isIRHash(this._hash))
|
|
24
|
+
return this._hash;
|
|
25
|
+
this._hash = hashIrData(concatUint8Arr(IRDelayed.tag, irHashToBytes(this.delayed.hash)));
|
|
26
|
+
return this._hash;
|
|
27
|
+
}
|
|
28
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
29
|
+
markHashAsInvalid() {
|
|
30
|
+
this._hash = undefined;
|
|
31
|
+
this.parent?.markHashAsInvalid();
|
|
32
|
+
}
|
|
33
|
+
children() {
|
|
34
|
+
return [this.delayed];
|
|
17
35
|
}
|
|
18
36
|
static get kind() { return IRNodeKind.Delayed; }
|
|
19
37
|
get kind() { return IRDelayed.kind; }
|
|
@@ -24,20 +42,11 @@ export class IRDelayed {
|
|
|
24
42
|
if (!isIRTerm(newDelayed)) {
|
|
25
43
|
throw new BasePlutsError("invalid IRTerm to be delayed");
|
|
26
44
|
}
|
|
27
|
-
if (!shallowEqualIRTermHash(this._delayed, newDelayed))
|
|
28
|
-
this.markHashAsInvalid();
|
|
29
45
|
// keep the parent reference in the old child, useful for compilation
|
|
30
46
|
// _delayed.parent = undefined;
|
|
31
47
|
this._delayed = newDelayed;
|
|
32
48
|
this._delayed.parent = this;
|
|
33
49
|
}
|
|
34
|
-
_hash;
|
|
35
|
-
get hash() {
|
|
36
|
-
if (!isIRHash(this._hash)) {
|
|
37
|
-
this._hash = hashIrData(concatUint8Arr(IRDelayed.tag, this.delayed.hash));
|
|
38
|
-
}
|
|
39
|
-
return this._hash;
|
|
40
|
-
}
|
|
41
50
|
_parent;
|
|
42
51
|
get parent() { return this._parent; }
|
|
43
52
|
set parent(newParent) {
|
|
@@ -50,13 +59,8 @@ export class IRDelayed {
|
|
|
50
59
|
return;
|
|
51
60
|
this._parent = newParent;
|
|
52
61
|
}
|
|
53
|
-
isHashPresent() { return isIRHash(this._hash); }
|
|
54
|
-
markHashAsInvalid() {
|
|
55
|
-
this._hash = undefined;
|
|
56
|
-
this._parent?.markHashAsInvalid();
|
|
57
|
-
}
|
|
58
62
|
clone() {
|
|
59
|
-
return new IRDelayed(this.delayed.clone(), this.
|
|
63
|
+
return new IRDelayed(this.delayed.clone(), this._hash);
|
|
60
64
|
}
|
|
61
65
|
toJSON() { return this.toJson(); }
|
|
62
66
|
toJson() {
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
2
2
|
import { ToJson } from "../../utils/ToJson.js";
|
|
3
|
-
import { IHash } from "../interfaces/IHash.js";
|
|
4
3
|
import { IIRParent } from "../interfaces/IIRParent.js";
|
|
5
4
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
6
5
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
7
|
-
import { IRHash } from "../IRHash.js";
|
|
8
6
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
7
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
8
|
+
import { IRHash } from "../IRHash.js";
|
|
9
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
9
10
|
export interface IRErrorMetadata extends BaseIRMetadata {
|
|
10
11
|
}
|
|
11
|
-
export declare class IRError implements Cloneable<IRError>,
|
|
12
|
+
export declare class IRError implements IIRTerm, Cloneable<IRError>, IIRParent, ToJson {
|
|
12
13
|
readonly meta: IRErrorMetadata;
|
|
13
14
|
msg?: string;
|
|
14
15
|
addInfos?: any;
|
|
15
16
|
constructor(msg?: string, addInfos?: any);
|
|
16
|
-
|
|
17
|
-
get kind(): IRNodeKind.Error;
|
|
18
|
-
static get tag(): Uint8Array;
|
|
17
|
+
toUPLC(): UPLCTerm;
|
|
19
18
|
get hash(): IRHash;
|
|
20
19
|
isHashPresent(): boolean;
|
|
21
20
|
markHashAsInvalid(): void;
|
|
21
|
+
children(): IRTerm[];
|
|
22
|
+
static get kind(): IRNodeKind.Error;
|
|
23
|
+
get kind(): IRNodeKind.Error;
|
|
24
|
+
static get tag(): Uint8Array;
|
|
22
25
|
private _parent;
|
|
23
26
|
get parent(): IRParentTerm | undefined;
|
|
24
27
|
set parent(newParent: IRParentTerm | undefined);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
2
|
-
import { hashIrData } from "../IRHash.js";
|
|
3
2
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
3
|
+
import { hashIrData } from "../IRHash.js";
|
|
4
|
+
import { ErrorUPLC } from "@harmoniclabs/uplc";
|
|
4
5
|
const irErrorBitTag = new Uint8Array([IRNodeKind.Error]);
|
|
5
|
-
const
|
|
6
|
+
const irErrorHash = hashIrData(irErrorBitTag);
|
|
6
7
|
export class IRError {
|
|
7
8
|
meta;
|
|
8
9
|
msg;
|
|
@@ -13,12 +14,18 @@ export class IRError {
|
|
|
13
14
|
this.meta = {};
|
|
14
15
|
this._parent = undefined;
|
|
15
16
|
}
|
|
17
|
+
toUPLC() {
|
|
18
|
+
return new ErrorUPLC(this.msg, this.addInfos);
|
|
19
|
+
}
|
|
20
|
+
get hash() { return irErrorHash; }
|
|
21
|
+
isHashPresent() { return true; }
|
|
22
|
+
markHashAsInvalid() { throw new Error("IRError: hash is always present and valid"); }
|
|
23
|
+
children() {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
16
26
|
static get kind() { return IRNodeKind.Error; }
|
|
17
27
|
get kind() { return IRError.kind; }
|
|
18
28
|
static get tag() { return irErrorBitTag.slice(); }
|
|
19
|
-
get hash() { return errorHash; }
|
|
20
|
-
isHashPresent() { return true; }
|
|
21
|
-
markHashAsInvalid() { throw new Error("IRError.markHashAsInvalid was called but error doesn't have childs"); }
|
|
22
29
|
_parent;
|
|
23
30
|
get parent() { return this._parent; }
|
|
24
31
|
set parent(newParent) {
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
2
2
|
import { ToJson } from "../../utils/ToJson.js";
|
|
3
|
-
import { IRTerm } from "../IRTerm.js";
|
|
4
|
-
import { IHash } from "../interfaces/IHash.js";
|
|
3
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
5
4
|
import { IIRParent } from "../interfaces/IIRParent.js";
|
|
6
5
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
7
6
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
8
7
|
import { IRHash } from "../IRHash.js";
|
|
9
8
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
9
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
10
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
10
11
|
export interface IRForcedMetadata extends BaseIRMetadata {
|
|
11
12
|
}
|
|
12
|
-
export declare class IRForced implements Cloneable<IRForced>,
|
|
13
|
+
export declare class IRForced implements IIRTerm, Cloneable<IRForced>, IIRParent, ToJson {
|
|
13
14
|
readonly meta: IRForcedMetadata;
|
|
14
15
|
constructor(forced: IRTerm, _unsafeHash?: IRHash);
|
|
15
|
-
|
|
16
|
-
get forced(): IRTerm;
|
|
17
|
-
set forced(newForced: IRTerm | undefined);
|
|
16
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
18
17
|
private _hash;
|
|
19
18
|
get hash(): IRHash;
|
|
20
19
|
isHashPresent(): boolean;
|
|
21
20
|
markHashAsInvalid(): void;
|
|
21
|
+
children(): IRTerm[];
|
|
22
|
+
private _forced;
|
|
23
|
+
get forced(): IRTerm;
|
|
24
|
+
set forced(newForced: IRTerm | undefined);
|
|
22
25
|
private _parent;
|
|
23
26
|
get parent(): IRParentTerm | undefined;
|
|
24
27
|
set parent(newParent: IRParentTerm | undefined);
|
|
@@ -2,19 +2,37 @@ import { BasePlutsError } from "../../utils/BasePlutsError.js";
|
|
|
2
2
|
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
3
3
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
4
4
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
5
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
6
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
5
|
+
import { hashIrData, irHashToBytes, isIRHash } from "../IRHash.js";
|
|
7
6
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
7
|
+
import { Force } from "@harmoniclabs/uplc";
|
|
8
8
|
export class IRForced {
|
|
9
9
|
meta;
|
|
10
10
|
constructor(forced, _unsafeHash) {
|
|
11
11
|
this.meta = {};
|
|
12
|
-
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
13
12
|
if (!isIRTerm(forced))
|
|
14
13
|
throw new Error("IRForced argument was not an IRTerm");
|
|
15
14
|
this._forced = forced;
|
|
16
15
|
this._forced.parent = this;
|
|
17
16
|
this._parent = undefined;
|
|
17
|
+
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
18
|
+
}
|
|
19
|
+
toUPLC(ctx) {
|
|
20
|
+
return new Force(this.forced.toUPLC(ctx));
|
|
21
|
+
}
|
|
22
|
+
_hash;
|
|
23
|
+
get hash() {
|
|
24
|
+
if (isIRHash(this._hash))
|
|
25
|
+
return this._hash;
|
|
26
|
+
this._hash = hashIrData(concatUint8Arr(IRForced.tag, irHashToBytes(this.forced.hash)));
|
|
27
|
+
return this._hash;
|
|
28
|
+
}
|
|
29
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
30
|
+
markHashAsInvalid() {
|
|
31
|
+
this._hash = undefined;
|
|
32
|
+
this.parent?.markHashAsInvalid();
|
|
33
|
+
}
|
|
34
|
+
children() {
|
|
35
|
+
return [this._forced];
|
|
18
36
|
}
|
|
19
37
|
_forced;
|
|
20
38
|
get forced() { return this._forced; }
|
|
@@ -22,25 +40,11 @@ export class IRForced {
|
|
|
22
40
|
if (!isIRTerm(newForced)) {
|
|
23
41
|
throw new BasePlutsError("invalid IRTerm to be forced");
|
|
24
42
|
}
|
|
25
|
-
if (!shallowEqualIRTermHash(this._forced, newForced))
|
|
26
|
-
this.markHashAsInvalid();
|
|
27
43
|
// keep the parent reference in the old child, useful for compilation
|
|
28
44
|
// _forced.parent = undefined;
|
|
29
45
|
this._forced = newForced;
|
|
30
46
|
this._forced.parent = this;
|
|
31
47
|
}
|
|
32
|
-
_hash;
|
|
33
|
-
get hash() {
|
|
34
|
-
if (!isIRHash(this._hash)) {
|
|
35
|
-
this._hash = hashIrData(concatUint8Arr(IRForced.tag, this._forced.hash));
|
|
36
|
-
}
|
|
37
|
-
return this._hash;
|
|
38
|
-
}
|
|
39
|
-
isHashPresent() { return isIRHash(this._hash); }
|
|
40
|
-
markHashAsInvalid() {
|
|
41
|
-
this._hash = undefined;
|
|
42
|
-
this.parent?.markHashAsInvalid();
|
|
43
|
-
}
|
|
44
48
|
_parent;
|
|
45
49
|
get parent() { return this._parent; }
|
|
46
50
|
set parent(newParent) {
|
|
@@ -57,7 +61,7 @@ export class IRForced {
|
|
|
57
61
|
get kind() { return IRForced.kind; }
|
|
58
62
|
static get tag() { return new Uint8Array([IRForced.kind]); }
|
|
59
63
|
clone() {
|
|
60
|
-
return new IRForced(this.forced.clone(), this.
|
|
64
|
+
return new IRForced(this.forced.clone(), this._hash);
|
|
61
65
|
}
|
|
62
66
|
toJSON() { return this.toJson(); }
|
|
63
67
|
toJson() {
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
2
2
|
import { ToJson } from "../../utils/ToJson.js";
|
|
3
|
-
import { IRTerm } from "../IRTerm.js";
|
|
4
|
-
import { IHash } from "../interfaces/IHash.js";
|
|
3
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
5
4
|
import { IIRParent } from "../interfaces/IIRParent.js";
|
|
6
5
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
7
6
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
8
|
-
import { IRHash } from "../IRHash.js";
|
|
9
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
8
|
+
import { IRHash } from "../IRHash.js";
|
|
9
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
10
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
10
11
|
export interface IRFuncMetadata extends BaseIRMetadata {
|
|
11
12
|
}
|
|
12
|
-
export declare class IRFunc implements Cloneable<IRFunc>,
|
|
13
|
-
readonly
|
|
14
|
-
|
|
13
|
+
export declare class IRFunc implements IIRTerm, Cloneable<IRFunc>, IIRParent, ToJson {
|
|
14
|
+
readonly params: symbol[];
|
|
15
|
+
get arity(): number;
|
|
16
|
+
constructor(params: symbol[], body: IRTerm, _unsafeHash?: IRHash | undefined);
|
|
17
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
18
|
+
private _hash;
|
|
19
|
+
get hash(): IRHash;
|
|
20
|
+
isHashPresent(): boolean;
|
|
21
|
+
markHashAsInvalid(): void;
|
|
22
|
+
children(): IRTerm[];
|
|
15
23
|
static get kind(): IRNodeKind.Func;
|
|
16
24
|
get kind(): IRNodeKind.Func;
|
|
17
25
|
static get tag(): Uint8Array;
|
|
18
26
|
private _body;
|
|
19
27
|
get body(): IRTerm;
|
|
20
28
|
set body(newBody: IRTerm);
|
|
21
|
-
private _hash;
|
|
22
|
-
get hash(): IRHash;
|
|
23
|
-
isHashPresent(): boolean;
|
|
24
|
-
markHashAsInvalid(): void;
|
|
25
29
|
readonly meta: IRFuncMetadata;
|
|
26
30
|
get name(): string | undefined;
|
|
27
31
|
private _parent;
|
|
@@ -3,36 +3,46 @@ import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
|
3
3
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
4
4
|
import { positiveIntAsBytes } from "../utils/positiveIntAsBytes.js";
|
|
5
5
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
6
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
7
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
8
6
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
7
|
+
import { hashIrData, irHashToBytes, isIRHash } from "../IRHash.js";
|
|
8
|
+
import { Lambda } from "@harmoniclabs/uplc";
|
|
9
9
|
export class IRFunc {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
throw new BasePlutsError("invalid arity for 'IRFunc'");
|
|
10
|
+
params = [];
|
|
11
|
+
get arity() { return this.params.length; }
|
|
12
|
+
constructor(params, body, _unsafeHash) {
|
|
14
13
|
if (!isIRTerm(body))
|
|
15
14
|
throw new Error("IRFunc body argument was not an IRTerm");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value: arity,
|
|
19
|
-
writable: false,
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: false
|
|
22
|
-
},
|
|
23
|
-
meta: {
|
|
24
|
-
value: {
|
|
25
|
-
name: typeof func_name === "string" ? func_name : (void 0)
|
|
26
|
-
},
|
|
27
|
-
writable: true,
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: false
|
|
30
|
-
}
|
|
31
|
-
});
|
|
15
|
+
this.params = params.slice();
|
|
16
|
+
this.meta = {};
|
|
32
17
|
this._body = body;
|
|
33
18
|
this._body.parent = this;
|
|
34
|
-
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
35
19
|
this._parent = undefined;
|
|
20
|
+
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
21
|
+
}
|
|
22
|
+
toUPLC(ctx) {
|
|
23
|
+
ctx = ctx.newChild(this.params);
|
|
24
|
+
const arity = this.params.length;
|
|
25
|
+
const irBody = this._body;
|
|
26
|
+
// IRRecursive not valid for uplc translation
|
|
27
|
+
let result = irBody.toUPLC(ctx);
|
|
28
|
+
for (let i = 0; i < arity; i++)
|
|
29
|
+
result = new Lambda(result);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
_hash;
|
|
33
|
+
get hash() {
|
|
34
|
+
if (isIRHash(this._hash))
|
|
35
|
+
return this._hash;
|
|
36
|
+
this._hash = hashIrData(concatUint8Arr(IRFunc.tag, positiveIntAsBytes(this.arity), irHashToBytes(this._body.hash)));
|
|
37
|
+
return this._hash;
|
|
38
|
+
}
|
|
39
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
40
|
+
markHashAsInvalid() {
|
|
41
|
+
this._hash = undefined;
|
|
42
|
+
this.parent?.markHashAsInvalid();
|
|
43
|
+
}
|
|
44
|
+
children() {
|
|
45
|
+
return [this._body];
|
|
36
46
|
}
|
|
37
47
|
static get kind() { return IRNodeKind.Func; }
|
|
38
48
|
get kind() { return IRFunc.kind; }
|
|
@@ -43,25 +53,11 @@ export class IRFunc {
|
|
|
43
53
|
if (!isIRTerm(newBody)) {
|
|
44
54
|
throw new BasePlutsError("invalid IRTerm to be a function body");
|
|
45
55
|
}
|
|
46
|
-
if (!shallowEqualIRTermHash(this._body, newBody))
|
|
47
|
-
this.markHashAsInvalid();
|
|
48
56
|
// keep the parent reference in the old child, useful for compilation
|
|
49
57
|
// _body.parent = undefined;
|
|
50
58
|
this._body = newBody;
|
|
51
59
|
this._body.parent = this;
|
|
52
60
|
}
|
|
53
|
-
_hash;
|
|
54
|
-
get hash() {
|
|
55
|
-
if (!isIRHash(this._hash)) {
|
|
56
|
-
this._hash = hashIrData(concatUint8Arr(IRFunc.tag, positiveIntAsBytes(this.arity), this._body.hash));
|
|
57
|
-
}
|
|
58
|
-
return this._hash;
|
|
59
|
-
}
|
|
60
|
-
isHashPresent() { return isIRHash(this._hash); }
|
|
61
|
-
markHashAsInvalid() {
|
|
62
|
-
this._hash = undefined;
|
|
63
|
-
this.parent?.markHashAsInvalid();
|
|
64
|
-
}
|
|
65
61
|
meta;
|
|
66
62
|
get name() { return this.meta.name; }
|
|
67
63
|
;
|
|
@@ -78,7 +74,8 @@ export class IRFunc {
|
|
|
78
74
|
this._parent = newParent;
|
|
79
75
|
}
|
|
80
76
|
clone() {
|
|
81
|
-
return new IRFunc(this.
|
|
77
|
+
return new IRFunc(this.params, // .slice() in constructor
|
|
78
|
+
this._body.clone());
|
|
82
79
|
}
|
|
83
80
|
toJSON() { return this.toJson(); }
|
|
84
81
|
toJson() {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IRMetadata } from "../interfaces/IRMetadata.js";
|
|
2
2
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
3
3
|
import { ToJson } from "../../utils/ToJson.js";
|
|
4
|
-
import { IRTerm } from "../IRTerm.js";
|
|
5
|
-
import {
|
|
4
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
5
|
+
import { IIRParent } from "../interfaces/index.js";
|
|
6
6
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
7
|
-
import { IRHash } from "../IRHash.js";
|
|
8
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
8
|
+
import { IRHash } from "../IRHash.js";
|
|
9
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
9
10
|
export type HoistedSetEntry = {
|
|
10
11
|
hoisted: IRHoisted;
|
|
11
12
|
nReferences: number;
|
|
@@ -18,21 +19,26 @@ export interface IRHoistedMeta {
|
|
|
18
19
|
**/
|
|
19
20
|
forceHoist?: boolean;
|
|
20
21
|
name?: string | undefined;
|
|
22
|
+
handled?: boolean;
|
|
21
23
|
}
|
|
22
24
|
export interface IRHoistedMetadata extends IRMetadata {
|
|
23
25
|
meta: IRHoistedMeta;
|
|
24
26
|
}
|
|
25
|
-
export declare class IRHoisted implements Cloneable<IRHoisted>,
|
|
27
|
+
export declare class IRHoisted implements IIRTerm, Cloneable<IRHoisted>, IIRParent, ToJson, IRHoistedMetadata {
|
|
26
28
|
readonly meta: IRHoistedMeta;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
static get tag(): Uint8Array;
|
|
29
|
+
get name(): symbol;
|
|
30
|
+
constructor(hoisted: IRTerm, metadata?: Partial<IRHoistedMeta>, _unsafeHash?: IRHash | undefined);
|
|
31
|
+
toUPLC(): UPLCTerm;
|
|
31
32
|
private _hash;
|
|
32
33
|
get hash(): IRHash;
|
|
33
|
-
markHashAsInvalid(): void;
|
|
34
34
|
isHashPresent(): boolean;
|
|
35
|
+
markHashAsInvalid(): void;
|
|
36
|
+
children(): IRTerm[];
|
|
37
|
+
static get kind(): IRNodeKind.Hoisted;
|
|
38
|
+
get kind(): IRNodeKind.Hoisted;
|
|
39
|
+
static get tag(): Uint8Array;
|
|
35
40
|
private _hoisted;
|
|
41
|
+
get value(): IRTerm;
|
|
36
42
|
get hoisted(): IRTerm;
|
|
37
43
|
set hoisted(newHoisted: IRTerm);
|
|
38
44
|
private _deps;
|
|
@@ -53,3 +59,4 @@ export declare class IRHoisted implements Cloneable<IRHoisted>, IHash, IIRParent
|
|
|
53
59
|
export declare function getSortedHoistedSet(hoistedTerms: HoistedSetEntry[]): HoistedSetEntry[];
|
|
54
60
|
export declare function getHoistedTerms(irTerm: IRTerm): HoistedSetEntry[];
|
|
55
61
|
export declare function cloneHoistedSetEntry({ hoisted, nReferences }: HoistedSetEntry): HoistedSetEntry;
|
|
62
|
+
export declare function tryInferName(value: IRTerm): string | undefined;
|