@dhis2/expression-parser 1.3.1 → 1.4.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.
@@ -352,7 +352,7 @@
352
352
  function addFormatStructureForTime(structure) {
353
353
  this.ik(structure);
354
354
  }
355
- initMetadataForInterface(AbstractWithDateTimeBuilder, 'AbstractWithDateTimeBuilder', VOID, VOID, [AbstractWithDateBuilder, AbstractWithTimeBuilder, WithDate, WithTime]);
355
+ initMetadataForInterface(AbstractWithDateTimeBuilder, 'AbstractWithDateTimeBuilder', VOID, VOID, [AbstractWithDateBuilder, AbstractWithTimeBuilder, WithTime, WithDate]);
356
356
  initMetadataForClass(Builder_0, 'Builder', VOID, VOID, [AbstractDateTimeFormatBuilder, AbstractWithDateTimeBuilder]);
357
357
  initMetadataForClass(LocalDateTimeFormat, 'LocalDateTimeFormat', VOID, AbstractDateTimeFormat);
358
358
  function set_fractionOfSecond(value) {
@@ -23,6 +23,7 @@
23
23
  var numberToDouble = kotlin_kotlin.$_$.w6;
24
24
  var isNaN_0 = kotlin_kotlin.$_$.u9;
25
25
  var isInfinite = kotlin_kotlin.$_$.t9;
26
+ var Exception = kotlin_kotlin.$_$.c9;
26
27
  var Long = kotlin_kotlin.$_$.e9;
27
28
  var RoundingMode_ROUND_HALF_AWAY_FROM_ZERO_getInstance = kotlin_com_ionspin_kotlin_bignum.$_$.b;
28
29
  var DecimalMode = kotlin_com_ionspin_kotlin_bignum.$_$.a;
@@ -61,7 +62,6 @@
61
62
  var numberToChar = kotlin_kotlin.$_$.v6;
62
63
  var toBoolean = kotlin_kotlin.$_$.p8;
63
64
  var toDouble = kotlin_kotlin.$_$.r8;
64
- var Exception = kotlin_kotlin.$_$.c9;
65
65
  var getKClassFromExpression = kotlin_kotlin.$_$.j7;
66
66
  var toMutableList = kotlin_kotlin.$_$.p4;
67
67
  var THROW_CCE = kotlin_kotlin.$_$.h9;
@@ -618,7 +618,7 @@
618
618
  return tmp;
619
619
  }
620
620
  function d2_modulus(left, right) {
621
- return numberToDouble(Companion_getInstance_3().a1d(left, right));
621
+ return numberToDouble(Companion_getInstance_3().b1d(left, right));
622
622
  }
623
623
  function d2_monthsBetween(start, end) {
624
624
  // Inline function 'kotlin.require' call
@@ -1466,6 +1466,22 @@
1466
1466
  var d = numberToDouble(n);
1467
1467
  return isNaN_0(d) || isInfinite(d);
1468
1468
  }
1469
+ function tryToNumber($this, value) {
1470
+ var tmp;
1471
+ try {
1472
+ tmp = Companion_instance_7.q1c(value);
1473
+ } catch ($p) {
1474
+ var tmp_0;
1475
+ if ($p instanceof Exception) {
1476
+ var _unused_var__etf5q3 = $p;
1477
+ tmp_0 = null;
1478
+ } else {
1479
+ throw $p;
1480
+ }
1481
+ tmp = tmp_0;
1482
+ }
1483
+ return tmp;
1484
+ }
1469
1485
  var BinaryOperator_EXP_instance;
1470
1486
  var BinaryOperator_MUL_instance;
1471
1487
  var BinaryOperator_DIV_instance;
@@ -1484,7 +1500,7 @@
1484
1500
  Companion_instance = this;
1485
1501
  this.p1c_1 = new DecimalMode(new Long(16, 0), RoundingMode_ROUND_HALF_AWAY_FROM_ZERO_getInstance());
1486
1502
  }
