@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/tokenizer/Token.js
CHANGED
|
@@ -78,129 +78,139 @@ export var Token;
|
|
|
78
78
|
Token[Token["Test"] = 38] = "Test";
|
|
79
79
|
Token[Token["Fail"] = 39] = "Fail";
|
|
80
80
|
Token[Token["Assert"] = 40] = "Assert";
|
|
81
|
+
// contract keywords
|
|
82
|
+
Token[Token["Contract"] = 41] = "Contract";
|
|
83
|
+
Token[Token["Param"] = 42] = "Param";
|
|
84
|
+
Token[Token["Spend"] = 43] = "Spend";
|
|
85
|
+
Token[Token["Mint"] = 44] = "Mint";
|
|
86
|
+
Token[Token["Certify"] = 45] = "Certify";
|
|
87
|
+
Token[Token["Withdraw"] = 46] = "Withdraw";
|
|
88
|
+
Token[Token["Propose"] = 47] = "Propose";
|
|
89
|
+
Token[Token["Vote"] = 48] = "Vote";
|
|
90
|
+
Token[Token["Context"] = 49] = "Context";
|
|
81
91
|
// punctuation
|
|
82
92
|
/** `{` */
|
|
83
|
-
Token[Token["OpenBrace"] =
|
|
93
|
+
Token[Token["OpenBrace"] = 50] = "OpenBrace";
|
|
84
94
|
/** `}` */
|
|
85
|
-
Token[Token["CloseBrace"] =
|
|
86
|
-
Token[Token["OpenParen"] =
|
|
87
|
-
Token[Token["CloseParen"] =
|
|
95
|
+
Token[Token["CloseBrace"] = 51] = "CloseBrace";
|
|
96
|
+
Token[Token["OpenParen"] = 52] = "OpenParen";
|
|
97
|
+
Token[Token["CloseParen"] = 53] = "CloseParen";
|
|
88
98
|
/** `[` */
|
|
89
|
-
Token[Token["OpenBracket"] =
|
|
99
|
+
Token[Token["OpenBracket"] = 54] = "OpenBracket";
|
|
90
100
|
/** `]` */
|
|
91
|
-
Token[Token["CloseBracket"] =
|
|
101
|
+
Token[Token["CloseBracket"] = 55] = "CloseBracket";
|
|
92
102
|
/** `.` */
|
|
93
|
-
Token[Token["Dot"] =
|
|
103
|
+
Token[Token["Dot"] = 56] = "Dot";
|
|
94
104
|
/** `...` */
|
|
95
|
-
Token[Token["Dot_Dot_Dot"] =
|
|
105
|
+
Token[Token["Dot_Dot_Dot"] = 57] = "Dot_Dot_Dot";
|
|
96
106
|
/** `;` */
|
|
97
|
-
Token[Token["Semicolon"] =
|
|
107
|
+
Token[Token["Semicolon"] = 58] = "Semicolon";
|
|
98
108
|
/** `,` */
|
|
99
|
-
Token[Token["Comma"] =
|
|
109
|
+
Token[Token["Comma"] = 59] = "Comma";
|
|
100
110
|
/** `<` */
|
|
101
|
-
Token[Token["LessThan"] =
|
|
111
|
+
Token[Token["LessThan"] = 60] = "LessThan";
|
|
102
112
|
/** `>` */
|
|
103
|
-
Token[Token["GreaterThan"] =
|
|
113
|
+
Token[Token["GreaterThan"] = 61] = "GreaterThan";
|
|
104
114
|
/** `<=` */
|
|
105
|
-
Token[Token["LessThan_Equals"] =
|
|
115
|
+
Token[Token["LessThan_Equals"] = 62] = "LessThan_Equals";
|
|
106
116
|
/** `>=` */
|
|
107
|
-
Token[Token["GreaterThan_Equals"] =
|
|
117
|
+
Token[Token["GreaterThan_Equals"] = 63] = "GreaterThan_Equals";
|
|
108
118
|
/** `==` */
|
|
109
|
-
Token[Token["Equals_Equals"] =
|
|
119
|
+
Token[Token["Equals_Equals"] = 64] = "Equals_Equals";
|
|
110
120
|
/** `!=` */
|
|
111
|
-
Token[Token["Exclamation_Equals"] =
|
|
121
|
+
Token[Token["Exclamation_Equals"] = 65] = "Exclamation_Equals";
|
|
112
122
|
/** `===` */
|
|
113
|
-
Token[Token["Equals_Equals_Equals"] =
|
|
123
|
+
Token[Token["Equals_Equals_Equals"] = 66] = "Equals_Equals_Equals";
|
|
114
124
|
/** `!==` */
|
|
115
|
-
Token[Token["Exclamation_Equals_Equals"] =
|
|
125
|
+
Token[Token["Exclamation_Equals_Equals"] = 67] = "Exclamation_Equals_Equals";
|
|
116
126
|
/** `=>` */
|
|
117
|
-
Token[Token["FatArrow"] =
|
|
127
|
+
Token[Token["FatArrow"] = 68] = "FatArrow";
|
|
118
128
|
/** `+` */
|
|
119
|
-
Token[Token["Plus"] =
|
|
129
|
+
Token[Token["Plus"] = 69] = "Plus";
|
|
120
130
|
/** `-` */
|
|
121
|
-
Token[Token["Minus"] =
|
|
131
|
+
Token[Token["Minus"] = 70] = "Minus";
|
|
122
132
|
/** `**` */
|
|
123
|
-
Token[Token["Asterisk_Asterisk"] =
|
|
133
|
+
Token[Token["Asterisk_Asterisk"] = 71] = "Asterisk_Asterisk";
|
|
124
134
|
/** `*` */
|
|
125
|
-
Token[Token["Asterisk"] =
|
|
135
|
+
Token[Token["Asterisk"] = 72] = "Asterisk";
|
|
126
136
|
/** `/` */
|
|
127
|
-
Token[Token["Slash"] =
|
|
137
|
+
Token[Token["Slash"] = 73] = "Slash";
|
|
128
138
|
/** `%` */
|
|
129
|
-
Token[Token["Percent"] =
|
|
139
|
+
Token[Token["Percent"] = 74] = "Percent";
|
|
130
140
|
/** `++` */
|
|
131
|
-
Token[Token["Plus_Plus"] =
|
|
141
|
+
Token[Token["Plus_Plus"] = 75] = "Plus_Plus";
|
|
132
142
|
/** `--` */
|
|
133
|
-
Token[Token["Minus_Minus"] =
|
|
143
|
+
Token[Token["Minus_Minus"] = 76] = "Minus_Minus";
|
|
134
144
|
/** `<<` */
|
|
135
|
-
Token[Token["LessThan_LessThan"] =
|
|
145
|
+
Token[Token["LessThan_LessThan"] = 77] = "LessThan_LessThan";
|
|
136
146
|
/** `>>` */
|
|
137
|
-
Token[Token["GreaterThan_GreaterThan"] =
|
|
147
|
+
Token[Token["GreaterThan_GreaterThan"] = 78] = "GreaterThan_GreaterThan";
|
|
138
148
|
/** `>>>` */
|
|
139
|
-
Token[Token["GreaterThan_GreaterThan_GreaterThan"] =
|
|
149
|
+
Token[Token["GreaterThan_GreaterThan_GreaterThan"] = 79] = "GreaterThan_GreaterThan_GreaterThan";
|
|
140
150
|
/** `+` */
|
|
141
|
-
Token[Token["Ampersand"] =
|
|
151
|
+
Token[Token["Ampersand"] = 80] = "Ampersand";
|
|
142
152
|
/** `|` */
|
|
143
|
-
Token[Token["Bar"] =
|
|
153
|
+
Token[Token["Bar"] = 81] = "Bar";
|
|
144
154
|
/** `^` */
|
|
145
|
-
Token[Token["Caret"] =
|
|
155
|
+
Token[Token["Caret"] = 82] = "Caret";
|
|
146
156
|
/** `!` */
|
|
147
|
-
Token[Token["Exclamation"] =
|
|
157
|
+
Token[Token["Exclamation"] = 83] = "Exclamation";
|
|
148
158
|
/** `~` */
|
|
149
|
-
Token[Token["Tilde"] =
|
|
159
|
+
Token[Token["Tilde"] = 84] = "Tilde";
|
|
150
160
|
/** `&&` */
|
|
151
|
-
Token[Token["Ampersand_Ampersand"] =
|
|
161
|
+
Token[Token["Ampersand_Ampersand"] = 85] = "Ampersand_Ampersand";
|
|
152
162
|
/** `||` */
|
|
153
|
-
Token[Token["Bar_Bar"] =
|
|
163
|
+
Token[Token["Bar_Bar"] = 86] = "Bar_Bar";
|
|
154
164
|
/** `?` */
|
|
155
|
-
Token[Token["Question"] =
|
|
165
|
+
Token[Token["Question"] = 87] = "Question";
|
|
156
166
|
/** `:` */
|
|
157
|
-
Token[Token["Colon"] =
|
|
167
|
+
Token[Token["Colon"] = 88] = "Colon";
|
|
158
168
|
/** `=` */
|
|
159
|
-
Token[Token["Equals"] =
|
|
160
|
-
Token[Token["Plus_Equals"] =
|
|
161
|
-
Token[Token["Minus_Equals"] =
|
|
162
|
-
Token[Token["Asterisk_Equals"] =
|
|
163
|
-
Token[Token["Asterisk_Asterisk_Equals"] =
|
|
164
|
-
Token[Token["Slash_Equals"] =
|
|
165
|
-
Token[Token["Percent_Equals"] =
|
|
166
|
-
Token[Token["LessThan_LessThan_Equals"] =
|
|
167
|
-
Token[Token["GreaterThan_GreaterThan_Equals"] =
|
|
168
|
-
Token[Token["GreaterThan_GreaterThan_GreaterThan_Equals"] =
|
|
169
|
-
Token[Token["Ampersand_Equals"] =
|
|
170
|
-
Token[Token["Bar_Equals"] =
|
|
171
|
-
Token[Token["Caret_Equals"] =
|
|
172
|
-
Token[Token["At"] =
|
|
169
|
+
Token[Token["Equals"] = 89] = "Equals";
|
|
170
|
+
Token[Token["Plus_Equals"] = 90] = "Plus_Equals";
|
|
171
|
+
Token[Token["Minus_Equals"] = 91] = "Minus_Equals";
|
|
172
|
+
Token[Token["Asterisk_Equals"] = 92] = "Asterisk_Equals";
|
|
173
|
+
Token[Token["Asterisk_Asterisk_Equals"] = 93] = "Asterisk_Asterisk_Equals";
|
|
174
|
+
Token[Token["Slash_Equals"] = 94] = "Slash_Equals";
|
|
175
|
+
Token[Token["Percent_Equals"] = 95] = "Percent_Equals";
|
|
176
|
+
Token[Token["LessThan_LessThan_Equals"] = 96] = "LessThan_LessThan_Equals";
|
|
177
|
+
Token[Token["GreaterThan_GreaterThan_Equals"] = 97] = "GreaterThan_GreaterThan_Equals";
|
|
178
|
+
Token[Token["GreaterThan_GreaterThan_GreaterThan_Equals"] = 98] = "GreaterThan_GreaterThan_GreaterThan_Equals";
|
|
179
|
+
Token[Token["Ampersand_Equals"] = 99] = "Ampersand_Equals";
|
|
180
|
+
Token[Token["Bar_Equals"] = 100] = "Bar_Equals";
|
|
181
|
+
Token[Token["Caret_Equals"] = 101] = "Caret_Equals";
|
|
182
|
+
Token[Token["At"] = 102] = "At";
|
|
173
183
|
/** `??=` */
|
|
174
|
-
Token[Token["Question_Question_Equals"] =
|
|
184
|
+
Token[Token["Question_Question_Equals"] = 103] = "Question_Question_Equals";
|
|
175
185
|
/** `||=` */
|
|
176
|
-
Token[Token["Bar_Bar_Equals"] =
|
|
186
|
+
Token[Token["Bar_Bar_Equals"] = 104] = "Bar_Bar_Equals";
|
|
177
187
|
/** `&&=` */
|
|
178
|
-
Token[Token["Ampersand_Ampersand_Equals"] =
|
|
188
|
+
Token[Token["Ampersand_Ampersand_Equals"] = 105] = "Ampersand_Ampersand_Equals";
|
|
179
189
|
/** `??` */
|
|
180
|
-
Token[Token["Question_Question"] =
|
|
190
|
+
Token[Token["Question_Question"] = 106] = "Question_Question";
|
|
181
191
|
/** `?.` */
|
|
182
|
-
Token[Token["Question_Dot"] =
|
|
192
|
+
Token[Token["Question_Dot"] = 107] = "Question_Dot";
|
|
183
193
|
/** `!.` */
|
|
184
|
-
Token[Token["Exclamation_Dot"] =
|
|
194
|
+
Token[Token["Exclamation_Dot"] = 108] = "Exclamation_Dot";
|
|
185
195
|
// custom native types for pebble
|
|
186
|
-
Token[Token["Data"] =
|
|
187
|
-
Token[Token["Bytes"] =
|
|
188
|
-
Token[Token["Optional"] =
|
|
189
|
-
Token[Token["List"] =
|
|
190
|
-
Token[Token["LinearMap"] =
|
|
196
|
+
Token[Token["Data"] = 109] = "Data";
|
|
197
|
+
Token[Token["Bytes"] = 110] = "Bytes";
|
|
198
|
+
Token[Token["Optional"] = 111] = "Optional";
|
|
199
|
+
Token[Token["List"] = 112] = "List";
|
|
200
|
+
Token[Token["LinearMap"] = 113] = "LinearMap";
|
|
191
201
|
// struct decl modifiers
|
|
192
202
|
// taggedModifier, // `tagged` data struct
|
|
193
|
-
Token[Token["Runtime"] =
|
|
203
|
+
Token[Token["Runtime"] = 114] = "Runtime";
|
|
194
204
|
// literals
|
|
195
|
-
Token[Token["Identifier"] =
|
|
196
|
-
Token[Token["StringLiteral"] =
|
|
197
|
-
Token[Token["HexBytesLiteral"] =
|
|
198
|
-
Token[Token["IntegerLiteral"] =
|
|
205
|
+
Token[Token["Identifier"] = 115] = "Identifier";
|
|
206
|
+
Token[Token["StringLiteral"] = 116] = "StringLiteral";
|
|
207
|
+
Token[Token["HexBytesLiteral"] = 117] = "HexBytesLiteral";
|
|
208
|
+
Token[Token["IntegerLiteral"] = 118] = "IntegerLiteral";
|
|
199
209
|
// FloatLiteral,
|
|
200
|
-
Token[Token["StringTemplateLiteralQuote"] =
|
|
210
|
+
Token[Token["StringTemplateLiteralQuote"] = 119] = "StringTemplateLiteralQuote";
|
|
201
211
|
// meta
|
|
202
|
-
Token[Token["Invalid"] =
|
|
203
|
-
Token[Token["EndOfFile"] =
|
|
212
|
+
Token[Token["Invalid"] = 120] = "Invalid";
|
|
213
|
+
Token[Token["EndOfFile"] = 121] = "EndOfFile";
|
|
204
214
|
})(Token || (Token = {}));
|
|
205
215
|
Object.freeze(Token);
|
|
206
216
|
/*
|
|
@@ -31,6 +31,12 @@ export function tokenFromKeyword(text) {
|
|
|
31
31
|
return Token.Const;
|
|
32
32
|
if (text === "continue")
|
|
33
33
|
return Token.Continue;
|
|
34
|
+
if (text === "contract")
|
|
35
|
+
return Token.Contract;
|
|
36
|
+
if (text === "certify")
|
|
37
|
+
return Token.Certify;
|
|
38
|
+
if (text === "context")
|
|
39
|
+
return Token.Context;
|
|
34
40
|
// if (text === "constructor") return Token.Constructor;
|
|
35
41
|
break;
|
|
36
42
|
}
|
|
@@ -44,6 +50,8 @@ export function tokenFromKeyword(text) {
|
|
|
44
50
|
// if (text === "delete") return Token.Delete;
|
|
45
51
|
if (text === "debugger")
|
|
46
52
|
return Token.Debugger;
|
|
53
|
+
if (text === "data")
|
|
54
|
+
return Token.Data;
|
|
47
55
|
break;
|
|
48
56
|
}
|
|
49
57
|
case 101 /* CharCode.e */: {
|
|
@@ -129,6 +137,8 @@ export function tokenFromKeyword(text) {
|
|
|
129
137
|
// if (text === "module") return Token.Module;
|
|
130
138
|
if (text === "match")
|
|
131
139
|
return Token.Match;
|
|
140
|
+
if (text === "mint")
|
|
141
|
+
return Token.Mint;
|
|
132
142
|
break;
|
|
133
143
|
}
|
|
134
144
|
case 110 /* CharCode.n */: {
|
|
@@ -145,21 +155,27 @@ export function tokenFromKeyword(text) {
|
|
|
145
155
|
// if (text === "override") return Token.Override;
|
|
146
156
|
break;
|
|
147
157
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
case 112 /* CharCode.p */: {
|
|
159
|
+
// if (len === 7) {
|
|
160
|
+
// if (text === "private") return Token.Private;
|
|
161
|
+
// if (text === "package") return Token.Package;
|
|
162
|
+
// break;
|
|
163
|
+
// }
|
|
164
|
+
// if (text === "public") return Token.Public;
|
|
165
|
+
// if (text === "protected") return Token.Protected;
|
|
166
|
+
if (text === "param")
|
|
167
|
+
return Token.Param;
|
|
168
|
+
if (text === "propose")
|
|
169
|
+
return Token.Propose;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
158
172
|
case 114 /* CharCode.r */: {
|
|
159
173
|
if (text === "return")
|
|
160
174
|
return Token.Return;
|
|
161
175
|
if (text === "readonly")
|
|
162
176
|
return Token.Readonly;
|
|
177
|
+
if (text === "runtime")
|
|
178
|
+
return Token.Runtime;
|
|
163
179
|
break;
|
|
164
180
|
}
|
|
165
181
|
case 115 /* CharCode.s */: {
|
|
@@ -171,6 +187,8 @@ export function tokenFromKeyword(text) {
|
|
|
171
187
|
return Token.Struct;
|
|
172
188
|
break;
|
|
173
189
|
}
|
|
190
|
+
if (text === "spend")
|
|
191
|
+
return Token.Spend;
|
|
174
192
|
// if (text === "set") return Token.Set;
|
|
175
193
|
// if (text === "super") return Token.Super;
|
|
176
194
|
break;
|
|
@@ -202,6 +220,8 @@ export function tokenFromKeyword(text) {
|
|
|
202
220
|
return Token.Var;
|
|
203
221
|
if (text === "void")
|
|
204
222
|
return Token.Void;
|
|
223
|
+
if (text === "vote")
|
|
224
|
+
return Token.Vote;
|
|
205
225
|
break;
|
|
206
226
|
}
|
|
207
227
|
case 119 /* CharCode.w */: {
|
|
@@ -210,6 +230,8 @@ export function tokenFromKeyword(text) {
|
|
|
210
230
|
if (text === "when")
|
|
211
231
|
return Token.When;
|
|
212
232
|
// if (text === "with") return Token.With;
|
|
233
|
+
if (text === "withdraw")
|
|
234
|
+
return Token.Withdraw;
|
|
213
235
|
break;
|
|
214
236
|
}
|
|
215
237
|
// case CharCode.y: {
|
|
@@ -17,6 +17,16 @@ export function tokenIsAlsoIdentifier(token) {
|
|
|
17
17
|
// case Token.Namespace:
|
|
18
18
|
// case Token.Null:
|
|
19
19
|
case Token.Readonly:
|
|
20
|
+
// all the contract keywords are also identifiers (except 'context')
|
|
21
|
+
case Token.Contract:
|
|
22
|
+
case Token.Param:
|
|
23
|
+
case Token.Spend:
|
|
24
|
+
case Token.Mint:
|
|
25
|
+
case Token.Certify:
|
|
26
|
+
case Token.Withdraw:
|
|
27
|
+
case Token.Propose:
|
|
28
|
+
case Token.Vote:
|
|
29
|
+
// case Token.Context:
|
|
20
30
|
// case Token.Type: // we don't allow it in pebble
|
|
21
31
|
case Token.Void: return true;
|
|
22
32
|
default: return false;
|
|
@@ -48,7 +48,7 @@ export default class BitUtils {
|
|
|
48
48
|
static minBytesRequired(bigint) {
|
|
49
49
|
if (bigint < BigInt(0))
|
|
50
50
|
throw new Error("BitUtils.minBytesRequired works for positives integers only");
|
|
51
|
-
const fullByteOnes = BigInt(
|
|
51
|
+
const fullByteOnes = BigInt(0b1111_1111);
|
|
52
52
|
let mask = fullByteOnes;
|
|
53
53
|
let bytesRequired = 1;
|
|
54
54
|
while (bigint !== (bigint & mask)) {
|
|
@@ -45,7 +45,7 @@ export default class UPLCFlatUtils {
|
|
|
45
45
|
assert(integer > BigInt(0), "'UPLCFlatUtils.encodeBigIntAsVariableLengthBitStream' can only encode non-negative integers; the given input was: " + integer.toString());
|
|
46
46
|
// store binary string for easy BitStream creation
|
|
47
47
|
const chunks = [];
|
|
48
|
-
let mask = BigInt(
|
|
48
|
+
let mask = BigInt(0b0111_1111);
|
|
49
49
|
// 1. Converting to binary
|
|
50
50
|
const nBits = BitUtils.getNOfUsedBits(integer);
|
|
51
51
|
for (let nAddedBits = 0; nAddedBits < nBits; nAddedBits += 7) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harmoniclabs/pebble",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-dev6",
|
|
4
4
|
"description": "A simple, yet rock solid, functional language with an imperative bias, targeting UPLC",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"buidl": "npm run build",
|
|
18
18
|
"build": "rm -rf ./dist && npm run build:light",
|
|
19
19
|
"build:light": "npm run genDiagnosticMessages && tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json",
|
|
20
|
+
"build-and-replace": "npm run build && cp -r ./dist ../pebble-cli/node_modules/@harmoniclabs/pebble",
|
|
20
21
|
"genDiagnosticMessages": "node ./scripts/genDiagnosticMessages.js",
|
|
21
22
|
"test": "jest",
|
|
22
23
|
"test:debug": "node --nolazy --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --colors --verbose",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { iterTree } from "../../toUPLC/_internal/iterTree.js";
|
|
2
|
-
import { IRSelfCall } from "../IRSelfCall.js";
|
|
3
|
-
import { IRVar } from "../IRVar.js";
|
|
4
|
-
export function isClosedAtDbn(term, dbn = 0) {
|
|
5
|
-
let isClosed = true;
|
|
6
|
-
iterTree(term, (node, diff) => {
|
|
7
|
-
const realDbn = dbn + diff;
|
|
8
|
-
if (node instanceof IRVar ||
|
|
9
|
-
node instanceof IRSelfCall) {
|
|
10
|
-
// realDbn === 0 implies no variables are in scope
|
|
11
|
-
// so if node.dbn === 0 and realDbn === 0 then the variable is open
|
|
12
|
-
// and is pointing outside of the scope
|
|
13
|
-
isClosed = isClosed || node.dbn < realDbn;
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
// shouldSkipNode
|
|
17
|
-
undefined,
|
|
18
|
-
// shouldStop
|
|
19
|
-
() => !isClosed // exit early
|
|
20
|
-
);
|
|
21
|
-
return isClosed;
|
|
22
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IRTerm } from "../../IRTerm.js";
|
|
2
|
-
import { UPLCTerm } from "@harmoniclabs/uplc";
|
|
3
|
-
export type RawSrcMap = {
|
|
4
|
-
[node_index: number]: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function _irToUplc(ir: IRTerm, srcmap?: RawSrcMap | undefined, node_index?: number): {
|
|
7
|
-
term: UPLCTerm;
|
|
8
|
-
max_idx: number;
|
|
9
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { IRApp } from "../../IRNodes/IRApp.js";
|
|
2
|
-
import { IRConst } from "../../IRNodes/IRConst.js";
|
|
3
|
-
import { IRFunc } from "../../IRNodes/IRFunc.js";
|
|
4
|
-
import { IRHoisted } from "../../IRNodes/IRHoisted.js";
|
|
5
|
-
import { IRLetted } from "../../IRNodes/IRLetted.js";
|
|
6
|
-
import { IRNative } from "../../IRNodes/IRNative/index.js";
|
|
7
|
-
import { nativeTagToString } from "../../IRNodes/IRNative/IRNativeTag.js";
|
|
8
|
-
import { IRVar } from "../../IRNodes/IRVar.js";
|
|
9
|
-
import { showIR } from "../../utils/showIR.js";
|
|
10
|
-
import { IRError } from "../../IRNodes/IRError.js";
|
|
11
|
-
import { IRForced } from "../../IRNodes/IRForced.js";
|
|
12
|
-
import { IRDelayed } from "../../IRNodes/IRDelayed.js";
|
|
13
|
-
import { UPLCVar, Lambda, Application, Builtin, ErrorUPLC, Force, Delay, Constr, Case } from "@harmoniclabs/uplc";
|
|
14
|
-
import { IRConstr } from "../../IRNodes/IRConstr.js";
|
|
15
|
-
import { IRCase } from "../../IRNodes/IRCase.js";
|
|
16
|
-
import { irHashToHex } from "../../IRHash.js";
|
|
17
|
-
import { IRRecursive } from "../../IRNodes/IRRecursive.js";
|
|
18
|
-
import { IRSelfCall } from "../../IRNodes/IRSelfCall.js";
|
|
19
|
-
export function _irToUplc(ir, srcmap = undefined, node_index = 0) {
|
|
20
|
-
if (!(ir instanceof IRConst)) {
|
|
21
|
-
// console.log("_irToUplc", ir, node_index, Date.now());
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
// if( ir.parent )
|
|
25
|
-
// {
|
|
26
|
-
// console.log(ir.parent ? Object.getPrototypeOf( ir.parent ).constructor.name : undefined, Date.now() );
|
|
27
|
-
// }
|
|
28
|
-
// else
|
|
29
|
-
// {
|
|
30
|
-
// console.log( Error().stack );
|
|
31
|
-
// }
|
|
32
|
-
}
|
|
33
|
-
if (ir instanceof IRConst) {
|
|
34
|
-
return {
|
|
35
|
-
term: ir.toUPLC(),
|
|
36
|
-
max_idx: node_index
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (ir instanceof IRVar)
|
|
40
|
-
return {
|
|
41
|
-
term: new UPLCVar(ir.dbn),
|
|
42
|
-
max_idx: node_index
|
|
43
|
-
};
|
|
44
|
-
if (ir instanceof IRFunc) {
|
|
45
|
-
const { term: body, max_idx } = _irToUplc(ir.body, srcmap, node_index);
|
|
46
|
-
let lam = new Lambda(body);
|
|
47
|
-
for (let i = 1; i < ir.arity; i++) {
|
|
48
|
-
lam = new Lambda(lam);
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
term: lam,
|
|
52
|
-
max_idx
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (ir instanceof IRRecursive) {
|
|
56
|
-
throw new Error("Can't convert 'IRRecursive' to valid UPLC;" +
|
|
57
|
-
"IRRecursive are expected to be converted before calling '_irToUplc'");
|
|
58
|
-
}
|
|
59
|
-
if (ir instanceof IRSelfCall) {
|
|
60
|
-
throw new Error("Can't convert 'IRSelfCall' to valid UPLC;" +
|
|
61
|
-
"IRSelfCall are expected to be converted before calling '_irToUplc'");
|
|
62
|
-
}
|
|
63
|
-
if (ir instanceof IRApp) {
|
|
64
|
-
const { term: fn, max_idx: fn_max_idx } = _irToUplc(ir.fn, srcmap, node_index + 1);
|
|
65
|
-
const { term: arg, max_idx: arg_max_idx } = _irToUplc(ir.arg, srcmap, fn_max_idx + 1);
|
|
66
|
-
let src = ir.meta.__src__;
|
|
67
|
-
if (srcmap && typeof src === "string") {
|
|
68
|
-
srcmap[node_index] = adaptSrcString(src);
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
term: new Application(fn, arg),
|
|
72
|
-
max_idx: arg_max_idx
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (ir instanceof IRNative) {
|
|
76
|
-
if (ir.tag < 0)
|
|
77
|
-
throw new Error("Can't translate '" + nativeTagToString(ir.tag) + "' 'IRNative' to 'UPLCBuiltin'");
|
|
78
|
-
return {
|
|
79
|
-
term: new Builtin(ir.tag),
|
|
80
|
-
max_idx: node_index
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (ir instanceof IRLetted) {
|
|
84
|
-
throw new Error("Can't convert 'IRLetted' to valid UPLC");
|
|
85
|
-
}
|
|
86
|
-
if (ir instanceof IRHoisted) {
|
|
87
|
-
// return this.hoisted.toUPLC();
|
|
88
|
-
throw new Error("Can't convert 'IRHoisted' to valid UPLC;" +
|
|
89
|
-
"\nhoisted hash was: " + irHashToHex(ir.hash) +
|
|
90
|
-
"\nhoisted term was: " + showIR(ir.hoisted).text);
|
|
91
|
-
}
|
|
92
|
-
if (ir instanceof IRError) {
|
|
93
|
-
if (typeof ir.addInfos.__src__ === "string" && srcmap) {
|
|
94
|
-
srcmap[node_index] = adaptSrcString(ir.addInfos.__src__);
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
term: new ErrorUPLC(ir.msg, ir.addInfos),
|
|
98
|
-
max_idx: node_index
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
if (ir instanceof IRForced) {
|
|
102
|
-
const { term: toForce, max_idx } = _irToUplc(ir.forced, srcmap, node_index);
|
|
103
|
-
return {
|
|
104
|
-
term: new Force(toForce),
|
|
105
|
-
max_idx
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
if (ir instanceof IRDelayed) {
|
|
109
|
-
const { term: toDelay, max_idx } = _irToUplc(ir.delayed, srcmap, node_index);
|
|
110
|
-
return {
|
|
111
|
-
term: new Delay(toDelay),
|
|
112
|
-
max_idx
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (ir instanceof IRConstr) {
|
|
116
|
-
if (ir.fields.length === 0) {
|
|
117
|
-
return {
|
|
118
|
-
term: new Constr(ir.index, []),
|
|
119
|
-
max_idx: node_index + 1
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const fields = Array.from(ir.fields)
|
|
123
|
-
.slice(1)
|
|
124
|
-
.reduce((accum, field, i) => {
|
|
125
|
-
accum.push(_irToUplc(field, srcmap, accum[i].max_idx + 1));
|
|
126
|
-
return accum;
|
|
127
|
-
}, [_irToUplc(ir.fields[0], srcmap, node_index)]);
|
|
128
|
-
return {
|
|
129
|
-
term: new Constr(ir.index, fields.map(({ term }) => term)),
|
|
130
|
-
max_idx: fields[fields.length - 1].max_idx
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
if (ir instanceof IRCase) {
|
|
134
|
-
const { term: constrTerm, max_idx } = _irToUplc(ir.constrTerm, srcmap, node_index);
|
|
135
|
-
const conts = Array.from(ir.continuations)
|
|
136
|
-
.slice(1)
|
|
137
|
-
.reduce((accum, cont, i) => {
|
|
138
|
-
accum.push(_irToUplc(cont, srcmap, accum[i].max_idx + 1));
|
|
139
|
-
return accum;
|
|
140
|
-
}, [_irToUplc(ir.continuations[0], srcmap, max_idx + 1)]);
|
|
141
|
-
return {
|
|
142
|
-
term: new Case(constrTerm, conts.map(({ term }) => term)),
|
|
143
|
-
max_idx: conts[conts.length - 1].max_idx
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
throw new Error("unknown IR term calling '_irToUplc'");
|
|
147
|
-
}
|
|
148
|
-
function adaptSrcString(src) {
|
|
149
|
-
// " at $ (some/path/to/src.ts:line:column)" -> "some/path/to/src.ts:line:column"
|
|
150
|
-
let idx = src.indexOf("(");
|
|
151
|
-
src = idx >= 0 ? src.slice(idx + 1, src.length - 1) : src;
|
|
152
|
-
// " at some/path/to/src.ts:line:column" -> "some/path/to/src.ts:line:column"
|
|
153
|
-
idx = src.indexOf("at ");
|
|
154
|
-
src = idx >= 0 ? src.slice(idx + 3) : src;
|
|
155
|
-
return src;
|
|
156
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IRTerm } from "../../../IRTerm.js";
|
|
2
|
-
import { IRLetted } from "../../../IRNodes/IRLetted.js";
|
|
3
|
-
/**
|
|
4
|
-
* add 1 to every var's DeBruijn that accesses stuff outside the parent node
|
|
5
|
-
* not including the `parentNode` node
|
|
6
|
-
* since the new function introdcued substituting the letted term
|
|
7
|
-
* is added inside the `parentNode` node
|
|
8
|
-
**/
|
|
9
|
-
export declare function incrementUnboundDbns(theTerm: IRTerm, shouldNotModifyLetted: (letted: IRLetted, dbn: number) => boolean): void;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { IRVar } from "../../../IRNodes/IRVar.js";
|
|
2
|
-
import { IRLetted } from "../../../IRNodes/IRLetted.js";
|
|
3
|
-
import { IRApp } from "../../../IRNodes/IRApp.js";
|
|
4
|
-
import { IRDelayed } from "../../../IRNodes/IRDelayed.js";
|
|
5
|
-
import { IRForced } from "../../../IRNodes/IRForced.js";
|
|
6
|
-
import { IRFunc } from "../../../IRNodes/IRFunc.js";
|
|
7
|
-
import { IRCase } from "../../../IRNodes/IRCase.js";
|
|
8
|
-
import { mapArrayLike } from "../../../IRNodes/utils/mapArrayLike.js";
|
|
9
|
-
import { IRConstr } from "../../../IRNodes/IRConstr.js";
|
|
10
|
-
import { IRRecursive } from "../../../IRNodes/IRRecursive.js";
|
|
11
|
-
import { IRSelfCall } from "../../../IRNodes/IRSelfCall.js";
|
|
12
|
-
/**
|
|
13
|
-
* add 1 to every var's DeBruijn that accesses stuff outside the parent node
|
|
14
|
-
* not including the `parentNode` node
|
|
15
|
-
* since the new function introdcued substituting the letted term
|
|
16
|
-
* is added inside the `parentNode` node
|
|
17
|
-
**/
|
|
18
|
-
export function incrementUnboundDbns(theTerm, shouldNotModifyLetted) {
|
|
19
|
-
const stack = [{ term: theTerm, dbn: 0 }];
|
|
20
|
-
while (stack.length > 0) {
|
|
21
|
-
const { term: t, dbn } = stack.pop();
|
|
22
|
-
if ((t instanceof IRVar ||
|
|
23
|
-
t instanceof IRSelfCall) &&
|
|
24
|
-
t.dbn >= dbn) {
|
|
25
|
-
// there's a new variable in scope
|
|
26
|
-
t.dbn++;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (t instanceof IRLetted) {
|
|
30
|
-
if (shouldNotModifyLetted(t, dbn)) {
|
|
31
|
-
// don't modify letted to be hoisted
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
else // other letted to be handled in one of the next cycles
|
|
35
|
-
{
|
|
36
|
-
// `IRLambdas` DeBruijn are tracking the level of instantiation
|
|
37
|
-
// we add a new variable so the dbn of instantiation increments
|
|
38
|
-
t.dbn += 1;
|
|
39
|
-
stack.push({ term: t.value, dbn });
|
|
40
|
-
}
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (t instanceof IRApp) {
|
|
44
|
-
stack.push({ term: t.arg, dbn }, { term: t.fn, dbn });
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (t instanceof IRCase) {
|
|
48
|
-
stack.push({ term: t.constrTerm, dbn }, ...mapArrayLike(t.continuations, continuation => ({ term: continuation, dbn })));
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (t instanceof IRConstr) {
|
|
52
|
-
stack.push(...mapArrayLike(t.fields, field => ({ term: field, dbn })));
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (t instanceof IRDelayed) {
|
|
56
|
-
stack.push({ term: t.delayed, dbn });
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (t instanceof IRForced) {
|
|
60
|
-
stack.push({ term: t.forced, dbn });
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (t instanceof IRFunc) {
|
|
64
|
-
stack.push({ term: t.body, dbn: dbn + t.arity });
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (t instanceof IRRecursive) {
|
|
68
|
-
stack.push({ term: t.body, dbn: dbn + t.arity });
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
// skip hoisted since closed
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|