@elaraai/east 0.0.1-beta.3 → 0.0.1-beta.31
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 +30 -8
- package/dist/src/analyze.d.ts +3 -0
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +76 -15
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/ast.d.ts +37 -33
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast_to_ir.d.ts +6 -0
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +135 -101
- 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 +32 -0
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +12 -4
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/compile.d.ts +26 -1
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +388 -257
- package/dist/src/compile.js.map +1 -1
- package/dist/src/datetime_format/types.d.ts +23 -23
- package/dist/src/eastir.d.ts +4 -0
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +27 -7
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/error.d.ts +12 -1
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +31 -1
- package/dist/src/error.js.map +1 -1
- package/dist/src/expr/array.d.ts +109 -1
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +204 -44
- 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 +16 -28
- package/dist/src/expr/ast.js.map +1 -1
- package/dist/src/expr/asyncfunction.js +1 -1
- package/dist/src/expr/asyncfunction.js.map +1 -1
- package/dist/src/expr/blob.d.ts +73 -1
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +97 -7
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +232 -12
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +646 -140
- 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 +57 -5
- 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 +183 -33
- package/dist/src/expr/datetime.js.map +1 -1
- package/dist/src/expr/dict.d.ts +42 -0
- package/dist/src/expr/dict.d.ts.map +1 -1
- package/dist/src/expr/dict.js +105 -55
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/expr.d.ts +1 -1
- package/dist/src/expr/expr.d.ts.map +1 -1
- 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 +190 -16
- 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 +1 -1
- package/dist/src/expr/function.js.map +1 -1
- package/dist/src/expr/index.d.ts +202 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +207 -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 +188 -17
- package/dist/src/expr/integer.js.map +1 -1
- package/dist/src/expr/libs/blob.js +2 -2
- package/dist/src/expr/libs/blob.js.map +1 -1
- package/dist/src/expr/libs/integer.d.ts +19 -0
- package/dist/src/expr/libs/integer.d.ts.map +1 -1
- package/dist/src/expr/libs/integer.js +47 -0
- package/dist/src/expr/libs/integer.js.map +1 -1
- package/dist/src/expr/libs/string.js +1 -1
- package/dist/src/expr/libs/string.js.map +1 -1
- 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 +3 -3
- 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 +97 -47
- 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 +172 -22
- 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 +1 -1
- package/dist/src/expr/struct.js.map +1 -1
- package/dist/src/expr/types.d.ts +7 -6
- package/dist/src/expr/types.d.ts.map +1 -1
- package/dist/src/expr/variant.d.ts +123 -1
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +66 -2
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/fuzz.d.ts +36 -2
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +344 -77
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +12 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +13 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir.d.ts +1551 -1505
- package/dist/src/ir.d.ts.map +1 -1
- package/dist/src/ir.js +49 -34
- package/dist/src/ir.js.map +1 -1
- package/dist/src/location.d.ts +30 -10
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +70 -28
- package/dist/src/location.js.map +1 -1
- 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 +380 -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 +480 -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 +328 -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 +18 -0
- package/dist/src/patch/index.d.ts.map +1 -0
- package/dist/src/patch/index.js +20 -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 +302 -0
- package/dist/src/patch/invert.js.map +1 -0
- package/dist/src/patch/type_of_patch.d.ts +17 -0
- package/dist/src/patch/type_of_patch.d.ts.map +1 -0
- package/dist/src/patch/type_of_patch.js +143 -0
- package/dist/src/patch/type_of_patch.js.map +1 -0
- package/dist/src/patch/types.d.ts +166 -0
- package/dist/src/patch/types.d.ts.map +1 -0
- package/dist/src/patch/types.js +69 -0
- package/dist/src/patch/types.js.map +1 -0
- package/dist/src/platform.d.ts +6 -0
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/serialization/beast.d.ts.map +1 -1
- package/dist/src/serialization/beast.js +53 -18
- package/dist/src/serialization/beast.js.map +1 -1
- package/dist/src/serialization/beast2.d.ts +39 -3
- package/dist/src/serialization/beast2.d.ts.map +1 -1
- package/dist/src/serialization/beast2.js +241 -18
- package/dist/src/serialization/beast2.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +139 -0
- package/dist/src/serialization/csv.d.ts.map +1 -0
- package/dist/src/serialization/csv.js +615 -0
- package/dist/src/serialization/csv.js.map +1 -0
- package/dist/src/serialization/index.d.ts +2 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +2 -1
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/type_of_type.d.ts +45 -34
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.js +62 -1
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/types.d.ts +8 -8
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +4 -4
- package/dist/src/types.js.map +1 -1
- package/package.json +4 -5
package/dist/src/expr/dict.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { get_location } 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
|
-
location: get_location(
|
|
65
|
+
location: get_location(),
|
|
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
|
-
location: get_location(
|
|
93
|
+
location: get_location(),
|
|
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
|
-
location: get_location(
|
|
139
|
+
location: get_location(),
|
|
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
|
-
location: get_location(
|
|
151
|
+
location: get_location(),
|
|
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
|
-
location: get_location(
|
|
196
|
+
location: get_location(),
|
|
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
|
-
location: get_location(
|
|
233
|
+
location: get_location(),
|
|
233
234
|
builtin: "DictInsert",
|
|
234
235
|
type_parameters: [this.key_type, this.value_type],
|
|
235
236
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -265,7 +266,7 @@ export class DictExpr extends Expr {
|
|
|
265
266
|
return this[FactorySymbol]({
|
|
266
267
|
ast_type: "Builtin",
|
|
267
268
|
type: NullType,
|
|
268
|
-
location: get_location(
|
|
269
|
+
location: get_location(),
|
|
269
270
|
builtin: "DictInsertOrUpdate",
|
|
270
271
|
type_parameters: [this.key_type, this.value_type],
|
|
271
272
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -302,7 +303,7 @@ export class DictExpr extends Expr {
|
|
|
302
303
|
return this[FactorySymbol]({
|
|
303
304
|
ast_type: "Builtin",
|
|
304
305
|
type: NullType,
|
|
305
|
-
location: get_location(
|
|
306
|
+
location: get_location(),
|
|
306
307
|
builtin: "DictUpdate",
|
|
307
308
|
type_parameters: [this.key_type, this.value_type],
|
|
308
309
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -358,7 +359,7 @@ export class DictExpr extends Expr {
|
|
|
358
359
|
let initialExpr;
|
|
359
360
|
if (initialFn === undefined) {
|
|
360
361
|
// 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`, get_location(
|
|
362
|
+
initialExpr = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`, get_location()));
|
|
362
363
|
}
|
|
363
364
|
else {
|
|
364
365
|
initialExpr = Expr.from(initialFn, FunctionType([this.key_type], this.value_type));
|
|
@@ -366,7 +367,7 @@ export class DictExpr extends Expr {
|
|
|
366
367
|
return this[FactorySymbol]({
|
|
367
368
|
ast_type: "Builtin",
|
|
368
369
|
type: NullType,
|
|
369
|
-
location: get_location(
|
|
370
|
+
location: get_location(),
|
|
370
371
|
builtin: "DictMerge",
|
|
371
372
|
type_parameters: [this.key_type, this.value_type, value2Type],
|
|
372
373
|
arguments: [this[AstSymbol], keyAst, valueAst, Expr.ast(updateFnExpr), Expr.ast(initialExpr)],
|
|
@@ -403,7 +404,7 @@ export class DictExpr extends Expr {
|
|
|
403
404
|
return this[FactorySymbol]({
|
|
404
405
|
ast_type: "Builtin",
|
|
405
406
|
type: this.value_type,
|
|
406
|
-
location: get_location(
|
|
407
|
+
location: get_location(),
|
|
407
408
|
builtin: "DictGetOrInsert",
|
|
408
409
|
type_parameters: [this.key_type, this.value_type],
|
|
409
410
|
arguments: [this[AstSymbol], keyAst, Expr.ast(defaultValueExpr)],
|
|
@@ -438,7 +439,7 @@ export class DictExpr extends Expr {
|
|
|
438
439
|
return this[FactorySymbol]({
|
|
439
440
|
ast_type: "Builtin",
|
|
440
441
|
type: NullType,
|
|
441
|
-
location: get_location(
|
|
442
|
+
location: get_location(),
|
|
442
443
|
builtin: "DictDelete",
|
|
443
444
|
type_parameters: [this.key_type, this.value_type],
|
|
444
445
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -469,7 +470,7 @@ export class DictExpr extends Expr {
|
|
|
469
470
|
return this[FactorySymbol]({
|
|
470
471
|
ast_type: "Builtin",
|
|
471
472
|
type: BooleanType,
|
|
472
|
-
location: get_location(
|
|
473
|
+
location: get_location(),
|
|
473
474
|
builtin: "DictTryDelete",
|
|
474
475
|
type_parameters: [this.key_type, this.value_type],
|
|
475
476
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -502,7 +503,7 @@ export class DictExpr extends Expr {
|
|
|
502
503
|
return this[FactorySymbol]({
|
|
503
504
|
ast_type: "Builtin",
|
|
504
505
|
type: this.value_type,
|
|
505
|
-
location: get_location(
|
|
506
|
+
location: get_location(),
|
|
506
507
|
builtin: "DictPop",
|
|
507
508
|
type_parameters: [this.key_type, this.value_type],
|
|
508
509
|
arguments: [this[AstSymbol], keyAst],
|
|
@@ -537,7 +538,7 @@ export class DictExpr extends Expr {
|
|
|
537
538
|
return this[FactorySymbol]({
|
|
538
539
|
ast_type: "Builtin",
|
|
539
540
|
type: this.value_type,
|
|
540
|
-
location: get_location(
|
|
541
|
+
location: get_location(),
|
|
541
542
|
builtin: "DictSwap",
|
|
542
543
|
type_parameters: [this.key_type, this.value_type],
|
|
543
544
|
arguments: [this[AstSymbol], keyAst, valueAst],
|
|
@@ -565,7 +566,7 @@ export class DictExpr extends Expr {
|
|
|
565
566
|
return this[FactorySymbol]({
|
|
566
567
|
ast_type: "Builtin",
|
|
567
568
|
type: NullType,
|
|
568
|
-
location: get_location(
|
|
569
|
+
location: get_location(),
|
|
569
570
|
builtin: "DictClear",
|
|
570
571
|
type_parameters: [this.key_type, this.value_type],
|
|
571
572
|
arguments: [this[AstSymbol]],
|
|
@@ -602,7 +603,7 @@ export class DictExpr extends Expr {
|
|
|
602
603
|
let mergerAst;
|
|
603
604
|
if (mergeFn === undefined) {
|
|
604
605
|
// 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`, get_location(
|
|
606
|
+
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()));
|
|
606
607
|
mergerAst = Expr.ast(mergerExpr);
|
|
607
608
|
}
|
|
608
609
|
else {
|
|
@@ -612,7 +613,7 @@ export class DictExpr extends Expr {
|
|
|
612
613
|
return this[FactorySymbol]({
|
|
613
614
|
ast_type: "Builtin",
|
|
614
615
|
type: NullType,
|
|
615
|
-
location: get_location(
|
|
616
|
+
location: get_location(),
|
|
616
617
|
builtin: "DictUnionInPlace",
|
|
617
618
|
type_parameters: [this.key_type, this.value_type],
|
|
618
619
|
arguments: [this[AstSymbol], Expr.ast(dict2Expr), mergerAst],
|
|
@@ -659,7 +660,7 @@ export class DictExpr extends Expr {
|
|
|
659
660
|
let initialExpr;
|
|
660
661
|
if (initialFn === undefined) {
|
|
661
662
|
// 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`, get_location(
|
|
663
|
+
initialExpr = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`, get_location()));
|
|
663
664
|
}
|
|
664
665
|
else {
|
|
665
666
|
initialExpr = Expr.from(initialFn, FunctionType([this.key_type], this.value_type));
|
|
@@ -667,7 +668,7 @@ export class DictExpr extends Expr {
|
|
|
667
668
|
return this[FactorySymbol]({
|
|
668
669
|
ast_type: "Builtin",
|
|
669
670
|
type: NullType,
|
|
670
|
-
location: get_location(
|
|
671
|
+
location: get_location(),
|
|
671
672
|
builtin: "DictMergeAll",
|
|
672
673
|
type_parameters: [this.key_type, this.value_type, value2Type],
|
|
673
674
|
arguments: [this[AstSymbol], dict2Ast, Expr.ast(mergerExpr), Expr.ast(initialExpr)],
|
|
@@ -694,7 +695,7 @@ export class DictExpr extends Expr {
|
|
|
694
695
|
return this[FactorySymbol]({
|
|
695
696
|
ast_type: "Builtin",
|
|
696
697
|
type: SetType(this.key_type),
|
|
697
|
-
location: get_location(
|
|
698
|
+
location: get_location(),
|
|
698
699
|
builtin: "DictKeys",
|
|
699
700
|
type_parameters: [this.key_type, this.value_type],
|
|
700
701
|
arguments: [this[AstSymbol]],
|
|
@@ -738,7 +739,7 @@ export class DictExpr extends Expr {
|
|
|
738
739
|
let onMissingAst;
|
|
739
740
|
if (onMissing === undefined) {
|
|
740
741
|
// 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`, get_location(
|
|
742
|
+
const defaultFunction = Expr.function([this.key_type], this.value_type, ($, key) => $.error(Expr.str `Key ${key} not found in dictionary`, get_location()));
|
|
742
743
|
onMissingAst = Expr.ast(defaultFunction);
|
|
743
744
|
}
|
|
744
745
|
else {
|
|
@@ -748,7 +749,7 @@ export class DictExpr extends Expr {
|
|
|
748
749
|
return this[FactorySymbol]({
|
|
749
750
|
ast_type: "Builtin",
|
|
750
751
|
type: this[TypeSymbol],
|
|
751
|
-
location: get_location(
|
|
752
|
+
location: get_location(),
|
|
752
753
|
builtin: "DictGetKeys",
|
|
753
754
|
type_parameters: [this.key_type, this.value_type],
|
|
754
755
|
arguments: [this[AstSymbol], keysAst, onMissingAst],
|
|
@@ -788,7 +789,7 @@ export class DictExpr extends Expr {
|
|
|
788
789
|
return this[FactorySymbol]({
|
|
789
790
|
ast_type: "Builtin",
|
|
790
791
|
type: NullType,
|
|
791
|
-
location: get_location(
|
|
792
|
+
location: get_location(),
|
|
792
793
|
builtin: "DictForEach",
|
|
793
794
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
794
795
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -814,7 +815,7 @@ export class DictExpr extends Expr {
|
|
|
814
815
|
return this[FactorySymbol]({
|
|
815
816
|
ast_type: "Builtin",
|
|
816
817
|
type: this[TypeSymbol],
|
|
817
|
-
location: get_location(
|
|
818
|
+
location: get_location(),
|
|
818
819
|
builtin: "DictCopy",
|
|
819
820
|
type_parameters: [this.key_type, this.value_type],
|
|
820
821
|
arguments: [this[AstSymbol]],
|
|
@@ -833,7 +834,7 @@ export class DictExpr extends Expr {
|
|
|
833
834
|
return Expr.fromAst({
|
|
834
835
|
ast_type: "Builtin",
|
|
835
836
|
type: DictType(this.key_type, returnType),
|
|
836
|
-
location: get_location(
|
|
837
|
+
location: get_location(),
|
|
837
838
|
builtin: "DictMap",
|
|
838
839
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
839
840
|
arguments: [this[AstSymbol], Expr.ast(fnExpr)],
|
|
@@ -863,7 +864,7 @@ export class DictExpr extends Expr {
|
|
|
863
864
|
return Expr.fromAst({
|
|
864
865
|
ast_type: "Builtin",
|
|
865
866
|
type: this[TypeSymbol],
|
|
866
|
-
location: get_location(
|
|
867
|
+
location: get_location(),
|
|
867
868
|
builtin: "DictFilter",
|
|
868
869
|
type_parameters: [this.key_type, this.value_type],
|
|
869
870
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -889,7 +890,7 @@ export class DictExpr extends Expr {
|
|
|
889
890
|
return Expr.fromAst({
|
|
890
891
|
ast_type: "Builtin",
|
|
891
892
|
type: this[TypeSymbol],
|
|
892
|
-
location: get_location(
|
|
893
|
+
location: get_location(),
|
|
893
894
|
builtin: "DictFilterMap",
|
|
894
895
|
type_parameters: [this.key_type, this.value_type, someType],
|
|
895
896
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -912,7 +913,7 @@ export class DictExpr extends Expr {
|
|
|
912
913
|
return Expr.fromAst({
|
|
913
914
|
ast_type: "Builtin",
|
|
914
915
|
type: ArrayType(returnType),
|
|
915
|
-
location: get_location(
|
|
916
|
+
location: get_location(),
|
|
916
917
|
builtin: "DictToArray",
|
|
917
918
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
918
919
|
arguments: [this[AstSymbol], Expr.ast(fnExpr)],
|
|
@@ -939,7 +940,7 @@ export class DictExpr extends Expr {
|
|
|
939
940
|
return Expr.fromAst({
|
|
940
941
|
ast_type: "Builtin",
|
|
941
942
|
type: SetType(keyType),
|
|
942
|
-
location: get_location(
|
|
943
|
+
location: get_location(),
|
|
943
944
|
builtin: "DictToSet",
|
|
944
945
|
type_parameters: [this.key_type, this.value_type, keyType],
|
|
945
946
|
arguments: [this[AstSymbol], keyFnAst],
|
|
@@ -952,7 +953,7 @@ export class DictExpr extends Expr {
|
|
|
952
953
|
const valueType = valueFnAst.type.output;
|
|
953
954
|
let onConflictAst;
|
|
954
955
|
if (onConflictFn === undefined) {
|
|
955
|
-
const location = get_location(
|
|
956
|
+
const location = get_location();
|
|
956
957
|
const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`, location));
|
|
957
958
|
onConflictAst = Expr.ast(onConflictFunction);
|
|
958
959
|
}
|
|
@@ -962,7 +963,7 @@ export class DictExpr extends Expr {
|
|
|
962
963
|
return Expr.fromAst({
|
|
963
964
|
ast_type: "Builtin",
|
|
964
965
|
type: DictType(keyType, valueType),
|
|
965
|
-
location: get_location(
|
|
966
|
+
location: get_location(),
|
|
966
967
|
builtin: "DictToDict",
|
|
967
968
|
type_parameters: [this.key_type, this.value_type, keyType, valueType],
|
|
968
969
|
arguments: [this[AstSymbol], keyFnAst, valueFnAst, onConflictAst],
|
|
@@ -978,7 +979,7 @@ export class DictExpr extends Expr {
|
|
|
978
979
|
return Expr.fromAst({
|
|
979
980
|
ast_type: "Builtin",
|
|
980
981
|
type: ArrayType(elementType),
|
|
981
|
-
location: get_location(
|
|
982
|
+
location: get_location(),
|
|
982
983
|
builtin: "DictFlattenToArray",
|
|
983
984
|
type_parameters: [this.key_type, this.value_type, elementType],
|
|
984
985
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -994,7 +995,7 @@ export class DictExpr extends Expr {
|
|
|
994
995
|
return Expr.fromAst({
|
|
995
996
|
ast_type: "Builtin",
|
|
996
997
|
type: SetType(elementType),
|
|
997
|
-
location: get_location(
|
|
998
|
+
location: get_location(),
|
|
998
999
|
builtin: "DictFlattenToSet",
|
|
999
1000
|
type_parameters: [this.key_type, this.value_type, elementType],
|
|
1000
1001
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -1010,7 +1011,7 @@ export class DictExpr extends Expr {
|
|
|
1010
1011
|
const valueType = returnType.value;
|
|
1011
1012
|
let onConflictAst;
|
|
1012
1013
|
if (onConflictFn === undefined) {
|
|
1013
|
-
const location = get_location(
|
|
1014
|
+
const location = get_location();
|
|
1014
1015
|
const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`, location));
|
|
1015
1016
|
onConflictAst = Expr.ast(onConflictFunction);
|
|
1016
1017
|
}
|
|
@@ -1020,7 +1021,7 @@ export class DictExpr extends Expr {
|
|
|
1020
1021
|
return Expr.fromAst({
|
|
1021
1022
|
ast_type: "Builtin",
|
|
1022
1023
|
type: DictType(keyType, valueType),
|
|
1023
|
-
location: get_location(
|
|
1024
|
+
location: get_location(),
|
|
1024
1025
|
builtin: "DictFlattenToDict",
|
|
1025
1026
|
type_parameters: [this.key_type, this.value_type, keyType, valueType],
|
|
1026
1027
|
arguments: [this[AstSymbol], fnAst, onConflictAst],
|
|
@@ -1035,7 +1036,7 @@ export class DictExpr extends Expr {
|
|
|
1035
1036
|
return Expr.fromAst({
|
|
1036
1037
|
ast_type: "Builtin",
|
|
1037
1038
|
type: DictType(keyType, initType),
|
|
1038
|
-
location: get_location(
|
|
1039
|
+
location: get_location(),
|
|
1039
1040
|
builtin: "DictGroupFold",
|
|
1040
1041
|
type_parameters: [this.key_type, this.value_type, keyType, initType],
|
|
1041
1042
|
arguments: [this[AstSymbol], keyFnAst, initFnAst, reduceFnAst],
|
|
@@ -1239,7 +1240,7 @@ export class DictExpr extends Expr {
|
|
|
1239
1240
|
return this[FactorySymbol]({
|
|
1240
1241
|
ast_type: "Builtin",
|
|
1241
1242
|
type: returnType,
|
|
1242
|
-
location: get_location(
|
|
1243
|
+
location: get_location(),
|
|
1243
1244
|
builtin: "DictReduce",
|
|
1244
1245
|
type_parameters: [this.key_type, this.value_type, returnType],
|
|
1245
1246
|
arguments: [this[AstSymbol], fnAst, initAst],
|
|
@@ -1252,7 +1253,7 @@ export class DictExpr extends Expr {
|
|
|
1252
1253
|
return this[FactorySymbol]({
|
|
1253
1254
|
ast_type: "Builtin",
|
|
1254
1255
|
type: mapType,
|
|
1255
|
-
location: get_location(
|
|
1256
|
+
location: get_location(),
|
|
1256
1257
|
builtin: "DictMapReduce",
|
|
1257
1258
|
type_parameters: [this.key_type, this.value_type, mapType],
|
|
1258
1259
|
arguments: [this[AstSymbol], mapAst, combineAst],
|
|
@@ -1271,7 +1272,7 @@ export class DictExpr extends Expr {
|
|
|
1271
1272
|
return Expr.fromAst({
|
|
1272
1273
|
ast_type: "Builtin",
|
|
1273
1274
|
type: returnType,
|
|
1274
|
-
location: get_location(
|
|
1275
|
+
location: get_location(),
|
|
1275
1276
|
builtin: "DictFirstMap",
|
|
1276
1277
|
type_parameters: [this.key_type, this.value_type, someType],
|
|
1277
1278
|
arguments: [this[AstSymbol], fnAst],
|
|
@@ -1313,20 +1314,20 @@ export class DictExpr extends Expr {
|
|
|
1313
1314
|
const valueParam = {
|
|
1314
1315
|
ast_type: "Variable",
|
|
1315
1316
|
type: this.value_type,
|
|
1316
|
-
location: get_location(
|
|
1317
|
+
location: get_location(),
|
|
1317
1318
|
mutable: false,
|
|
1318
1319
|
};
|
|
1319
1320
|
const keyParam = {
|
|
1320
1321
|
ast_type: "Variable",
|
|
1321
1322
|
type: this.key_type,
|
|
1322
|
-
location: get_location(
|
|
1323
|
+
location: get_location(),
|
|
1323
1324
|
mutable: false,
|
|
1324
1325
|
};
|
|
1325
1326
|
// Check if boolean value is NOT true, then return some(null) to stop, otherwise return none to continue
|
|
1326
1327
|
const notCondition = {
|
|
1327
1328
|
ast_type: "Builtin",
|
|
1328
1329
|
type: BooleanType,
|
|
1329
|
-
location: get_location(
|
|
1330
|
+
location: get_location(),
|
|
1330
1331
|
builtin: "BooleanNot",
|
|
1331
1332
|
type_parameters: [],
|
|
1332
1333
|
arguments: [valueParam]
|
|
@@ -1334,23 +1335,23 @@ export class DictExpr extends Expr {
|
|
|
1334
1335
|
const checkFnAst = {
|
|
1335
1336
|
ast_type: "Function",
|
|
1336
1337
|
type: FunctionType([this.value_type, this.key_type], optionType),
|
|
1337
|
-
location: get_location(
|
|
1338
|
+
location: get_location(),
|
|
1338
1339
|
parameters: [valueParam, keyParam],
|
|
1339
1340
|
body: {
|
|
1340
1341
|
ast_type: "IfElse",
|
|
1341
1342
|
type: optionType,
|
|
1342
|
-
location: get_location(
|
|
1343
|
+
location: get_location(),
|
|
1343
1344
|
ifs: [{
|
|
1344
1345
|
predicate: notCondition,
|
|
1345
|
-
body: { ast_type: "Variant", type: optionType, location: get_location(
|
|
1346
|
+
body: { ast_type: "Variant", type: optionType, location: get_location(), case: "some", value: { ast_type: "Value", type: NullType, location: get_location(), value: null } }
|
|
1346
1347
|
}],
|
|
1347
|
-
else_body: { ast_type: "Variant", type: optionType, location: get_location(
|
|
1348
|
+
else_body: { ast_type: "Variant", type: optionType, location: get_location(), case: "none", value: { ast_type: "Value", type: NullType, location: get_location(), value: null } }
|
|
1348
1349
|
}
|
|
1349
1350
|
};
|
|
1350
1351
|
const result = Expr.fromAst({
|
|
1351
1352
|
ast_type: "Builtin",
|
|
1352
1353
|
type: optionType,
|
|
1353
|
-
location: get_location(
|
|
1354
|
+
location: get_location(),
|
|
1354
1355
|
builtin: "DictFirstMap",
|
|
1355
1356
|
type_parameters: [this.key_type, this.value_type, NullType],
|
|
1356
1357
|
arguments: [this[AstSymbol], checkFnAst],
|
|
@@ -1400,36 +1401,36 @@ export class DictExpr extends Expr {
|
|
|
1400
1401
|
const valueParam = {
|
|
1401
1402
|
ast_type: "Variable",
|
|
1402
1403
|
type: this.value_type,
|
|
1403
|
-
location: get_location(
|
|
1404
|
+
location: get_location(),
|
|
1404
1405
|
mutable: false,
|
|
1405
1406
|
};
|
|
1406
1407
|
const keyParam = {
|
|
1407
1408
|
ast_type: "Variable",
|
|
1408
1409
|
type: this.key_type,
|
|
1409
|
-
location: get_location(
|
|
1410
|
+
location: get_location(),
|
|
1410
1411
|
mutable: false,
|
|
1411
1412
|
};
|
|
1412
1413
|
// Check if boolean value is true, then return some(null) to stop, otherwise return none to continue
|
|
1413
1414
|
const checkFnAst = {
|
|
1414
1415
|
ast_type: "Function",
|
|
1415
1416
|
type: FunctionType([this.value_type, this.key_type], optionType),
|
|
1416
|
-
location: get_location(
|
|
1417
|
+
location: get_location(),
|
|
1417
1418
|
parameters: [valueParam, keyParam],
|
|
1418
1419
|
body: {
|
|
1419
1420
|
ast_type: "IfElse",
|
|
1420
1421
|
type: optionType,
|
|
1421
|
-
location: get_location(
|
|
1422
|
+
location: get_location(),
|
|
1422
1423
|
ifs: [{
|
|
1423
1424
|
predicate: valueParam,
|
|
1424
|
-
body: { ast_type: "Variant", type: optionType, location: get_location(
|
|
1425
|
+
body: { ast_type: "Variant", type: optionType, location: get_location(), case: "some", value: { ast_type: "Value", type: NullType, location: get_location(), value: null } }
|
|
1425
1426
|
}],
|
|
1426
|
-
else_body: { ast_type: "Variant", type: optionType, location: get_location(
|
|
1427
|
+
else_body: { ast_type: "Variant", type: optionType, location: get_location(), case: "none", value: { ast_type: "Value", type: NullType, location: get_location(), value: null } }
|
|
1427
1428
|
}
|
|
1428
1429
|
};
|
|
1429
1430
|
const result = Expr.fromAst({
|
|
1430
1431
|
ast_type: "Builtin",
|
|
1431
1432
|
type: optionType,
|
|
1432
|
-
location: get_location(
|
|
1433
|
+
location: get_location(),
|
|
1433
1434
|
builtin: "DictFirstMap",
|
|
1434
1435
|
type_parameters: [this.key_type, this.value_type, NullType],
|
|
1435
1436
|
arguments: [this[AstSymbol], checkFnAst],
|
|
@@ -1488,5 +1489,54 @@ export class DictExpr extends Expr {
|
|
|
1488
1489
|
}
|
|
1489
1490
|
}
|
|
1490
1491
|
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Checks if this dictionary equals another dictionary (same key-value pairs).
|
|
1494
|
+
*
|
|
1495
|
+
* @param other - The dictionary to compare against
|
|
1496
|
+
* @returns A BooleanExpr that is true if the dictionaries are equal
|
|
1497
|
+
*
|
|
1498
|
+
* @example
|
|
1499
|
+
* ```ts
|
|
1500
|
+
* const isEqual = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], BooleanType, ($, a, b) => {
|
|
1501
|
+
* $.return(a.equals(b));
|
|
1502
|
+
* });
|
|
1503
|
+
* const compiled = East.compile(isEqual.toIR(), []);
|
|
1504
|
+
* compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["a", 1n], ["b", 2n]])); // true
|
|
1505
|
+
* compiled(new Map([["a", 1n]]), new Map([["a", 1n], ["b", 2n]])); // false
|
|
1506
|
+
* ```
|
|
1507
|
+
*/
|
|
1508
|
+
equals(other) {
|
|
1509
|
+
return equal(this, other);
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Checks if this dictionary does not equal another dictionary.
|
|
1513
|
+
*
|
|
1514
|
+
* @param other - The dictionary to compare against
|
|
1515
|
+
* @returns A BooleanExpr that is true if the dictionaries are not equal
|
|
1516
|
+
*
|
|
1517
|
+
* @example
|
|
1518
|
+
* ```ts
|
|
1519
|
+
* const isNotEqual = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], BooleanType, ($, a, b) => {
|
|
1520
|
+
* $.return(a.notEquals(b));
|
|
1521
|
+
* });
|
|
1522
|
+
* const compiled = East.compile(isNotEqual.toIR(), []);
|
|
1523
|
+
* compiled(new Map([["a", 1n]]), new Map([["a", 1n], ["b", 2n]])); // true
|
|
1524
|
+
* compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["a", 1n], ["b", 2n]])); // false
|
|
1525
|
+
* ```
|
|
1526
|
+
*/
|
|
1527
|
+
notEquals(other) {
|
|
1528
|
+
return notEqual(this, other);
|
|
1529
|
+
}
|
|
1530
|
+
// ============================================================================
|
|
1531
|
+
// Aliases for comparison operations
|
|
1532
|
+
// ============================================================================
|
|
1533
|
+
/** Alias for {@link equals} */
|
|
1534
|
+
eq = this.equals;
|
|
1535
|
+
/** Alias for {@link equals} */
|
|
1536
|
+
equal = this.equals;
|
|
1537
|
+
/** Alias for {@link notEquals} */
|
|
1538
|
+
ne = this.notEquals;
|
|
1539
|
+
/** Alias for {@link notEquals} */
|
|
1540
|
+
notEqual = this.notEquals;
|
|
1491
1541
|
}
|
|
1492
1542
|
//# sourceMappingURL=dict.js.map
|