1487
- protoOf(Companion).q1c = function (symbol) {
1503
+ protoOf(Companion).r1c = function (symbol) {
1488
1504
  var tmp;
1489
1505
  switch (symbol) {
1490
1506
  case 'and':
@@ -1501,7 +1517,7 @@
1501
1517
  var _iterator__ex2g4s = tmp0.l();
1502
1518
  while (_iterator__ex2g4s.m()) {
1503
1519
  var element = _iterator__ex2g4s.n();
1504
- if (element.t1c_1 === symbol) {
1520
+ if (element.u1c_1 === symbol) {
1505
1521
  tmp$ret$1 = element;
1506
1522
  break $l$block;
1507
1523
  }
@@ -1514,7 +1530,7 @@
1514
1530
  }
1515
1531
  return tmp;
1516
1532
  };
1517
- protoOf(Companion).w1c = function (left, right) {
1533
+ protoOf(Companion).x1c = function (left, right) {
1518
1534
  // Inline function 'kotlin.require' call
1519
1535
  if (!!(left == null)) {
1520
1536
  var message = 'left operator of addition must not be null';
@@ -1527,7 +1543,7 @@
1527
1543
  }
1528
1544
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) ? numberToDouble(left) + numberToDouble(right) : asBigDecimal(this, left).fz(asBigDecimal(this, right)).b10(false);
1529
1545
  };
1530
- protoOf(Companion).x1c = function (left, right) {
1546
+ protoOf(Companion).y1c = function (left, right) {
1531
1547
  // Inline function 'kotlin.require' call
1532
1548
  if (!!(left == null)) {
1533
1549
  var message = 'left operator of subtraction must not be null';
@@ -1540,7 +1556,7 @@
1540
1556
  }
1541
1557
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) ? numberToDouble(left) - numberToDouble(right) : asBigDecimal(this, left).hz(asBigDecimal(this, right)).b10(false);
1542
1558
  };
1543
- protoOf(Companion).y1c = function (left, right) {
1559
+ protoOf(Companion).z1c = function (left, right) {
1544
1560
  // Inline function 'kotlin.require' call
1545
1561
  if (!!(left == null)) {
1546
1562
  var message = 'left operator of multiplication must not be null';
@@ -1553,7 +1569,7 @@
1553
1569
  }
1554
1570
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) ? numberToDouble(left) * numberToDouble(right) : asBigDecimal(this, left).jz(asBigDecimal(this, right)).b10(false);
1555
1571
  };
1556
- protoOf(Companion).z1c = function (left, right) {
1572
+ protoOf(Companion).a1d = function (left, right) {
1557
1573
  // Inline function 'kotlin.require' call
1558
1574
  if (!!(left == null)) {
1559
1575
  var message = 'left operator of division must not be null';
@@ -1566,7 +1582,7 @@
1566
1582
  }
1567
1583
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) || numberToDouble(right) === 0.0 ? numberToDouble(left) / numberToDouble(right) : asBigDecimal(this, left).lz(asBigDecimal(this, right)).b10(false);
1568
1584
  };
1569
- protoOf(Companion).a1d = function (left, right) {
1585
+ protoOf(Companion).b1d = function (left, right) {
1570
1586
  // Inline function 'kotlin.require' call
1571
1587
  if (!!(left == null)) {
1572
1588
  var message = 'left operator of modulo must not be null';
@@ -1579,7 +1595,7 @@
1579
1595
  }
1580
1596
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) || numberToDouble(right) === 0.0 ? numberToDouble(left) % numberToDouble(right) : Companion_getInstance().ky(numberToDouble(left)).nz(Companion_getInstance().ky(numberToDouble(right))).b10(false);
1581
1597
  };
1582
- protoOf(Companion).b1d = function (base, exponent) {
1598
+ protoOf(Companion).c1d = function (base, exponent) {
1583
1599
  // Inline function 'kotlin.require' call
1584
1600
  if (!!(base == null)) {
1585
1601
  var message = 'base operator of exponential function must not be null';
@@ -1601,17 +1617,17 @@
1601
1617
  }
1602
1618
  return tmp;
1603
1619
  };
1604
- protoOf(Companion).c1d = function (left, right) {
1620
+ protoOf(Companion).d1d = function (left, right) {
1605
1621
  if (left == null)
1606
1622
  return right === true ? true : null;
1607
1623
  if (right == null)
1608
1624
  return left === true ? true : null;
1609
1625
  return left || right;
1610
1626
  };
1611
- protoOf(Companion).d1d = function (left, right) {
1627
+ protoOf(Companion).e1d = function (left, right) {
1612
1628
  return left == null || right == null ? null : left && right;
1613
1629
  };
1614
- protoOf(Companion).e1d = function (left, right) {
1630
+ protoOf(Companion).f1d = function (left, right) {
1615
1631
  var tmp;
1616
1632
  var tmp_0;
1617
1633
  if (!(left == null) ? typeof left === 'string' : false) {
@@ -1622,7 +1638,7 @@
1622
1638
  if (tmp_0) {
1623
1639
  tmp = compareTo(left, right) < 0;
1624
1640
  } else {
1625
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) < ensureNotNull(Companion_instance_7.f1d(right));
1641
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) < ensureNotNull(Companion_instance_7.q1c(right));
1626
1642
  }
1627
1643
  return tmp;
1628
1644
  };
@@ -1637,7 +1653,7 @@
1637
1653
  if (tmp_0) {
1638
1654
  tmp = compareTo(left, right) <= 0;
1639
1655
  } else {
1640
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) <= ensureNotNull(Companion_instance_7.f1d(right));
1656
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) <= ensureNotNull(Companion_instance_7.q1c(right));
1641
1657
  }
1642
1658
  return tmp;
1643
1659
  };
@@ -1652,7 +1668,7 @@
1652
1668
  if (tmp_0) {
1653
1669
  tmp = compareTo(left, right) > 0;
1654
1670
  } else {
1655
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) > ensureNotNull(Companion_instance_7.f1d(right));
1671
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) > ensureNotNull(Companion_instance_7.q1c(right));
1656
1672
  }
1657
1673
  return tmp;
1658
1674
  };
