@harmoniclabs/pebble 0.1.0-dev5 → 0.1.0-dev7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IR/IRHash.d.ts +3 -3
- package/dist/IR/IRHash.js +47 -52
- package/dist/IR/IRNodes/IRApp.d.ts +12 -8
- package/dist/IR/IRNodes/IRApp.js +34 -20
- package/dist/IR/IRNodes/IRCase.d.ts +11 -7
- package/dist/IR/IRNodes/IRCase.js +33 -32
- package/dist/IR/IRNodes/IRConst.d.ts +7 -5
- package/dist/IR/IRNodes/IRConst.js +23 -13
- package/dist/IR/IRNodes/IRConstr.d.ts +11 -7
- package/dist/IR/IRNodes/IRConstr.js +34 -37
- package/dist/IR/IRNodes/IRDelayed.d.ts +12 -9
- package/dist/IR/IRNodes/IRDelayed.js +22 -18
- package/dist/IR/IRNodes/IRError.d.ts +9 -6
- package/dist/IR/IRNodes/IRError.js +12 -5
- package/dist/IR/IRNodes/IRForced.d.ts +9 -6
- package/dist/IR/IRNodes/IRForced.js +22 -18
- package/dist/IR/IRNodes/IRFunc.d.ts +14 -10
- package/dist/IR/IRNodes/IRFunc.js +35 -38
- package/dist/IR/IRNodes/IRHoisted.d.ts +16 -9
- package/dist/IR/IRNodes/IRHoisted.js +36 -18
- package/dist/IR/IRNodes/IRLetted.d.ts +14 -34
- package/dist/IR/IRNodes/IRLetted.js +65 -297
- package/dist/IR/IRNodes/IRNative/IRNativeTag.d.ts +3 -3
- package/dist/IR/IRNodes/IRNative/IRNativeTag.js +4 -4
- package/dist/IR/IRNodes/IRNative/index.d.ts +10 -8
- package/dist/IR/IRNodes/IRNative/index.js +56 -18
- package/dist/IR/IRNodes/IRNative/isForcedNative.d.ts +2 -0
- package/dist/IR/IRNodes/IRNative/isForcedNative.js +1 -1
- package/dist/IR/IRNodes/IRRecursive.d.ts +18 -10
- package/dist/IR/IRNodes/IRRecursive.js +36 -44
- package/dist/IR/IRNodes/IRSelfCall.d.ts +10 -24
- package/dist/IR/IRNodes/IRSelfCall.js +25 -87
- package/dist/IR/IRNodes/IRVar.d.ts +11 -19
- package/dist/IR/IRNodes/IRVar.js +26 -54
- package/dist/IR/IRNodes/utils/dependsByDbns.d.ts +1 -1
- package/dist/IR/IRNodes/utils/dependsByDbns.js +5 -11
- package/dist/IR/IRNodes/utils/hashVarSym.d.ts +1 -0
- package/dist/IR/IRNodes/utils/hashVarSym.js +37 -0
- package/dist/IR/IRNodes/utils/makeArrayLikeProxy.d.ts +2 -1
- package/dist/IR/IRTerm.d.ts +7 -0
- package/dist/IR/toUPLC/CompilerOptions.d.ts +5 -0
- package/dist/IR/toUPLC/CompilerOptions.js +10 -1
- package/dist/IR/toUPLC/_internal/_modifyChildFromTo.js +3 -0
- package/dist/IR/toUPLC/_internal/findAll.js +2 -73
- package/dist/IR/toUPLC/_internal/getDebruijnInTerm.js +7 -34
- package/dist/IR/toUPLC/_internal/iterTree.js +3 -17
- package/dist/IR/toUPLC/common_hoisted.d.ts +2 -0
- package/dist/IR/toUPLC/common_hoisted.js +4 -0
- package/dist/IR/toUPLC/compileIRToUPLC.d.ts +1 -1
- package/dist/IR/toUPLC/compileIRToUPLC.js +91 -14
- package/dist/IR/toUPLC/ctx/ToUplcCtx.d.ts +16 -0
- package/dist/IR/toUPLC/ctx/ToUplcCtx.js +67 -0
- package/dist/IR/toUPLC/subRoutines/_comptimeDropN.d.ts +8 -0
- package/dist/IR/toUPLC/subRoutines/_comptimeDropN.js +95 -0
- package/dist/IR/toUPLC/subRoutines/handleHoistedAndReturnRoot/index.js +7 -54
- package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.d.ts +6 -13
- package/dist/IR/toUPLC/subRoutines/handleLetted/groupByScope.js +65 -71
- package/dist/IR/toUPLC/subRoutines/handleLetted/index.js +44 -170
- package/dist/IR/toUPLC/subRoutines/handleRecursiveTerms.js +7 -3
- package/dist/IR/toUPLC/subRoutines/hoistForcedNatives.js +3 -2
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.d.ts +22 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/InlineSingleUseCtx.js +59 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.d.ts +0 -0
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseAndReturnRoot/inlineSingleUseAndReturnRoot.js +217 -0
- package/dist/IR/toUPLC/subRoutines/markRecursiveHoistsAsForced.js +12 -49
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.d.ts +1 -1
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/expandFuncsAndReturnRoot.js +11 -14
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/{index.d.ts → performUplcOptimizationsAndReturnRoot.d.ts} +0 -2
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/performUplcOptimizationsAndReturnRoot.js +151 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.d.ts +11 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/RemoveUnusedVarsCtx.js +46 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.d.ts +2 -0
- package/dist/IR/toUPLC/subRoutines/removeUnusuedVarsAndReturnRoot/removeUnusuedVarsAndReturnRoot.js +80 -0
- package/dist/IR/toUPLC/subRoutines/replaceHoistedWithLetted.js +18 -11
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +45 -0
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +277 -478
- package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.d.ts +2 -0
- package/dist/IR/toUPLC/subRoutines/rewriteNativesAppliedToConstantsAndReturnRoot.js +85 -0
- package/dist/IR/toUPLC/subRoutines/sanifyTree.js +1 -0
- package/dist/IR/toUPLC/utils/getApplicationTerms.d.ts +6 -0
- package/dist/IR/toUPLC/utils/getApplicationTerms.js +37 -0
- package/dist/IR/tree_utils/_ir_lazyChooseList.d.ts +2 -2
- package/dist/IR/tree_utils/_ir_lazyChooseList.js +4 -2
- package/dist/IR/tree_utils/_ir_lazyIfThenElse.d.ts +1 -1
- package/dist/IR/tree_utils/_ir_lazyIfThenElse.js +4 -2
- package/dist/IR/tree_utils/_ir_let.d.ts +2 -1
- package/dist/IR/tree_utils/_ir_let.js +6 -2
- package/dist/IR/utils/isClosedIRTerm.d.ts +1 -0
- package/dist/IR/utils/isClosedIRTerm.js +40 -26
- package/dist/IR/utils/positiveIntAsBytes.d.ts +1 -0
- package/dist/IR/utils/positiveIntAsBytes.js +4 -4
- package/dist/IR/utils/showIR.d.ts +10 -21
- package/dist/IR/utils/showIR.js +66 -64
- package/dist/ast/nodes/common/Identifier.d.ts +1 -0
- package/dist/ast/nodes/common/Identifier.js +3 -0
- package/dist/ast/nodes/expr/CaseExpr.d.ts +5 -5
- package/dist/ast/nodes/expr/ElemAccessExpr.d.ts +2 -2
- package/dist/ast/nodes/expr/ParentesizedExpr.d.ts +1 -1
- package/dist/ast/nodes/expr/PebbleExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/PropAccessExpr.d.ts +3 -3
- package/dist/ast/nodes/expr/TernaryExpr.d.ts +3 -3
- package/dist/ast/nodes/expr/TypeConversionExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/TypeConversionExpr.js +2 -0
- package/dist/ast/nodes/expr/binary/BinaryExpr.d.ts +42 -42
- package/dist/ast/nodes/expr/functions/CallExpr.d.ts +1 -1
- package/dist/ast/nodes/expr/functions/FuncExpr.d.ts +2 -1
- package/dist/ast/nodes/expr/functions/FuncExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitContextExpr.d.ts +6 -0
- package/dist/ast/nodes/expr/litteral/LitContextExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitFailExpr.d.ts +6 -0
- package/dist/ast/nodes/expr/litteral/LitFailExpr.js +6 -0
- package/dist/ast/nodes/expr/litteral/LitteralExpr.d.ts +3 -1
- package/dist/ast/nodes/expr/litteral/LitteralExpr.js +5 -1
- package/dist/ast/nodes/statements/AssertStmt.d.ts +2 -2
- package/dist/ast/nodes/statements/AssignmentStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/BlockStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/FailStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/ForOfStmt.d.ts +4 -2
- package/dist/ast/nodes/statements/ForOfStmt.js +6 -0
- package/dist/ast/nodes/statements/ForStmt.d.ts +6 -4
- package/dist/ast/nodes/statements/ForStmt.js +6 -0
- package/dist/ast/nodes/statements/IfStmt.d.ts +8 -5
- package/dist/ast/nodes/statements/IfStmt.js +13 -0
- package/dist/ast/nodes/statements/MatchStmt.d.ts +13 -4
- package/dist/ast/nodes/statements/MatchStmt.js +22 -1
- package/dist/ast/nodes/statements/PebbleStmt.d.ts +2 -1
- package/dist/ast/nodes/statements/PebbleStmt.js +3 -1
- package/dist/ast/nodes/statements/ReturnStmt.d.ts +1 -1
- package/dist/ast/nodes/statements/WhileStmt.d.ts +4 -2
- package/dist/ast/nodes/statements/WhileStmt.js +6 -0
- package/dist/ast/nodes/statements/declarations/ContractDecl.d.ts +17 -0
- package/dist/ast/nodes/statements/declarations/ContractDecl.js +22 -0
- package/dist/ast/nodes/statements/declarations/VarDecl/ArrayLikeDeconstr.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/HasInit.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/NamedDeconstructVarDecl.d.ts +1 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.d.ts +2 -1
- package/dist/ast/nodes/statements/declarations/VarDecl/SimpleVarDecl.js +6 -0
- package/dist/ast/nodes/statements/declarations/VarDecl/SingleDeconstructVarDecl.d.ts +1 -1
- package/dist/compiler/AstCompiler/AstCompiler.d.ts +7 -2
- package/dist/compiler/AstCompiler/AstCompiler.js +129 -25
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.d.ts +10 -0
- package/dist/compiler/AstCompiler/internal/_deriveContractBody/_deriveContractBody.js +777 -0
- package/dist/compiler/AstCompiler/internal/exprs/_compileBinaryExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileExpr.js +5 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileFuncExpr.js +7 -4
- package/dist/compiler/AstCompiler/internal/exprs/_compileLitteralExpr.js +8 -2
- package/dist/compiler/AstCompiler/internal/exprs/_compilePropAccessExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileTypeConversionExpr.js +2 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileUnaryPrefixExpr.js +1 -1
- package/dist/compiler/AstCompiler/internal/exprs/_compileVarAccessExpr.js +3 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileAssignmentStmt.js +8 -8
- package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.d.ts +2 -2
- package/dist/compiler/AstCompiler/internal/statements/_compileMatchStmt.js +48 -24
- package/dist/compiler/AstCompiler/internal/statements/_compileStatement.js +4 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.d.ts +2 -1
- package/dist/compiler/AstCompiler/internal/statements/_compileVarStmt.js +4 -3
- package/dist/compiler/AstCompiler/internal/types/_compileDataEncodedConcreteType.js +1 -1
- package/dist/compiler/AstCompiler/internal/types/_compileSopEncodedConcreteType.js +4 -1
- package/dist/compiler/AstCompiler/scope/AstScope.d.ts +1 -0
- package/dist/compiler/AstCompiler/scope/AstScope.js +9 -3
- package/dist/compiler/AstCompiler/utils/getPropAccessReturnType.js +6 -4
- package/dist/compiler/Compiler.js +7 -1
- package/dist/compiler/TirCompiler/compileTirProgram.js +4 -1
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.d.ts +17 -5
- package/dist/compiler/TirCompiler/expressify/ExpressifyCtx.js +79 -49
- package/dist/compiler/TirCompiler/expressify/determineReassignedVariablesAndReturn.js +13 -2
- package/dist/compiler/TirCompiler/expressify/expressify.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressify.js +102 -41
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.d.ts +2 -1
- package/dist/compiler/TirCompiler/expressify/expressifyForStmt.js +77 -12
- package/dist/compiler/TirCompiler/expressify/expressifyIfBranch.js +1 -1
- package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.d.ts +1 -2
- package/dist/compiler/TirCompiler/expressify/expressifyVarAssignmentStmt.js +16 -9
- package/dist/compiler/TirCompiler/expressify/expressifyVarDecl.js +6 -8
- package/dist/compiler/TirCompiler/expressify/expressifyVars.js +146 -13
- package/dist/compiler/TirCompiler/expressify/flattenSopNamedDeconstructInplace_addTopDestructToCtx_getNestedDeconstruct.js +1 -0
- package/dist/compiler/internalVar.d.ts +1 -1
- package/dist/compiler/internalVar.js +31 -24
- package/dist/compiler/io/CompilerIoApi.d.ts +1 -1
- package/dist/compiler/io/IOutputStream.d.ts +1 -0
- package/dist/compiler/io/IOutputStream.js +18 -3
- package/dist/compiler/path/getAbsolutePath.js +4 -6
- package/dist/compiler/tir/expressions/ITirExpr.d.ts +2 -0
- package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.d.ts +4 -2
- package/dist/compiler/tir/expressions/TirAssertAndContinueExpr.js +16 -2
- package/dist/compiler/tir/expressions/TirCallExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirCallExpr.js +16 -1
- package/dist/compiler/tir/expressions/TirCaseExpr.d.ts +6 -1
- package/dist/compiler/tir/expressions/TirCaseExpr.js +105 -60
- package/dist/compiler/tir/expressions/TirElemAccessExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirElemAccessExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirFailExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirFailExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirFromDataExpr.d.ts +3 -2
- package/dist/compiler/tir/expressions/TirFromDataExpr.js +85 -56
- package/dist/compiler/tir/expressions/TirFuncExpr.d.ts +4 -10
- package/dist/compiler/tir/expressions/TirFuncExpr.js +30 -13
- package/dist/compiler/tir/expressions/TirHoistedExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirHoistedExpr.js +8 -0
- package/dist/compiler/tir/expressions/TirInlineClosedIR.d.ts +4 -1
- package/dist/compiler/tir/expressions/TirInlineClosedIR.js +8 -0
- package/dist/compiler/tir/expressions/TirLettedExpr.d.ts +6 -3
- package/dist/compiler/tir/expressions/TirLettedExpr.js +20 -7
- package/dist/compiler/tir/expressions/TirNativeFunc.d.ts +9 -5
- package/dist/compiler/tir/expressions/TirNativeFunc.js +58 -22
- package/dist/compiler/tir/expressions/TirParentesizedExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirParentesizedExpr.js +6 -0
- package/dist/compiler/tir/expressions/TirPropAccessExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirPropAccessExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirTernaryExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTernaryExpr.js +16 -5
- package/dist/compiler/tir/expressions/TirToDataExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirToDataExpr.js +56 -25
- package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTraceIfFalseExpr.js +21 -4
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/TirTypeConversionExpr.js +9 -1
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.d.ts +6 -3
- package/dist/compiler/tir/expressions/TirVariableAccessExpr.js +22 -8
- package/dist/compiler/tir/expressions/ToIRTermCtx.d.ts +19 -20
- package/dist/compiler/tir/expressions/ToIRTermCtx.js +74 -50
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.d.ts +41 -0
- package/dist/compiler/tir/expressions/binary/TirBinaryExpr.js +180 -4
- package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.d.ts +4 -2
- package/dist/compiler/tir/expressions/litteral/TirLitArrExpr.js +8 -2
- package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.d.ts +17 -0
- package/dist/compiler/tir/expressions/litteral/TirLitFailExpr.js +21 -0
- package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitFalseExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitHexBytesExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitIntExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/litteral/TirLitNamedObjExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.d.ts +3 -1
- package/dist/compiler/tir/expressions/litteral/TirLitObjExpr.js +5 -0
- package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitStrExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitThisExpr.js +7 -3
- package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitTrueExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitUndefExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.d.ts +4 -1
- package/dist/compiler/tir/expressions/litteral/TirLitVoidExpr.js +4 -0
- package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.d.ts +2 -1
- package/dist/compiler/tir/expressions/litteral/TirLitteralExpr.js +3 -1
- package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryExclamation.js +8 -3
- package/dist/compiler/tir/expressions/unary/TirUnaryMinus.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryMinus.js +8 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryPlus.d.ts +3 -1
- package/dist/compiler/tir/expressions/unary/TirUnaryPlus.js +6 -0
- package/dist/compiler/tir/expressions/unary/TirUnaryTilde.d.ts +4 -2
- package/dist/compiler/tir/expressions/unary/TirUnaryTilde.js +8 -2
- package/dist/compiler/tir/program/TypedProgram.d.ts +3 -2
- package/dist/compiler/tir/program/TypedProgram.js +9 -0
- package/dist/compiler/tir/program/stdScope/stdScope.js +135 -149
- package/dist/compiler/tir/statements/TirAssertStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirAssertStmt.js +10 -0
- package/dist/compiler/tir/statements/TirAssignmentStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirAssignmentStmt.js +8 -0
- package/dist/compiler/tir/statements/TirBlockStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirBlockStmt.js +16 -0
- package/dist/compiler/tir/statements/TirBreakStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirBreakStmt.js +8 -0
- package/dist/compiler/tir/statements/TirContinueStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirContinueStmt.js +8 -0
- package/dist/compiler/tir/statements/TirFailStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirFailStmt.js +8 -0
- package/dist/compiler/tir/statements/TirForOfStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirForOfStmt.js +14 -0
- package/dist/compiler/tir/statements/TirForStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirForStmt.js +21 -0
- package/dist/compiler/tir/statements/TirIfStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirIfStmt.js +16 -0
- package/dist/compiler/tir/statements/TirMatchStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirMatchStmt.js +30 -0
- package/dist/compiler/tir/statements/TirReturnStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirReturnStmt.js +8 -0
- package/dist/compiler/tir/statements/TirStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.d.ts +2 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirArrayLikeDeconstr.js +30 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.d.ts +3 -1
- package/dist/compiler/tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js +28 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.d.ts +3 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSimpleVarDecl.js +13 -0
- package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.d.ts +3 -1
- package/dist/compiler/tir/statements/TirVarDecl/TirSingleDeconstructVarDecl.js +28 -0
- package/dist/compiler/tir/statements/TirWhileStmt.d.ts +2 -0
- package/dist/compiler/tir/statements/TirWhileStmt.js +14 -0
- package/dist/compiler/tir/types/utils/canAssignTo.js +1 -1
- package/dist/diagnostics/DiagnosticEmitter.js +1 -1
- package/dist/diagnostics/diagnosticMessages.generated.d.ts +10 -1
- package/dist/diagnostics/diagnosticMessages.generated.js +20 -2
- package/dist/parser/Parser.d.ts +8 -3
- package/dist/parser/Parser.js +180 -32
- package/dist/parser/Precedence.js +1 -0
- package/dist/tokenizer/Token.d.ts +81 -72
- package/dist/tokenizer/Token.js +82 -72
- package/dist/tokenizer/utils/tokenFromKeyword.js +32 -10
- package/dist/tokenizer/utils/tokenIsAlsoIdentifier.js +10 -0
- package/dist/utils/BitUtils/index.js +1 -1
- package/dist/utils/UPLCFlatUtils/index.js +1 -1
- package/dist/utils/array/keepSortedArrInplace.js +1 -0
- package/package.json +3 -1
- package/dist/IR/IRNodes/utils/isClosedAtDbn.d.ts +0 -2
- package/dist/IR/IRNodes/utils/isClosedAtDbn.js +0 -22
- package/dist/IR/toUPLC/_internal/_irToUplc.d.ts +0 -9
- package/dist/IR/toUPLC/_internal/_irToUplc.js +0 -156
- package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.d.ts +0 -9
- package/dist/IR/toUPLC/subRoutines/handleLetted/incrementUnboundDbns.js +0 -73
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.d.ts +0 -1
- package/dist/IR/toUPLC/subRoutines/inlineSingleUseApplications.js +0 -12
- package/dist/IR/toUPLC/subRoutines/performUplcOptimizationsAndReturnRoot/index.js +0 -227
- package/dist/IR/tree_utils/_ir_apps.d.ts +0 -3
- package/dist/IR/tree_utils/_ir_apps.js +0 -8
- package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.d.ts +0 -5
- package/dist/compiler/TirCompiler/internal/_compileHoistedDeps.js +0 -37
|
@@ -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,6 @@ export class TirPropAccessExpr {
|
|
|
24
32
|
}
|
|
25
33
|
get isConstant() { return false; }
|
|
26
34
|
toIR(ctx) {
|
|
27
|
-
throw new Error("property access cannot be translated to IR");
|
|
35
|
+
throw new Error("property access cannot be translated to IR (missed expressify). Expr: " + this.toString());
|
|
28
36
|
}
|
|
29
37
|
}
|
|
@@ -11,7 +11,9 @@ export declare class TirTernaryExpr implements ITirExpr {
|
|
|
11
11
|
readonly type: TirType;
|
|
12
12
|
readonly range: SourceRange;
|
|
13
13
|
constructor(condition: TirExpr, ifTrue: TirExpr, ifFalse: TirExpr, 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;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IRForced } from "../../../IR/IRNodes/IRForced.js";
|
|
3
|
-
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
4
|
-
import { _ir_apps } from "../../../IR/tree_utils/_ir_apps.js";
|
|
1
|
+
import { _ir_lazyIfThenElse } from "../../../IR/tree_utils/_ir_lazyIfThenElse.js";
|
|
5
2
|
import { mergeSortedStrArrInplace } from "../../../utils/array/mergeSortedStrArrInplace.js";
|
|
6
3
|
export class TirTernaryExpr {
|
|
7
4
|
condition;
|
|
@@ -16,6 +13,20 @@ export class TirTernaryExpr {
|
|
|
16
13
|
this.type = type;
|
|
17
14
|
this.range = range;
|
|
18
15
|
}
|
|
16
|
+
toString() {
|
|
17
|
+
return `(${this.condition.toString()} ? ${this.ifTrue.toString()} : ${this.ifFalse.toString()})`;
|
|
18
|
+
}
|
|
19
|
+
pretty(indent) {
|
|
20
|
+
const singleIndent = " ";
|
|
21
|
+
const indent_base = singleIndent.repeat(indent);
|
|
22
|
+
const indent_0 = "\n" + indent_base;
|
|
23
|
+
const indent_1 = indent_0 + singleIndent;
|
|
24
|
+
return (`(` +
|
|
25
|
+
`${this.condition.pretty(indent)} ?` +
|
|
26
|
+
`${indent_1}${this.ifTrue.pretty(indent + 1)} :` +
|
|
27
|
+
`${indent_1}${this.ifFalse.pretty(indent + 1)}` +
|
|
28
|
+
`)`);
|
|
29
|
+
}
|
|
19
30
|
clone() {
|
|
20
31
|
return new TirTernaryExpr(this.condition.clone(), this.ifTrue.clone(), this.ifFalse.clone(), this.type.clone(), this.range.clone());
|
|
21
32
|
}
|
|
@@ -31,6 +42,6 @@ export class TirTernaryExpr {
|
|
|
31
42
|
&& this.ifFalse.isConstant);
|
|
32
43
|
}
|
|
33
44
|
toIR(ctx) {
|
|
34
|
-
return
|
|
45
|
+
return _ir_lazyIfThenElse(this.condition.toIR(ctx), this.ifTrue.toIR(ctx), this.ifFalse.toIR(ctx));
|
|
35
46
|
}
|
|
36
47
|
}
|
|
@@ -15,7 +15,9 @@ export declare class TirToDataExpr implements ITirExpr {
|
|
|
15
15
|
expr: TirExpr;
|
|
16
16
|
readonly range: SourceRange;
|
|
17
17
|
constructor(expr: TirExpr, range: SourceRange);
|
|
18
|
-
|
|
18
|
+
toString(): string;
|
|
19
|
+
pretty(indent: number): string;
|
|
20
|
+
clone(): TirExpr;
|
|
19
21
|
get isConstant(): boolean;
|
|
20
22
|
get type(): TirDataT;
|
|
21
23
|
deps(): string[];
|
|
@@ -5,7 +5,6 @@ import { IRFunc } from "../../../IR/IRNodes/IRFunc.js";
|
|
|
5
5
|
import { IRHoisted } from "../../../IR/IRNodes/IRHoisted.js";
|
|
6
6
|
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
7
7
|
import { IRVar } from "../../../IR/IRNodes/IRVar.js";
|
|
8
|
-
import { _ir_apps } from "../../../IR/tree_utils/_ir_apps.js";
|
|
9
8
|
import { data_t } from "../program/stdScope/stdScope.js";
|
|
10
9
|
import { TirDataStructType, TirSoPStructType } from "../types/TirStructType.js";
|
|
11
10
|
import { isTirType } from "../types/TirType.js";
|
|
@@ -22,6 +21,8 @@ import { TirDataOptT } from "../types/TirNativeType/native/Optional/data.js";
|
|
|
22
21
|
import { TirSopOptT } from "../types/TirNativeType/native/Optional/sop.js";
|
|
23
22
|
import { TirStringT } from "../types/TirNativeType/native/string.js";
|
|
24
23
|
import { TirVoidT } from "../types/TirNativeType/native/void.js";
|
|
24
|
+
import { hoisted_constr1_empty } from "../../../IR/toUPLC/common_hoisted.js";
|
|
25
|
+
import { _ir_apps } from "../../../IR/IRNodes/IRApp.js";
|
|
25
26
|
export function isTirDataEncodedType(type) {
|
|
26
27
|
type = getUnaliased(type) ?? type;
|
|
27
28
|
return (type instanceof TirDataT
|
|
@@ -35,6 +36,14 @@ export class TirToDataExpr {
|
|
|
35
36
|
this.expr = expr;
|
|
36
37
|
this.range = range;
|
|
37
38
|
}
|
|
39
|
+
toString() {
|
|
40
|
+
return `toData( ${this.expr.toString()} )`;
|
|
41
|
+
}
|
|
42
|
+
pretty(indent) {
|
|
43
|
+
const singleIndent = " ";
|
|
44
|
+
const indent_base = singleIndent.repeat(indent);
|
|
45
|
+
return `toData(${this.expr.pretty(indent)})`;
|
|
46
|
+
}
|
|
38
47
|
clone() {
|
|
39
48
|
return new TirToDataExpr(this.expr.clone(), this.range.clone());
|
|
40
49
|
}
|
|
@@ -67,13 +76,14 @@ export function _inlineToData(origin_t, exprIR) {
|
|
|
67
76
|
const value_t = getOptTypeArg(from_t);
|
|
68
77
|
if (!isTirType(value_t))
|
|
69
78
|
throw new Error("TirToDataExpr: unreachable");
|
|
79
|
+
const valueName = Symbol("value");
|
|
70
80
|
return new IRCase(exprIR, [
|
|
71
81
|
// case Just{ value }
|
|
72
|
-
new IRFunc(
|
|
73
|
-
_ir_apps(IRNative.constrData, IRConst.int(0), _ir_apps(IRNative.mkCons, _inlineToData(value_t, new IRVar(
|
|
82
|
+
new IRFunc([valueName], // value
|
|
83
|
+
_ir_apps(IRNative.constrData, IRConst.int(0), _ir_apps(IRNative.mkCons, _inlineToData(value_t, new IRVar(valueName)), // value to data
|
|
74
84
|
IRConst.listOf(data_t)([])))),
|
|
75
85
|
// case Nothing
|
|
76
|
-
|
|
86
|
+
hoisted_constr1_empty.clone()
|
|
77
87
|
]);
|
|
78
88
|
}
|
|
79
89
|
if (from_t instanceof TirSoPStructType) {
|
|
@@ -107,25 +117,22 @@ export function _toDataUplcFunc(origin_t) {
|
|
|
107
117
|
|| elems_t instanceof TirDataOptT
|
|
108
118
|
|| elems_t instanceof TirDataT)
|
|
109
119
|
return IRNative.listData;
|
|
110
|
-
return
|
|
111
|
-
_ir_apps(IRNative.listData, _ir_apps(IRNative._mkMapList, IRConst.listOf(elems_t)([]), _toDataUplcFunc(elems_t), new IRVar(0) // list
|
|
112
|
-
))));
|
|
120
|
+
return mkMapListToData(elems_t);
|
|
113
121
|
}
|
|
114
122
|
if (from_t instanceof TirSopOptT
|
|
115
|
-
|| from_t instanceof TirSoPStructType)
|
|
116
|
-
return
|
|
117
|
-
_inlineToData(from_t, new IRVar(0) // sop
|
|
118
|
-
)));
|
|
119
|
-
}
|
|
123
|
+
|| from_t instanceof TirSoPStructType)
|
|
124
|
+
return mkSopToData(from_t);
|
|
120
125
|
throw new Error(`TirFromDataExpr: cannot convert from Data to type ${from_t.toString()}`);
|
|
121
126
|
}
|
|
122
|
-
const _mkUnitData = new IRHoisted(new IRFunc(
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
const _mkUnitData = new IRHoisted(new IRFunc([Symbol("unit")], IRConst.data(new DataConstr(0, []))));
|
|
128
|
+
const bool_var_name = Symbol("bool");
|
|
129
|
+
const _boolToData = new IRHoisted(new IRFunc([bool_var_name], // bool
|
|
130
|
+
_ir_apps(IRNative.strictIfThenElse, new IRVar(bool_var_name), // bool
|
|
131
|
+
new IRHoisted(IRConst.data(new DataConstr(0, []))), new IRHoisted(IRConst.data(new DataConstr(1, []))))));
|
|
132
|
+
const str_var_name = Symbol("str");
|
|
133
|
+
const _strToData = new IRHoisted(new IRFunc([str_var_name], // string
|
|
134
|
+
_ir_apps(IRNative.bData, _ir_apps(IRNative.encodeUtf8, new IRVar(str_var_name) // string
|
|
135
|
+
))));
|
|
129
136
|
export function _inlineSingleSopConstrToData(sop_t, exprIR) {
|
|
130
137
|
if (sop_t.constructors.length !== 1)
|
|
131
138
|
throw new Error("_inilneSingeSopConstrFromData: multiple constructors");
|
|
@@ -141,15 +148,16 @@ export function _inlineSingleSopConstrToData(sop_t, exprIR) {
|
|
|
141
148
|
new IRCase(exprIR, [IRNative._id])), IRConst.listOf(data_t)([])));
|
|
142
149
|
}
|
|
143
150
|
let lst = IRConst.listOf(data_t)([]);
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
const fieldsVarsNames = constr.fields.map(f => Symbol(f.name));
|
|
152
|
+
for (let i = constr.fields.length - 1; i >= 0; i--) {
|
|
153
|
+
const filedExpr = new IRVar(fieldsVarsNames[i]);
|
|
146
154
|
const field_t = getUnaliased(constr.fields[i].type);
|
|
147
155
|
if (!isTirType(field_t))
|
|
148
156
|
throw new Error("TirFromDataExpr: unreachable");
|
|
149
157
|
lst = _ir_apps(IRNative.mkCons, _inlineToData(field_t, filedExpr), lst);
|
|
150
158
|
}
|
|
151
159
|
return _ir_apps(IRNative.constrData, IRConst.int(0), new IRCase(exprIR, [
|
|
152
|
-
new IRFunc(
|
|
160
|
+
new IRFunc(fieldsVarsNames, lst)
|
|
153
161
|
]));
|
|
154
162
|
}
|
|
155
163
|
export function _inlineMultiSopConstrToData(sop_t, exprIR) {
|
|
@@ -159,14 +167,37 @@ export function _inlineMultiSopConstrToData(sop_t, exprIR) {
|
|
|
159
167
|
if (constr.fields.length === 0)
|
|
160
168
|
return new IRHoisted(IRConst.data(new DataConstr(constrIdx, [])));
|
|
161
169
|
let lst = IRConst.listOf(data_t)([]);
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
const fieldsVarsNames = constr.fields.map(f => Symbol(f.name));
|
|
171
|
+
for (let i = constr.fields.length - 1; i >= 0; i--) {
|
|
172
|
+
const filedExpr = new IRVar(fieldsVarsNames[i]);
|
|
164
173
|
const field_t = getUnaliased(constr.fields[i].type);
|
|
165
174
|
if (!isTirType(field_t))
|
|
166
175
|
throw new Error("TirFromDataExpr: unreachable");
|
|
167
176
|
lst = _ir_apps(IRNative.mkCons, _inlineToData(field_t, filedExpr), lst);
|
|
168
177
|
}
|
|
169
|
-
return new IRFunc(
|
|
178
|
+
return new IRFunc(fieldsVarsNames, _ir_apps(IRNative.constrData, IRConst.int(constrIdx), lst));
|
|
170
179
|
});
|
|
171
180
|
return new IRCase(exprIR, cases);
|
|
172
181
|
}
|
|
182
|
+
const _mapListToDataOfType = {};
|
|
183
|
+
function mkMapListToData(elems_t) {
|
|
184
|
+
const key = elems_t.toTirTypeKey();
|
|
185
|
+
if (_mapListToDataOfType[key])
|
|
186
|
+
return _mapListToDataOfType[key].clone();
|
|
187
|
+
const hoisted_mapListToData_lst = Symbol("hoisted_mapListToData_lst");
|
|
188
|
+
_mapListToDataOfType[key] = new IRHoisted(new IRFunc([hoisted_mapListToData_lst], // list
|
|
189
|
+
_ir_apps(IRNative.listData, _ir_apps(IRNative._mkMapList, IRConst.listOf(elems_t)([]), _toDataUplcFunc(elems_t), new IRVar(hoisted_mapListToData_lst) // list
|
|
190
|
+
))));
|
|
191
|
+
return _mapListToDataOfType[key].clone();
|
|
192
|
+
}
|
|
193
|
+
const _sopToDataOfType = {};
|
|
194
|
+
function mkSopToData(from_t) {
|
|
195
|
+
const key = from_t.toTirTypeKey();
|
|
196
|
+
if (_sopToDataOfType[key])
|
|
197
|
+
return _sopToDataOfType[key].clone();
|
|
198
|
+
const sop_var = Symbol("sop");
|
|
199
|
+
_sopToDataOfType[key] = new IRHoisted(new IRFunc([sop_var], // sop
|
|
200
|
+
_inlineToData(from_t, new IRVar(sop_var) // sop
|
|
201
|
+
)));
|
|
202
|
+
return _sopToDataOfType[key].clone();
|
|
203
|
+
}
|
|
@@ -16,7 +16,9 @@ export declare class TirTraceIfFalseExpr implements ITirExpr {
|
|
|
16
16
|
condition: TirExpr,
|
|
17
17
|
/** must be string */
|
|
18
18
|
traceStrExpr: TirExpr, range: SourceRange);
|
|
19
|
-
|
|
19
|
+
toString(): string;
|
|
20
|
+
pretty(indent: number): string;
|
|
21
|
+
clone(): TirExpr;
|
|
20
22
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
21
23
|
get isConstant(): boolean;
|
|
22
24
|
deps(): string[];
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { mergeSortedStrArrInplace } from "../../../utils/array/mergeSortedStrArrInplace.js";
|
|
2
2
|
import { bool_t } from "../program/stdScope/stdScope.js";
|
|
3
3
|
import { IRConst } from "../../../IR/IRNodes/IRConst.js";
|
|
4
|
-
import { IRDelayed } from "../../../IR/IRNodes/IRDelayed.js";
|
|
5
|
-
import { IRForced } from "../../../IR/IRNodes/IRForced.js";
|
|
6
4
|
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
7
|
-
import { _ir_apps } from "../../../IR/
|
|
5
|
+
import { _ir_apps } from "../../../IR/IRNodes/IRApp.js";
|
|
6
|
+
import { _ir_lazyIfThenElse } from "../../../IR/tree_utils/_ir_lazyIfThenElse.js";
|
|
8
7
|
export class TirTraceIfFalseExpr {
|
|
9
8
|
condition;
|
|
10
9
|
traceStrExpr;
|
|
@@ -19,11 +18,29 @@ export class TirTraceIfFalseExpr {
|
|
|
19
18
|
this.traceStrExpr = traceStrExpr;
|
|
20
19
|
this.range = range;
|
|
21
20
|
}
|
|
21
|
+
toString() {
|
|
22
|
+
return `traceIfFalse( ${this.condition.toString()}, ${this.traceStrExpr.toString()} )`;
|
|
23
|
+
}
|
|
24
|
+
pretty(indent) {
|
|
25
|
+
const singleIndent = " ";
|
|
26
|
+
const indent_base = singleIndent.repeat(indent);
|
|
27
|
+
const indent_1 = indent_base + singleIndent;
|
|
28
|
+
return (`traceIfFalse(` +
|
|
29
|
+
`\n${indent_1}${this.condition.pretty(indent + 1)},` +
|
|
30
|
+
`\n${indent_1}${this.traceStrExpr.pretty(indent + 1)}` +
|
|
31
|
+
`\n${indent_base})`);
|
|
32
|
+
}
|
|
22
33
|
clone() {
|
|
23
34
|
return new TirTraceIfFalseExpr(this.condition.clone(), this.traceStrExpr.clone(), this.range.clone());
|
|
24
35
|
}
|
|
25
36
|
toIR(ctx) {
|
|
26
|
-
return
|
|
37
|
+
return _ir_lazyIfThenElse(
|
|
38
|
+
// condition
|
|
39
|
+
this.condition.toIR(ctx),
|
|
40
|
+
// then
|
|
41
|
+
IRConst.bool(true),
|
|
42
|
+
// else
|
|
43
|
+
_ir_apps(IRNative.trace, this.traceStrExpr.toIR(ctx), IRConst.bool(false)));
|
|
27
44
|
}
|
|
28
45
|
get isConstant() { return this.condition.isConstant && this.traceStrExpr.isConstant; }
|
|
29
46
|
deps() {
|
|
@@ -9,8 +9,10 @@ export declare class TirTypeConversionExpr implements ITirExpr {
|
|
|
9
9
|
readonly type: TirType;
|
|
10
10
|
readonly range: SourceRange;
|
|
11
11
|
constructor(expr: TirExpr, type: TirType, range: SourceRange);
|
|
12
|
+
toString(): string;
|
|
13
|
+
pretty(indent: number): string;
|
|
12
14
|
deps(): string[];
|
|
13
15
|
get isConstant(): boolean;
|
|
14
|
-
clone():
|
|
16
|
+
clone(): TirExpr;
|
|
15
17
|
toIR(ctx: ToIRTermCtx): IRTerm;
|
|
16
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { _ir_apps } from "../../../IR/IRNodes/IRApp.js";
|
|
1
2
|
import { IRNative } from "../../../IR/IRNodes/IRNative/index.js";
|
|
2
|
-
import { _ir_apps } from "../../../IR/tree_utils/_ir_apps.js";
|
|
3
3
|
import { TirBoolT } from "../types/TirNativeType/native/bool.js";
|
|
4
4
|
import { TirBytesT } from "../types/TirNativeType/native/bytes.js";
|
|
5
5
|
import { TirDataT } from "../types/TirNativeType/native/data.js";
|
|
@@ -18,6 +18,14 @@ export class TirTypeConversionExpr {
|
|
|
18
18
|
this.type = type;
|
|
19
19
|
this.range = range;
|
|
20
20
|
}
|
|
21
|
+
toString() {
|
|
22
|
+
return `(${this.expr.toString()} as ${this.type.toString()})`;
|
|
23
|
+
}
|
|
24
|
+
pretty(indent) {
|
|
25
|
+
const singleIndent = " ";
|
|
26
|
+
const indent_base = singleIndent.repeat(indent);
|
|
27
|
+
return (`(${this.expr.pretty(indent)} as ${this.type.toString()})`);
|
|
28
|
+
}
|
|
21
29
|
deps() {
|
|
22
30
|
return this.expr.deps();
|
|
23
31
|
}
|
|
@@ -3,14 +3,17 @@ import { IRSelfCall } from "../../../IR/IRNodes/IRSelfCall.js";
|
|
|
3
3
|
import { IRVar } from "../../../IR/IRNodes/IRVar.js";
|
|
4
4
|
import { ResolveValueResult } from "../../AstCompiler/scope/AstScope.js";
|
|
5
5
|
import { TirType } from "../types/TirType.js";
|
|
6
|
-
import { ITirExpr } from "./ITirExpr.js";
|
|
6
|
+
import type { ITirExpr } from "./ITirExpr.js";
|
|
7
|
+
import type { TirExpr } from "./TirExpr.js";
|
|
7
8
|
import { ToIRTermCtx } from "./ToIRTermCtx.js";
|
|
8
9
|
export declare class TirVariableAccessExpr implements ITirExpr {
|
|
9
|
-
readonly resolvedValue: ResolveValueResult;
|
|
10
10
|
readonly range: SourceRange;
|
|
11
|
+
readonly resolvedValue: Readonly<ResolveValueResult>;
|
|
11
12
|
get type(): TirType;
|
|
12
13
|
constructor(resolvedValue: ResolveValueResult, range: SourceRange);
|
|
13
|
-
|
|
14
|
+
toString(): string;
|
|
15
|
+
pretty(indent: number): string;
|
|
16
|
+
clone(): TirExpr;
|
|
14
17
|
get isConstant(): boolean;
|
|
15
18
|
get varName(): string;
|
|
16
19
|
deps(): string[];
|
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
import { IRSelfCall } from "../../../IR/IRNodes/IRSelfCall.js";
|
|
2
2
|
import { IRVar } from "../../../IR/IRNodes/IRVar.js";
|
|
3
3
|
export class TirVariableAccessExpr {
|
|
4
|
-
resolvedValue;
|
|
5
4
|
range;
|
|
5
|
+
resolvedValue;
|
|
6
6
|
get type() {
|
|
7
7
|
return this.resolvedValue.variableInfos.type;
|
|
8
8
|
}
|
|
9
9
|
constructor(resolvedValue, range) {
|
|
10
|
-
this.resolvedValue = resolvedValue;
|
|
11
10
|
this.range = range;
|
|
11
|
+
this.resolvedValue = Object.freeze(resolvedValue);
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return this.varName;
|
|
15
|
+
}
|
|
16
|
+
pretty(indent) {
|
|
17
|
+
const singleIndent = " ";
|
|
18
|
+
const indent_base = singleIndent.repeat(indent);
|
|
19
|
+
return `${this.varName}`;
|
|
12
20
|
}
|
|
13
21
|
clone() {
|
|
14
|
-
return new TirVariableAccessExpr(
|
|
22
|
+
return new TirVariableAccessExpr({
|
|
23
|
+
...this.resolvedValue,
|
|
24
|
+
variableInfos: {
|
|
25
|
+
...this.resolvedValue.variableInfos,
|
|
26
|
+
type: this.resolvedValue.variableInfos.type.clone()
|
|
27
|
+
},
|
|
28
|
+
// isDefinedOutsideFuncScope: this.resolvedValue.isDefinedOutsideFuncScope
|
|
29
|
+
}, this.range.clone());
|
|
15
30
|
}
|
|
16
31
|
get isConstant() { return false; }
|
|
17
32
|
get varName() {
|
|
18
33
|
return this.resolvedValue.variableInfos.name;
|
|
19
34
|
}
|
|
20
|
-
deps() {
|
|
21
|
-
return [this.varName];
|
|
22
|
-
}
|
|
35
|
+
deps() { return [this.varName]; }
|
|
23
36
|
toIR(ctx) {
|
|
24
37
|
const ir = ctx.getVarAccessIR(this.varName);
|
|
25
38
|
if (!(ir instanceof IRVar
|
|
26
|
-
|| ir instanceof IRSelfCall))
|
|
27
|
-
throw new Error(
|
|
39
|
+
|| ir instanceof IRSelfCall)) {
|
|
40
|
+
throw new Error(`variable '${this.varName}' is missing in [${ctx.allVariables().join(", ")}]`);
|
|
41
|
+
}
|
|
28
42
|
return ir;
|
|
29
43
|
}
|
|
30
44
|
}
|
|
@@ -2,28 +2,27 @@ import { IRVar } from "../../../IR/IRNodes/IRVar.js";
|
|
|
2
2
|
import { IRSelfCall } from "../../../IR/IRNodes/IRSelfCall.js";
|
|
3
3
|
export declare class ToIRTermCtx {
|
|
4
4
|
readonly parent: ToIRTermCtx | undefined;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* used to resolve the variables in 0(1) time
|
|
8
|
-
*/
|
|
9
|
-
private readonly variableToCtx;
|
|
10
|
-
private readonly variables;
|
|
11
|
-
private readonly _parentDbn;
|
|
12
|
-
get dbn(): bigint;
|
|
5
|
+
readonly _creationStack?: string | undefined;
|
|
6
|
+
private readonly localVars;
|
|
13
7
|
private _firstVariableIsRecursive;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
variableToCtx: Map<string, ToIRTermCtx>);
|
|
8
|
+
_children: ToIRTermCtx[];
|
|
9
|
+
constructor(parent: ToIRTermCtx | undefined);
|
|
10
|
+
localVariables(): string[];
|
|
11
|
+
allVariables(): string[];
|
|
20
12
|
static root(): ToIRTermCtx;
|
|
21
13
|
newChild(): ToIRTermCtx;
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
getVarAccessDbn(name: string): bigint | undefined;
|
|
14
|
+
private localVarSym;
|
|
15
|
+
getVarAccessSym(name: string): symbol | undefined;
|
|
25
16
|
getVarAccessIR(name: string): IRVar | IRSelfCall | undefined;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @returns the symbol of the defined variable (for eventual `new IRFunc( ... )`)
|
|
19
|
+
**/
|
|
20
|
+
defineVar(varName: string | symbol): symbol;
|
|
21
|
+
/**
|
|
22
|
+
* @returns the symbol of the defined recursive variable (for eventual `new IRRecursive( ... )`)
|
|
23
|
+
**/
|
|
24
|
+
defineRecursiveVar(name: string): symbol;
|
|
25
|
+
private _parentDbn;
|
|
26
|
+
get dbn(): number;
|
|
27
|
+
pushUnusedVar(postfix?: string): symbol;
|
|
29
28
|
}
|
|
@@ -3,75 +3,99 @@ import { IRSelfCall } from "../../../IR/IRNodes/IRSelfCall.js";
|
|
|
3
3
|
const _1n = BigInt(1);
|
|
4
4
|
export class ToIRTermCtx {
|
|
5
5
|
parent;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
_parentDbn;
|
|
9
|
-
get dbn() {
|
|
10
|
-
return this._parentDbn + BigInt(this.variables.length);
|
|
11
|
-
}
|
|
6
|
+
_creationStack;
|
|
7
|
+
localVars = new Map();
|
|
12
8
|
_firstVariableIsRecursive = false;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* quick access from a variable name to its context
|
|
16
|
-
* used to resolve the variables in 0(1) time
|
|
17
|
-
*/
|
|
18
|
-
variableToCtx) {
|
|
9
|
+
_children = [];
|
|
10
|
+
constructor(parent) {
|
|
19
11
|
this.parent = parent;
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
12
|
+
this.parent?._children.push(this);
|
|
13
|
+
this._creationStack = new Error().stack;
|
|
14
|
+
this.localVars = new Map();
|
|
15
|
+
// DO NOT SET _parentDbn HERE
|
|
16
|
+
// it must be a getter to reflect changes in parent
|
|
17
|
+
// (parent dbn can change)
|
|
22
18
|
this._firstVariableIsRecursive = false;
|
|
23
19
|
}
|
|
20
|
+
localVariables() {
|
|
21
|
+
return [...this.localVars.keys()];
|
|
22
|
+
}
|
|
23
|
+
allVariables() {
|
|
24
|
+
return ((this.parent?.allVariables() ?? [])
|
|
25
|
+
.concat([...this.localVariables()]));
|
|
26
|
+
}
|
|
24
27
|
static root() {
|
|
25
|
-
return new ToIRTermCtx(undefined
|
|
28
|
+
return new ToIRTermCtx(undefined);
|
|
26
29
|
}
|
|
27
30
|
newChild() {
|
|
28
|
-
return new ToIRTermCtx(this
|
|
31
|
+
return new ToIRTermCtx(this);
|
|
29
32
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (idx < 0)
|
|
33
|
-
return undefined;
|
|
34
|
-
return this._parentDbn + BigInt(idx);
|
|
33
|
+
localVarSym(name) {
|
|
34
|
+
return this.localVars.get(name);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return undefined;
|
|
40
|
-
return ctx.localVarDbn(name);
|
|
41
|
-
}
|
|
42
|
-
getVarAccessDbn(name) {
|
|
43
|
-
const declDbn = this.getVarDeclDbn(name);
|
|
44
|
-
if (typeof declDbn !== "bigint")
|
|
45
|
-
return undefined;
|
|
46
|
-
return this.dbn - (declDbn + _1n);
|
|
36
|
+
getVarAccessSym(name) {
|
|
37
|
+
return (this.localVarSym(name)
|
|
38
|
+
?? this.parent?.getVarAccessSym(name));
|
|
47
39
|
}
|
|
48
40
|
getVarAccessIR(name) {
|
|
49
|
-
const
|
|
50
|
-
if (typeof
|
|
41
|
+
const accessSym = this.getVarAccessSym(name);
|
|
42
|
+
if (typeof accessSym !== "symbol")
|
|
51
43
|
return undefined;
|
|
52
|
-
if (
|
|
53
|
-
&& this.
|
|
54
|
-
return new IRSelfCall(
|
|
55
|
-
return new IRVar(
|
|
44
|
+
if (this._firstVariableIsRecursive
|
|
45
|
+
&& name === this.localVars.keys().next().value)
|
|
46
|
+
return new IRSelfCall(accessSym);
|
|
47
|
+
return new IRVar(accessSym);
|
|
56
48
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @returns the symbol of the defined variable (for eventual `new IRFunc( ... )`)
|
|
51
|
+
**/
|
|
52
|
+
defineVar(varName) {
|
|
53
|
+
const name = typeof varName === "string" ? varName : varName.description;
|
|
54
|
+
// allow shadowing
|
|
55
|
+
// const exsistingCtx = this.variableToCtx.get( name );
|
|
56
|
+
// if(
|
|
57
|
+
// exsistingCtx
|
|
58
|
+
// && exsistingCtx.localVarSym( name ) !== undefined
|
|
59
|
+
// ) throw new Error(`variable '${name}' already defined in the current scope`);
|
|
60
|
+
if (this.localVars.has(name)) {
|
|
61
|
+
throw new Error(`variable '${name}' already defined in the current scope`);
|
|
63
62
|
}
|
|
64
|
-
|
|
65
|
-
this.
|
|
63
|
+
const sym = typeof varName === "string" ? Symbol(name) : varName;
|
|
64
|
+
this.localVars.set(name, sym);
|
|
65
|
+
// this.variableToCtx.set( name, this );
|
|
66
|
+
return sym;
|
|
66
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* @returns the symbol of the defined recursive variable (for eventual `new IRRecursive( ... )`)
|
|
70
|
+
**/
|
|
67
71
|
defineRecursiveVar(name) {
|
|
68
|
-
if (this.
|
|
72
|
+
if (this.localVars.size > 0
|
|
69
73
|
|| this._firstVariableIsRecursive)
|
|
70
74
|
throw new Error("recursive variable must be the first defined variable in the context");
|
|
71
|
-
this.defineVar(name);
|
|
72
75
|
this._firstVariableIsRecursive = true;
|
|
76
|
+
return this.defineVar(name);
|
|
77
|
+
}
|
|
78
|
+
_parentDbn = undefined;
|
|
79
|
+
get dbn() {
|
|
80
|
+
if (typeof this._parentDbn !== "number")
|
|
81
|
+
this._parentDbn = this.parent instanceof ToIRTermCtx ? this.parent.dbn : 0;
|
|
82
|
+
return this.localVars.size + this._parentDbn;
|
|
73
83
|
}
|
|
74
|
-
pushUnusedVar() {
|
|
75
|
-
this.variables.push("");
|
|
84
|
+
pushUnusedVar(postfix) {
|
|
85
|
+
// this.variables.push( "" );
|
|
86
|
+
// just to increment dbn
|
|
87
|
+
// we need a new unique name in the `variables` map
|
|
88
|
+
// (if we just use empty string, or the same string, it will overwrite the previous "unused" entry)
|
|
89
|
+
//
|
|
90
|
+
// we start with the number so we know it is not a valid variable name
|
|
91
|
+
// but we add "_unused" so the key is not an integer (which would be sorted first in Object.keys)
|
|
92
|
+
const prefix = this.dbn.toString();
|
|
93
|
+
if (!(typeof postfix === "string"
|
|
94
|
+
&& postfix.length > 0))
|
|
95
|
+
postfix = "unused";
|
|
96
|
+
const name = prefix + "_" + postfix;
|
|
97
|
+
const sym = Symbol(name);
|
|
98
|
+
this.localVars.set(name, sym);
|
|
99
|
+
return sym;
|
|
76
100
|
}
|
|
77
101
|
}
|