@harmoniclabs/pebble 0.1.0-dev4 → 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.d.ts +1 -0
- package/dist/compiler/path/getAbsolutePath.js +8 -5
- 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
package/dist/IR/IRHash.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type IRHash =
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
export type IRHash = number;
|
|
2
|
+
export declare function __VERY_UNSAFE_FORGET_IRHASH_ONLY_USE_AT_END_OF_UPLC_COMPILATION(): void;
|
|
4
3
|
export declare function hashIrData(data: Uint8Array): IRHash;
|
|
5
4
|
export declare function isIRHash(hash: any): hash is IRHash;
|
|
6
5
|
export declare function equalIrHash(a: IRHash, b: IRHash): boolean;
|
|
7
6
|
export declare function irHashToHex(hash: IRHash): string;
|
|
8
7
|
export declare function irHashFromHex(hex: string): IRHash;
|
|
8
|
+
export declare function irHashToBytes(hash: IRHash): Uint8Array;
|
package/dist/IR/IRHash.js
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (_cleanSize <= _MIN_CACHE_SIZE)
|
|
12
|
-
return; // don't clean unitl minimum size
|
|
13
|
-
const halfSize = _cleanSize >= (_MAX_DOUBLING_CACHE_SIZE * 2) ? _cleanSize - _MAX_DOUBLING_CACHE_SIZE : _cleanSize >>> 1;
|
|
14
|
-
if (_hash_cache.size < halfSize)
|
|
15
|
-
_cleanSize = halfSize;
|
|
16
|
-
}
|
|
17
|
-
// cleaning
|
|
18
|
-
for (const [key, ref] of _hash_cache.entries()) {
|
|
19
|
-
if (ref.deref() === undefined)
|
|
20
|
-
_hash_cache.delete(key);
|
|
21
|
-
}
|
|
22
|
-
// scale up
|
|
23
|
-
if (_hash_cache.size >= _cleanSize) {
|
|
24
|
-
_cleanSize = _cleanSize >= _MAX_DOUBLING_CACHE_SIZE ?
|
|
25
|
-
_cleanSize + _MAX_DOUBLING_CACHE_SIZE :
|
|
26
|
-
_cleanSize * 2;
|
|
27
|
-
}
|
|
1
|
+
import { fromHex, toBase64 } from "@harmoniclabs/uint8array-utils";
|
|
2
|
+
// HASH GENERATOR
|
|
3
|
+
const MAX_SAFE_INTEGER = Number(globalThis.Number?.MAX_SAFE_INTEGER ?? ((2 ** 53) - 1));
|
|
4
|
+
const MIN_SAFE_INTEGER = Number(globalThis.Number?.MIN_SAFE_INTEGER ?? -MAX_SAFE_INTEGER);
|
|
5
|
+
let _preimage_to_hash = {};
|
|
6
|
+
let _next_hash = MIN_SAFE_INTEGER;
|
|
7
|
+
function _getNextHash() {
|
|
8
|
+
if (_next_hash >= MAX_SAFE_INTEGER)
|
|
9
|
+
throw new Error("ran out of IR hashes");
|
|
10
|
+
return _next_hash++;
|
|
28
11
|
}
|
|
12
|
+
export function __VERY_UNSAFE_FORGET_IRHASH_ONLY_USE_AT_END_OF_UPLC_COMPILATION() {
|
|
13
|
+
_preimage_to_hash = {};
|
|
14
|
+
_next_hash = MIN_SAFE_INTEGER;
|
|
15
|
+
}
|
|
16
|
+
// HASH UTILS
|
|
17
|
+
function _positiveHash(hash) {
|
|
18
|
+
return BigInt(hash) + BigInt(MAX_SAFE_INTEGER) + BigInt(1);
|
|
19
|
+
}
|
|
20
|
+
function _fromPositiveHash(posHash) {
|
|
21
|
+
const res = Number(posHash - BigInt(MAX_SAFE_INTEGER) - BigInt(1));
|
|
22
|
+
if (!isIRHash(res))
|
|
23
|
+
throw new Error("internal error: invalid hash generated");
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
// END HASH GENERATOR
|
|
29
27
|
export function hashIrData(data) {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_cleanCache();
|
|
38
|
-
return result;
|
|
28
|
+
const preimage = toBase64(data);
|
|
29
|
+
const exsisting = _preimage_to_hash[preimage];
|
|
30
|
+
if (typeof exsisting === "number")
|
|
31
|
+
return exsisting;
|
|
32
|
+
const nextHash = _getNextHash();
|
|
33
|
+
_preimage_to_hash[preimage] = nextHash;
|
|
34
|
+
return nextHash;
|
|
39
35
|
}
|
|
40
36
|
export function isIRHash(hash) {
|
|
41
|
-
return (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
hash
|
|
46
|
-
hash
|
|
37
|
+
return (typeof hash === "number"
|
|
38
|
+
&& hash === hash // not NaN
|
|
39
|
+
&& hash <= MAX_SAFE_INTEGER
|
|
40
|
+
&& hash >= MIN_SAFE_INTEGER
|
|
41
|
+
&& BigInt(hash) <= hash
|
|
42
|
+
&& BigInt(hash) >= hash);
|
|
47
43
|
}
|
|
48
44
|
export function equalIrHash(a, b) {
|
|
49
45
|
// we can allow ourselves to use standard equality
|
|
@@ -63,16 +59,15 @@ export function equalIrHash(a, b) {
|
|
|
63
59
|
//*/
|
|
64
60
|
}
|
|
65
61
|
export function irHashToHex(hash) {
|
|
66
|
-
return
|
|
62
|
+
return _positiveHash(hash)
|
|
63
|
+
.toString(16)
|
|
64
|
+
// we MUST pad to 16 chars
|
|
65
|
+
// otherwise, hash concatenation could be ambiguous
|
|
66
|
+
.padStart(16, "0");
|
|
67
67
|
}
|
|
68
68
|
export function irHashFromHex(hex) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
parseInt(hex.slice(0, 8), 16),
|
|
74
|
-
parseInt(hex.slice(8, 16), 16),
|
|
75
|
-
parseInt(hex.slice(16, 24), 16),
|
|
76
|
-
parseInt(hex.slice(24, 32), 16)
|
|
77
|
-
]);
|
|
69
|
+
return _fromPositiveHash(BigInt("0x" + hex));
|
|
70
|
+
}
|
|
71
|
+
export function irHashToBytes(hash) {
|
|
72
|
+
return fromHex(irHashToHex(hash));
|
|
78
73
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import { IRTerm } from "../IRTerm.js";
|
|
2
|
-
import { IHash } from "../interfaces/IHash.js";
|
|
1
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
3
2
|
import { IIRParent } from "../interfaces/IIRParent.js";
|
|
4
3
|
import { ToJson } from "../../utils/ToJson.js";
|
|
5
4
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
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 IRAppMeta extends BaseIRMetadata {
|
|
11
12
|
__src__?: string | undefined;
|
|
12
13
|
}
|
|
13
|
-
export declare class IRApp implements Cloneable<IRApp>,
|
|
14
|
+
export declare class IRApp implements IIRTerm, Cloneable<IRApp>, IIRParent, ToJson {
|
|
14
15
|
constructor(_fn_: IRTerm, _arg_: IRTerm, meta?: IRAppMeta | undefined, _unsafeHash?: IRHash);
|
|
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;
|
|
16
23
|
get kind(): IRNodeKind;
|
|
17
24
|
static get tag(): Uint8Array;
|
|
@@ -21,10 +28,6 @@ export declare class IRApp implements Cloneable<IRApp>, IHash, IIRParent, ToJson
|
|
|
21
28
|
private _arg;
|
|
22
29
|
get arg(): IRTerm;
|
|
23
30
|
set arg(newArg: IRTerm);
|
|
24
|
-
private _hash;
|
|
25
|
-
get hash(): IRHash;
|
|
26
|
-
markHashAsInvalid(): void;
|
|
27
|
-
isHashPresent(): boolean;
|
|
28
31
|
private _parent;
|
|
29
32
|
get parent(): IRParentTerm | undefined;
|
|
30
33
|
set parent(newParent: IRParentTerm | undefined);
|
|
@@ -34,3 +37,4 @@ export declare class IRApp implements Cloneable<IRApp>, IHash, IIRParent, ToJson
|
|
|
34
37
|
toJSON(): any;
|
|
35
38
|
toJson(): any;
|
|
36
39
|
}
|
|
40
|
+
export declare function _ir_apps(...terms: [IRTerm, IRTerm, ...IRTerm[]]): IRApp;
|
package/dist/IR/IRNodes/IRApp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
2
2
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
3
3
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
4
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
5
4
|
import { isObject } from "@harmoniclabs/obj-utils";
|
|
6
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
7
5
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
6
|
+
import { hashIrData, irHashToBytes, isIRHash } from "../IRHash.js";
|
|
7
|
+
import { Application } from "@harmoniclabs/uplc";
|
|
8
8
|
export class IRApp {
|
|
9
9
|
constructor(_fn_, _arg_, meta = undefined, _unsafeHash) {
|
|
10
10
|
if (!isIRTerm(_fn_))
|
|
@@ -18,6 +18,29 @@ export class IRApp {
|
|
|
18
18
|
this._arg.parent = this;
|
|
19
19
|
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
20
20
|
}
|
|
21
|
+
toUPLC(ctx) {
|
|
22
|
+
const arg = this._arg.toUPLC(ctx);
|
|
23
|
+
const fn = this._fn.toUPLC(ctx);
|
|
24
|
+
return new Application(fn, arg);
|
|
25
|
+
}
|
|
26
|
+
_hash;
|
|
27
|
+
get hash() {
|
|
28
|
+
if (isIRHash(this._hash))
|
|
29
|
+
return this._hash;
|
|
30
|
+
this._hash = hashIrData(concatUint8Arr(IRApp.tag, irHashToBytes(this._fn.hash), irHashToBytes(this._arg.hash)));
|
|
31
|
+
return this._hash;
|
|
32
|
+
}
|
|
33
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
34
|
+
markHashAsInvalid() {
|
|
35
|
+
this._hash = undefined;
|
|
36
|
+
this.parent?.markHashAsInvalid();
|
|
37
|
+
}
|
|
38
|
+
children() {
|
|
39
|
+
return [
|
|
40
|
+
this._fn,
|
|
41
|
+
this._arg
|
|
42
|
+
];
|
|
43
|
+
}
|
|
21
44
|
static get kind() { return IRNodeKind.App; }
|
|
22
45
|
get kind() { return IRApp.kind; }
|
|
23
46
|
static get tag() { return new Uint8Array([IRApp.kind]); }
|
|
@@ -26,8 +49,6 @@ export class IRApp {
|
|
|
26
49
|
set fn(newFn) {
|
|
27
50
|
if (!isIRTerm(newFn))
|
|
28
51
|
return;
|
|
29
|
-
if (!shallowEqualIRTermHash(this._fn, newFn))
|
|
30
|
-
this.markHashAsInvalid();
|
|
31
52
|
// keep the parent reference in the old child, useful for compilation
|
|
32
53
|
// fn.parent = undefined;
|
|
33
54
|
this._fn = newFn;
|
|
@@ -38,26 +59,11 @@ export class IRApp {
|
|
|
38
59
|
set arg(newArg) {
|
|
39
60
|
if (!isIRTerm(newArg))
|
|
40
61
|
return;
|
|
41
|
-
if (!shallowEqualIRTermHash(this._arg, newArg))
|
|
42
|
-
this.markHashAsInvalid();
|
|
43
62
|
// keep the parent reference in the old child, useful for compilation
|
|
44
63
|
// arg.parent = undefined;
|
|
45
64
|
this._arg = newArg;
|
|
46
65
|
this._arg.parent = this;
|
|
47
66
|
}
|
|
48
|
-
_hash;
|
|
49
|
-
get hash() {
|
|
50
|
-
if (!isIRHash(this._hash)) {
|
|
51
|
-
// basically a merkle tree
|
|
52
|
-
this._hash = hashIrData(concatUint8Arr(IRApp.tag, this._fn.hash, this._arg.hash));
|
|
53
|
-
}
|
|
54
|
-
return this._hash;
|
|
55
|
-
}
|
|
56
|
-
markHashAsInvalid() {
|
|
57
|
-
this._hash = undefined;
|
|
58
|
-
this.parent?.markHashAsInvalid();
|
|
59
|
-
}
|
|
60
|
-
isHashPresent() { return isIRHash(this._hash); }
|
|
61
67
|
_parent;
|
|
62
68
|
get parent() { return this._parent; }
|
|
63
69
|
set parent(newParent) {
|
|
@@ -78,7 +84,7 @@ export class IRApp {
|
|
|
78
84
|
return this._meta;
|
|
79
85
|
}
|
|
80
86
|
clone() {
|
|
81
|
-
return new IRApp(this.fn.clone(), this.arg.clone(), isObject(this._meta) ? { ...this._meta } : undefined, this.
|
|
87
|
+
return new IRApp(this.fn.clone(), this.arg.clone(), isObject(this._meta) ? { ...this._meta } : undefined, this._hash);
|
|
82
88
|
}
|
|
83
89
|
toJSON() { return this.toJson(); }
|
|
84
90
|
toJson() {
|
|
@@ -89,3 +95,11 @@ export class IRApp {
|
|
|
89
95
|
};
|
|
90
96
|
}
|
|
91
97
|
}
|
|
98
|
+
export function _ir_apps(...terms) {
|
|
99
|
+
// if( terms.length === 1 ) return terms[0] as IRApp;
|
|
100
|
+
let term = new IRApp(terms[0], terms[1]);
|
|
101
|
+
for (let i = 2; i < terms.length; i++) {
|
|
102
|
+
term = new IRApp(term, terms[i]);
|
|
103
|
+
}
|
|
104
|
+
return term;
|
|
105
|
+
}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { Cloneable } from "../../utils/Cloneable.js";
|
|
2
2
|
import { ToJson } from "../../utils/ToJson.js";
|
|
3
|
-
import { IRTerm } from "../IRTerm.js";
|
|
4
|
-
import {
|
|
3
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
4
|
+
import { IIRParent } from "../interfaces/index.js";
|
|
5
5
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
6
6
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
7
7
|
import { MutArrayLike } from "../utils/MutArrayLike.js";
|
|
8
|
-
import { IRHash } from "../IRHash.js";
|
|
9
8
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
9
|
+
import { IRHash } from "../IRHash.js";
|
|
10
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
11
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
10
12
|
export interface IRCaseMeta extends BaseIRMetadata {
|
|
11
13
|
}
|
|
12
|
-
export declare class IRCase implements Cloneable<IRCase>,
|
|
14
|
+
export declare class IRCase implements IIRTerm, Cloneable<IRCase>, IIRParent, ToJson {
|
|
15
|
+
readonly continuations: MutArrayLike<IRTerm>;
|
|
13
16
|
static get kind(): IRNodeKind.Case;
|
|
14
17
|
get kind(): IRNodeKind.Case;
|
|
15
18
|
static get tag(): Uint8Array;
|
|
16
|
-
constructor(constrTerm: IRTerm, continuations: ArrayLike<IRTerm>, meta?: IRCaseMeta, _unsafeHash?: IRHash);
|
|
19
|
+
constructor(constrTerm: IRTerm, continuations: ArrayLike<IRTerm>, meta?: IRCaseMeta, _unsafeHash?: IRHash | undefined);
|
|
20
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
17
21
|
private _hash;
|
|
18
22
|
get hash(): IRHash;
|
|
19
|
-
markHashAsInvalid(): void;
|
|
20
23
|
isHashPresent(): boolean;
|
|
24
|
+
markHashAsInvalid(): void;
|
|
25
|
+
children(): IRTerm[];
|
|
21
26
|
private _constrTerm;
|
|
22
27
|
get constrTerm(): IRTerm;
|
|
23
28
|
set constrTerm(newConstrTerm: IRTerm);
|
|
24
|
-
readonly continuations: MutArrayLike<IRTerm>;
|
|
25
29
|
private _parent;
|
|
26
30
|
get parent(): IRParentTerm | undefined;
|
|
27
31
|
set parent(newParent: IRParentTerm | undefined);
|
|
@@ -2,11 +2,12 @@ import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
|
2
2
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
3
3
|
import { mapArrayLike } from "./utils/mapArrayLike.js";
|
|
4
4
|
import { makeArrayLikeProxy } from "./utils/makeArrayLikeProxy.js";
|
|
5
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
6
|
-
import { shallowEqualIRTermHash } from "../utils/equalIRTerm.js";
|
|
7
5
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
8
6
|
import { isIRTerm } from "../utils/isIRTerm.js";
|
|
7
|
+
import { hashIrData, irHashToBytes, isIRHash } from "../IRHash.js";
|
|
8
|
+
import { Case } from "@harmoniclabs/uplc";
|
|
9
9
|
export class IRCase {
|
|
10
|
+
continuations;
|
|
10
11
|
static get kind() { return IRNodeKind.Case; }
|
|
11
12
|
get kind() { return IRCase.kind; }
|
|
12
13
|
static get tag() { return new Uint8Array([IRCase.kind]); }
|
|
@@ -15,56 +16,56 @@ export class IRCase {
|
|
|
15
16
|
this.meta = meta;
|
|
16
17
|
this._constrTerm = constrTerm;
|
|
17
18
|
this._constrTerm.parent = self;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
newElem
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!shallowEqualIRTermHash(oldElem, newElem))
|
|
33
|
-
self.markHashAsInvalid();
|
|
34
|
-
return newElem;
|
|
35
|
-
}),
|
|
36
|
-
writable: false,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: false
|
|
19
|
+
this.continuations = makeArrayLikeProxy(continuations, isIRTerm,
|
|
20
|
+
// initModifyElem
|
|
21
|
+
// function called once for each element in the array
|
|
22
|
+
// only at element definition
|
|
23
|
+
newElem => {
|
|
24
|
+
newElem.parent = self;
|
|
25
|
+
return newElem;
|
|
26
|
+
},
|
|
27
|
+
// modifyElem
|
|
28
|
+
(newElem, oldElem) => {
|
|
29
|
+
// keep the parent reference in the old child, useful for compilation
|
|
30
|
+
// oldElem.parent = undefined;
|
|
31
|
+
newElem.parent = self;
|
|
32
|
+
return newElem;
|
|
39
33
|
});
|
|
40
34
|
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
41
35
|
}
|
|
36
|
+
toUPLC(ctx) {
|
|
37
|
+
const constrTermUplc = this.constrTerm.toUPLC(ctx);
|
|
38
|
+
const continuationsUplc = mapArrayLike(this.continuations, c => c.toUPLC(ctx));
|
|
39
|
+
return new Case(constrTermUplc, continuationsUplc);
|
|
40
|
+
}
|
|
42
41
|
_hash;
|
|
43
42
|
get hash() {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
43
|
+
if (isIRHash(this._hash))
|
|
44
|
+
return this._hash;
|
|
45
|
+
this._hash = hashIrData(concatUint8Arr(IRCase.tag, irHashToBytes(this.constrTerm.hash), ...Array.from(this.continuations, c => irHashToBytes(c.hash))));
|
|
48
46
|
return this._hash;
|
|
49
47
|
}
|
|
48
|
+
isHashPresent() { return isIRHash(this._hash); }
|
|
50
49
|
markHashAsInvalid() {
|
|
51
50
|
this._hash = undefined;
|
|
52
51
|
this.parent?.markHashAsInvalid();
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
children() {
|
|
54
|
+
return [
|
|
55
|
+
this.constrTerm,
|
|
56
|
+
...Array.from(this.continuations)
|
|
57
|
+
];
|
|
58
|
+
}
|
|
55
59
|
_constrTerm;
|
|
56
60
|
get constrTerm() { return this._constrTerm; }
|
|
57
61
|
set constrTerm(newConstrTerm) {
|
|
58
62
|
if (!isIRTerm(newConstrTerm))
|
|
59
63
|
return;
|
|
60
|
-
if (!shallowEqualIRTermHash(this._constrTerm, newConstrTerm))
|
|
61
|
-
this.markHashAsInvalid();
|
|
62
64
|
// keep the parent reference in the old child, useful for compilation
|
|
63
65
|
// constrTerm.parent = undefined;
|
|
64
66
|
this._constrTerm = newConstrTerm;
|
|
65
67
|
this._constrTerm.parent = this;
|
|
66
68
|
}
|
|
67
|
-
continuations;
|
|
68
69
|
_parent;
|
|
69
70
|
get parent() { return this._parent; }
|
|
70
71
|
set parent(newParent) {
|
|
@@ -79,7 +80,7 @@ export class IRCase {
|
|
|
79
80
|
}
|
|
80
81
|
meta;
|
|
81
82
|
clone() {
|
|
82
|
-
return new IRCase(this.constrTerm, mapArrayLike(this.continuations, f => f.clone()), { ...this.meta }, this.
|
|
83
|
+
return new IRCase(this.constrTerm, mapArrayLike(this.continuations, f => f.clone()), { ...this.meta }, this._hash);
|
|
83
84
|
}
|
|
84
85
|
toJSON() { return this.toJson(); }
|
|
85
86
|
toJson() {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Cloneable } from "@harmoniclabs/cbor/dist/utils/Cloneable";
|
|
2
2
|
import { Data } from "@harmoniclabs/plutus-data";
|
|
3
3
|
import { ToJson } from "../../utils/ToJson.js";
|
|
4
|
-
import {
|
|
4
|
+
import { IIRParent } from "../interfaces/index.js";
|
|
5
5
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
6
6
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
7
|
-
import { IRHash } from "../IRHash.js";
|
|
8
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
9
8
|
import { TirType } from "../../compiler/tir/types/TirType.js";
|
|
10
9
|
import { ConstType, UPLCConst } from "@harmoniclabs/uplc";
|
|
10
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
11
|
+
import { IRHash } from "../IRHash.js";
|
|
11
12
|
export interface IRConstPair {
|
|
12
13
|
fst: IRConstValue;
|
|
13
14
|
snd: IRConstValue;
|
|
@@ -16,18 +17,19 @@ export declare function isIRConstPair(value: any): value is IRConstPair;
|
|
|
16
17
|
export type IRConstValue = bigint | Uint8Array | string | boolean | IRConstValue[] | IRConstPair | Data | undefined;
|
|
17
18
|
export interface IRConstMetadata extends BaseIRMetadata {
|
|
18
19
|
}
|
|
19
|
-
export declare class IRConst implements Cloneable<IRConst>,
|
|
20
|
+
export declare class IRConst implements IIRTerm, Cloneable<IRConst>, IIRParent, ToJson {
|
|
20
21
|
readonly type: TirType;
|
|
21
22
|
readonly value: IRConstValue;
|
|
22
23
|
static get kind(): IRNodeKind.Const;
|
|
23
24
|
get kind(): IRNodeKind.Const;
|
|
24
25
|
static get tag(): Uint8Array;
|
|
25
26
|
constructor(type: TirType, value: IRConstValue, _unsafeHash?: IRHash);
|
|
26
|
-
toUPLC(): UPLCConst;
|
|
27
27
|
private _hash;
|
|
28
28
|
get hash(): IRHash;
|
|
29
|
-
markHashAsInvalid(): void;
|
|
30
29
|
isHashPresent(): boolean;
|
|
30
|
+
markHashAsInvalid(): void;
|
|
31
|
+
children(): IRTerm[];
|
|
32
|
+
toUPLC(): UPLCConst;
|
|
31
33
|
private _meta;
|
|
32
34
|
get meta(): IRConstMetadata | undefined;
|
|
33
35
|
private _parent;
|
|
@@ -6,7 +6,6 @@ import UPLCFlatUtils from "../../utils/UPLCFlatUtils/index.js";
|
|
|
6
6
|
import { concatUint8Arr } from "../utils/concatUint8Arr.js";
|
|
7
7
|
import { positiveBigIntAsBytes } from "../utils/positiveIntAsBytes.js";
|
|
8
8
|
import { isIRParentTerm } from "../utils/isIRParentTerm.js";
|
|
9
|
-
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
10
9
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
11
10
|
import { getUnaliased } from "../../compiler/tir/types/utils/getUnaliased.js";
|
|
12
11
|
import { TirAliasType } from "../../compiler/tir/types/TirAliasType.js";
|
|
@@ -26,6 +25,8 @@ import { TirDataOptT } from "../../compiler/tir/types/TirNativeType/native/Optio
|
|
|
26
25
|
import { TirSopOptT } from "../../compiler/tir/types/TirNativeType/native/Optional/sop.js";
|
|
27
26
|
import { TirStringT } from "../../compiler/tir/types/TirNativeType/native/string.js";
|
|
28
27
|
import { TirVoidT } from "../../compiler/tir/types/TirNativeType/native/void.js";
|
|
28
|
+
import { hashIrData, isIRHash } from "../IRHash.js";
|
|
29
|
+
import { ByteString } from "@harmoniclabs/bytestring";
|
|
29
30
|
export function isIRConstPair(value) {
|
|
30
31
|
return (value instanceof Pair &&
|
|
31
32
|
isIRConstValue(value.fst) &&
|
|
@@ -45,20 +46,29 @@ export class IRConst {
|
|
|
45
46
|
this._parent = undefined;
|
|
46
47
|
this._hash = isIRHash(_unsafeHash) ? _unsafeHash : undefined;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
return new UPLCConst(tirTypeToUplcType(getUnaliased(this.type)), this.value);
|
|
50
|
-
}
|
|
51
|
-
_hash;
|
|
49
|
+
_hash = undefined;
|
|
52
50
|
get hash() {
|
|
53
|
-
if (
|
|
54
|
-
this._hash
|
|
55
|
-
|
|
51
|
+
if (isIRHash(this._hash))
|
|
52
|
+
return this._hash;
|
|
53
|
+
this._hash = hashIrData(concatUint8Arr(IRConst.tag, new Uint8Array(this.type.toUplcConstType()), serializeIRConstValue(this.value, this.type)));
|
|
56
54
|
return this._hash;
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
isHashPresent() { return true; }
|
|
57
|
+
markHashAsInvalid() {
|
|
58
|
+
this._hash = undefined;
|
|
59
|
+
this.parent?.markHashAsInvalid();
|
|
60
|
+
}
|
|
61
|
+
children() {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
toUPLC() {
|
|
65
|
+
const type = getUnaliased(this.type);
|
|
66
|
+
if (type instanceof TirBytesT && this.value instanceof Uint8Array) {
|
|
67
|
+
// make a copy to prevent external mutation
|
|
68
|
+
return new UPLCConst(tirTypeToUplcType(type), new ByteString(this.value));
|
|
69
|
+
}
|
|
70
|
+
return new UPLCConst(tirTypeToUplcType(type), this.value);
|
|
71
|
+
}
|
|
62
72
|
_meta = undefined;
|
|
63
73
|
get meta() {
|
|
64
74
|
if (!this._meta)
|
|
@@ -78,7 +88,7 @@ export class IRConst {
|
|
|
78
88
|
this._parent = newParent;
|
|
79
89
|
}
|
|
80
90
|
clone() {
|
|
81
|
-
return new IRConst(this.type, this.value, this.
|
|
91
|
+
return new IRConst(this.type, this.value, this._hash);
|
|
82
92
|
}
|
|
83
93
|
toJSON() { return this.toJson(); }
|
|
84
94
|
toJson() {
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { Cloneable } from "../../utils/Cloneable.js";
|
|
2
2
|
import { ToJson } from "../../utils/ToJson.js";
|
|
3
|
-
import { IRTerm } from "../IRTerm.js";
|
|
4
|
-
import {
|
|
3
|
+
import { IIRTerm, IRTerm } from "../IRTerm.js";
|
|
4
|
+
import { IIRParent } from "../interfaces/index.js";
|
|
5
5
|
import { IRParentTerm } from "../utils/isIRParentTerm.js";
|
|
6
6
|
import { BaseIRMetadata } from "./BaseIRMetadata.js";
|
|
7
|
-
import { MutArrayLike } from "../utils/MutArrayLike.js";
|
|
8
|
-
import { IRHash } from "../IRHash.js";
|
|
9
7
|
import { IRNodeKind } from "../IRNodeKind.js";
|
|
8
|
+
import { IRHash } from "../IRHash.js";
|
|
9
|
+
import { MutArrayLike } from "../utils/MutArrayLike.js";
|
|
10
|
+
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
11
|
+
import { ToUplcCtx } from "../toUPLC/ctx/ToUplcCtx.js";
|
|
10
12
|
export interface IRConstrMeta extends BaseIRMetadata {
|
|
11
13
|
}
|
|
12
|
-
export declare class IRConstr implements Cloneable<IRConstr>,
|
|
14
|
+
export declare class IRConstr implements IIRTerm, Cloneable<IRConstr>, IIRParent, ToJson {
|
|
13
15
|
readonly index: bigint;
|
|
14
16
|
readonly fields: MutArrayLike<IRTerm>;
|
|
15
17
|
readonly meta: IRConstrMeta;
|
|
16
18
|
static get kind(): IRNodeKind.Constr;
|
|
17
19
|
get kind(): IRNodeKind.Constr;
|
|
18
20
|
static get tag(): Uint8Array;
|
|
19
|
-
constructor(index: number | bigint, fields: ArrayLike<IRTerm>, meta?: IRConstrMeta, _unsafeHash?: IRHash);
|
|
21
|
+
constructor(index: number | bigint, fields: ArrayLike<IRTerm>, meta?: IRConstrMeta, _unsafeHash?: IRHash | undefined);
|
|
22
|
+
toUPLC(ctx: ToUplcCtx): UPLCTerm;
|
|
20
23
|
private _hash;
|
|
21
24
|
get hash(): IRHash;
|
|
22
|
-
markHashAsInvalid(): void;
|
|
23
25
|
isHashPresent(): boolean;
|
|
26
|
+
markHashAsInvalid(): void;
|
|
27
|
+
children(): IRTerm[];
|
|
24
28
|
private _parent;
|
|
25
29
|
get parent(): IRParentTerm | undefined;
|
|
26
30
|
set parent(newParent: IRParentTerm | undefined);
|