@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.
- 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 +0 -2
- package/dist/IR/IRNodes/IRNative/IRNativeTag.js +0 -4
- package/dist/IR/IRNodes/IRNative/index.d.ts +9 -8
- package/dist/IR/IRNodes/IRNative/index.js +55 -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/_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 +75 -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 +67 -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 +43 -0
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +255 -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 +39 -25
- package/dist/IR/utils/positiveIntAsBytes.d.ts +1 -0
- package/dist/IR/utils/positiveIntAsBytes.js +4 -0
- 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 +6 -2
- package/dist/compiler/AstCompiler/AstCompiler.js +91 -24
- 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 +1 -1
- 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 +3 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +2 -2
- 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.js +2 -2
- 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.js +4 -3
- package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +6 -4
- package/dist/compiler/Compiler.js +3 -1
- package/dist/compiler/TirCompiler/compileTirProgram.js +3 -1
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +13 -3
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +41 -37
- package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +11 -2
- package/dist/compiler/TirCompiler/expressify/expressify.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressify.js +82 -36
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +57 -8
- package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +1 -1
- package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +1 -1
- package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +1 -0
- package/dist/compiler/TirCompiler/expressify/expressifyVars.js +131 -9
- package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +3 -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 +103 -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 +5 -2
- package/dist/compiler/tir/expressions/TirLettedExpr.js +19 -4
- package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +8 -5
- package/dist/compiler/tir/expressions/TirNativeFunc.js +50 -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 -0
- 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 +7 -3
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +17 -7
- package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +16 -20
- package/dist/compiler/tir/expressions/ToIRTermCtx.js +67 -50
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +40 -0
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +174 -3
- 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 +1 -0
- package/dist/compiler/tir/program/TypedProgram.js +9 -0
- package/dist/compiler/tir/program/stdScope/stdScope.js +126 -126
- 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 +3 -0
- package/dist/compiler/tir/statements/TirIfStmt.js +19 -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 +162 -30
- 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/package.json +2 -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
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
2
|
-
import { IHash } from "../../interfaces/IHash.js";
|
|
3
2
|
import { IIRParent } from "../../interfaces/IIRParent.js";
|
|
4
3
|
import { IRNativeTag } from "./IRNativeTag.js";
|
|
5
4
|
import { IRParentTerm } from "../../utils/isIRParentTerm.js";
|
|
6
5
|
import { BaseIRMetadata } from "../BaseIRMetadata.js";
|
|
7
6
|
import { ToJson } from "../../../utils/ToJson.js";
|
|
8
|
-
import { IRHash } from "../../IRHash.js";
|
|
9
7
|
import { IRNodeKind } from "../../IRNodeKind.js";
|
|
10
8
|
import { TirType } from "../../../compiler/tir/types/TirType.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { IIRTerm, IRTerm } from "../../IRTerm.js";
|
|
10
|
+
import { IRHash } from "../../IRHash.js";
|
|
11
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
12
|
+
import { IRHoisted } from "../IRHoisted.js";
|
|
13
13
|
export interface IRNativeMetadata extends BaseIRMetadata {
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* `IRNative` ⊇ (`Builtins` + `std::fn`)
|
|
17
17
|
**/
|
|
18
|
-
export declare class IRNative implements Cloneable<IRNative>,
|
|
18
|
+
export declare class IRNative implements IIRTerm, Cloneable<IRNative>, IIRParent, ToJson {
|
|
19
19
|
readonly tag: IRNativeTag;
|
|
20
20
|
static get kind(): IRNodeKind.Native;
|
|
21
21
|
get kind(): IRNodeKind.Native;
|
|
22
22
|
static get tag(): Uint8Array;
|
|
23
23
|
constructor(tag: IRNativeTag);
|
|
24
|
+
toUPLC(): UPLCTerm;
|
|
25
|
+
private _hash;
|
|
24
26
|
get hash(): IRHash;
|
|
27
|
+
isHashPresent(): boolean;
|
|
25
28
|
markHashAsInvalid(): void;
|
|
26
|
-
|
|
29
|
+
children(): IRTerm[];
|
|
27
30
|
private _meta;
|
|
28
31
|
get meta(): IRNativeMetadata;
|
|
29
32
|
private _parent;
|
|
@@ -136,9 +139,7 @@ export declare class IRNative implements Cloneable<IRNative>, IHash, IIRParent,
|
|
|
136
139
|
static get _id(): IRNative;
|
|
137
140
|
static get _not(): IRNative;
|
|
138
141
|
static get _strictAnd(): IRNative;
|
|
139
|
-
static get _and(): IRNative;
|
|
140
142
|
static get _strictOr(): IRNative;
|
|
141
|
-
static get _or(): IRNative;
|
|
142
143
|
static get _gtBS(): IRNative;
|
|
143
144
|
static get _gtEqBS(): IRNative;
|
|
144
145
|
static get _gtInt(): IRNative;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { concatUint8Arr } from "../../utils/concatUint8Arr.js";
|
|
2
|
-
import {
|
|
2
|
+
import { zigzagBigintAsBytes } from "../../utils/positiveIntAsBytes.js";
|
|
3
3
|
import { IRNativeTag, nativeTagToString } from "./IRNativeTag.js";
|
|
4
|
-
import UPLCFlatUtils from "../../../utils/UPLCFlatUtils/index.js";
|
|
5
4
|
import { isIRParentTerm } from "../../utils/isIRParentTerm.js";
|
|
6
|
-
import { hashIrData } from "../../IRHash.js";
|
|
7
5
|
import { isObject } from "@harmoniclabs/obj-utils";
|
|
8
6
|
import { IRNodeKind } from "../../IRNodeKind.js";
|
|
9
|
-
import { IRConst, IRFunc, IRHoisted, IRVar } from "../index.js";
|
|
10
|
-
import { _ir_apps } from "../../tree_utils/_ir_apps.js";
|
|
11
7
|
import { getUnaliased } from "../../../compiler/tir/types/utils/getUnaliased.js";
|
|
12
8
|
import { TirDataStructType } from "../../../compiler/tir/types/TirStructType.js";
|
|
13
9
|
import { TirAliasType } from "../../../compiler/tir/types/TirAliasType.js";
|
|
@@ -22,12 +18,19 @@ import { TirListT } from "../../../compiler/tir/types/TirNativeType/native/list.
|
|
|
22
18
|
import { TirDataOptT } from "../../../compiler/tir/types/TirNativeType/native/Optional/data.js";
|
|
23
19
|
import { TirStringT } from "../../../compiler/tir/types/TirNativeType/native/string.js";
|
|
24
20
|
import { TirVoidT } from "../../../compiler/tir/types/TirNativeType/native/void.js";
|
|
21
|
+
import { isIRHash, hashIrData } from "../../IRHash.js";
|
|
22
|
+
import { Builtin } from "@harmoniclabs/uplc";
|
|
23
|
+
import { _ir_apps } from "../IRApp.js";
|
|
24
|
+
import { IRHoisted } from "../IRHoisted.js";
|
|
25
|
+
import { IRFunc } from "../IRFunc.js";
|
|
26
|
+
import { IRVar } from "../IRVar.js";
|
|
27
|
+
import { IRConst } from "../IRConst.js";
|
|
25
28
|
/**
|
|
26
29
|
* we might not need all the hashes
|
|
27
30
|
*
|
|
28
31
|
* but one we get one for a specific tag is not worth it re calculate it
|
|
29
32
|
*/
|
|
30
|
-
const
|
|
33
|
+
const nativeHashesPreimageCache = {};
|
|
31
34
|
/**
|
|
32
35
|
* `IRNative` ⊇ (`Builtins` + `std::fn`)
|
|
33
36
|
**/
|
|
@@ -38,15 +41,28 @@ export class IRNative {
|
|
|
38
41
|
static get tag() { return new Uint8Array([IRNative.kind]); }
|
|
39
42
|
constructor(tag) {
|
|
40
43
|
this.tag = tag;
|
|
44
|
+
this._hash = undefined;
|
|
41
45
|
}
|
|
46
|
+
toUPLC() {
|
|
47
|
+
if (this.tag < 0)
|
|
48
|
+
throw new Error("IRNative tag cannot be negative during uplc translation");
|
|
49
|
+
return new Builtin(this.tag);
|
|
50
|
+
}
|
|
51
|
+
_hash;
|
|
42
52
|
get hash() {
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return
|
|
53
|
+
if (isIRHash(this._hash))
|
|
54
|
+
return this._hash;
|
|
55
|
+
this._hash = hashIrData(concatUint8Arr(IRNative.tag, zigzagBigintAsBytes(BigInt(this.tag))));
|
|
56
|
+
return this._hash;
|
|
57
|
+
}
|
|
58
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
59
|
+
markHashAsInvalid() {
|
|
60
|
+
this._hash = undefined;
|
|
61
|
+
this.parent?.markHashAsInvalid();
|
|
62
|
+
}
|
|
63
|
+
children() {
|
|
64
|
+
return [];
|
|
47
65
|
}
|
|
48
|
-
markHashAsInvalid() { throw new Error("IRNative should never be invalid; 'markHashAsInvalid' called"); }
|
|
49
|
-
isHashPresent() { return true; }
|
|
50
66
|
_meta;
|
|
51
67
|
get meta() {
|
|
52
68
|
if (!isObject(this._meta))
|
|
@@ -178,9 +194,7 @@ export class IRNative {
|
|
|
178
194
|
static get _id() { return new IRNative(IRNativeTag._id); }
|
|
179
195
|
static get _not() { return new IRNative(IRNativeTag._not); }
|
|
180
196
|
static get _strictAnd() { return new IRNative(IRNativeTag._strictAnd); }
|
|
181
|
-
static get _and() { return new IRNative(IRNativeTag._and); }
|
|
182
197
|
static get _strictOr() { return new IRNative(IRNativeTag._strictOr); }
|
|
183
|
-
static get _or() { return new IRNative(IRNativeTag._or); }
|
|
184
198
|
static get _gtBS() { return new IRNative(IRNativeTag._gtBS); }
|
|
185
199
|
static get _gtEqBS() { return new IRNative(IRNativeTag._gtEqBS); }
|
|
186
200
|
static get _gtInt() { return new IRNative(IRNativeTag._gtInt); }
|
|
@@ -227,14 +241,37 @@ export class IRNative {
|
|
|
227
241
|
if (type instanceof TirLinearMapT)
|
|
228
242
|
return IRNative.equalListOf(new TirPairDataT());
|
|
229
243
|
if (type instanceof TirUnConstrDataResultT)
|
|
230
|
-
return
|
|
231
|
-
// don't even hoist, who is even going to use this?
|
|
244
|
+
return getEqUnConstr();
|
|
232
245
|
if (type instanceof TirVoidT)
|
|
233
|
-
return
|
|
246
|
+
return getEqVoid();
|
|
234
247
|
const tsEnsureExsaustiveCheck = type;
|
|
235
248
|
throw new Error("invalid type for std equality");
|
|
236
249
|
}
|
|
237
250
|
static equalListOf(type) {
|
|
238
|
-
|
|
251
|
+
const key = type.toTirTypeKey();
|
|
252
|
+
if (!(eqListNames[key] instanceof IRHoisted)) {
|
|
253
|
+
eqListNames[key] = new IRHoisted(_ir_apps(IRNative._mkEqualsList, IRNative.equals(type)), { forceHoist: false, name: `equalsListOf_${type.toString()}` });
|
|
254
|
+
}
|
|
255
|
+
return eqListNames[key].clone();
|
|
239
256
|
}
|
|
240
257
|
}
|
|
258
|
+
/// NOTE, wrap in functions to break circular dependencies
|
|
259
|
+
const eqListNames = {};
|
|
260
|
+
const eqUnConstr_a = Symbol("a");
|
|
261
|
+
const eqUnConstr_b = Symbol("b");
|
|
262
|
+
let _eqUnConstr = undefined;
|
|
263
|
+
function getEqUnConstr() {
|
|
264
|
+
if (_eqUnConstr instanceof IRHoisted)
|
|
265
|
+
return _eqUnConstr.clone();
|
|
266
|
+
_eqUnConstr = new IRHoisted(new IRFunc([eqUnConstr_a, eqUnConstr_b], _ir_apps(IRNative.equalsData, _ir_apps(IRNative.constrData, new IRVar(eqUnConstr_a)), _ir_apps(IRNative.constrData, new IRVar(eqUnConstr_b)))));
|
|
267
|
+
return _eqUnConstr.clone();
|
|
268
|
+
}
|
|
269
|
+
const eqVoid_a = Symbol("a");
|
|
270
|
+
const eqVoid_b = Symbol("b");
|
|
271
|
+
let _eqVoid = undefined;
|
|
272
|
+
function getEqVoid() {
|
|
273
|
+
if (_eqVoid instanceof IRHoisted)
|
|
274
|
+
return _eqVoid.clone();
|
|
275
|
+
_eqVoid = new IRHoisted(new IRFunc([eqVoid_a, eqVoid_b], IRConst.bool(true)));
|
|
276
|
+
return _eqVoid.clone();
|
|
277
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { IRNative } from "./index.js";
|
|
2
2
|
import { IRTerm } from "../../IRTerm.js";
|
|
3
|
+
import { IRNativeTag } from "./IRNativeTag.js";
|
|
4
|
+
export declare function isForcedNativeTag(tag: IRNativeTag): boolean;
|
|
3
5
|
export declare function isForcedNative(node: IRTerm): node is IRNative;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IRNative } from "./index.js";
|
|
2
2
|
import { IRNativeTag } from "./IRNativeTag.js";
|
|
3
|
-
function isForcedNativeTag(tag) {
|
|
3
|
+
export function isForcedNativeTag(tag) {
|
|
4
4
|
return (tag === IRNativeTag.strictIfThenElse ||
|
|
5
5
|
tag === IRNativeTag.chooseUnit ||
|
|
6
6
|
tag === IRNativeTag.trace ||
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
2
|
+
import { Cloneable } from "../../utils/Cloneable.js";
|
|
3
|
+
import { ToJson } from "../../utils/ToJson.js";
|
|
4
|
+
import { IIRParent } from "../interfaces/index.js";
|
|
1
5
|
import { IRHash } from "../IRHash.js";
|
|
2
6
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
3
|
-
import { IRTerm } from "../IRTerm.js";
|
|
7
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
8
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
4
9
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
5
10
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
6
11
|
export interface IRRecursiveMetadata extends BaseIRMetadata {
|
|
7
12
|
}
|
|
8
|
-
export declare class IRRecursive {
|
|
13
|
+
export declare class IRRecursive implements IIRTerm, Cloneable<IRRecursive>, IIRParent, ToJson {
|
|
14
|
+
get arity(): number;
|
|
15
|
+
readonly name: symbol;
|
|
16
|
+
get params(): symbol[];
|
|
17
|
+
readonly meta: IRRecursiveMetadata;
|
|
18
|
+
constructor(name: symbol, body: IRTerm, _unsafeHash?: IRHash | undefined);
|
|
19
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
20
|
+
private _hash;
|
|
21
|
+
get hash(): IRHash;
|
|
22
|
+
isHashPresent(): boolean;
|
|
23
|
+
markHashAsInvalid(): void;
|
|
24
|
+
children(): IRTerm[];
|
|
9
25
|
static get kind(): IRNodeKind.Recursive;
|
|
10
26
|
get kind(): IRNodeKind.Recursive;
|
|
11
27
|
static get tag(): Uint8Array;
|
|
12
|
-
readonly arity: number;
|
|
13
|
-
constructor(body: IRTerm, func_name?: string | undefined, _unsafeHash?: IRHash);
|
|
14
28
|
private _body;
|
|
15
29
|
get body(): IRTerm;
|
|
16
30
|
set body(newBody: IRTerm);
|
|
17
|
-
private _hash;
|
|
18
|
-
get hash(): IRHash;
|
|
19
|
-
isHashPresent(): boolean;
|
|
20
|
-
markHashAsInvalid(): void;
|
|
21
|
-
readonly meta: IRRecursiveMetadata;
|
|
22
|
-
get name(): string | undefined;
|
|
23
31
|
private _parent;
|
|
24
32
|
get parent(): IRParentTerm | undefined;
|
|
25
33
|
set parent(newParent: IRTerm | undefined);
|
|
@@ -1,69 +1,61 @@
|
|
|
1
1
|
import { BasePlutsError } from "../../utils/BasePlutsError.js";
|
|
2
|
-
import { isIRHash, hashIrData } from "../IRHash.js";
|
|
2
|
+
import { isIRHash, hashIrData, irHashToBytes } from "../IRHash.js";
|
|
3
3
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
4
4
|
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
5
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
6
5
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
7
6
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
8
7
|
export class IRRecursive {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
8
|
+
get arity() { return 1; }
|
|
9
|
+
name;
|
|
10
|
+
get params() { return [this.name]; }
|
|
11
|
+
meta;
|
|
12
|
+
constructor(name, body, _unsafeHash) {
|
|
14
13
|
if (!isIRTerm(body))
|
|
15
14
|
throw new Error("IRRecursive body argument was not an IRTerm");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
if (!(typeof name === "symbol"
|
|
16
|
+
&& typeof name.description === "string"
|
|
17
|
+
&& name.description.length > 0))
|
|
18
|
+
throw new BasePlutsError("invalid name for IRVar");
|
|
19
|
+
this.name = name;
|
|
20
|
+
this._parent = undefined;
|
|
21
|
+
this.meta = { name: name.description };
|
|
32
22
|
this._body = body;
|
|
33
23
|
this._body.parent = this;
|
|
34
24
|
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
35
|
-
this._parent = undefined;
|
|
36
25
|
}
|
|
26
|
+
toUPLC(ctx) {
|
|
27
|
+
throw new Error("Can't convert 'IRRecursive' to valid UPLC;" +
|
|
28
|
+
"IRRecursive are expected to be converted before calling '_irToUplc'");
|
|
29
|
+
}
|
|
30
|
+
_hash;
|
|
31
|
+
get hash() {
|
|
32
|
+
if (isIRHash(this._hash))
|
|
33
|
+
return this._hash;
|
|
34
|
+
this._hash = hashIrData(concatUint8Arr(IRRecursive.tag, irHashToBytes(this._body.hash)));
|
|
35
|
+
return this._hash;
|
|
36
|
+
}
|
|
37
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
38
|
+
markHashAsInvalid() {
|
|
39
|
+
this._hash = undefined;
|
|
40
|
+
this.parent?.markHashAsInvalid();
|
|
41
|
+
}
|
|
42
|
+
children() {
|
|
43
|
+
return [this._body];
|
|
44
|
+
}
|
|
45
|
+
static get kind() { return IRNodeKind.Recursive; }
|
|
46
|
+
get kind() { return IRRecursive.kind; }
|
|
47
|
+
static get tag() { return new Uint8Array([IRRecursive.kind]); }
|
|
37
48
|
_body;
|
|
38
49
|
get body() { return this._body; }
|
|
39
50
|
set body(newBody) {
|
|
40
51
|
if (!isIRTerm(newBody)) {
|
|
41
52
|
throw new BasePlutsError("invalid IRTerm to be a function body");
|
|
42
53
|
}
|
|
43
|
-
if (!shallowEqualIRTermHash(this._body, newBody))
|
|
44
|
-
this.markHashAsInvalid();
|
|
45
54
|
// keep the parent reference in the old child, useful for compilation
|
|
46
55
|
// _body.parent = undefined;
|
|
47
56
|
this._body = newBody;
|
|
48
57
|
this._body.parent = this;
|
|
49
58
|
}
|
|
50
|
-
_hash;
|
|
51
|
-
get hash() {
|
|
52
|
-
if (!isIRHash(this._hash)) {
|
|
53
|
-
this._hash = hashIrData(concatUint8Arr(IRRecursive.tag,
|
|
54
|
-
// positiveIntAsBytes( this.arity ),
|
|
55
|
-
this._body.hash));
|
|
56
|
-
}
|
|
57
|
-
return this._hash;
|
|
58
|
-
}
|
|
59
|
-
isHashPresent() { return isIRHash(this._hash); }
|
|
60
|
-
markHashAsInvalid() {
|
|
61
|
-
this._hash = undefined;
|
|
62
|
-
this.parent?.markHashAsInvalid();
|
|
63
|
-
}
|
|
64
|
-
meta;
|
|
65
|
-
get name() { return this.meta.name; }
|
|
66
|
-
;
|
|
67
59
|
_parent;
|
|
68
60
|
get parent() { return this._parent; }
|
|
69
61
|
set parent(newParent) {
|
|
@@ -77,7 +69,7 @@ export class IRRecursive {
|
|
|
77
69
|
this._parent = newParent;
|
|
78
70
|
}
|
|
79
71
|
clone() {
|
|
80
|
-
return new IRRecursive(this.
|
|
72
|
+
return new IRRecursive(this.name, this._body.clone(), this._hash);
|
|
81
73
|
}
|
|
82
74
|
toJSON() { return this.toJson(); }
|
|
83
75
|
toJson() {
|
|
@@ -1,45 +1,31 @@
|
|
|
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
6
|
import { IRHash } from "../IRHash.js";
|
|
8
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
9
|
-
import {
|
|
8
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
9
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
10
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
10
11
|
export interface IRSelfCallMetadata extends BaseIRMetadata {
|
|
11
12
|
}
|
|
12
|
-
export declare class IRSelfCall implements Cloneable<IRSelfCall>,
|
|
13
|
+
export declare class IRSelfCall implements IIRTerm, Cloneable<IRSelfCall>, IIRParent, ToJson {
|
|
14
|
+
readonly name: symbol;
|
|
15
|
+
readonly meta: IRSelfCallMetadata;
|
|
16
|
+
constructor(name: symbol, _unsafeHash?: IRHash | undefined);
|
|
17
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
13
18
|
private _hash;
|
|
14
19
|
get hash(): IRHash;
|
|
15
|
-
|
|
16
|
-
* called inside the dbn setter
|
|
17
|
-
*/
|
|
20
|
+
isHashPresent(): boolean;
|
|
18
21
|
markHashAsInvalid(): void;
|
|
19
|
-
isHashPresent(): true;
|
|
20
|
-
private _dbn;
|
|
21
|
-
/**
|
|
22
|
-
* the IR DeBruijn index is not necessarly the same of the UPLC
|
|
23
|
-
* ( more ofthen than not it won't be the same )
|
|
24
|
-
*
|
|
25
|
-
* this is because in the IR things like `plet`
|
|
26
|
-
* are skipping some DeBruijin levels that are instead present
|
|
27
|
-
* in the final UPLC
|
|
28
|
-
**/
|
|
29
|
-
get dbn(): number;
|
|
30
|
-
set dbn(newDbn: number);
|
|
31
22
|
static get kind(): IRNodeKind.SelfCall;
|
|
32
23
|
get kind(): IRNodeKind.SelfCall;
|
|
33
24
|
static get tag(): Uint8Array;
|
|
34
|
-
readonly meta: IRSelfCallMetadata;
|
|
35
|
-
private _definition;
|
|
36
|
-
get definition(): IRRecursive;
|
|
37
|
-
set definition(newDefinition: IRRecursive | undefined);
|
|
38
25
|
private _parent;
|
|
39
26
|
get parent(): IRParentTerm | undefined;
|
|
40
27
|
set parent(newParent: IRParentTerm | undefined);
|
|
41
|
-
|
|
42
|
-
constructor(DeBruijn: number | bigint);
|
|
28
|
+
children(): IRTerm[];
|
|
43
29
|
clone(): IRSelfCall;
|
|
44
30
|
toJSON(): any;
|
|
45
31
|
toJson(): any;
|
|
@@ -1,65 +1,41 @@
|
|
|
1
1
|
import { BasePlutsError } from "../../utils/BasePlutsError.js";
|
|
2
2
|
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
3
|
-
import { positiveIntAsBytes } from "../utils/positiveIntAsBytes.js";
|
|
4
3
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
5
4
|
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
6
5
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
7
|
-
import {
|
|
8
|
-
import { IRFunc } from "./IRFunc.js";
|
|
6
|
+
import { hashVarSym } from "./utils/hashVarSym.js";
|
|
9
7
|
export class IRSelfCall {
|
|
8
|
+
name;
|
|
9
|
+
meta;
|
|
10
|
+
constructor(name, _unsafeHash) {
|
|
11
|
+
if (!(typeof name === "symbol"
|
|
12
|
+
&& typeof name.description === "string"
|
|
13
|
+
&& name.description.length > 0))
|
|
14
|
+
throw new BasePlutsError("invalid name for IRSelfCall");
|
|
15
|
+
this.name = name;
|
|
16
|
+
this._parent = undefined;
|
|
17
|
+
this.meta = {};
|
|
18
|
+
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
19
|
+
}
|
|
20
|
+
toUPLC(ctx) {
|
|
21
|
+
throw new Error("Can't convert 'IRSelfCall' to valid UPLC;" +
|
|
22
|
+
"IRSelfCall are expected to be converted before calling '_irToUplc'");
|
|
23
|
+
}
|
|
10
24
|
_hash;
|
|
11
25
|
get hash() {
|
|
12
|
-
if (
|
|
13
|
-
this._hash
|
|
14
|
-
|
|
26
|
+
if (isIRHash(this._hash))
|
|
27
|
+
return this._hash;
|
|
28
|
+
this._hash = hashIrData(concatUint8Arr(IRSelfCall.tag, hashVarSym(this.name)));
|
|
15
29
|
return this._hash;
|
|
16
30
|
}
|
|
17
|
-
|
|
18
|
-
* called inside the dbn setter
|
|
19
|
-
*/
|
|
31
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
20
32
|
markHashAsInvalid() {
|
|
21
33
|
this._hash = undefined;
|
|
22
34
|
this.parent?.markHashAsInvalid();
|
|
23
35
|
}
|
|
24
|
-
isHashPresent() { return true; }
|
|
25
|
-
_dbn;
|
|
26
|
-
/**
|
|
27
|
-
* the IR DeBruijn index is not necessarly the same of the UPLC
|
|
28
|
-
* ( more ofthen than not it won't be the same )
|
|
29
|
-
*
|
|
30
|
-
* this is because in the IR things like `plet`
|
|
31
|
-
* are skipping some DeBruijin levels that are instead present
|
|
32
|
-
* in the final UPLC
|
|
33
|
-
**/
|
|
34
|
-
get dbn() { return this._dbn; }
|
|
35
|
-
set dbn(newDbn) {
|
|
36
|
-
if (!(Number.isSafeInteger(newDbn) && newDbn >= 0)) {
|
|
37
|
-
throw new BasePlutsError("invalid index for an `IRSelfCall` instance; new DeBruijn was: " + newDbn);
|
|
38
|
-
}
|
|
39
|
-
if (newDbn === this._dbn)
|
|
40
|
-
return; // everything ok
|
|
41
|
-
this.markHashAsInvalid();
|
|
42
|
-
this._dbn = newDbn;
|
|
43
|
-
}
|
|
44
36
|
static get kind() { return IRNodeKind.SelfCall; }
|
|
45
37
|
get kind() { return IRSelfCall.kind; }
|
|
46
38
|
static get tag() { return new Uint8Array([IRSelfCall.kind]); }
|
|
47
|
-
meta;
|
|
48
|
-
_definition;
|
|
49
|
-
get definition() {
|
|
50
|
-
if (!(this._definition instanceof IRRecursive)) {
|
|
51
|
-
this._definition = this._findDefinition();
|
|
52
|
-
}
|
|
53
|
-
return this._definition;
|
|
54
|
-
}
|
|
55
|
-
set definition(newDefinition) {
|
|
56
|
-
if (newDefinition === undefined) {
|
|
57
|
-
this._definition = undefined;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
else
|
|
61
|
-
throw new Error("IRSelfCall definition (IRRecursive parent) can't be changed unless set to undefined");
|
|
62
|
-
}
|
|
63
39
|
_parent;
|
|
64
40
|
get parent() { return this._parent; }
|
|
65
41
|
set parent(newParent) {
|
|
@@ -73,55 +49,17 @@ export class IRSelfCall {
|
|
|
73
49
|
// change parent
|
|
74
50
|
this._parent = newParent;
|
|
75
51
|
// if we change parent, _definition should be recalculated
|
|
76
|
-
this._definition = undefined;
|
|
77
|
-
}
|
|
78
|
-
_findDefinition() {
|
|
79
|
-
let node = this;
|
|
80
|
-
let dbn = this.dbn;
|
|
81
|
-
while (node.parent !== undefined) {
|
|
82
|
-
node = node.parent;
|
|
83
|
-
if (node instanceof IRRecursive ||
|
|
84
|
-
node instanceof IRFunc) {
|
|
85
|
-
if (dbn === 0) {
|
|
86
|
-
if (node.parent instanceof IRRecursive)
|
|
87
|
-
return node.parent;
|
|
88
|
-
else
|
|
89
|
-
throw new Error("IRSelfCall was pointing to a IRFunc node");
|
|
90
|
-
}
|
|
91
|
-
dbn -= node.arity;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
throw new Error("IRSelfCall instance was not inside a IRRecursive instance");
|
|
95
|
-
}
|
|
96
|
-
constructor(DeBruijn) {
|
|
97
|
-
Object.defineProperty(this, "meta", {
|
|
98
|
-
value: {},
|
|
99
|
-
writable: false,
|
|
100
|
-
enumerable: true,
|
|
101
|
-
configurable: false
|
|
102
|
-
});
|
|
103
|
-
this._hash = undefined;
|
|
104
|
-
DeBruijn = typeof DeBruijn === "number" ? DeBruijn : Number(DeBruijn);
|
|
105
|
-
this._dbn = DeBruijn;
|
|
106
|
-
// call setter to check for validity
|
|
107
|
-
this.dbn = DeBruijn;
|
|
108
|
-
this._parent = undefined;
|
|
52
|
+
// this._definition = undefined;
|
|
109
53
|
}
|
|
54
|
+
children() { return []; }
|
|
110
55
|
clone() {
|
|
111
|
-
return new IRSelfCall(this.
|
|
56
|
+
return new IRSelfCall(this.name, this._hash);
|
|
112
57
|
}
|
|
113
58
|
toJSON() { return this.toJson(); }
|
|
114
59
|
toJson() {
|
|
115
60
|
return {
|
|
116
61
|
type: "IRSelfCall",
|
|
117
|
-
|
|
62
|
+
name: this.name
|
|
118
63
|
};
|
|
119
64
|
}
|
|
120
65
|
}
|
|
121
|
-
const dbnSelfCallCache = {};
|
|
122
|
-
function getSelfCallHashAtDbn(dbn) {
|
|
123
|
-
if (!isIRHash(dbnSelfCallCache[dbn])) {
|
|
124
|
-
dbnSelfCallCache[dbn] = (hashIrData(concatUint8Arr(IRSelfCall.tag, positiveIntAsBytes(dbn))));
|
|
125
|
-
}
|
|
126
|
-
return dbnSelfCallCache[dbn];
|
|
127
|
-
}
|
|
@@ -1,40 +1,32 @@
|
|
|
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
6
|
import { IRHash } from "../IRHash.js";
|
|
8
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
8
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
9
|
+
import { UPLCVar } from "@harmoniclabs/uplc";
|
|
10
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
9
11
|
export interface IRVarMetadata extends BaseIRMetadata {
|
|
10
12
|
}
|
|
11
|
-
export declare class IRVar implements Cloneable<IRVar>,
|
|
13
|
+
export declare class IRVar implements IIRTerm, Cloneable<IRVar>, IIRParent, ToJson {
|
|
14
|
+
private readonly _creationStack;
|
|
15
|
+
readonly meta: IRVarMetadata;
|
|
16
|
+
readonly name: symbol;
|
|
17
|
+
constructor(name: symbol, _unsafeHash?: IRHash | undefined);
|
|
18
|
+
toUPLC(ctx: ToUplcCtx): UPLCVar;
|
|
12
19
|
private _hash;
|
|
13
20
|
get hash(): IRHash;
|
|
14
|
-
|
|
15
|
-
* called inside the dbn setter
|
|
16
|
-
*/
|
|
21
|
+
isHashPresent(): boolean;
|
|
17
22
|
markHashAsInvalid(): void;
|
|
18
|
-
isHashPresent(): true;
|
|
19
|
-
private _dbn;
|
|
20
|
-
/**
|
|
21
|
-
* the IR DeBruijn index is not necessarly the same of the UPLC
|
|
22
|
-
* ( more ofthen than not it won't be the same )
|
|
23
|
-
*
|
|
24
|
-
* this is because in the IR things like `IRLetted` and `IRHoisted`
|
|
25
|
-
* are skipping some DeBruijin levels that are instead present
|
|
26
|
-
* in the final UPLC
|
|
27
|
-
**/
|
|
28
|
-
get dbn(): number;
|
|
29
|
-
set dbn(newDbn: number);
|
|
30
23
|
static get kind(): IRNodeKind.Var;
|
|
31
24
|
get kind(): IRNodeKind.Var;
|
|
32
25
|
static get tag(): Uint8Array;
|
|
33
|
-
readonly meta: IRVarMetadata;
|
|
34
26
|
private _parent;
|
|
35
27
|
get parent(): IRParentTerm | undefined;
|
|
36
28
|
set parent(newParent: IRParentTerm | undefined);
|
|
37
|
-
|
|
29
|
+
children(): IRTerm[];
|
|
38
30
|
clone(): IRVar;
|
|
39
31
|
toJSON(): any;
|
|
40
32
|
toJson(): any;
|