@elaraai/east 0.0.1-beta.9 → 1.0.0
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/LICENSE.md +15 -666
- package/README.md +113 -88
- package/dist/src/analyze.d.ts +3 -0
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +223 -111
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/analyze.spec.d.ts +2 -0
- package/dist/src/analyze.spec.d.ts.map +1 -0
- package/dist/src/analyze.spec.js +445 -0
- package/dist/src/analyze.spec.js.map +1 -0
- package/dist/src/ast.d.ts +54 -35
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast_to_ir.coerce_to.spec.d.ts +15 -0
- package/dist/src/ast_to_ir.coerce_to.spec.d.ts.map +1 -0
- package/dist/src/ast_to_ir.coerce_to.spec.js +420 -0
- package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -0
- package/dist/src/ast_to_ir.d.ts +18 -4
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +233 -178
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +194 -2
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/comparison.d.ts +2 -2
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +115 -40
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/comparison.spec.d.ts +2 -0
- package/dist/src/comparison.spec.d.ts.map +1 -0
- package/dist/src/comparison.spec.js +1200 -0
- package/dist/src/comparison.spec.js.map +1 -0
- package/dist/src/compile.d.ts +31 -9
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1048 -548
- package/dist/src/compile.js.map +1 -1
- package/dist/src/containers/matrix.d.ts +15 -0
- package/dist/src/containers/matrix.d.ts.map +1 -0
- package/dist/src/containers/matrix.js +15 -0
- package/dist/src/containers/matrix.js.map +1 -0
- package/dist/src/containers/ref.d.ts.map +1 -1
- package/dist/src/containers/ref.js +1 -1
- package/dist/src/containers/ref.js.map +1 -1
- package/dist/src/containers/sortedmap.spec.d.ts +2 -0
- package/dist/src/containers/sortedmap.spec.d.ts.map +1 -0
- package/dist/src/containers/sortedmap.spec.js +180 -0
- package/dist/src/containers/sortedmap.spec.js.map +1 -0
- package/dist/src/containers/sortedset.spec.d.ts +2 -0
- package/dist/src/containers/sortedset.spec.d.ts.map +1 -0
- package/dist/src/containers/sortedset.spec.js +228 -0
- package/dist/src/containers/sortedset.spec.js.map +1 -0
- package/dist/src/containers/variant.d.ts.map +1 -1
- package/dist/src/containers/variant.js +1 -1
- package/dist/src/containers/variant.js.map +1 -1
- package/dist/src/containers/variant.spec.d.ts +2 -0
- package/dist/src/containers/variant.spec.d.ts.map +1 -0
- package/dist/src/containers/variant.spec.js +217 -0
- package/dist/src/containers/variant.spec.js.map +1 -0
- package/dist/src/datetime_format/parse.spec.d.ts +6 -0
- package/dist/src/datetime_format/parse.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/parse.spec.js +379 -0
- package/dist/src/datetime_format/parse.spec.js.map +1 -0
- package/dist/src/datetime_format/print.spec.d.ts +6 -0
- package/dist/src/datetime_format/print.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/print.spec.js +257 -0
- package/dist/src/datetime_format/print.spec.js.map +1 -0
- package/dist/src/datetime_format/tokenize.spec.d.ts +2 -0
- package/dist/src/datetime_format/tokenize.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/tokenize.spec.js +508 -0
- package/dist/src/datetime_format/tokenize.spec.js.map +1 -0
- package/dist/src/datetime_format/types.d.ts +23 -23
- package/dist/src/default.d.ts.map +1 -1
- package/dist/src/default.js +33 -0
- package/dist/src/default.js.map +1 -1
- package/dist/src/default.spec.d.ts +2 -0
- package/dist/src/default.spec.d.ts.map +1 -0
- package/dist/src/default.spec.js +178 -0
- package/dist/src/default.spec.js.map +1 -0
- package/dist/src/eastir.d.ts +7 -0
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +55 -7
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/error.d.ts +14 -4
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +28 -3
- package/dist/src/error.js.map +1 -1
- package/dist/src/example.d.ts +87 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +18 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/expr/array.d.ts +43 -1
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +103 -53
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/ast.d.ts +1 -1
- package/dist/src/expr/ast.d.ts.map +1 -1
- package/dist/src/expr/ast.js +112 -54
- package/dist/src/expr/ast.js.map +1 -1
- package/dist/src/expr/asyncfunction.d.ts.map +1 -1
- package/dist/src/expr/asyncfunction.js +6 -4
- package/dist/src/expr/asyncfunction.js.map +1 -1
- package/dist/src/expr/blob.d.ts +48 -0
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +63 -8
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +213 -12
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +796 -293
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/boolean.d.ts +44 -0
- package/dist/src/expr/boolean.d.ts.map +1 -1
- package/dist/src/expr/boolean.js +58 -6
- package/dist/src/expr/boolean.js.map +1 -1
- package/dist/src/expr/datetime.d.ts +135 -0
- package/dist/src/expr/datetime.d.ts.map +1 -1
- package/dist/src/expr/datetime.js +184 -34
- package/dist/src/expr/datetime.js.map +1 -1
- package/dist/src/expr/dict.d.ts +47 -2
- package/dist/src/expr/dict.d.ts.map +1 -1
- package/dist/src/expr/dict.js +122 -61
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/expr.d.ts +3 -1
- package/dist/src/expr/expr.d.ts.map +1 -1
- package/dist/src/expr/expr.js +4 -3
- package/dist/src/expr/expr.js.map +1 -1
- package/dist/src/expr/float.d.ts +153 -0
- package/dist/src/expr/float.d.ts.map +1 -1
- package/dist/src/expr/float.js +191 -17
- package/dist/src/expr/float.js.map +1 -1
- package/dist/src/expr/function.d.ts +7 -2
- package/dist/src/expr/function.d.ts.map +1 -1
- package/dist/src/expr/function.js +6 -4
- package/dist/src/expr/function.js.map +1 -1
- package/dist/src/expr/index.d.ts +186 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +183 -2
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/integer.d.ts +180 -0
- package/dist/src/expr/integer.d.ts.map +1 -1
- package/dist/src/expr/integer.js +189 -18
- package/dist/src/expr/integer.js.map +1 -1
- package/dist/src/expr/libs/array.js +3 -3
- package/dist/src/expr/libs/array.js.map +1 -1
- package/dist/src/expr/libs/blob.js +3 -3
- package/dist/src/expr/libs/blob.js.map +1 -1
- package/dist/src/expr/libs/dict.js +1 -1
- package/dist/src/expr/libs/dict.js.map +1 -1
- package/dist/src/expr/libs/matrix.d.ts +17 -0
- package/dist/src/expr/libs/matrix.d.ts.map +1 -0
- package/dist/src/expr/libs/matrix.js +60 -0
- package/dist/src/expr/libs/matrix.js.map +1 -0
- package/dist/src/expr/libs/set.js +1 -1
- package/dist/src/expr/libs/set.js.map +1 -1
- package/dist/src/expr/libs/string.d.ts.map +1 -1
- package/dist/src/expr/libs/string.js +2 -1
- package/dist/src/expr/libs/string.js.map +1 -1
- package/dist/src/expr/libs/vector.d.ts +16 -0
- package/dist/src/expr/libs/vector.d.ts.map +1 -0
- package/dist/src/expr/libs/vector.js +44 -0
- package/dist/src/expr/libs/vector.js.map +1 -0
- package/dist/src/expr/matrix.d.ts +109 -0
- package/dist/src/expr/matrix.d.ts.map +1 -0
- package/dist/src/expr/matrix.js +224 -0
- package/dist/src/expr/matrix.js.map +1 -0
- package/dist/src/expr/recursive.d.ts +83 -0
- package/dist/src/expr/recursive.d.ts.map +1 -0
- package/dist/src/expr/recursive.js +99 -0
- package/dist/src/expr/recursive.js.map +1 -0
- package/dist/src/expr/ref.js +5 -5
- package/dist/src/expr/ref.js.map +1 -1
- package/dist/src/expr/set.d.ts +44 -2
- package/dist/src/expr/set.d.ts.map +1 -1
- package/dist/src/expr/set.js +102 -52
- package/dist/src/expr/set.js.map +1 -1
- package/dist/src/expr/string.d.ts +134 -0
- package/dist/src/expr/string.d.ts.map +1 -1
- package/dist/src/expr/string.js +173 -23
- package/dist/src/expr/string.js.map +1 -1
- package/dist/src/expr/struct.d.ts +1 -1
- package/dist/src/expr/struct.d.ts.map +1 -1
- package/dist/src/expr/struct.js +2 -2
- package/dist/src/expr/struct.js.map +1 -1
- package/dist/src/expr/types.d.ts +12 -9
- package/dist/src/expr/types.d.ts.map +1 -1
- package/dist/src/expr/variant.d.ts +108 -11
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +76 -38
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/expr/vector.d.ts +102 -0
- package/dist/src/expr/vector.d.ts.map +1 -0
- package/dist/src/expr/vector.js +202 -0
- package/dist/src/expr/vector.js.map +1 -0
- package/dist/src/fuzz.d.ts +36 -2
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +409 -77
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +12 -2
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +13 -2
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir.d.ts +1754 -1484
- package/dist/src/ir.d.ts.map +1 -1
- package/dist/src/ir.js +51 -34
- package/dist/src/ir.js.map +1 -1
- package/dist/src/ir.spec.d.ts +2 -0
- package/dist/src/ir.spec.d.ts.map +1 -0
- package/dist/src/ir.spec.js +35 -0
- package/dist/src/ir.spec.js.map +1 -0
- package/dist/src/location.d.ts +56 -17
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +226 -29
- package/dist/src/location.js.map +1 -1
- package/dist/src/location.spec.d.ts +2 -0
- package/dist/src/location.spec.d.ts.map +1 -0
- package/dist/src/location.spec.js +102 -0
- package/dist/src/location.spec.js.map +1 -0
- package/dist/src/patch/apply.d.ts +15 -0
- package/dist/src/patch/apply.d.ts.map +1 -0
- package/dist/src/patch/apply.js +352 -0
- package/dist/src/patch/apply.js.map +1 -0
- package/dist/src/patch/compose.d.ts +15 -0
- package/dist/src/patch/compose.d.ts.map +1 -0
- package/dist/src/patch/compose.js +448 -0
- package/dist/src/patch/compose.js.map +1 -0
- package/dist/src/patch/diff.d.ts +15 -0
- package/dist/src/patch/diff.d.ts.map +1 -0
- package/dist/src/patch/diff.js +347 -0
- package/dist/src/patch/diff.js.map +1 -0
- package/dist/src/patch/fuzz.d.ts +73 -0
- package/dist/src/patch/fuzz.d.ts.map +1 -0
- package/dist/src/patch/fuzz.js +159 -0
- package/dist/src/patch/fuzz.js.map +1 -0
- package/dist/src/patch/index.d.ts +32 -0
- package/dist/src/patch/index.d.ts.map +1 -0
- package/dist/src/patch/index.js +48 -0
- package/dist/src/patch/index.js.map +1 -0
- package/dist/src/patch/invert.d.ts +15 -0
- package/dist/src/patch/invert.d.ts.map +1 -0
- package/dist/src/patch/invert.js +284 -0
- package/dist/src/patch/invert.js.map +1 -0
- package/dist/src/patch/merge.d.ts +56 -0
- package/dist/src/patch/merge.d.ts.map +1 -0
- package/dist/src/patch/merge.js +586 -0
- package/dist/src/patch/merge.js.map +1 -0
- package/dist/src/patch/merge.spec.d.ts +2 -0
- package/dist/src/patch/merge.spec.d.ts.map +1 -0
- package/dist/src/patch/merge.spec.js +1139 -0
- package/dist/src/patch/merge.spec.js.map +1 -0
- package/dist/src/patch/patch.spec.d.ts +2 -0
- package/dist/src/patch/patch.spec.d.ts.map +1 -0
- package/dist/src/patch/patch.spec.js +452 -0
- package/dist/src/patch/patch.spec.js.map +1 -0
- package/dist/src/patch/path.d.ts +115 -0
- package/dist/src/patch/path.d.ts.map +1 -0
- package/dist/src/patch/path.js +192 -0
- package/dist/src/patch/path.js.map +1 -0
- package/dist/src/patch/path.spec.d.ts +6 -0
- package/dist/src/patch/path.spec.d.ts.map +1 -0
- package/dist/src/patch/path.spec.js +322 -0
- package/dist/src/patch/path.spec.js.map +1 -0
- package/dist/src/patch/prune.d.ts +77 -0
- package/dist/src/patch/prune.d.ts.map +1 -0
- package/dist/src/patch/prune.js +115 -0
- package/dist/src/patch/prune.js.map +1 -0
- package/dist/src/patch/prune.spec.d.ts +6 -0
- package/dist/src/patch/prune.spec.d.ts.map +1 -0
- package/dist/src/patch/prune.spec.js +473 -0
- package/dist/src/patch/prune.spec.js.map +1 -0
- package/dist/src/patch/type_of_patch.d.ts +25 -0
- package/dist/src/patch/type_of_patch.d.ts.map +1 -0
- package/dist/src/patch/type_of_patch.js +144 -0
- package/dist/src/patch/type_of_patch.js.map +1 -0
- package/dist/src/patch/types.d.ts +220 -0
- package/dist/src/patch/types.d.ts.map +1 -0
- package/dist/src/patch/types.js +62 -0
- package/dist/src/patch/types.js.map +1 -0
- package/dist/src/patch/validate.d.ts +44 -0
- package/dist/src/patch/validate.d.ts.map +1 -0
- package/dist/src/patch/validate.js +190 -0
- package/dist/src/patch/validate.js.map +1 -0
- package/dist/src/patch/validate.spec.d.ts +6 -0
- package/dist/src/patch/validate.spec.d.ts.map +1 -0
- package/dist/src/patch/validate.spec.js +225 -0
- package/dist/src/patch/validate.spec.js.map +1 -0
- package/dist/src/patch/walk.d.ts +121 -0
- package/dist/src/patch/walk.d.ts.map +1 -0
- package/dist/src/patch/walk.js +385 -0
- package/dist/src/patch/walk.js.map +1 -0
- package/dist/src/patch/walk.spec.d.ts +6 -0
- package/dist/src/patch/walk.spec.d.ts.map +1 -0
- package/dist/src/patch/walk.spec.js +621 -0
- package/dist/src/patch/walk.spec.js.map +1 -0
- package/dist/src/platform.d.ts +6 -0
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.spec.d.ts +2 -0
- package/dist/src/platform.spec.d.ts.map +1 -0
- package/dist/src/platform.spec.js +330 -0
- package/dist/src/platform.spec.js.map +1 -0
- package/dist/src/serialization/beast.d.ts.map +1 -1
- package/dist/src/serialization/beast.js +12 -0
- package/dist/src/serialization/beast.js.map +1 -1
- package/dist/src/serialization/beast.spec.d.ts +6 -0
- package/dist/src/serialization/beast.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast.spec.js +406 -0
- package/dist/src/serialization/beast.spec.js.map +1 -0
- package/dist/src/serialization/beast2/index.d.ts +50 -0
- package/dist/src/serialization/beast2/index.d.ts.map +1 -0
- package/dist/src/serialization/beast2/index.js +756 -0
- package/dist/src/serialization/beast2/index.js.map +1 -0
- package/dist/src/serialization/beast2/index.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/index.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/index.spec.js +528 -0
- package/dist/src/serialization/beast2/index.spec.js.map +1 -0
- package/dist/src/serialization/beast2/sourcemap-table.d.ts +29 -0
- package/dist/src/serialization/beast2/sourcemap-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/sourcemap-table.js +82 -0
- package/dist/src/serialization/beast2/sourcemap-table.js.map +1 -0
- package/dist/src/serialization/beast2/string-table.d.ts +16 -0
- package/dist/src/serialization/beast2/string-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/string-table.js +38 -0
- package/dist/src/serialization/beast2/string-table.js.map +1 -0
- package/dist/src/serialization/beast2/type-table.d.ts +86 -0
- package/dist/src/serialization/beast2/type-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/type-table.js +618 -0
- package/dist/src/serialization/beast2/type-table.js.map +1 -0
- package/dist/src/serialization/beast2/value-table.d.ts +40 -0
- package/dist/src/serialization/beast2/value-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/value-table.js +157 -0
- package/dist/src/serialization/beast2/value-table.js.map +1 -0
- package/dist/src/serialization/binary-utils.d.ts +33 -0
- package/dist/src/serialization/binary-utils.d.ts.map +1 -1
- package/dist/src/serialization/binary-utils.js +157 -0
- package/dist/src/serialization/binary-utils.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +17 -17
- package/dist/src/serialization/csv.d.ts.map +1 -1
- package/dist/src/serialization/csv.js +10 -8
- package/dist/src/serialization/csv.js.map +1 -1
- package/dist/src/serialization/csv.spec.d.ts +2 -0
- package/dist/src/serialization/csv.spec.d.ts.map +1 -0
- package/dist/src/serialization/csv.spec.js +556 -0
- package/dist/src/serialization/csv.spec.js.map +1 -0
- package/dist/src/serialization/east-inferred.spec.d.ts +2 -0
- package/dist/src/serialization/east-inferred.spec.d.ts.map +1 -0
- package/dist/src/serialization/east-inferred.spec.js +322 -0
- package/dist/src/serialization/east-inferred.spec.js.map +1 -0
- package/dist/src/serialization/east.d.ts +1 -1
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +178 -26
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/east.spec.d.ts +2 -0
- package/dist/src/serialization/east.spec.d.ts.map +1 -0
- package/dist/src/serialization/east.spec.js +1548 -0
- package/dist/src/serialization/east.spec.js.map +1 -0
- package/dist/src/serialization/index.d.ts +1 -2
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -2
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts +1 -1
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +123 -24
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/serialization/json.spec.d.ts +2 -0
- package/dist/src/serialization/json.spec.d.ts.map +1 -0
- package/dist/src/serialization/json.spec.js +1297 -0
- package/dist/src/serialization/json.spec.js.map +1 -0
- package/dist/src/type_of_type.d.ts +72 -35
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.is_data.spec.d.ts +6 -0
- package/dist/src/type_of_type.is_data.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.is_data.spec.js +221 -0
- package/dist/src/type_of_type.is_data.spec.js.map +1 -0
- package/dist/src/type_of_type.js +355 -80
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/type_of_type.to_etv.spec.d.ts +6 -0
- package/dist/src/type_of_type.to_etv.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.to_etv.spec.js +263 -0
- package/dist/src/type_of_type.to_etv.spec.js.map +1 -0
- package/dist/src/types.d.ts +82 -12
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.error.spec.d.ts +2 -0
- package/dist/src/types.error.spec.d.ts.map +1 -0
- package/dist/src/types.error.spec.js +665 -0
- package/dist/src/types.error.spec.js.map +1 -0
- package/dist/src/types.js +663 -156
- package/dist/src/types.js.map +1 -1
- package/dist/src/types.spec.d.ts +2 -0
- package/dist/src/types.spec.d.ts.map +1 -0
- package/dist/src/types.spec.js +946 -0
- package/dist/src/types.spec.js.map +1 -0
- package/dist/src/walker.d.ts +65 -0
- package/dist/src/walker.d.ts.map +1 -0
- package/dist/src/walker.js +165 -0
- package/dist/src/walker.js.map +1 -0
- package/dist/src/walker.spec.d.ts +6 -0
- package/dist/src/walker.spec.d.ts.map +1 -0
- package/dist/src/walker.spec.js +109 -0
- package/dist/src/walker.spec.js.map +1 -0
- package/package.json +16 -38
- package/dist/src/serialization/beast2-stream.d.ts +0 -38
- package/dist/src/serialization/beast2-stream.d.ts.map +0 -1
- package/dist/src/serialization/beast2-stream.js +0 -670
- package/dist/src/serialization/beast2-stream.js.map +0 -1
- package/dist/src/serialization/beast2.d.ts +0 -41
- package/dist/src/serialization/beast2.d.ts.map +0 -1
- package/dist/src/serialization/beast2.js +0 -495
- package/dist/src/serialization/beast2.js.map +0 -1
package/dist/src/expr/dict.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { get_location_id } from "../location.js";
|
|
2
2
|
import { DictType, BooleanType, FunctionType, IntegerType, NullType, OptionType, SetType, NeverType, VariantType, printType, FloatType, isTypeEqual, ArrayType } from "../types.js";
|
|
3
3
|
import { valueOrExprToAst, valueOrExprToAstTyped } from "./ast.js";
|
|
4
|
+
import { equal, notEqual } from "./block.js";
|
|
4
5
|
import { AstSymbol, Expr, FactorySymbol, TypeSymbol } from "./expr.js";
|
|
5
6
|
import { none, some } from "../containers/variant.js";
|
|
6
7
|
/**
|
|
@@ -61,7 +62,7 @@ export class DictExpr extends Expr {
|
|
|
61
62
|
return this[FactorySymbol]({
|
|
62
63
|
ast_type: "Builtin",
|
|
63
64
|
type: IntegerType,
|
|
64
|
-
|
|
65
|
+
loc_id: get_location_id(),
|
|
65
66
|
builtin: "DictSize",
|
|
66
67
|
type_parameters: [this.key_type, this.value_type],
|
|
67
68
|
arguments: [this[AstSymbol]],
|
|
@@ -89,7 +90,7 @@ export class DictExpr extends Expr {
|
|
|
89
90
|
return this[FactorySymbol]({
|
|
90
91
|
ast_type: "Builtin",
|
|
91
92
|
type: BooleanType,
|
|
92
|
-
|
|
93
|
+
loc_id: get_location_id(),
|
|
93
94
|
builtin: "DictHas",
|
|
94
95
|
type_parameters: [this.key_type, this.value_type],
|
|
95
96
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -135,7 +136,7 @@ export class DictExpr extends Expr {
|
|
|
135
136
|
return this[FactorySymbol]({
|
|
136
137
|
ast_type: "Builtin",
|
|
137
138
|
type: this.value_type,
|
|
138
|
-
|
|
139
|
+
loc_id: get_location_id(),
|
|
139
140
|
builtin: "DictGet",
|
|
140
141
|
type_parameters: [this.key_type, this.value_type],
|
|
141
142
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -147,7 +148,7 @@ export class DictExpr extends Expr {
|
|
|
147
148
|
return this[FactorySymbol]({
|
|
148
149
|
ast_type: "Builtin",
|
|
149
150
|
type: this.value_type,
|
|
150
|
-
|
|
151
|
+
loc_id: get_location_id(),
|
|
151
152
|
builtin: "DictGetOrDefault",
|
|
152
153
|
type_parameters: [this.key_type, this.value_type],
|
|
153
154
|
arguments: [this[AstSymbol], keyAst, onMissingAst],
|
|
@@ -192,7 +193,7 @@ export class DictExpr extends Expr {
|
|
|
192
193
|
return this[FactorySymbol]({
|
|
193
194
|
ast_type: "Builtin",
|
|
194
195
|
type: OptionType(this.value_type),
|
|
195
|
-
|
|
196
|
+
loc_id: get_location_id(),
|
|
196
197
|
builtin: "DictTryGet",
|
|
197
198
|
type_parameters: [this.key_type, this.value_type],
|
|
198
199
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -229,7 +230,7 @@ export class DictExpr extends Expr {
|
|
|
229
230
|
return this[FactorySymbol]({
|
|
230
231
|
ast_type: "Builtin",
|
|
231
232
|
type: NullType,
|
|
232
|
-
|
|
233
|
+
loc_id: get_location_id(),
|
|
233
234
|
builtin: "DictInsert",
|
|
234
235
|
type_parameters: [this.key_type, this.value_type],
|
|
235
236
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -238,14 +239,17 @@ export class DictExpr extends Expr {
|
|
|
238
239
|
/**
|
|
239
240
|
* Inserts or updates a key-value pair in the dictionary.
|
|
240
241
|
*
|
|
241
|
-
* If the key
|
|
242
|
+
* If the key does not exist, inserts the value. If the key already exists, the value is replaced by default,
|
|
243
|
+
* or resolved using the optional `onConflict` handler.
|
|
242
244
|
*
|
|
243
245
|
* @param key - The key to insert or update
|
|
244
246
|
* @param value - The new value to associate with the key
|
|
247
|
+
* @param onConflict - Optional conflict handler called with (existing, new, key) when the key already exists; if omitted, the new value overwrites the existing one
|
|
245
248
|
* @returns A NullExpr
|
|
246
249
|
*
|
|
247
250
|
* @see {@link insert} for inserting only (errors on duplicate)
|
|
248
251
|
* @see {@link update} for updating only (errors on missing key)
|
|
252
|
+
* @see {@link merge} to update based on the existing value
|
|
249
253
|
*
|
|
250
254
|
* @example
|
|
251
255
|
* ```ts
|
|
@@ -259,16 +263,24 @@ export class DictExpr extends Expr {
|
|
|
259
263
|
* compiled(dict, "a", 10n); // dict now has Map([["a", 10n], ["b", 2n]])
|
|
260
264
|
* ```
|
|
261
265
|
*/
|
|
262
|
-
insertOrUpdate(key, value) {
|
|
266
|
+
insertOrUpdate(key, value, onConflict) {
|
|
263
267
|
const keyAst = valueOrExprToAstTyped(key, this.key_type);
|
|
264
268
|
const valueAst = valueOrExprToAstTyped(value, this.value_type);
|
|
269
|
+
let onConflictExpr;
|
|
270
|
+
if (onConflict === undefined) {
|
|
271
|
+
// Default: replace existing with new value
|
|
272
|
+
onConflictExpr = Expr.function([this.value_type, this.value_type, this.key_type], this.value_type, (_$, _existing, newValue) => newValue);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
onConflictExpr = Expr.from(onConflict, FunctionType([this.value_type, this.value_type, this.key_type], this.value_type));
|
|
276
|
+
}
|
|
265
277
|
return this[FactorySymbol]({
|
|
266
278
|
ast_type: "Builtin",
|
|
267
279
|
type: NullType,
|
|
268
|
-
|
|
280
|
+
loc_id: get_location_id(),
|
|
269
281
|
builtin: "DictInsertOrUpdate",
|
|
270
282
|
type_parameters: [this.key_type, this.value_type],
|
|
271
|
-
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
283
|
+
arguments: [this[AstSymbol], keyAst, valueAst, Expr.ast(onConflictExpr)],
|
|
272
284
|
});
|
|
273
285
|
}
|
|
274
286
|
/**
|
|
@@ -302,7 +314,7 @@ export class DictExpr extends Expr {
|
|
|
302
314
|
return this[FactorySymbol]({
|
|
303
315
|
ast_type: "Builtin",
|
|
304
316
|
type: NullType,
|
|
305
|
-
|
|
317
|
+
loc_id: get_location_id(),
|
|
306
318
|
builtin: "DictUpdate",
|
|
307
319
|
type_parameters: [this.key_type, this.value_type],
|
|
308
320
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -358,7 +370,7 @@ export class DictExpr extends Expr {
|
|
|
358
370
|
let initialExpr;
|
|
359
371
|
if (initialFn === undefined) {
|
|
360
372
|
// Default: create function that throws error
|
|
361
|
-
initialExpr = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`,
|
|
373
|
+
initialExpr = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`, get_location_id()));
|
|
362
374
|
}
|
|
363
375
|
else {
|
|
364
376
|
initialExpr = Expr.from(initialFn, FunctionType([this.key_type], this.value_type));
|
|
@@ -366,7 +378,7 @@ export class DictExpr extends Expr {
|
|
|
366
378
|
return this[FactorySymbol]({
|
|
367
379
|
ast_type: "Builtin",
|
|
368
380
|
type: NullType,
|
|
369
|
-
|
|
381
|
+
loc_id: get_location_id(),
|
|
370
382
|
builtin: "DictMerge",
|
|
371
383
|
type_parameters: [this.key_type, this.value_type, value2Type],
|
|
372
384
|
arguments: [this[AstSymbol], keyAst, valueAst, Expr.ast(updateFnExpr), Expr.ast(initialExpr)],
|
|
@@ -403,7 +415,7 @@ export class DictExpr extends Expr {
|
|
|
403
415
|
return this[FactorySymbol]({
|
|
404
416
|
ast_type: "Builtin",
|
|
405
417
|
type: this.value_type,
|
|
406
|
-
|
|
418
|
+
loc_id: get_location_id(),
|
|
407
419
|
builtin: "DictGetOrInsert",
|
|
408
420
|
type_parameters: [this.key_type, this.value_type],
|
|
409
421
|
arguments: [this[AstSymbol], keyAst, Expr.ast(defaultValueExpr)],
|
|
@@ -438,7 +450,7 @@ export class DictExpr extends Expr {
|
|
|
438
450
|
return this[FactorySymbol]({
|
|
439
451
|
ast_type: "Builtin",
|
|
440
452
|
type: NullType,
|
|
441
|
-
|
|
453
|
+
loc_id: get_location_id(),
|
|
442
454
|
builtin: "DictDelete",
|
|
443
455
|
type_parameters: [this.key_type, this.value_type],
|
|
444
456
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -469,7 +481,7 @@ export class DictExpr extends Expr {
|
|
|
469
481
|
return this[FactorySymbol]({
|
|
470
482
|
ast_type: "Builtin",
|
|
471
483
|
type: BooleanType,
|
|
472
|
-
|
|
484
|
+
loc_id: get_location_id(),
|
|
473
485
|
builtin: "DictTryDelete",
|
|
474
486
|
type_parameters: [this.key_type, this.value_type],
|
|
475
487
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -502,7 +514,7 @@ export class DictExpr extends Expr {
|
|
|
502
514
|
return this[FactorySymbol]({
|
|
503
515
|
ast_type: "Builtin",
|
|
504
516
|
type: this.value_type,
|
|
505
|
-
|
|
517
|
+
loc_id: get_location_id(),
|
|
506
518
|
builtin: "DictPop",
|
|
507
519
|
type_parameters: [this.key_type, this.value_type],
|
|
508
520
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -537,7 +549,7 @@ export class DictExpr extends Expr {
|
|
|
537
549
|
return this[FactorySymbol]({
|
|
538
550
|
ast_type: "Builtin",
|
|
539
551
|
type: this.value_type,
|
|
540
|
-
|
|
552
|
+
loc_id: get_location_id(),
|
|
541
553
|
builtin: "DictSwap",
|
|
542
554
|
type_parameters: [this.key_type, this.value_type],
|
|
543
555
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -565,7 +577,7 @@ export class DictExpr extends Expr {
|
|
|
565
577
|
return this[FactorySymbol]({
|
|
566
578
|
ast_type: "Builtin",
|
|
567
579
|
type: NullType,
|
|
568
|
-
|
|
580
|
+
loc_id: get_location_id(),
|
|
569
581
|
builtin: "DictClear",
|
|
570
582
|
type_parameters: [this.key_type, this.value_type],
|
|
571
583
|
arguments: [this[AstSymbol]],
|
|
@@ -602,7 +614,7 @@ export class DictExpr extends Expr {
|
|
|
602
614
|
let mergerAst;
|
|
603
615
|
if (mergeFn === undefined) {
|
|
604
616
|
// Default: replace existing value with new value (ignore key and existing, return new)
|
|
605
|
-
const mergerExpr = Expr.function([this.value_type, this.value_type, this.key_type], this.value_type, ($, _v1, _v2, k) => $.error(Expr.str `Key ${k} exists in both dictionaries`,
|
|
617
|
+
const mergerExpr = Expr.function([this.value_type, this.value_type, this.key_type], this.value_type, ($, _v1, _v2, k) => $.error(Expr.str `Key ${k} exists in both dictionaries`, get_location_id()));
|
|
606
618
|
mergerAst = Expr.ast(mergerExpr);
|
|
607
619
|
}
|
|
608
620
|
else {
|
|
@@ -612,7 +624,7 @@ export class DictExpr extends Expr {
|
|
|
612
624
|
return this[FactorySymbol]({
|
|
613
625
|
ast_type: "Builtin",
|
|
614
626
|
type: NullType,
|
|
615
|
-
|
|
627
|
+
loc_id: get_location_id(),
|
|
616
628
|
builtin: "DictUnionInPlace",
|
|
617
629
|
type_parameters: [this.key_type, this.value_type],
|
|
618
630
|
arguments: [this[AstSymbol], Expr.ast(dict2Expr), mergerAst],
|
|
@@ -659,7 +671,7 @@ export class DictExpr extends Expr {
|
|
|
659
671
|
let initialExpr;
|
|
660
672
|
if (initialFn === undefined) {
|
|
661
673
|
// Default: create function that throws error
|
|
662
|
-
initialExpr = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`,
|
|
674
|
+
initialExpr = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`, get_location_id()));
|
|
663
675
|
}
|
|
664
676
|
else {
|
|
665
677
|
initialExpr = Expr.from(initialFn, FunctionType([this.key_type], this.value_type));
|
|
@@ -667,7 +679,7 @@ export class DictExpr extends Expr {
|
|
|
667
679
|
return this[FactorySymbol]({
|
|
668
680
|
ast_type: "Builtin",
|
|
669
681
|
type: NullType,
|
|
670
|
-
|
|
682
|
+
loc_id: get_location_id(),
|
|
671
683
|
builtin: "DictMergeAll",
|
|
672
684
|
type_parameters: [this.key_type, this.value_type, value2Type],
|
|
673
685
|
arguments: [this[AstSymbol], dict2Ast, Expr.ast(mergerExpr), Expr.ast(initialExpr)],
|
|
@@ -694,7 +706,7 @@ export class DictExpr extends Expr {
|
|
|
694
706
|
return this[FactorySymbol]({
|
|
695
707
|
ast_type: "Builtin",
|
|
696
708
|
type: SetType(this.key_type),
|
|
697
|
-
|
|
709
|
+
loc_id: get_location_id(),
|
|
698
710
|
builtin: "DictKeys",
|
|
699
711
|
type_parameters: [this.key_type, this.value_type],
|
|
700
712
|
arguments: [this[AstSymbol]],
|
|
@@ -738,7 +750,7 @@ export class DictExpr extends Expr {
|
|
|
738
750
|
let onMissingAst;
|
|
739
751
|
if (onMissing === undefined) {
|
|
740
752
|
// Default: throw error with key information if key doesn't exist
|
|
741
|
-
const defaultFunction = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`,
|
|
753
|
+
const defaultFunction = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`, get_location_id()));
|
|
742
754
|
onMissingAst = Expr.ast(defaultFunction);
|
|
743
755
|
}
|
|
744
756
|
else {
|
|
@@ -748,7 +760,7 @@ export class DictExpr extends Expr {
|
|
|
748
760
|
return this[FactorySymbol]({
|
|
749
761
|
ast_type: "Builtin",
|
|
750
762
|
type: this[TypeSymbol],
|
|
751
|
-
|
|
763
|
+
loc_id: get_location_id(),
|
|
752
764
|
builtin: "DictGetKeys",
|
|
753
765
|
type_parameters: [this.key_type, this.value_type],
|
|
754
766
|
arguments: [this[AstSymbol], keysAst, onMissingAst],
|
|
@@ -788,7 +800,7 @@ export class DictExpr extends Expr {
|
|
|
788
800
|
return this[FactorySymbol]({
|
|
789
801
|
ast_type: "Builtin",
|
|
790
802
|
type: NullType,
|
|
791
|
-
|
|
803
|
+
loc_id: get_location_id(),
|
|
792
804
|
builtin: "DictForEach",
|
|
793
805
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
794
806
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -814,7 +826,7 @@ export class DictExpr extends Expr {
|
|
|
814
826
|
return this[FactorySymbol]({
|
|
815
827
|
ast_type: "Builtin",
|
|
816
828
|
type: this[TypeSymbol],
|
|
817
|
-
|
|
829
|
+
loc_id: get_location_id(),
|
|
818
830
|
builtin: "DictCopy",
|
|
819
831
|
type_parameters: [this.key_type, this.value_type],
|
|
820
832
|
arguments: [this[AstSymbol]],
|
|
@@ -833,7 +845,7 @@ export class DictExpr extends Expr {
|
|
|
833
845
|
return Expr.fromAst({
|
|
834
846
|
ast_type: "Builtin",
|
|
835
847
|
type: DictType(this.key_type, returnType),
|
|
836
|
-
|
|
848
|
+
loc_id: get_location_id(),
|
|
837
849
|
builtin: "DictMap",
|
|
838
850
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
839
851
|
arguments: [this[AstSymbol], Expr.ast(fnExpr)],
|
|
@@ -863,7 +875,7 @@ export class DictExpr extends Expr {
|
|
|
863
875
|
return Expr.fromAst({
|
|
864
876
|
ast_type: "Builtin",
|
|
865
877
|
type: this[TypeSymbol],
|
|
866
|
-
|
|
878
|
+
loc_id: get_location_id(),
|
|
867
879
|
builtin: "DictFilter",
|
|
868
880
|
type_parameters: [this.key_type, this.value_type],
|
|
869
881
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -889,7 +901,7 @@ export class DictExpr extends Expr {
|
|
|
889
901
|
return Expr.fromAst({
|
|
890
902
|
ast_type: "Builtin",
|
|
891
903
|
type: this[TypeSymbol],
|
|
892
|
-
|
|
904
|
+
loc_id: get_location_id(),
|
|
893
905
|
builtin: "DictFilterMap",
|
|
894
906
|
type_parameters: [this.key_type, this.value_type, someType],
|
|
895
907
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -912,7 +924,7 @@ export class DictExpr extends Expr {
|
|
|
912
924
|
return Expr.fromAst({
|
|
913
925
|
ast_type: "Builtin",
|
|
914
926
|
type: ArrayType(returnType),
|
|
915
|
-
|
|
927
|
+
loc_id: get_location_id(),
|
|
916
928
|
builtin: "DictToArray",
|
|
917
929
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
918
930
|
arguments: [this[AstSymbol], Expr.ast(fnExpr)],
|
|
@@ -939,7 +951,7 @@ export class DictExpr extends Expr {
|
|
|
939
951
|
return Expr.fromAst({
|
|
940
952
|
ast_type: "Builtin",
|
|
941
953
|
type: SetType(keyType),
|
|
942
|
-
|
|
954
|
+
loc_id: get_location_id(),
|
|
943
955
|
builtin: "DictToSet",
|
|
944
956
|
type_parameters: [this.key_type, this.value_type, keyType],
|
|
945
957
|
arguments: [this[AstSymbol], keyFnAst],
|
|
@@ -952,8 +964,8 @@ export class DictExpr extends Expr {
|
|
|
952
964
|
const valueType = valueFnAst.type.output;
|
|
953
965
|
let onConflictAst;
|
|
954
966
|
if (onConflictFn === undefined) {
|
|
955
|
-
const
|
|
956
|
-
const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`,
|
|
967
|
+
const loc_id = get_location_id();
|
|
968
|
+
const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`, loc_id));
|
|
957
969
|
onConflictAst = Expr.ast(onConflictFunction);
|
|
958
970
|
}
|
|
959
971
|
else {
|
|
@@ -962,7 +974,7 @@ export class DictExpr extends Expr {
|
|
|
962
974
|
return Expr.fromAst({
|
|
963
975
|
ast_type: "Builtin",
|
|
964
976
|
type: DictType(keyType, valueType),
|
|
965
|
-
|
|
977
|
+
loc_id: get_location_id(),
|
|
966
978
|
builtin: "DictToDict",
|
|
967
979
|
type_parameters: [this.key_type, this.value_type, keyType, valueType],
|
|
968
980
|
arguments: [this[AstSymbol], keyFnAst, valueFnAst, onConflictAst],
|
|
@@ -978,7 +990,7 @@ export class DictExpr extends Expr {
|
|
|
978
990
|
return Expr.fromAst({
|
|
979
991
|
ast_type: "Builtin",
|
|
980
992
|
type: ArrayType(elementType),
|
|
981
|
-
|
|
993
|
+
loc_id: get_location_id(),
|
|
982
994
|
builtin: "DictFlattenToArray",
|
|
983
995
|
type_parameters: [this.key_type, this.value_type, elementType],
|
|
984
996
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -994,7 +1006,7 @@ export class DictExpr extends Expr {
|
|
|
994
1006
|
return Expr.fromAst({
|
|
995
1007
|
ast_type: "Builtin",
|
|
996
1008
|
type: SetType(elementType),
|
|
997
|
-
|
|
1009
|
+
loc_id: get_location_id(),
|
|
998
1010
|
builtin: "DictFlattenToSet",
|
|
999
1011
|
type_parameters: [this.key_type, this.value_type, elementType],
|
|
1000
1012
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -1010,8 +1022,8 @@ export class DictExpr extends Expr {
|
|
|
1010
1022
|
const valueType = returnType.value;
|
|
1011
1023
|
let onConflictAst;
|
|
1012
1024
|
if (onConflictFn === undefined) {
|
|
1013
|
-
const
|
|
1014
|
-
const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`,
|
|
1025
|
+
const loc_id = get_location_id();
|
|
1026
|
+
const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`, loc_id));
|
|
1015
1027
|
onConflictAst = Expr.ast(onConflictFunction);
|
|
1016
1028
|
}
|
|
1017
1029
|
else {
|
|
@@ -1020,7 +1032,7 @@ export class DictExpr extends Expr {
|
|
|
1020
1032
|
return Expr.fromAst({
|
|
1021
1033
|
ast_type: "Builtin",
|
|
1022
1034
|
type: DictType(keyType, valueType),
|
|
1023
|
-
|
|
1035
|
+
loc_id: get_location_id(),
|
|
1024
1036
|
builtin: "DictFlattenToDict",
|
|
1025
1037
|
type_parameters: [this.key_type, this.value_type, keyType, valueType],
|
|
1026
1038
|
arguments: [this[AstSymbol], fnAst, onConflictAst],
|
|
@@ -1035,7 +1047,7 @@ export class DictExpr extends Expr {
|
|
|
1035
1047
|
return Expr.fromAst({
|
|
1036
1048
|
ast_type: "Builtin",
|
|
1037
1049
|
type: DictType(keyType, initType),
|
|
1038
|
-
|
|
1050
|
+
loc_id: get_location_id(),
|
|
1039
1051
|
builtin: "DictGroupFold",
|
|
1040
1052
|
type_parameters: [this.key_type, this.value_type, keyType, initType],
|
|
1041
1053
|
arguments: [this[AstSymbol], keyFnAst, initFnAst, reduceFnAst],
|
|
@@ -1239,7 +1251,7 @@ export class DictExpr extends Expr {
|
|
|
1239
1251
|
return this[FactorySymbol]({
|
|
1240
1252
|
ast_type: "Builtin",
|
|
1241
1253
|
type: returnType,
|
|
1242
|
-
|
|
1254
|
+
loc_id: get_location_id(),
|
|
1243
1255
|
builtin: "DictReduce",
|
|
1244
1256
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
1245
1257
|
arguments: [this[AstSymbol], fnAst, initAst],
|
|
@@ -1252,7 +1264,7 @@ export class DictExpr extends Expr {
|
|
|
1252
1264
|
return this[FactorySymbol]({
|
|
1253
1265
|
ast_type: "Builtin",
|
|
1254
1266
|
type: mapType,
|
|
1255
|
-
|
|
1267
|
+
loc_id: get_location_id(),
|
|
1256
1268
|
builtin: "DictMapReduce",
|
|
1257
1269
|
type_parameters: [this.key_type, this.value_type, mapType],
|
|
1258
1270
|
arguments: [this[AstSymbol], mapAst, combineAst],
|
|
@@ -1271,7 +1283,7 @@ export class DictExpr extends Expr {
|
|
|
1271
1283
|
return Expr.fromAst({
|
|
1272
1284
|
ast_type: "Builtin",
|
|
1273
1285
|
type: returnType,
|
|
1274
|
-
|
|
1286
|
+
loc_id: get_location_id(),
|
|
1275
1287
|
builtin: "DictFirstMap",
|
|
1276
1288
|
type_parameters: [this.key_type, this.value_type, someType],
|
|
1277
1289
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -1313,20 +1325,20 @@ export class DictExpr extends Expr {
|
|
|
1313
1325
|
const valueParam = {
|
|
1314
1326
|
ast_type: "Variable",
|
|
1315
1327
|
type: this.value_type,
|
|
1316
|
-
|
|
1328
|
+
loc_id: get_location_id(),
|
|
1317
1329
|
mutable: false,
|
|
1318
1330
|
};
|
|
1319
1331
|
const keyParam = {
|
|
1320
1332
|
ast_type: "Variable",
|
|
1321
1333
|
type: this.key_type,
|
|
1322
|
-
|
|
1334
|
+
loc_id: get_location_id(),
|
|
1323
1335
|
mutable: false,
|
|
1324
1336
|
};
|
|
1325
1337
|
// Check if boolean value is NOT true, then return some(null) to stop, otherwise return none to continue
|
|
1326
1338
|
const notCondition = {
|
|
1327
1339
|
ast_type: "Builtin",
|
|
1328
1340
|
type: BooleanType,
|
|
1329
|
-
|
|
1341
|
+
loc_id: get_location_id(),
|
|
1330
1342
|
builtin: "BooleanNot",
|
|
1331
1343
|
type_parameters: [],
|
|
1332
1344
|
arguments: [valueParam]
|
|
@@ -1334,23 +1346,23 @@ export class DictExpr extends Expr {
|
|
|
1334
1346
|
const checkFnAst = {
|
|
1335
1347
|
ast_type: "Function",
|
|
1336
1348
|
type: FunctionType([this.value_type, this.key_type], optionType),
|
|
1337
|
-
|
|
1349
|
+
loc_id: get_location_id(),
|
|
1338
1350
|
parameters: [valueParam, keyParam],
|
|
1339
1351
|
body: {
|
|
1340
1352
|
ast_type: "IfElse",
|
|
1341
1353
|
type: optionType,
|
|
1342
|
-
|
|
1354
|
+
loc_id: get_location_id(),
|
|
1343
1355
|
ifs: [{
|
|
1344
1356
|
predicate: notCondition,
|
|
1345
|
-
body: { ast_type: "Variant", type: optionType,
|
|
1357
|
+
body: { ast_type: "Variant", type: optionType, loc_id: get_location_id(), case: "some", value: { ast_type: "Value", type: NullType, loc_id: get_location_id(), value: null } }
|
|
1346
1358
|
}],
|
|
1347
|
-
else_body: { ast_type: "Variant", type: optionType,
|
|
1359
|
+
else_body: { ast_type: "Variant", type: optionType, loc_id: get_location_id(), case: "none", value: { ast_type: "Value", type: NullType, loc_id: get_location_id(), value: null } }
|
|
1348
1360
|
}
|
|
1349
1361
|
};
|
|
1350
1362
|
const result = Expr.fromAst({
|
|
1351
1363
|
ast_type: "Builtin",
|
|
1352
1364
|
type: optionType,
|
|
1353
|
-
|
|
1365
|
+
loc_id: get_location_id(),
|
|
1354
1366
|
builtin: "DictFirstMap",
|
|
1355
1367
|
type_parameters: [this.key_type, this.value_type, NullType],
|
|
1356
1368
|
arguments: [this[AstSymbol], checkFnAst],
|
|
@@ -1400,36 +1412,36 @@ export class DictExpr extends Expr {
|
|
|
1400
1412
|
const valueParam = {
|
|
1401
1413
|
ast_type: "Variable",
|
|
1402
1414
|
type: this.value_type,
|
|
1403
|
-
|
|
1415
|
+
loc_id: get_location_id(),
|
|
1404
1416
|
mutable: false,
|
|
1405
1417
|
};
|
|
1406
1418
|
const keyParam = {
|
|
1407
1419
|
ast_type: "Variable",
|
|
1408
1420
|
type: this.key_type,
|
|
1409
|
-
|
|
1421
|
+
loc_id: get_location_id(),
|
|
1410
1422
|
mutable: false,
|
|
1411
1423
|
};
|
|
1412
1424
|
// Check if boolean value is true, then return some(null) to stop, otherwise return none to continue
|
|
1413
1425
|
const checkFnAst = {
|
|
1414
1426
|
ast_type: "Function",
|
|
1415
1427
|
type: FunctionType([this.value_type, this.key_type], optionType),
|
|
1416
|
-
|
|
1428
|
+
loc_id: get_location_id(),
|
|
1417
1429
|
parameters: [valueParam, keyParam],
|
|
1418
1430
|
body: {
|
|
1419
1431
|
ast_type: "IfElse",
|
|
1420
1432
|
type: optionType,
|
|
1421
|
-
|
|
1433
|
+
loc_id: get_location_id(),
|
|
1422
1434
|
ifs: [{
|
|
1423
1435
|
predicate: valueParam,
|
|
1424
|
-
body: { ast_type: "Variant", type: optionType,
|
|
1436
|
+
body: { ast_type: "Variant", type: optionType, loc_id: get_location_id(), case: "some", value: { ast_type: "Value", type: NullType, loc_id: get_location_id(), value: null } }
|
|
1425
1437
|
}],
|
|
1426
|
-
else_body: { ast_type: "Variant", type: optionType,
|
|
1438
|
+
else_body: { ast_type: "Variant", type: optionType, loc_id: get_location_id(), case: "none", value: { ast_type: "Value", type: NullType, loc_id: get_location_id(), value: null } }
|
|
1427
1439
|
}
|
|
1428
1440
|
};
|
|
1429
1441
|
const result = Expr.fromAst({
|
|
1430
1442
|
ast_type: "Builtin",
|
|
1431
1443
|
type: optionType,
|
|
1432
|
-
|
|
1444
|
+
loc_id: get_location_id(),
|
|
1433
1445
|
builtin: "DictFirstMap",
|
|
1434
1446
|
type_parameters: [this.key_type, this.value_type, NullType],
|
|
1435
1447
|
arguments: [this[AstSymbol], checkFnAst],
|
|
@@ -1488,5 +1500,54 @@ export class DictExpr extends Expr {
|
|
|
1488
1500
|
}
|
|
1489
1501
|
}
|
|
1490
1502
|
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Checks if this dictionary equals another dictionary (same key-value pairs).
|
|
1505
|
+
*
|
|
1506
|
+
* @param other - The dictionary to compare against
|
|
1507
|
+
* @returns A BooleanExpr that is true if the dictionaries are equal
|
|
1508
|
+
*
|
|
1509
|
+
* @example
|
|
1510
|
+
* ```ts
|
|
1511
|
+
* const isEqual = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], BooleanType, ($, a, b) => {
|
|
1512
|
+
* $.return(a.equals(b));
|
|
1513
|
+
* });
|
|
1514
|
+
* const compiled = East.compile(isEqual.toIR(), []);
|
|
1515
|
+
* compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["a", 1n], ["b", 2n]])); // true
|
|
1516
|
+
* compiled(new Map([["a", 1n]]), new Map([["a", 1n], ["b", 2n]])); // false
|
|
1517
|
+
* ```
|
|
1518
|
+
*/
|
|
1519
|
+
equals(other) {
|
|
1520
|
+
return equal(this, other);
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Checks if this dictionary does not equal another dictionary.
|
|
1524
|
+
*
|
|
1525
|
+
* @param other - The dictionary to compare against
|
|
1526
|
+
* @returns A BooleanExpr that is true if the dictionaries are not equal
|
|
1527
|
+
*
|
|
1528
|
+
* @example
|
|
1529
|
+
* ```ts
|
|
1530
|
+
* const isNotEqual = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], BooleanType, ($, a, b) => {
|
|
1531
|
+
* $.return(a.notEquals(b));
|
|
1532
|
+
* });
|
|
1533
|
+
* const compiled = East.compile(isNotEqual.toIR(), []);
|
|
1534
|
+
* compiled(new Map([["a", 1n]]), new Map([["a", 1n], ["b", 2n]])); // true
|
|
1535
|
+
* compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["a", 1n], ["b", 2n]])); // false
|
|
1536
|
+
* ```
|
|
1537
|
+
*/
|
|
1538
|
+
notEquals(other) {
|
|
1539
|
+
return notEqual(this, other);
|
|
1540
|
+
}
|
|
1541
|
+
// ============================================================================
|
|
1542
|
+
// Aliases for comparison operations
|
|
1543
|
+
// ============================================================================
|
|
1544
|
+
/** Alias for {@link equals} */
|
|
1545
|
+
eq = this.equals;
|
|
1546
|
+
/** Alias for {@link equals} */
|
|
1547
|
+
equal = this.equals;
|
|
1548
|
+
/** Alias for {@link notEquals} */
|
|
1549
|
+
ne = this.notEquals;
|
|
1550
|
+
/** Alias for {@link notEquals} */
|
|
1551
|
+
notEqual = this.notEquals;
|
|
1491
1552
|
}
|
|
1492
1553
|
//# sourceMappingURL=dict.js.map
|