@harmoniclabs/pebble 0.1.0-dev5 → 0.1.0-dev6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IR/IRHash.d.ts +3 -3
- package/dist/IR/IRHash.js +47 -52
- package/dist/IR/IRNodes/IRApp.d.ts +12 -8
- package/dist/IR/IRNodes/IRApp.js +34 -20
- package/dist/IR/IRNodes/IRCase.d.ts +11 -7
- package/dist/IR/IRNodes/IRCase.js +33 -32
- package/dist/IR/IRNodes/IRConst.d.ts +7 -5
- package/dist/IR/IRNodes/IRConst.js +23 -13
- package/dist/IR/IRNodes/IRConstr.d.ts +11 -7
- package/dist/IR/IRNodes/IRConstr.js +34 -37
- package/dist/IR/IRNodes/IRDelayed.d.ts +12 -9
- package/dist/IR/IRNodes/IRDelayed.js +22 -18
- package/dist/IR/IRNodes/IRError.d.ts +9 -6
- package/dist/IR/IRNodes/IRError.js +12 -5
- package/dist/IR/IRNodes/IRForced.d.ts +9 -6
- package/dist/IR/IRNodes/IRForced.js +22 -18
- package/dist/IR/IRNodes/IRFunc.d.ts +14 -10
- package/dist/IR/IRNodes/IRFunc.js +35 -38
- package/dist/IR/IRNodes/IRHoisted.d.ts +16 -9
- package/dist/IR/IRNodes/IRHoisted.js +36 -18
- package/dist/IR/IRNodes/IRLetted.d.ts +14 -34
- package/dist/IR/IRNodes/IRLetted.js +65 -297
- package/dist/IR/IRNodes/IRNative/IRNativeTag.d.ts +0 -2
- package/dist/IR/IRNodes/IRNative/IRNativeTag.js +0 -4
- package/dist/IR/IRNodes/IRNative/index.d.ts +9 -8
- package/dist/IR/IRNodes/IRNative/index.js +55 -18
- package/dist/IR/IRNodes/IRNative/isForcedNative.d.ts +2 -0
- package/dist/IR/IRNodes/IRNative/isForcedNative.js +1 -1
- package/dist/IR/IRNodes/IRRecursive.d.ts +18 -10
- package/dist/IR/IRNodes/IRRecursive.js +36 -44
- package/dist/IR/IRNodes/IRSelfCall.d.ts +10 -24
- package/dist/IR/IRNodes/IRSelfCall.js +25 -87
- package/dist/IR/IRNodes/IRVar.d.ts +11 -19
- package/dist/IR/IRNodes/IRVar.js +26 -54
- package/dist/IR/IRNodes/utils/dependsByDbns.d.ts +1 -1
- package/dist/IR/IRNodes/utils/dependsByDbns.js +5 -11
- package/dist/IR/IRNodes/utils/hashVarSym.d.ts +1 -0
- package/dist/IR/IRNodes/utils/hashVarSym.js +37 -0
- package/dist/IR/IRNodes/utils/makeArrayLikeProxy.d.ts +2 -1
- package/dist/IR/IRTerm.d.ts +7 -0
- package/dist/IR/toUPLC/_internal/_modifyChildFromTo.js +3 -0
- package/dist/IR/toUPLC/_internal/findAll.js +2 -73
- package/dist/IR/toUPLC/_internal/getDebruijnInTerm.js +7 -34
- package/dist/IR/toUPLC/_internal/iterTree.js +3 -17
- package/dist/IR/toUPLC/common_hoisted.d.ts +2 -0
- package/dist/IR/toUPLC/common_hoisted.js +4 -0
- package/dist/IR/toUPLC/compileIRToUPLC.d.ts +1 -1
- package/dist/IR/toUPLC/compileIRToUPLC.js +91 -14
- package/dist/IR/toUPLC/ctx/ToUplcCtx.d.ts +16 -0
- package/dist/IR/toUPLC/ctx/ToUplcCtx.js +75 -0
- package/dist/IR/toUPLC/subRoutines/_comptimeDropN.d.ts +8 -0
- package/dist/IR/toUPLC/subRoutines/_comptimeDropN.js +95 -0
- package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.js +7 -54
- package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.d.ts +6 -13
- package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.js +67 -71
- package/dist/IR/toUPLC/subRoutines/handleLetted/index.js +44 -170
- package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.js +7 -3
- package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.js +3 -2
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.d.ts +22 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.js +59 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.d.ts +0 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.js +217 -0
- package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.js +12 -49
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.d.ts +1 -1
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.js +11 -14
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/{index.d.ts → performUplcOptimizationsAndReturnRoot.d.ts} +0 -2
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/performUplcOptimizationsAndReturnRoot.js +151 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.d.ts +11 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.js +46 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.d.ts +2 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.js +80 -0
- package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.js +18 -11
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +43 -0
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +255 -478
- package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.d.ts +2 -0
- package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.js +85 -0
- package/dist/IR/toUPLC/subRoutines/sanifyTree.js +1 -0
- package/dist/IR/toUPLC/utils/getApplicationTerms.d.ts +6 -0
- package/dist/IR/toUPLC/utils/getApplicationTerms.js +37 -0
- package/dist/IR/tree_utils/_ir_lazyChooseList.d.ts +2 -2
- package/dist/IR/tree_utils/_ir_lazyChooseList.js +4 -2
- package/dist/IR/tree_utils/_ir_lazyIfThenElse.d.ts +1 -1
- package/dist/IR/tree_utils/_ir_lazyIfThenElse.js +4 -2
- package/dist/IR/tree_utils/_ir_let.d.ts +2 -1
- package/dist/IR/tree_utils/_ir_let.js +6 -2
- package/dist/IR/utils/isClosedIRTerm.d.ts +1 -0
- package/dist/IR/utils/isClosedIRTerm.js +39 -25
- package/dist/IR/utils/positiveIntAsBytes.d.ts +1 -0
- package/dist/IR/utils/positiveIntAsBytes.js +4 -0
- package/dist/IR/utils/showIR.d.ts +10 -21
- package/dist/IR/utils/showIR.js +66 -64
- package/dist/ast/nodes/common/Identifier.d.ts +1 -0
- package/dist/ast/nodes/common/Identifier.js +3 -0
- package/dist/ast/nodes/expr/CaseExpr.d.ts +5 -5
- package/dist/ast/nodes/expr/ElemAccessExpr.d.ts +2 -2
- package/dist/ast/nodes/expr/ParentesizedExpr.d.ts +1 -1
- package/dist/ast/nodes/expr/PebbleExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/PropAccessExpr.d.ts +3 -3
- package/dist/ast/nodes/expr/TernaryExpr.d.ts +3 -3
- package/dist/ast/nodes/expr/TypeConversionExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/TypeConversionExpr.js +2 -0
- package/dist/ast/nodes/expr/binary/BinaryExpr.d.ts +42 -42
- package/dist/ast/nodes/expr/functions/CallExpr.d.ts +1 -1
- package/dist/ast/nodes/expr/functions/FuncExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/functions/FuncExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitContextExpr.d.ts +6 -0
- package/dist/ast/nodes/expr/litteral/LitContextExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitFailExpr.d.ts +6 -0
- package/dist/ast/nodes/expr/litteral/LitFailExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitteralExpr.d.ts +3 -1
- package/dist/ast/nodes/expr/litteral/LitteralExpr.js +5 -1
- package/dist/ast/nodes/statements/AssertStmt.d.ts +2 -2
- package/dist/ast/nodes/statements/AssignmentStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/BlockStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/FailStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/ForOfStmt.d.ts +4 -2
- package/dist/ast/nodes/statements/ForOfStmt.js +6 -0
- package/dist/ast/nodes/statements/ForStmt.d.ts +6 -4
- package/dist/ast/nodes/statements/ForStmt.js +6 -0
- package/dist/ast/nodes/statements/IfStmt.d.ts +8 -5
- package/dist/ast/nodes/statements/IfStmt.js +13 -0
- package/dist/ast/nodes/statements/MatchStmt.d.ts +13 -4
- package/dist/ast/nodes/statements/MatchStmt.js +22 -1
- package/dist/ast/nodes/statements/PebbleStmt.d.ts +2 -1
- package/dist/ast/nodes/statements/PebbleStmt.js +3 -1
- package/dist/ast/nodes/statements/ReturnStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/WhileStmt.d.ts +4 -2
- package/dist/ast/nodes/statements/WhileStmt.js +6 -0
- package/dist/ast/nodes/statements/declarations/ContractDecl.d.ts +17 -0
- package/dist/ast/nodes/statements/declarations/ContractDecl.js +22 -0
- package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.d.ts +2 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.js +6 -0
- package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.d.ts +1 -1
- package/dist/compiler/AstCompiler/AstCompiler.d.ts +6 -2
- package/dist/compiler/AstCompiler/AstCompiler.js +91 -24
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.d.ts +10 -0
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.js +777 -0
- package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.js +8 -2
- package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.js +3 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +2 -2
- package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.d.ts +2 -2
- package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.js +48 -24
- package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +4 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.js +2 -2
- package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.js +1 -1
- package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.js +4 -1
- package/dist/compiler/AstCompiler/scope/AstScope.js +4 -3
- package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +6 -4
- package/dist/compiler/Compiler.js +3 -1
- package/dist/compiler/TirCompiler/compileTirProgram.js +3 -1
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +13 -3
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +41 -37
- package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +11 -2
- package/dist/compiler/TirCompiler/expressify/expressify.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressify.js +82 -36
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +57 -8
- package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +1 -1
- package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +1 -1
- package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +1 -0
- package/dist/compiler/TirCompiler/expressify/expressifyVars.js +131 -9
- package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +3 -1
- package/dist/compiler/io/IOutputStream.d.ts +1 -0
- package/dist/compiler/io/IOutputStream.js +18 -3
- package/dist/compiler/path/getAbsolutePath.js +4 -6
- package/dist/compiler/tir/expressions/ITirExpr.d.ts +2 -0
- package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.d.ts +4 -2
- package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.js +16 -2
- package/dist/compiler/tir/expressions/TirCallExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirCallExpr.js +16 -1
- package/dist/compiler/tir/expressions/TirCaseExpr.d.ts +6 -1
- package/dist/compiler/tir/expressions/TirCaseExpr.js +103 -60
- package/dist/compiler/tir/expressions/TirElemAccessExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirElemAccessExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirFailExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirFailExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirFromDataExpr.d.ts +3 -2
- package/dist/compiler/tir/expressions/TirFromDataExpr.js +85 -56
- package/dist/compiler/tir/expressions/TirFuncExpr.d.ts +4 -10
- package/dist/compiler/tir/expressions/TirFuncExpr.js +30 -13
- package/dist/compiler/tir/expressions/TirHoistedExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirHoistedExpr.js +8 -0
- package/dist/compiler/tir/expressions/TirInlineClosedIR.d.ts +4 -1
- package/dist/compiler/tir/expressions/TirInlineClosedIR.js +8 -0
- package/dist/compiler/tir/expressions/TirLettedExpr.d.ts +5 -2
- package/dist/compiler/tir/expressions/TirLettedExpr.js +19 -4
- package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +8 -5
- package/dist/compiler/tir/expressions/TirNativeFunc.js +50 -22
- package/dist/compiler/tir/expressions/TirParentesizedExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirParentesizedExpr.js +6 -0
- package/dist/compiler/tir/expressions/TirPropAccessExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirPropAccessExpr.js +9 -0
- package/dist/compiler/tir/expressions/TirTernaryExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTernaryExpr.js +16 -5
- package/dist/compiler/tir/expressions/TirToDataExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirToDataExpr.js +56 -25
- package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.js +21 -4
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.d.ts +7 -3
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +17 -7
- package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +16 -20
- package/dist/compiler/tir/expressions/ToIRTermCtx.js +67 -50
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +40 -0
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +174 -3
- package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.d.ts +4 -2
- package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.js +8 -2
- package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.d.ts +17 -0
- package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.js +21 -0
- package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.js +7 -3
- package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.d.ts +2 -1
- package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.js +3 -1
- package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.js +8 -3
- package/dist/compiler/tir/expressions/unary/TirUnaryMinus.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryMinus.js +8 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryPlus.d.ts +3 -1
- package/dist/compiler/tir/expressions/unary/TirUnaryPlus.js +6 -0
- package/dist/compiler/tir/expressions/unary/TirUnaryTilde.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryTilde.js +8 -2
- package/dist/compiler/tir/program/TypedProgram.d.ts +1 -0
- package/dist/compiler/tir/program/TypedProgram.js +9 -0
- package/dist/compiler/tir/program/stdScope/stdScope.js +126 -126
- package/dist/compiler/tir/statements/TirAssertStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirAssertStmt.js +10 -0
- package/dist/compiler/tir/statements/TirAssignmentStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirAssignmentStmt.js +8 -0
- package/dist/compiler/tir/statements/TirBlockStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirBlockStmt.js +16 -0
- package/dist/compiler/tir/statements/TirBreakStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirBreakStmt.js +8 -0
- package/dist/compiler/tir/statements/TirContinueStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirContinueStmt.js +8 -0
- package/dist/compiler/tir/statements/TirFailStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirFailStmt.js +8 -0
- package/dist/compiler/tir/statements/TirForOfStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirForOfStmt.js +14 -0
- package/dist/compiler/tir/statements/TirForStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirForStmt.js +21 -0
- package/dist/compiler/tir/statements/TirIfStmt.d.ts +3 -0
- package/dist/compiler/tir/statements/TirIfStmt.js +19 -0
- package/dist/compiler/tir/statements/TirMatchStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirMatchStmt.js +30 -0
- package/dist/compiler/tir/statements/TirReturnStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirReturnStmt.js +8 -0
- package/dist/compiler/tir/statements/TirStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.d.ts +2 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.js +30 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.d.ts +3 -1
- package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js +28 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.d.ts +3 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.js +13 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.d.ts +3 -1
- package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js +28 -0
- package/dist/compiler/tir/statements/TirWhileStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirWhileStmt.js +14 -0
- package/dist/compiler/tir/types/utils/canAssignTo.js +1 -1
- package/dist/diagnostics/DiagnosticEmitter.js +1 -1
- package/dist/diagnostics/diagnosticMessages.generated.d.ts +10 -1
- package/dist/diagnostics/diagnosticMessages.generated.js +20 -2
- package/dist/parser/Parser.d.ts +8 -3
- package/dist/parser/Parser.js +162 -30
- package/dist/tokenizer/Token.d.ts +81 -72
- package/dist/tokenizer/Token.js +82 -72
- package/dist/tokenizer/utils/tokenFromKeyword.js +32 -10
- package/dist/tokenizer/utils/tokenIsAlsoIdentifier.js +10 -0
- package/dist/utils/BitUtils/index.js +1 -1
- package/dist/utils/UPLCFlatUtils/index.js +1 -1
- package/package.json +2 -1
- package/dist/IR/IRNodes/utils/isClosedAtDbn.d.ts +0 -2
- package/dist/IR/IRNodes/utils/isClosedAtDbn.js +0 -22
- package/dist/IR/toUPLC/_internal/_irToUplc.d.ts +0 -9
- package/dist/IR/toUPLC/_internal/_irToUplc.js +0 -156
- package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.d.ts +0 -9
- package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.js +0 -73
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.d.ts +0 -1
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.js +0 -12
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.js +0 -227
- package/dist/IR/tree_utils/_ir_apps.d.ts +0 -3
- package/dist/IR/tree_utils/_ir_apps.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRApp } from "../../../IR/IRNodes/IRApp.js";
|
|
1
|
+
import { _ir_apps, IRApp } from "../../../IR/IRNodes/IRApp.js";
|
|
2
2
|
import { IRConst } from "../../../IR/IRNodes/IRConst.js";
|
|
3
3
|
import { IRConstr } from "../../../IR/IRNodes/IRConstr.js";
|
|
4
4
|
import { IRDelayed } from "../../../IR/IRNodes/IRDelayed.js";
|
|
@@ -7,7 +7,6 @@ import { IRFunc } from "../../../IR/IRNodes/IRFunc.js";
|
|
|
7
7
|
import { IRHoisted } from "../../../IR/IRNodes/IRHoisted.js";
|
|
8
8
|
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
9
9
|
import { IRVar } from "../../../IR/IRNodes/IRVar.js";
|
|
10
|
-
import { _ir_apps } from "../../../IR/tree_utils/_ir_apps.js";
|
|
11
10
|
import { _ir_let } from "../../../IR/tree_utils/_ir_let.js";
|
|
12
11
|
import { TirBoolT } from "../types/TirNativeType/native/bool.js";
|
|
13
12
|
import { TirBytesT } from "../types/TirNativeType/native/bytes.js";
|
|
@@ -33,6 +32,14 @@ export class TirFromDataExpr {
|
|
|
33
32
|
this.type = type;
|
|
34
33
|
this.range = range;
|
|
35
34
|
}
|
|
35
|
+
toString() {
|
|
36
|
+
return `fromData(${this.dataExpr.toString()}) as ${this.type.toString()}`;
|
|
37
|
+
}
|
|
38
|
+
pretty(indent) {
|
|
39
|
+
const singleIndent = " ";
|
|
40
|
+
const indent_base = singleIndent.repeat(indent);
|
|
41
|
+
return `fromData(${this.dataExpr.pretty(indent)}) as ${this.type.toString()}`;
|
|
42
|
+
}
|
|
36
43
|
clone() {
|
|
37
44
|
return new TirFromDataExpr(this.dataExpr.clone(), this.type.clone(), this.range.clone());
|
|
38
45
|
}
|
|
@@ -43,9 +50,6 @@ export class TirFromDataExpr {
|
|
|
43
50
|
toIR(ctx) {
|
|
44
51
|
return _inlineFromData(this.type, this.dataExpr.toIR(ctx));
|
|
45
52
|
}
|
|
46
|
-
toString() {
|
|
47
|
-
return `fromData(${this.dataExpr.toString()}) as ${this.type.toString()}`;
|
|
48
|
-
}
|
|
49
53
|
}
|
|
50
54
|
export function _inlineFromData(target_t, dataExprIR) {
|
|
51
55
|
const to_t = getUnaliased(target_t);
|
|
@@ -74,11 +78,11 @@ export function _inlineFromData(target_t, dataExprIR) {
|
|
|
74
78
|
if (!isTirType(value_t))
|
|
75
79
|
throw new Error("TirFromDataExpr: unreachable");
|
|
76
80
|
return _ir_let(// introuduce a var
|
|
77
|
-
_ir_apps(IRNative.unConstrData, dataExprIR), _ir_apps(IRNative.strictIfThenElse, _ir_apps(IRNative.equalsInteger, _ir_apps(IRNative.fstPair, new IRVar(
|
|
81
|
+
_ir_apps(IRNative.unConstrData, dataExprIR), unConstrDataResultSym => _ir_apps(IRNative.strictIfThenElse, _ir_apps(IRNative.equalsInteger, _ir_apps(IRNative.fstPair, new IRVar(unConstrDataResultSym) // unConstrData result
|
|
78
82
|
), IRConst.int(0)),
|
|
79
83
|
// then (Just value)
|
|
80
84
|
new IRConstr(0, [
|
|
81
|
-
_ir_apps(_fromDataUplcFunc(value_t), _ir_apps(IRNative.headList, _ir_apps(IRNative.sndPair, new IRVar(
|
|
85
|
+
_ir_apps(_fromDataUplcFunc(value_t), _ir_apps(IRNative.headList, _ir_apps(IRNative.sndPair, new IRVar(unConstrDataResultSym) // unConstrData result
|
|
82
86
|
)))
|
|
83
87
|
]),
|
|
84
88
|
// else (Nothing)
|
|
@@ -101,11 +105,11 @@ export function _fromDataUplcFunc(_target_t) {
|
|
|
101
105
|
if (target_t instanceof TirBytesT)
|
|
102
106
|
return IRNative.unBData;
|
|
103
107
|
if (target_t instanceof TirVoidT)
|
|
104
|
-
return _mkUnit;
|
|
108
|
+
return _mkUnit.clone();
|
|
105
109
|
if (target_t instanceof TirBoolT)
|
|
106
|
-
return _boolFromData;
|
|
110
|
+
return _boolFromData.clone();
|
|
107
111
|
if (target_t instanceof TirStringT)
|
|
108
|
-
return _strFromData;
|
|
112
|
+
return _strFromData.clone();
|
|
109
113
|
if (target_t instanceof TirLinearMapT)
|
|
110
114
|
// linear maps only have pairs as elements
|
|
111
115
|
// and we only support pairs of data (bc we only have `mkPairData`)
|
|
@@ -116,23 +120,23 @@ export function _fromDataUplcFunc(_target_t) {
|
|
|
116
120
|
|| elems_t instanceof TirDataOptT
|
|
117
121
|
|| elems_t instanceof TirDataT)
|
|
118
122
|
return IRNative.unListData;
|
|
119
|
-
return
|
|
120
|
-
_ir_apps(IRNative._mkMapList, IRConst.listOf(elems_t)([]), _fromDataUplcFunc(elems_t), _ir_apps(IRNative.unListData, new IRVar(0) // data
|
|
121
|
-
))));
|
|
123
|
+
return mkMapListFromData(elems_t);
|
|
122
124
|
}
|
|
123
125
|
if (target_t instanceof TirSopOptT
|
|
124
126
|
|| target_t instanceof TirSoPStructType) {
|
|
125
|
-
return
|
|
126
|
-
_inlineFromData(target_t, new IRVar(0) // data
|
|
127
|
-
)));
|
|
127
|
+
return mkSopFromData(target_t);
|
|
128
128
|
}
|
|
129
129
|
throw new Error(`TirFromDataExpr: cannot convert from Data to type ${target_t.toString()}`);
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
// replace old numeric-arity helpers
|
|
132
|
+
const _unitFromDataSym = Symbol("unit");
|
|
133
|
+
const _mkUnit = new IRHoisted(new IRFunc([_unitFromDataSym], IRConst.unit));
|
|
134
|
+
const _boolFromDataDataSym = Symbol("boolData");
|
|
135
|
+
const _boolFromData = new IRHoisted(new IRFunc([_boolFromDataDataSym], // data
|
|
136
|
+
_ir_apps(IRNative.equalsInteger, new IRApp(IRNative.fstPair, new IRApp(IRNative.unConstrData, new IRVar(_boolFromDataDataSym))), IRConst.int(0))));
|
|
137
|
+
const _strFromDataDataSym = Symbol("strData");
|
|
138
|
+
const _strFromData = new IRHoisted(new IRFunc([_strFromDataDataSym], // data
|
|
139
|
+
_ir_apps(IRNative.decodeUtf8, _ir_apps(IRNative.unBData, new IRVar(_strFromDataDataSym)))));
|
|
136
140
|
export function _inilneSingeSopConstrFromData(sop_t, dataExprIR) {
|
|
137
141
|
if (sop_t.constructors.length !== 1)
|
|
138
142
|
throw new Error("_inilneSingeSopConstrFromData: multiple constructors");
|
|
@@ -149,48 +153,73 @@ export function _inilneSingeSopConstrFromData(sop_t, dataExprIR) {
|
|
|
149
153
|
_ir_apps(IRNative.headList, _ir_apps(IRNative.sndPair, _ir_apps(IRNative.unConstrData, dataExprIR))))
|
|
150
154
|
]);
|
|
151
155
|
}
|
|
152
|
-
return _ir_let(_ir_apps(IRNative.sndPair, _ir_apps(IRNative.unConstrData, dataExprIR)), //
|
|
153
|
-
|
|
156
|
+
return _ir_let(_ir_apps(IRNative.sndPair, _ir_apps(IRNative.unConstrData, dataExprIR)), // introduce fields list
|
|
157
|
+
// introduce fields list
|
|
158
|
+
fieldsListSym => new IRConstr(0, constr.fields.map((field, i) => {
|
|
154
159
|
const field_t = getUnaliased(field.type);
|
|
155
160
|
if (!isTirType(field_t))
|
|
156
161
|
throw new Error("TirFromDataExpr: unreachable");
|
|
157
|
-
return _inlineFromData(field_t, _ir_apps(IRNative.headList, i === 0
|
|
158
|
-
|
|
159
|
-
)));
|
|
162
|
+
return _inlineFromData(field_t, _ir_apps(IRNative.headList, i === 0
|
|
163
|
+
? new IRVar(fieldsListSym)
|
|
164
|
+
: _ir_apps(IRNative._dropList, IRConst.int(i), new IRVar(fieldsListSym))));
|
|
160
165
|
})));
|
|
161
166
|
}
|
|
162
167
|
export function _inlineMultiSopConstrFromData(sop_t, dataExprIR) {
|
|
163
168
|
if (sop_t.constructors.length <= 1)
|
|
164
169
|
return _inilneSingeSopConstrFromData(sop_t, dataExprIR);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
))
|
|
175
|
-
|
|
170
|
+
return _ir_let(_ir_apps(IRNative.unConstrData, dataExprIR), // introduce unConstrData result
|
|
171
|
+
// introduce unConstrData result
|
|
172
|
+
unConstrDataSym => _ir_let(_ir_apps(IRNative.equalsInteger, _ir_apps(IRNative.fstPair, new IRVar(unConstrDataSym))), // introduce isConstrIdx predicate (a function expecting an int)
|
|
173
|
+
// introduce isConstrIdx predicate (a function expecting an int)
|
|
174
|
+
isConstrIdxSym => _ir_let(_ir_apps(IRNative.sndPair, new IRVar(unConstrDataSym)), // introduce fields list
|
|
175
|
+
// introduce fields list
|
|
176
|
+
fieldsListSym => {
|
|
177
|
+
const continuations = sop_t.constructors.map((constr, constrIdx) => {
|
|
178
|
+
if (constr.fields.length === 0)
|
|
179
|
+
return new IRHoisted(new IRConstr(constrIdx, []));
|
|
180
|
+
if (constr.fields.length === 1) {
|
|
181
|
+
const value_t = getUnaliased(constr.fields[0].type);
|
|
182
|
+
if (!isTirType(value_t))
|
|
183
|
+
throw new Error("TirFromDataExpr: unreachable");
|
|
184
|
+
return new IRConstr(constrIdx, [
|
|
185
|
+
_inlineFromData(value_t, _ir_apps(IRNative.headList, new IRVar(fieldsListSym)))
|
|
186
|
+
]);
|
|
187
|
+
}
|
|
188
|
+
return new IRConstr(constrIdx, constr.fields.map((field, i) => {
|
|
189
|
+
const field_t = getUnaliased(field.type);
|
|
190
|
+
if (!isTirType(field_t))
|
|
191
|
+
throw new Error("TirFromDataExpr: unreachable");
|
|
192
|
+
return _inlineFromData(field_t, _ir_apps(IRNative.headList, i === 0
|
|
193
|
+
? new IRVar(fieldsListSym)
|
|
194
|
+
: _ir_apps(IRNative._dropList, IRConst.int(i), new IRVar(fieldsListSym))));
|
|
195
|
+
}));
|
|
196
|
+
});
|
|
197
|
+
let finalIfThenElseChain = continuations[continuations.length - 1];
|
|
198
|
+
for (let i = continuations.length - 2; i >= 0; i--) {
|
|
199
|
+
finalIfThenElseChain = new IRForced(_ir_apps(IRNative.strictIfThenElse, _ir_apps(new IRVar(isConstrIdxSym), IRConst.int(i)), new IRDelayed(continuations[i]), new IRDelayed(finalIfThenElseChain)));
|
|
176
200
|
}
|
|
177
|
-
return
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
201
|
+
return finalIfThenElseChain;
|
|
202
|
+
})));
|
|
203
|
+
}
|
|
204
|
+
// new cached hoisted helpers (mirroring TirToDataExpr pattern)
|
|
205
|
+
const _mapListFromDataOfType = {};
|
|
206
|
+
function mkMapListFromData(elems_t) {
|
|
207
|
+
const key = elems_t.toTirTypeKey();
|
|
208
|
+
if (_mapListFromDataOfType[key])
|
|
209
|
+
return _mapListFromDataOfType[key].clone();
|
|
210
|
+
const listDataSym = Symbol("mapListFromData_data");
|
|
211
|
+
_mapListFromDataOfType[key] = new IRHoisted(new IRFunc([listDataSym], // data (list data)
|
|
212
|
+
_ir_apps(IRNative._mkMapList, IRConst.listOf(elems_t)([]), _fromDataUplcFunc(elems_t), _ir_apps(IRNative.unListData, new IRVar(listDataSym) // data
|
|
213
|
+
))));
|
|
214
|
+
return _mapListFromDataOfType[key].clone();
|
|
215
|
+
}
|
|
216
|
+
const _sopFromDataOfType = {};
|
|
217
|
+
function mkSopFromData(target_t) {
|
|
218
|
+
const key = target_t.toTirTypeKey();
|
|
219
|
+
if (_sopFromDataOfType[key])
|
|
220
|
+
return _sopFromDataOfType[key].clone();
|
|
221
|
+
const dataSym = Symbol("sop_data");
|
|
222
|
+
_sopFromDataOfType[key] = new IRHoisted(new IRFunc([dataSym], // data
|
|
223
|
+
_inlineFromData(target_t, new IRVar(dataSym))));
|
|
224
|
+
return _sopFromDataOfType[key].clone();
|
|
196
225
|
}
|
|
@@ -6,6 +6,7 @@ import { TirBlockStmt } from "../statements/TirBlockStmt.js";
|
|
|
6
6
|
import { ToIRTermCtx } from "./ToIRTermCtx.js";
|
|
7
7
|
import { TirFuncT } from "../types/TirNativeType/native/function.js";
|
|
8
8
|
import { IRTerm } from "../../../IR/IRTerm.js";
|
|
9
|
+
import type { TirExpr } from "./TirExpr.js";
|
|
9
10
|
export declare class TirFuncExpr implements ITirExpr {
|
|
10
11
|
readonly name: string;
|
|
11
12
|
readonly params: TirSimpleVarDecl[];
|
|
@@ -16,16 +17,9 @@ export declare class TirFuncExpr implements ITirExpr {
|
|
|
16
17
|
get type(): TirFuncT;
|
|
17
18
|
sig(): TirFuncT;
|
|
18
19
|
constructor(name: string, params: TirSimpleVarDecl[], returnType: TirType, body: TirBlockStmt, range: SourceRange, _isLoop?: boolean);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
readonly isSafe: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* `true` if, for all cases where the function can error,
|
|
26
|
-
* there is an alternative implementation that is safe (wrapping the result as `Optional`)
|
|
27
|
-
*/
|
|
28
|
-
readonly isRecoverable: boolean;
|
|
20
|
+
toString(): string;
|
|
21
|
+
pretty(indent: number): string;
|
|
22
|
+
clone(): TirExpr;
|
|
29
23
|
isAnonymous(): boolean;
|
|
30
24
|
private _deps;
|
|
31
25
|
private _defineDeps;
|
|
@@ -33,18 +33,34 @@ export class TirFuncExpr {
|
|
|
33
33
|
this.range = range;
|
|
34
34
|
this._isLoop = _isLoop;
|
|
35
35
|
}
|
|
36
|
+
toString() {
|
|
37
|
+
return (`function ${this.name}` +
|
|
38
|
+
`( ${this.params.map(p => p.toString()).join(", ")} )` +
|
|
39
|
+
`: ${this.returnType.toString()} ` +
|
|
40
|
+
`${this.body.toString()}`);
|
|
41
|
+
}
|
|
42
|
+
pretty(indent) {
|
|
43
|
+
const singleIndent = " ";
|
|
44
|
+
const indent_base = singleIndent.repeat(indent);
|
|
45
|
+
const indent_0 = "\n" + indent_base;
|
|
46
|
+
const indent_1 = indent_0 + singleIndent;
|
|
47
|
+
return (`function ${this.name}(` +
|
|
48
|
+
indent_1 + this.params.map(p => p.pretty(indent + 1)).join(`,${indent_1}`) +
|
|
49
|
+
`${indent_0}): ${this.returnType.toString()} ` +
|
|
50
|
+
this.body.pretty(indent));
|
|
51
|
+
}
|
|
36
52
|
clone() {
|
|
37
53
|
return new TirFuncExpr(this.name, this.params.slice(), this.returnType.clone(), this.body, this.range.clone(), this._isLoop);
|
|
38
54
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
isSafe = false;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
isRecoverable = false;
|
|
55
|
+
// / **
|
|
56
|
+
// * `true` if the function is guaranteed to never error
|
|
57
|
+
// * /
|
|
58
|
+
// readonly isSafe: boolean = false;
|
|
59
|
+
// / **
|
|
60
|
+
// * `true` if, for all cases where the function can error,
|
|
61
|
+
// * there is an alternative implementation that is safe (wrapping the result as `Optional`)
|
|
62
|
+
// * /
|
|
63
|
+
// readonly isRecoverable: boolean = false;
|
|
48
64
|
isAnonymous() {
|
|
49
65
|
return this.name === "";
|
|
50
66
|
}
|
|
@@ -81,12 +97,13 @@ export class TirFuncExpr {
|
|
|
81
97
|
const expr = returnStmt.value;
|
|
82
98
|
const isRecursive = this.isRecursive();
|
|
83
99
|
ctx = ctx.newChild();
|
|
100
|
+
let recursiveVarSym = undefined;
|
|
84
101
|
if (isRecursive)
|
|
85
|
-
ctx.defineRecursiveVar(this.name);
|
|
86
|
-
this.params.
|
|
87
|
-
let irFunc = new IRFunc(
|
|
102
|
+
recursiveVarSym = ctx.defineRecursiveVar(this.name);
|
|
103
|
+
const introuducedVars = this.params.map(param => ctx.defineVar(param.name));
|
|
104
|
+
let irFunc = new IRFunc(introuducedVars, expr.toIR(ctx));
|
|
88
105
|
if (isRecursive)
|
|
89
|
-
irFunc = new IRRecursive(
|
|
106
|
+
irFunc = new IRRecursive(recursiveVarSym, irFunc);
|
|
90
107
|
return irFunc;
|
|
91
108
|
}
|
|
92
109
|
}
|
|
@@ -10,7 +10,9 @@ export declare class TirHoistedExpr implements ITirExpr {
|
|
|
10
10
|
get type(): TirType;
|
|
11
11
|
get range(): SourceRange;
|
|
12
12
|
constructor(varName: string, expr: TirExpr);
|
|
13
|
-
|
|
13
|
+
toString(): string;
|
|
14
|
+
pretty(indent: number): string;
|
|
15
|
+
clone(): TirExpr;
|
|
14
16
|
deps(): string[];
|
|
15
17
|
unsafeClone(): TirHoistedExpr;
|
|
16
18
|
get isConstant(): boolean;
|
|
@@ -12,6 +12,14 @@ export class TirHoistedExpr {
|
|
|
12
12
|
this.varName = varName;
|
|
13
13
|
this.expr = expr;
|
|
14
14
|
}
|
|
15
|
+
toString() {
|
|
16
|
+
return `/*hoisted '${this.varName}'*/(${this.expr.toString()})`;
|
|
17
|
+
}
|
|
18
|
+
pretty(indent) {
|
|
19
|
+
const singleIndent = " ";
|
|
20
|
+
const indent_base = singleIndent.repeat(indent);
|
|
21
|
+
return `/*hoisted '${this.varName}'*/(${this.expr.pretty(indent)})`;
|
|
22
|
+
}
|
|
15
23
|
clone() {
|
|
16
24
|
return new TirHoistedExpr(this.varName, this.expr.clone());
|
|
17
25
|
}
|
|
@@ -2,6 +2,7 @@ import { SourceRange } from "../../../ast/Source/SourceRange.js";
|
|
|
2
2
|
import type { IRTerm } from "../../../IR/IRTerm.js";
|
|
3
3
|
import { TirFuncT } from "../types/TirNativeType/index.js";
|
|
4
4
|
import { ITirExpr } from "./ITirExpr.js";
|
|
5
|
+
import { TirExpr } from "./TirExpr.js";
|
|
5
6
|
import { ToIRTermCtx } from "./ToIRTermCtx.js";
|
|
6
7
|
export declare class TirInlineClosedIR implements ITirExpr {
|
|
7
8
|
readonly type: TirFuncT;
|
|
@@ -9,8 +10,10 @@ export declare class TirInlineClosedIR implements ITirExpr {
|
|
|
9
10
|
readonly range: SourceRange;
|
|
10
11
|
sig(): TirFuncT;
|
|
11
12
|
constructor(type: TirFuncT, getIr: (ctx: ToIRTermCtx) => IRTerm, range: SourceRange);
|
|
13
|
+
toString(): string;
|
|
14
|
+
pretty(indent: number): string;
|
|
12
15
|
get isConstant(): boolean;
|
|
13
|
-
clone():
|
|
16
|
+
clone(): TirExpr;
|
|
14
17
|
deps(): string[];
|
|
15
18
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
16
19
|
}
|
|
@@ -11,6 +11,14 @@ export class TirInlineClosedIR {
|
|
|
11
11
|
this.getIr = getIr;
|
|
12
12
|
this.range = range;
|
|
13
13
|
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `<closed IR> as ${this.type.toString()}`;
|
|
16
|
+
}
|
|
17
|
+
pretty(indent) {
|
|
18
|
+
const singleIndent = " ";
|
|
19
|
+
const indent_base = singleIndent.repeat(indent);
|
|
20
|
+
return `<closed IR> as ${this.type.toString()}`;
|
|
21
|
+
}
|
|
14
22
|
get isConstant() { return true; }
|
|
15
23
|
clone() {
|
|
16
24
|
return new TirInlineClosedIR(this.type.clone(), this.getIr, this.range.clone());
|
|
@@ -9,9 +9,12 @@ export declare class TirLettedExpr implements ITirExpr {
|
|
|
9
9
|
expr: TirExpr;
|
|
10
10
|
readonly range: SourceRange;
|
|
11
11
|
get type(): TirType;
|
|
12
|
-
|
|
12
|
+
private readonly _irVarSym;
|
|
13
|
+
constructor(varName: string, expr: TirExpr, range: SourceRange, _unsafeVarSym?: symbol | undefined);
|
|
14
|
+
toString(): string;
|
|
15
|
+
pretty(indent: number): string;
|
|
13
16
|
deps(): string[];
|
|
14
|
-
clone():
|
|
17
|
+
clone(): TirExpr;
|
|
15
18
|
unsafeClone(): TirLettedExpr;
|
|
16
19
|
get isConstant(): boolean;
|
|
17
20
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
@@ -6,23 +6,38 @@ export class TirLettedExpr {
|
|
|
6
6
|
get type() {
|
|
7
7
|
return this.expr.type;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
_irVarSym;
|
|
10
|
+
constructor(varName, expr, range, _unsafeVarSym) {
|
|
10
11
|
this.varName = varName;
|
|
11
12
|
this.expr = expr;
|
|
12
13
|
this.range = range;
|
|
14
|
+
if (!(typeof varName === "string"
|
|
15
|
+
&& varName.length > 0))
|
|
16
|
+
throw new Error("TirLettedExpr: varName must be a non empty string");
|
|
17
|
+
this._irVarSym = (typeof _unsafeVarSym === "symbol"
|
|
18
|
+
&& _unsafeVarSym.description === varName) ? _unsafeVarSym : Symbol(varName);
|
|
19
|
+
}
|
|
20
|
+
toString() {
|
|
21
|
+
return `/*letted '${this.varName}'*/(${this.expr.toString()})`;
|
|
22
|
+
}
|
|
23
|
+
pretty(indent) {
|
|
24
|
+
const singleIndent = " ";
|
|
25
|
+
const indent_base = singleIndent.repeat(indent);
|
|
26
|
+
const indent_0 = "\n" + indent_base;
|
|
27
|
+
return `/*letted '${this.varName}'*/(${indent_0}${this.expr.pretty(indent)}${indent_0})`;
|
|
13
28
|
}
|
|
14
29
|
deps() {
|
|
15
30
|
return this.expr.deps();
|
|
16
31
|
}
|
|
17
32
|
clone() {
|
|
18
|
-
return new TirLettedExpr(this.varName, this.expr.clone(), this.range.clone());
|
|
33
|
+
return new TirLettedExpr(this.varName, this.expr.clone(), this.range.clone(), this._irVarSym);
|
|
19
34
|
}
|
|
20
35
|
unsafeClone() {
|
|
21
36
|
return new TirLettedExpr(this.varName, this.expr, // this.expr.clone(),
|
|
22
|
-
this.range);
|
|
37
|
+
this.range, this._irVarSym);
|
|
23
38
|
}
|
|
24
39
|
get isConstant() { return this.expr.isConstant; }
|
|
25
40
|
toIR(ctx) {
|
|
26
|
-
return new IRLetted(
|
|
41
|
+
return new IRLetted(this._irVarSym, this.expr.toIR(ctx));
|
|
27
42
|
}
|
|
28
43
|
}
|
|
@@ -5,12 +5,16 @@ import type { IRTerm } from "../../../IR/IRTerm.js";
|
|
|
5
5
|
import { TirType } from "../types/TirType.js";
|
|
6
6
|
import { ToIRTermCtx } from "./ToIRTermCtx.js";
|
|
7
7
|
import { TirFuncT } from "../types/TirNativeType/native/function.js";
|
|
8
|
+
import { TirHoistedExpr } from "./TirHoistedExpr.js";
|
|
9
|
+
import { TirExpr } from "./TirExpr.js";
|
|
8
10
|
export declare class TirNativeFunc implements ITirExpr {
|
|
9
11
|
readonly tag: IRNativeTag;
|
|
10
12
|
readonly type: TirFuncT;
|
|
11
13
|
constructor(tag: IRNativeTag, type: TirFuncT);
|
|
14
|
+
toString(): string;
|
|
15
|
+
pretty(indent: number): string;
|
|
12
16
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
13
|
-
clone():
|
|
17
|
+
clone(): TirExpr;
|
|
14
18
|
get range(): SourceRange;
|
|
15
19
|
deps(): string[];
|
|
16
20
|
get isConstant(): boolean;
|
|
@@ -88,9 +92,7 @@ export declare class TirNativeFunc implements ITirExpr {
|
|
|
88
92
|
static _id(t: TirType): TirNativeFunc;
|
|
89
93
|
static get _not(): TirNativeFunc;
|
|
90
94
|
static get _strictAnd(): TirNativeFunc;
|
|
91
|
-
static get _and(): TirNativeFunc;
|
|
92
95
|
static get _strictOr(): TirNativeFunc;
|
|
93
|
-
static get _or(): TirNativeFunc;
|
|
94
96
|
static get _gtBS(): TirNativeFunc;
|
|
95
97
|
static get _gtEqBS(): TirNativeFunc;
|
|
96
98
|
static get _gtInt(): TirNativeFunc;
|
|
@@ -98,7 +100,8 @@ export declare class TirNativeFunc implements ITirExpr {
|
|
|
98
100
|
static get _pairDataToData(): TirNativeFunc;
|
|
99
101
|
static get _pairDataFromData(): TirNativeFunc;
|
|
100
102
|
static _mkEqualsList(elemT: TirType): TirNativeFunc;
|
|
101
|
-
static get _equalPairData():
|
|
102
|
-
static get _equalBoolean():
|
|
103
|
+
static get _equalPairData(): TirHoistedExpr;
|
|
104
|
+
static get _equalBoolean(): TirHoistedExpr;
|
|
105
|
+
static _equals(t: TirType): TirExpr;
|
|
103
106
|
static get _negateInt(): TirNativeFunc;
|
|
104
107
|
}
|
|
@@ -2,11 +2,16 @@ import { SourceRange } from "../../../ast/Source/SourceRange.js";
|
|
|
2
2
|
import { IRNativeTag } from "../../../IR/IRNodes/IRNative/IRNativeTag.js";
|
|
3
3
|
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
4
4
|
import { bool_t, bytes_t, data_t, int_t, void_t } from "../program/stdScope/stdScope.js";
|
|
5
|
-
import { TirUnConstrDataResultT, TirPairDataT } from "../types/TirNativeType/index.js";
|
|
5
|
+
import { TirUnConstrDataResultT, TirPairDataT, TirIntT, TirBytesT, TirDataT, TirBoolT } from "../types/TirNativeType/index.js";
|
|
6
6
|
import { TirFuncT } from "../types/TirNativeType/native/function.js";
|
|
7
7
|
import { TirLinearMapT } from "../types/TirNativeType/native/linearMap.js";
|
|
8
8
|
import { TirListT } from "../types/TirNativeType/native/list.js";
|
|
9
9
|
import { TirDataOptT } from "../types/TirNativeType/native/Optional/data.js";
|
|
10
|
+
import { TirDataStructType } from "../types/TirStructType.js";
|
|
11
|
+
import { getUnaliased } from "../types/utils/getUnaliased.js";
|
|
12
|
+
import { getListTypeArg } from "../types/utils/getListTypeArg.js";
|
|
13
|
+
import { TirHoistedExpr } from "./TirHoistedExpr.js";
|
|
14
|
+
import { TirCallExpr } from "./TirCallExpr.js";
|
|
10
15
|
export class TirNativeFunc {
|
|
11
16
|
tag;
|
|
12
17
|
type;
|
|
@@ -14,6 +19,14 @@ export class TirNativeFunc {
|
|
|
14
19
|
this.tag = tag;
|
|
15
20
|
this.type = type;
|
|
16
21
|
}
|
|
22
|
+
toString() {
|
|
23
|
+
return `<native ${IRNativeTag[this.tag]}>`;
|
|
24
|
+
}
|
|
25
|
+
pretty(indent) {
|
|
26
|
+
const singleIndent = " ";
|
|
27
|
+
const indent_base = singleIndent.repeat(indent);
|
|
28
|
+
return `<native ${IRNativeTag[this.tag]}>`;
|
|
29
|
+
}
|
|
17
30
|
toIR(ctx) {
|
|
18
31
|
return new IRNative(this.tag);
|
|
19
32
|
}
|
|
@@ -668,11 +681,9 @@ export class TirNativeFunc {
|
|
|
668
681
|
}
|
|
669
682
|
static _some(elemT) {
|
|
670
683
|
return new TirNativeFunc(IRNativeTag._some, new TirFuncT([
|
|
671
|
-
// predicate
|
|
672
|
-
new TirFuncT([
|
|
673
|
-
|
|
674
|
-
], bool_t),
|
|
675
|
-
// list
|
|
684
|
+
// predicate ((elemT) => bool)
|
|
685
|
+
new TirFuncT([elemT], bool_t),
|
|
686
|
+
// list<elemT>
|
|
676
687
|
new TirListT(elemT)
|
|
677
688
|
], bool_t));
|
|
678
689
|
}
|
|
@@ -713,24 +724,12 @@ export class TirNativeFunc {
|
|
|
713
724
|
bool_t
|
|
714
725
|
], bool_t));
|
|
715
726
|
}
|
|
716
|
-
static get _and() {
|
|
717
|
-
return new TirNativeFunc(IRNativeTag._and, new TirFuncT([
|
|
718
|
-
bool_t,
|
|
719
|
-
bool_t
|
|
720
|
-
], bool_t));
|
|
721
|
-
}
|
|
722
727
|
static get _strictOr() {
|
|
723
728
|
return new TirNativeFunc(IRNativeTag._strictOr, new TirFuncT([
|
|
724
729
|
bool_t,
|
|
725
730
|
bool_t
|
|
726
731
|
], bool_t));
|
|
727
732
|
}
|
|
728
|
-
static get _or() {
|
|
729
|
-
return new TirNativeFunc(IRNativeTag._or, new TirFuncT([
|
|
730
|
-
bool_t,
|
|
731
|
-
bool_t
|
|
732
|
-
], bool_t));
|
|
733
|
-
}
|
|
734
733
|
static get _gtBS() {
|
|
735
734
|
return new TirNativeFunc(IRNativeTag._gtBS, new TirFuncT([
|
|
736
735
|
bytes_t,
|
|
@@ -781,20 +780,49 @@ export class TirNativeFunc {
|
|
|
781
780
|
], bool_t));
|
|
782
781
|
}
|
|
783
782
|
static get _equalPairData() {
|
|
784
|
-
return new TirNativeFunc(IRNativeTag._equalPairData, new TirFuncT([
|
|
783
|
+
return new TirHoistedExpr("equal_pair_data", new TirNativeFunc(IRNativeTag._equalPairData, new TirFuncT([
|
|
785
784
|
// pairA
|
|
786
785
|
new TirPairDataT(),
|
|
787
786
|
// pairB
|
|
788
787
|
new TirPairDataT()
|
|
789
|
-
], bool_t));
|
|
788
|
+
], bool_t)));
|
|
790
789
|
}
|
|
791
790
|
static get _equalBoolean() {
|
|
792
|
-
return new TirNativeFunc(IRNativeTag._equalBoolean, new TirFuncT([
|
|
791
|
+
return new TirHoistedExpr("equal_boolean", new TirNativeFunc(IRNativeTag._equalBoolean, new TirFuncT([
|
|
793
792
|
// a
|
|
794
793
|
bool_t,
|
|
795
794
|
// b
|
|
796
795
|
bool_t
|
|
797
|
-
], bool_t));
|
|
796
|
+
], bool_t)));
|
|
797
|
+
}
|
|
798
|
+
static _equals(t) {
|
|
799
|
+
t = getUnaliased(t);
|
|
800
|
+
if (t instanceof TirIntT)
|
|
801
|
+
return this.equalsInteger;
|
|
802
|
+
if (t instanceof TirBytesT)
|
|
803
|
+
return this.equalsByteString;
|
|
804
|
+
if (t instanceof TirPairDataT)
|
|
805
|
+
return this._equalPairData;
|
|
806
|
+
if (t instanceof TirBoolT)
|
|
807
|
+
return this._equalBoolean;
|
|
808
|
+
if (t instanceof TirDataT
|
|
809
|
+
|| t instanceof TirDataOptT
|
|
810
|
+
|| t instanceof TirDataStructType)
|
|
811
|
+
return this.equalsData;
|
|
812
|
+
if (t instanceof TirListT) {
|
|
813
|
+
const elemT = getListTypeArg(t);
|
|
814
|
+
if (!elemT)
|
|
815
|
+
throw new Error(`Could not get element type of list type ${t.toString()}`);
|
|
816
|
+
const elemName = elemT.toConcreteTirTypeName();
|
|
817
|
+
const funcName = `equal_list_of_${elemName}`;
|
|
818
|
+
return new TirHoistedExpr(funcName, new TirCallExpr(this._mkEqualsList(elemT), [this._equals(elemT)], new TirFuncT([
|
|
819
|
+
// listA
|
|
820
|
+
new TirListT(elemT),
|
|
821
|
+
// listB
|
|
822
|
+
new TirListT(elemT)
|
|
823
|
+
], bool_t), SourceRange.unknown));
|
|
824
|
+
}
|
|
825
|
+
throw new Error(`No native equals function for type ${t.toString()}`);
|
|
798
826
|
}
|
|
799
827
|
static get _negateInt() {
|
|
800
828
|
return new TirNativeFunc(IRNativeTag._negateInt, new TirFuncT([
|
|
@@ -10,7 +10,9 @@ export declare class TirParentesizedExpr implements HasSourceRange, ITirExpr {
|
|
|
10
10
|
readonly type: TirType;
|
|
11
11
|
readonly range: SourceRange;
|
|
12
12
|
constructor(expr: TirExpr, type: TirType, range: SourceRange);
|
|
13
|
-
|
|
13
|
+
toString(): string;
|
|
14
|
+
pretty(indent: number): string;
|
|
15
|
+
clone(): TirExpr;
|
|
14
16
|
deps(): string[];
|
|
15
17
|
get isConstant(): boolean;
|
|
16
18
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
@@ -7,6 +7,12 @@ export class TirParentesizedExpr {
|
|
|
7
7
|
this.type = type;
|
|
8
8
|
this.range = range;
|
|
9
9
|
}
|
|
10
|
+
toString() {
|
|
11
|
+
return `(${this.expr.toString()})`;
|
|
12
|
+
}
|
|
13
|
+
pretty(indent) {
|
|
14
|
+
return `(${this.expr.pretty(indent)})`;
|
|
15
|
+
}
|
|
10
16
|
clone() {
|
|
11
17
|
return new TirParentesizedExpr(this.expr.clone(), this.type.clone(), this.range.clone());
|
|
12
18
|
}
|
|
@@ -11,7 +11,9 @@ export declare class TirPropAccessExpr implements ITirExpr {
|
|
|
11
11
|
readonly type: TirType;
|
|
12
12
|
readonly range: SourceRange;
|
|
13
13
|
constructor(object: TirExpr, prop: Identifier, type: TirType, range: SourceRange);
|
|
14
|
-
|
|
14
|
+
toString(): string;
|
|
15
|
+
pretty(indent: number): string;
|
|
16
|
+
clone(): TirExpr;
|
|
15
17
|
deps(): string[];
|
|
16
18
|
get isConstant(): boolean;
|
|
17
19
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
@@ -11,6 +11,14 @@ export class TirPropAccessExpr {
|
|
|
11
11
|
this.type = type;
|
|
12
12
|
this.range = range;
|
|
13
13
|
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `${this.object.toString()}.${this.prop.toString()}`;
|
|
16
|
+
}
|
|
17
|
+
pretty(indent) {
|
|
18
|
+
const singleIndent = " ";
|
|
19
|
+
const indent_base = singleIndent.repeat(indent);
|
|
20
|
+
return `${this.object.pretty(indent)}.${this.prop.toString()}`;
|
|
21
|
+
}
|
|
14
22
|
clone() {
|
|
15
23
|
return new TirPropAccessExpr(this.object.clone(), this.prop.clone(), this.type.clone(), this.range.clone());
|
|
16
24
|
}
|
|
@@ -24,6 +32,7 @@ export class TirPropAccessExpr {
|
|
|
24
32
|
}
|
|
25
33
|
get isConstant() { return false; }
|
|
26
34
|
toIR(ctx) {
|
|
35
|
+
console.log(this);
|
|
27
36
|
throw new Error("property access cannot be translated to IR");
|
|
28
37
|
}
|
|
29
38
|
}
|