@@ -1667,7 +1683,7 @@
1667
1683
  if (tmp_0) {
1668
1684
  tmp = compareTo(left, right) >= 0;
1669
1685
  } else {
1670
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) >= ensureNotNull(Companion_instance_7.f1d(right));
1686
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) >= ensureNotNull(Companion_instance_7.q1c(right));
1671
1687
  }
1672
1688
  return tmp;
1673
1689
  };
@@ -1676,27 +1692,43 @@
1676
1692
  return left == null && right == null;
1677
1693
  }
1678
1694
  var tmp;
1679
- if (typeof left === 'boolean') {
1695
+ if (isNumber(left)) {
1680
1696
  tmp = true;
1681
1697
  } else {
1682
- tmp = typeof right === 'boolean';
1698
+ tmp = isNumber(right);
1683
1699
  }
1684
1700
  if (tmp) {
1685
- return Companion_instance_7.k1d(left) == Companion_instance_7.k1d(right);
1701
+ var tmp0_elvis_lhs = tryToNumber(this, left);
1702
+ var tmp_0;
1703
+ if (tmp0_elvis_lhs == null) {
1704
+ return false;
1705
+ } else {
1706
+ tmp_0 = tmp0_elvis_lhs;
1707
+ }
1708
+ var leftNum = tmp_0;
1709
+ var tmp1_elvis_lhs = tryToNumber(this, right);
1710
+ var tmp_1;
1711
+ if (tmp1_elvis_lhs == null) {
1712
+ return false;
1713
+ } else {
1714
+ tmp_1 = tmp1_elvis_lhs;
1715
+ }
1716
+ var rightNum = tmp_1;
1717
+ return leftNum === rightNum;
1686
1718
  }
1687
- var tmp_0;
1688
- var tmp_1;
1689
- if (isNumber(left)) {
1690
- tmp_1 = true;
1719
+ var tmp_2;
1720
+ var tmp_3;
1721
+ if (typeof left === 'boolean') {
1722
+ tmp_3 = true;
1691
1723
  } else {
1692
- tmp_1 = isNumber(right);
1724
+ tmp_3 = typeof right === 'boolean';
1693
1725
  }
1694
- if (tmp_1) {
1695
- tmp_0 = Companion_instance_7.f1d(left) == Companion_instance_7.f1d(right);
1726
+ if (tmp_3) {
1727
+ tmp_2 = Companion_instance_7.k1d(left) == Companion_instance_7.k1d(right);
1696
1728
  } else {
1697
- tmp_0 = equals(left, right);
1729
+ tmp_2 = equals(left, right);
1698
1730
  }
1699
- return tmp_0;
1731
+ return tmp_2;
1700
1732
  };
1701
1733
  protoOf(Companion).l1d = function (left, right) {
1702
1734
  return !this.j1d(left, right);
@@ -1740,12 +1772,12 @@
1740
1772
  var $ENTRIES_0;
1741
1773
  function BinaryOperator(name, ordinal, symbol, returnType, operandsType) {
1742
1774
  Enum.call(this, name, ordinal);
1743
- this.t1c_1 = symbol;
1744
- this.u1c_1 = returnType;
1745
- this.v1c_1 = operandsType;
1775
+ this.u1c_1 = symbol;
1776
+ this.v1c_1 = returnType;
1777
+ this.w1c_1 = operandsType;
1746
1778
  }
1747
1779
  protoOf(BinaryOperator).m1d = function () {
1748
- return this.u1c_1;
1780
+ return this.v1c_1;
1749
1781
  };
1750
1782
  function BinaryOperator_EXP_getInstance() {
1751
1783
  BinaryOperator_initEntries();
@@ -2926,7 +2958,7 @@
2926
2958
  }
2927
2959
  function VariableType$Companion$fromSymbol$ref(p0) {
2928
2960
  var l = function (_this__u8e3s4) {
2929
- return p0.q1c(_this__u8e3s4);
2961
+ return p0.r1c(_this__u8e3s4);
2930
2962
  };
2931
2963
  l.callableName = 'fromSymbol';
2932
2964
  return l;
@@ -3029,7 +3061,7 @@
3029
3061
  }
3030
3062
  function UnaryOperator$Companion$fromSymbol$ref(p0) {
3031
3063
  var l = function (_this__u8e3s4) {
3032
- return p0.q1c(_this__u8e3s4);
3064
+ return p0.r1c(_this__u8e3s4);
3033
3065
  };
3034
3066
  l.callableName = 'fromSymbol';
3035
3067
  return l;
@@ -3041,14 +3073,14 @@
3041
3073
  }
3042
3074
  function BinaryOperator$Companion$fromSymbol$ref(p0) {
3043
3075
  var l = function (_this__u8e3s4) {
3044
- return p0.q1c(_this__u8e3s4);
3076
+ return p0.r1c(_this__u8e3s4);
3045
3077
  };
3046
3078
  l.callableName = 'fromSymbol';
3047
3079
  return l;
3048
3080
  }
3049
3081
  function BinaryOperator$_get_symbol_$ref_w802f3() {
3050
3082
  return function (p0) {
3051
- return p0.t1c_1;
3083
+ return p0.u1c_1;
3052
3084
  };
3053
3085
  }
3054
3086
  function toBoolean$ref() {
@@ -3835,11 +3867,11 @@
3835
3867
  }
3836
3868
  function Companion_7() {
3837
3869
  }
3838
- protoOf(Companion_7).f1d = function (value) {
3870
+ protoOf(Companion_7).q1c = function (value) {
3839
3871
  if (value == null)
3840
3872
  return null;
3841
3873
  if (value instanceof VariableValue)
3842
- return this.f1d(this.l1l(value));
3874
+ return this.q1c(this.l1l(value));
3843
3875
  if (typeof value === 'boolean')
3844
3876
  return equals(value, true) ? 1.0 : 0.0;
3845
3877
  if (value instanceof LocalDate)
@@ -3894,7 +3926,7 @@
3894
3926
  if (value instanceof VariableValue) {
3895
3927
  switch (value.o1l_1.d2_1) {
3896
3928
  case 1:
3897
- tmp = this.f1d(value.s1l());
3929
+ tmp = this.q1c(value.s1l());
3898
3930
  break;
3899
3931
  case 2:
3900
3932
  tmp = this.k1d(value.s1l());
@@ -3921,7 +3953,7 @@
3921
3953
  var UnaryOperator_DISTINCT_instance;
3922
3954
  function Companion_8() {
3923
3955
  }
3924
- protoOf(Companion_8).q1c = function (symbol) {
3956
+ protoOf(Companion_8).r1c = function (symbol) {
3925
3957
  var tmp;
3926
3958
  if ('not' === symbol) {
3927
3959
  tmp = UnaryOperator_NOT_getInstance();
@@ -4001,7 +4033,7 @@
4001
4033
  var VariableType_PROGRAM_RULE_instance;
4002
4034
  function Companion_9() {
4003
4035
  }
4004
- protoOf(Companion_9).q1c = function (symbol) {
4036
+ protoOf(Companion_9).r1c = function (symbol) {
4005
4037
  return 'V' === symbol ? VariableType_PROGRAM_getInstance() : VariableType_PROGRAM_RULE_getInstance();
4006
4038
  };
4007
4039
  var Companion_instance_9;
@@ -4404,7 +4436,7 @@
4404
4436
  }
4405
4437
  function BinaryOperator$Companion$and$ref(p0) {
4406
4438
  var l = function (_this__u8e3s4, p0_0) {
4407
- return p0.d1d(_this__u8e3s4, p0_0);
4439
+ return p0.e1d(_this__u8e3s4, p0_0);
4408
4440
  };
4409
4441
  l.callableName = 'and';
4410
4442
  return l;
@@ -4418,7 +4450,7 @@
4418
4450
  }
4419
4451
  function BinaryOperator$Companion$or$ref(p0) {
4420
4452
  var l = function (_this__u8e3s4, p0_0) {
4421
- return p0.c1d(_this__u8e3s4, p0_0);
4453
+ return p0.d1d(_this__u8e3s4, p0_0);
4422
4454
  };
4423
4455
  l.callableName = 'or';
4424
4456
  return l;
@@ -4432,7 +4464,7 @@
4432
4464
  }
4433
4465
  function BinaryOperator$Companion$lessThan$ref(p0) {
4434
4466
  var l = function (_this__u8e3s4, p0_0) {
4435
- return p0.e1d(_this__u8e3s4, p0_0);
4467
+ return p0.f1d(_this__u8e3s4, p0_0);
4436
4468
  };
4437
4469
  l.callableName = 'lessThan';
4438
4470
  return l;
@@ -4492,7 +4524,7 @@
4492
4524
  }
4493
4525
  function BinaryOperator$Companion$add$ref(p0) {
4494
4526
  var l = function (_this__u8e3s4, p0_0) {
4495
- return p0.w1c(_this__u8e3s4, p0_0);
4527
+ return p0.x1c(_this__u8e3s4, p0_0);
4496
4528
  };
4497
4529
  l.callableName = 'add';
4498
4530
  return l;
@@ -4506,7 +4538,7 @@
4506
4538
  }
4507
4539
  function BinaryOperator$Companion$subtract$ref(p0) {
4508
4540
  var l = function (_this__u8e3s4, p0_0) {
4509
- return p0.x1c(_this__u8e3s4, p0_0);
4541
+ return p0.y1c(_this__u8e3s4, p0_0);
4510
4542
  };
4511
4543
  l.callableName = 'subtract';
4512
4544
  return l;
@@ -4520,7 +4552,7 @@
4520
4552
  }
4521
4553
  function BinaryOperator$Companion$multiply$ref(p0) {
4522
4554
  var l = function (_this__u8e3s4, p0_0) {
4523
- return p0.y1c(_this__u8e3s4, p0_0);
4555
+ return p0.z1c(_this__u8e3s4, p0_0);
4524
4556
  };
4525
4557
  l.callableName = 'multiply';
4526
4558
  return l;
@@ -4534,7 +4566,7 @@
4534
4566
  }
4535
4567
  function BinaryOperator$Companion$divide$ref(p0) {
4536
4568
  var l = function (_this__u8e3s4, p0_0) {
4537
- return p0.z1c(_this__u8e3s4, p0_0);
4569
+ return p0.a1d(_this__u8e3s4, p0_0);
4538
4570
  };
4539
4571
  l.callableName = 'divide';
4540
4572
  return l;
@@ -4548,7 +4580,7 @@
4548
4580
  }
4549
4581
  function BinaryOperator$Companion$modulo$ref(p0) {
4550
4582
  var l = function (_this__u8e3s4, p0_0) {
4551
- return p0.a1d(_this__u8e3s4, p0_0);
4583
+ return p0.b1d(_this__u8e3s4, p0_0);
4552
4584
  };
4553
4585
  l.callableName = 'modulo';
4554
4586
  return l;
@@ -4562,7 +4594,7 @@
4562
4594
  }
4563
4595
  function BinaryOperator$Companion$exp$ref(p0) {
4564
4596
  var l = function (_this__u8e3s4, p0_0) {
4565
- return p0.b1d(_this__u8e3s4, p0_0);
4597
+ return p0.c1d(_this__u8e3s4, p0_0);
4566
4598
  };
4567
4599
  l.callableName = 'exp';
4568
4600
  return l;
@@ -4607,7 +4639,7 @@
4607
4639
  }
4608
4640
  function Typed$Companion$toNumberTypeCoercion$ref(p0) {
4609
4641
  var l = function (_this__u8e3s4) {
4610
- return p0.f1d(_this__u8e3s4);
4642
+ return p0.q1c(_this__u8e3s4);
4611
4643
  };
4612
4644
  l.callableName = 'toNumberTypeCoercion';
4613
4645
  return l;
@@ -5481,7 +5513,7 @@
5481
5513
  return type === NodeType_BINARY_OPERATOR_getInstance() && isStaticallyDefined($this, node.p1e(0)) && isStaticallyDefined($this, node.p1e(1));
5482
5514
  }
5483
5515
  function checkBinaryOperatorOperand($this, operator, operand, name) {
5484
- var expected = operator.e1e().v1c_1;
5516
+ var expected = operator.e1e().w1c_1;
5485
5517
  var leftActual = operand.m1d();
5486
5518
  if (!leftActual.isAssignableTo(expected)) {
5487
5519
  if (isStaticallyDefined(Companion_instance_13, operand)) {