@ball-lang/engine 1.5.4 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiled_engine.d.ts.map +1 -1
- package/dist/compiled_engine.js +147 -101
- package/dist/compiled_engine.js.map +1 -1
- package/package.json +1 -1
- package/src/compiled_engine.ts +136 -97
package/src/compiled_engine.ts
CHANGED
|
@@ -120,8 +120,14 @@ class BallDouble {
|
|
|
120
120
|
|
|
121
121
|
// Arithmetic helpers that propagate BallDouble through operations.
|
|
122
122
|
// If either operand is BallDouble, the result is BallDouble (preserving .0).
|
|
123
|
+
//
|
|
124
|
+
// Operator-overload dispatch checks for __op_X__ methods (TRAILING double
|
|
125
|
+
// underscore) — this MUST match the Dart encoder's canonical operator naming
|
|
126
|
+
// (_canonicalOperatorName in dart/encoder/lib/encoder.dart), which always
|
|
127
|
+
// emits a trailing __. A single-underscore lookup (__op_mul) never matches,
|
|
128
|
+
// so overloaded operators silently fall through to raw JS arithmetic (#205).
|
|
123
129
|
function __ball_mul(a: any, b: any): any {
|
|
124
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
130
|
+
if (a != null && typeof a === 'object' && typeof a.__op_mul__ === 'function') return a.__op_mul__(b);
|
|
125
131
|
if (typeof a === 'bigint' || typeof b === 'bigint') return __i64_wrap(__to_bigint(a) * __to_bigint(b));
|
|
126
132
|
const av = a instanceof BallDouble ? a.value : a;
|
|
127
133
|
const bv = b instanceof BallDouble ? b.value : b;
|
|
@@ -129,7 +135,7 @@ function __ball_mul(a: any, b: any): any {
|
|
|
129
135
|
return (a instanceof BallDouble || b instanceof BallDouble) ? new BallDouble(r) : r;
|
|
130
136
|
}
|
|
131
137
|
function __ball_add(a: any, b: any): any {
|
|
132
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
138
|
+
if (a != null && typeof a === 'object' && typeof a.__op_add__ === 'function') return a.__op_add__(b);
|
|
133
139
|
if (typeof a === 'bigint' || typeof b === 'bigint') return __i64_wrap(__to_bigint(a) + __to_bigint(b));
|
|
134
140
|
const av = a instanceof BallDouble ? a.value : a;
|
|
135
141
|
const bv = b instanceof BallDouble ? b.value : b;
|
|
@@ -137,7 +143,7 @@ function __ball_add(a: any, b: any): any {
|
|
|
137
143
|
return (a instanceof BallDouble || b instanceof BallDouble) ? new BallDouble(r) : r;
|
|
138
144
|
}
|
|
139
145
|
function __ball_sub(a: any, b: any): any {
|
|
140
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
146
|
+
if (a != null && typeof a === 'object' && typeof a.__op_sub__ === 'function') return a.__op_sub__(b);
|
|
141
147
|
if (typeof a === 'bigint' || typeof b === 'bigint') return __i64_wrap(__to_bigint(a) - __to_bigint(b));
|
|
142
148
|
const av = a instanceof BallDouble ? a.value : a;
|
|
143
149
|
const bv = b instanceof BallDouble ? b.value : b;
|
|
@@ -147,7 +153,7 @@ function __ball_sub(a: any, b: any): any {
|
|
|
147
153
|
|
|
148
154
|
// Dart equality: NaN != NaN, BallDouble value comparison, null == undefined.
|
|
149
155
|
function __ball_eq(a: any, b: any): boolean {
|
|
150
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
156
|
+
if (a != null && typeof a === 'object' && typeof a.__op_eq__ === 'function') return a.__op_eq__(b);
|
|
151
157
|
if (typeof a === 'bigint' || typeof b === 'bigint') {
|
|
152
158
|
if (typeof a === 'bigint' && typeof b === 'bigint') return a === b;
|
|
153
159
|
if (typeof a === 'bigint' && typeof b === 'number') return a === BigInt(b);
|
|
@@ -165,6 +171,39 @@ function __ball_eq(a: any, b: any): boolean {
|
|
|
165
171
|
return a === b;
|
|
166
172
|
}
|
|
167
173
|
|
|
174
|
+
// Relational operator-overload dispatch (less-than/greater-than/etc.),
|
|
175
|
+
// matching the __op_add__-style convention above. Unlike arithmetic,
|
|
176
|
+
// relational comparisons had NO overload attempt at all before #205 — every
|
|
177
|
+
// overloaded Vec2 < x etc. compiled straight to raw JS comparison.
|
|
178
|
+
function __ball_lt(a: any, b: any): any {
|
|
179
|
+
if (a != null && typeof a === 'object' && typeof a.__op_lt__ === 'function') return a.__op_lt__(b);
|
|
180
|
+
if (typeof a === 'bigint' || typeof b === 'bigint') return __to_bigint(a) < __to_bigint(b);
|
|
181
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
182
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
183
|
+
return av < bv;
|
|
184
|
+
}
|
|
185
|
+
function __ball_gt(a: any, b: any): any {
|
|
186
|
+
if (a != null && typeof a === 'object' && typeof a.__op_gt__ === 'function') return a.__op_gt__(b);
|
|
187
|
+
if (typeof a === 'bigint' || typeof b === 'bigint') return __to_bigint(a) > __to_bigint(b);
|
|
188
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
189
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
190
|
+
return av > bv;
|
|
191
|
+
}
|
|
192
|
+
function __ball_le(a: any, b: any): any {
|
|
193
|
+
if (a != null && typeof a === 'object' && typeof a.__op_le__ === 'function') return a.__op_le__(b);
|
|
194
|
+
if (typeof a === 'bigint' || typeof b === 'bigint') return __to_bigint(a) <= __to_bigint(b);
|
|
195
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
196
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
197
|
+
return av <= bv;
|
|
198
|
+
}
|
|
199
|
+
function __ball_ge(a: any, b: any): any {
|
|
200
|
+
if (a != null && typeof a === 'object' && typeof a.__op_ge__ === 'function') return a.__op_ge__(b);
|
|
201
|
+
if (typeof a === 'bigint' || typeof b === 'bigint') return __to_bigint(a) >= __to_bigint(b);
|
|
202
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
203
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
204
|
+
return av >= bv;
|
|
205
|
+
}
|
|
206
|
+
|
|
168
207
|
function __ball_to_string(v: any): string {
|
|
169
208
|
if (v === null || v === undefined) return 'null';
|
|
170
209
|
if (typeof v === 'bigint') return v.toString();
|
|
@@ -1437,13 +1476,13 @@ export class BallEngine {
|
|
|
1437
1476
|
|
|
1438
1477
|
_validateProgramLimits(): any {
|
|
1439
1478
|
let moduleCount = this.program.modules.length;
|
|
1440
|
-
if ((moduleCount
|
|
1479
|
+
if (__ball_gt(moduleCount, this.maxModules)) {
|
|
1441
1480
|
throw new BallRuntimeError((((('Too many modules: ' + __ball_to_string(moduleCount)) + ' (max ') + __ball_to_string(this.maxModules)) + ')'));
|
|
1442
1481
|
}
|
|
1443
1482
|
let maxProgramBytes = this.maxProgramSizeBytes;
|
|
1444
1483
|
if (!__ball_eq(maxProgramBytes, null)) {
|
|
1445
1484
|
let programSizeBytes = this.program.writeToBuffer().length;
|
|
1446
|
-
if ((programSizeBytes
|
|
1485
|
+
if (__ball_gt(programSizeBytes, maxProgramBytes)) {
|
|
1447
1486
|
throw new BallRuntimeError((((('Program too large: ' + __ball_to_string(programSizeBytes)) + ' bytes (max ') + __ball_to_string(maxProgramBytes)) + ')'));
|
|
1448
1487
|
}
|
|
1449
1488
|
}
|
|
@@ -1466,7 +1505,7 @@ export class BallEngine {
|
|
|
1466
1505
|
while (!(stack.length === 0)) {
|
|
1467
1506
|
let current = stack.pop();
|
|
1468
1507
|
let depth = current.depth;
|
|
1469
|
-
if ((depth
|
|
1508
|
+
if (__ball_gt(depth, this.maxExpressionDepth)) {
|
|
1470
1509
|
throw new BallRuntimeError((((('Expression too deep: ' + __ball_to_string(depth)) + ' levels (max ') + __ball_to_string(this.maxExpressionDepth)) + ')'));
|
|
1471
1510
|
}
|
|
1472
1511
|
do {
|
|
@@ -1536,7 +1575,7 @@ export class BallEngine {
|
|
|
1536
1575
|
|
|
1537
1576
|
_checkExpressionDepth(): any {
|
|
1538
1577
|
this._expressionDepth += 1;
|
|
1539
|
-
if ((this._expressionDepth
|
|
1578
|
+
if (__ball_gt(this._expressionDepth, this.maxExpressionDepth)) {
|
|
1540
1579
|
throw new BallRuntimeError((((('Expression too deep: ' + __ball_to_string(this._expressionDepth)) + ' levels (max ') + __ball_to_string(this.maxExpressionDepth)) + ')'));
|
|
1541
1580
|
}
|
|
1542
1581
|
}
|
|
@@ -1551,7 +1590,7 @@ export class BallEngine {
|
|
|
1551
1590
|
if (hasDescriptor(td)) {
|
|
1552
1591
|
this._types[td.name] = td.descriptor;
|
|
1553
1592
|
let tc = td.name.indexOf(':');
|
|
1554
|
-
if ((tc
|
|
1593
|
+
if (__ball_ge(tc, 0)) {
|
|
1555
1594
|
this._types[td.name.substring(__ball_add(tc, 1))] = td.descriptor;
|
|
1556
1595
|
}
|
|
1557
1596
|
}
|
|
@@ -1560,14 +1599,14 @@ export class BallEngine {
|
|
|
1560
1599
|
let enumName = enumDesc.name;
|
|
1561
1600
|
let enumMap = {};
|
|
1562
1601
|
let enumValueList = enumDesc.value;
|
|
1563
|
-
for (let vi = 0; (vi
|
|
1602
|
+
for (let vi = 0; __ball_lt(vi, enumValueList.length); (vi++)) {
|
|
1564
1603
|
let v = __ball_index(enumValueList, vi);
|
|
1565
1604
|
let entry = { ['__type__']: enumName, ['name']: v.name, ['index']: v.number };
|
|
1566
1605
|
enumMap[v.name] = entry;
|
|
1567
1606
|
}
|
|
1568
1607
|
this._enumValues[enumName] = enumMap;
|
|
1569
1608
|
let ec = enumName.indexOf(':');
|
|
1570
|
-
if ((ec
|
|
1609
|
+
if (__ball_ge(ec, 0)) {
|
|
1571
1610
|
this._enumValues[enumName.substring(__ball_add(ec, 1))] = enumMap;
|
|
1572
1611
|
}
|
|
1573
1612
|
}
|
|
@@ -1603,7 +1642,7 @@ export class BallEngine {
|
|
|
1603
1642
|
if (__ball_eq((__ball_eq(kindField, null) ? null : kindField.stringValue), 'constructor')) {
|
|
1604
1643
|
let entry = { module: module.name, func: func };
|
|
1605
1644
|
let dotIdx = func.name.indexOf('.');
|
|
1606
|
-
if ((dotIdx
|
|
1645
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
1607
1646
|
let className = func.name.substring(0, dotIdx);
|
|
1608
1647
|
let ctorSuffix = func.name.substring(__ball_add(dotIdx, 1));
|
|
1609
1648
|
if (__ball_eq(ctorSuffix, 'new')) {
|
|
@@ -1639,7 +1678,7 @@ export class BallEngine {
|
|
|
1639
1678
|
}
|
|
1640
1679
|
if (__ball_eq(kind, 'static_field')) {
|
|
1641
1680
|
let dotIdx = func.name.lastIndexOf('.');
|
|
1642
|
-
if ((dotIdx
|
|
1681
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
1643
1682
|
let bareName = func.name.substring(__ball_add(dotIdx, 1));
|
|
1644
1683
|
(this._staticFieldRefs[bareName] ??= ((() => {
|
|
1645
1684
|
return { module: module.name, func: func, fullName: func.name };
|
|
@@ -1649,7 +1688,7 @@ export class BallEngine {
|
|
|
1649
1688
|
}
|
|
1650
1689
|
let funcName = func.name;
|
|
1651
1690
|
let dotIdx = funcName.lastIndexOf('.');
|
|
1652
|
-
if ((dotIdx
|
|
1691
|
+
if (__ball_lt(dotIdx, 0)) {
|
|
1653
1692
|
return;
|
|
1654
1693
|
}
|
|
1655
1694
|
let methodName = funcName.substring(__ball_add(dotIdx, 1));
|
|
@@ -1686,7 +1725,7 @@ export class BallEngine {
|
|
|
1686
1725
|
|
|
1687
1726
|
_lookupTypeMethodWithInheritance(typeName: any, methodName: any): any {
|
|
1688
1727
|
let colonIdx = typeName.indexOf(':');
|
|
1689
|
-
let modPart = ((colonIdx
|
|
1728
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
1690
1729
|
let current = typeName;
|
|
1691
1730
|
while (!(current.length === 0)) {
|
|
1692
1731
|
let direct = __ball_index(this._typeMethodDispatch, BallEngine._typeMethodKey(current, methodName));
|
|
@@ -1694,7 +1733,7 @@ export class BallEngine {
|
|
|
1694
1733
|
return direct;
|
|
1695
1734
|
}
|
|
1696
1735
|
let currentColon = current.indexOf(':');
|
|
1697
|
-
if ((currentColon
|
|
1736
|
+
if (__ball_ge(currentColon, 0)) {
|
|
1698
1737
|
let bare = current.substring(__ball_add(currentColon, 1));
|
|
1699
1738
|
let bareHit = __ball_index(this._typeMethodDispatch, BallEngine._typeMethodKey(bare, methodName));
|
|
1700
1739
|
if (!__ball_eq(bareHit, null)) {
|
|
@@ -1716,7 +1755,7 @@ export class BallEngine {
|
|
|
1716
1755
|
return mixinHit;
|
|
1717
1756
|
}
|
|
1718
1757
|
let mixinColon = qualMixin.indexOf(':');
|
|
1719
|
-
if ((mixinColon
|
|
1758
|
+
if (__ball_ge(mixinColon, 0)) {
|
|
1720
1759
|
let bareMixin = qualMixin.substring(__ball_add(mixinColon, 1));
|
|
1721
1760
|
let bareMixinHit = __ball_index(this._typeMethodDispatch, BallEngine._typeMethodKey(bareMixin, methodName));
|
|
1722
1761
|
if (!__ball_eq(bareMixinHit, null)) {
|
|
@@ -1784,7 +1823,7 @@ export class BallEngine {
|
|
|
1784
1823
|
return;
|
|
1785
1824
|
}
|
|
1786
1825
|
let elapsed = __ball_sub(DateTime.now().millisecondsSinceEpoch, start);
|
|
1787
|
-
if ((elapsed
|
|
1826
|
+
if (__ball_gt(elapsed, timeout)) {
|
|
1788
1827
|
throw new BallRuntimeError('Execution timeout exceeded');
|
|
1789
1828
|
}
|
|
1790
1829
|
}
|
|
@@ -1804,10 +1843,10 @@ export class BallEngine {
|
|
|
1804
1843
|
_trackMemoryAllocation(bytes: any): any {
|
|
1805
1844
|
const input = bytes;
|
|
1806
1845
|
let limit = this.maxMemoryBytes;
|
|
1807
|
-
if ((__ball_eq(limit, null) || (bytes
|
|
1846
|
+
if ((__ball_eq(limit, null) || __ball_le(bytes, 0))) {
|
|
1808
1847
|
return;
|
|
1809
1848
|
}
|
|
1810
|
-
if ((__ball_add(this._memoryUsedBytes, bytes)
|
|
1849
|
+
if (__ball_gt(__ball_add(this._memoryUsedBytes, bytes), limit)) {
|
|
1811
1850
|
throw new BallRuntimeError('Memory limit exceeded');
|
|
1812
1851
|
}
|
|
1813
1852
|
this._memoryUsedBytes += bytes;
|
|
@@ -1834,7 +1873,7 @@ export class BallEngine {
|
|
|
1834
1873
|
if (func.isBase) {
|
|
1835
1874
|
return this._callBaseFunction(moduleName, func.name, input);
|
|
1836
1875
|
}
|
|
1837
|
-
if ((this._recursionDepth
|
|
1876
|
+
if (__ball_ge(this._recursionDepth, this.maxRecursionDepth)) {
|
|
1838
1877
|
throw new BallRuntimeError(('Maximum recursion depth exceeded: ' + __ball_to_string(this.maxRecursionDepth)));
|
|
1839
1878
|
}
|
|
1840
1879
|
(this._recursionDepth++);
|
|
@@ -1851,7 +1890,7 @@ export class BallEngine {
|
|
|
1851
1890
|
if (__ball_eq(kind, 'constructor')) {
|
|
1852
1891
|
let constructorInput = this._asMap(input);
|
|
1853
1892
|
let dotIdx = func.name.indexOf('.');
|
|
1854
|
-
let typeName = ((dotIdx
|
|
1893
|
+
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
1855
1894
|
let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
|
|
1856
1895
|
if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in constructorInput))) && !__ball_eq(this._findTypeDef(typeName), null))) {
|
|
1857
1896
|
return this._callObjectConstructor(moduleName, func, input);
|
|
@@ -1878,7 +1917,7 @@ export class BallEngine {
|
|
|
1878
1917
|
}
|
|
1879
1918
|
} else {
|
|
1880
1919
|
if (!__ball_eq(inputMap, null)) {
|
|
1881
|
-
for (let i = 0; (i
|
|
1920
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
1882
1921
|
let p = __ball_index(params, i);
|
|
1883
1922
|
if ((p in inputMap)) {
|
|
1884
1923
|
scope.bind(p, __ball_index(inputMap, p));
|
|
@@ -1894,7 +1933,7 @@ export class BallEngine {
|
|
|
1894
1933
|
}
|
|
1895
1934
|
} else {
|
|
1896
1935
|
if (Array.isArray(input)) {
|
|
1897
|
-
for (let i = 0; ((i
|
|
1936
|
+
for (let i = 0; (__ball_lt(i, params.length) && __ball_lt(i, input.length)); (i++)) {
|
|
1898
1937
|
scope.bind(__ball_index(params, i), __ball_index(input, i));
|
|
1899
1938
|
}
|
|
1900
1939
|
}
|
|
@@ -2014,7 +2053,7 @@ export class BallEngine {
|
|
|
2014
2053
|
|
|
2015
2054
|
async _callObjectConstructor(moduleName: any, func: any, input: any): Promise<any> {
|
|
2016
2055
|
let dotIdx = func.name.indexOf('.');
|
|
2017
|
-
let typeName = ((dotIdx
|
|
2056
|
+
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
2018
2057
|
let typeDef = this._findTypeDef(typeName);
|
|
2019
2058
|
if (__ball_eq(typeDef, null)) {
|
|
2020
2059
|
return null;
|
|
@@ -2028,7 +2067,7 @@ export class BallEngine {
|
|
|
2028
2067
|
let params = (hasMetadata(func) ? this._extractParams(func.metadata) : []);
|
|
2029
2068
|
let paramsMeta = (hasMetadata(func) ? this._extractParamsMeta(func.metadata) : []);
|
|
2030
2069
|
let resolvedParams = {};
|
|
2031
|
-
for (let i = 0; (i
|
|
2070
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2032
2071
|
let param = __ball_index(params, i);
|
|
2033
2072
|
let value = __no_init__;
|
|
2034
2073
|
if ((param in inputMap)) {
|
|
@@ -2038,11 +2077,11 @@ export class BallEngine {
|
|
|
2038
2077
|
value = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
|
|
2039
2078
|
}
|
|
2040
2079
|
}
|
|
2041
|
-
if (((__ball_eq(value, null) && (i
|
|
2080
|
+
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
|
|
2042
2081
|
value = __ball_index(__ball_index(paramsMeta, i), 'default');
|
|
2043
2082
|
}
|
|
2044
2083
|
resolvedParams[param] = value;
|
|
2045
|
-
let isThis = ((i
|
|
2084
|
+
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
2046
2085
|
if ((isThis || allFieldNames.includes(param))) {
|
|
2047
2086
|
instanceFields[param] = value;
|
|
2048
2087
|
} else {
|
|
@@ -2110,7 +2149,7 @@ export class BallEngine {
|
|
|
2110
2149
|
let idx = __ball_parse_int(indexMatch.group(2));
|
|
2111
2150
|
let rawArr = __ball_index(resolvedParams, arrName);
|
|
2112
2151
|
let arr = (false /* BallList is List in TS */ ? rawArr.items : rawArr);
|
|
2113
|
-
if ((Array.isArray(arr) && (idx
|
|
2152
|
+
if ((Array.isArray(arr) && __ball_lt(idx, arr.length))) {
|
|
2114
2153
|
targetFields[name] = __ball_index(arr, idx);
|
|
2115
2154
|
} else {
|
|
2116
2155
|
targetFields[name] = null;
|
|
@@ -2151,14 +2190,14 @@ export class BallEngine {
|
|
|
2151
2190
|
let paramsMeta = this._extractParamsMeta(func.metadata);
|
|
2152
2191
|
let instance = {};
|
|
2153
2192
|
let dotIdx = func.name.indexOf('.');
|
|
2154
|
-
let typeName = ((dotIdx
|
|
2193
|
+
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
2155
2194
|
instance['__type__'] = typeName;
|
|
2156
2195
|
let resolvedParams = {};
|
|
2157
2196
|
let inputMap = this._asMap(input);
|
|
2158
2197
|
if (!__ball_eq(inputMap, null)) {
|
|
2159
|
-
for (let i = 0; (i
|
|
2198
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2160
2199
|
let p = __ball_index(params, i);
|
|
2161
|
-
let isThis = ((i
|
|
2200
|
+
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
2162
2201
|
let val = __no_init__;
|
|
2163
2202
|
if ((p in inputMap)) {
|
|
2164
2203
|
val = __ball_index(inputMap, p);
|
|
@@ -2166,7 +2205,7 @@ export class BallEngine {
|
|
|
2166
2205
|
if ((('arg' + __ball_to_string(i)) in inputMap)) {
|
|
2167
2206
|
val = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
|
|
2168
2207
|
} else {
|
|
2169
|
-
val = ((i
|
|
2208
|
+
val = (__ball_lt(i, paramsMeta.length) ? __ball_index(__ball_index(paramsMeta, i), 'default') : null);
|
|
2170
2209
|
}
|
|
2171
2210
|
}
|
|
2172
2211
|
resolvedParams[p] = val;
|
|
@@ -2234,7 +2273,7 @@ export class BallEngine {
|
|
|
2234
2273
|
})() ?? '');
|
|
2235
2274
|
let argNames = this._parseSuperArgs(argsStr);
|
|
2236
2275
|
let superInput = {};
|
|
2237
|
-
for (let i = 0; (i
|
|
2276
|
+
for (let i = 0; __ball_lt(i, argNames.length); (i++)) {
|
|
2238
2277
|
let token = __ball_index(argNames, i);
|
|
2239
2278
|
if ((token in resolvedParams)) {
|
|
2240
2279
|
superInput[('arg' + __ball_to_string(i))] = __ball_index(resolvedParams, token);
|
|
@@ -2268,7 +2307,7 @@ export class BallEngine {
|
|
|
2268
2307
|
let superCtorEntry = this._lookupConstructor(superclass);
|
|
2269
2308
|
if (!__ball_eq(superCtorEntry, null)) {
|
|
2270
2309
|
let superInput = {};
|
|
2271
|
-
for (let i = 0; (i
|
|
2310
|
+
for (let i = 0; __ball_lt(i, resolvedParams.length); (i++)) {
|
|
2272
2311
|
superInput[('arg' + __ball_to_string(i))] = resolvedParams.values.elementAt(i);
|
|
2273
2312
|
}
|
|
2274
2313
|
return this._callFunction(superCtorEntry.module, superCtorEntry.func, superInput);
|
|
@@ -2289,7 +2328,7 @@ export class BallEngine {
|
|
|
2289
2328
|
for (const entry of this._constructors.entries) {
|
|
2290
2329
|
let key = entry.key;
|
|
2291
2330
|
let colonIdx = key.indexOf(':');
|
|
2292
|
-
let bare = ((colonIdx
|
|
2331
|
+
let bare = (__ball_ge(colonIdx, 0) ? key.substring(__ball_add(colonIdx, 1)) : key);
|
|
2293
2332
|
if (__ball_eq(bare, name)) {
|
|
2294
2333
|
return entry.value;
|
|
2295
2334
|
}
|
|
@@ -2812,7 +2851,7 @@ export class BallEngine {
|
|
|
2812
2851
|
if (__ball_eq((__ball_eq(kindField, null) ? null : kindField.stringValue), 'constructor')) {
|
|
2813
2852
|
let entry = { module: module.name, func: func };
|
|
2814
2853
|
let dotIdx = func.name.indexOf('.');
|
|
2815
|
-
if ((dotIdx
|
|
2854
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
2816
2855
|
let className = func.name.substring(0, dotIdx);
|
|
2817
2856
|
let ctorSuffix = func.name.substring(__ball_add(dotIdx, 1));
|
|
2818
2857
|
if (__ball_eq(ctorSuffix, 'new')) {
|
|
@@ -3042,7 +3081,7 @@ export class BallEngine {
|
|
|
3042
3081
|
let className = __ball_index(selfMap, '__class_ref__');
|
|
3043
3082
|
let qualifiedName = (className.includes(':') ? className : ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(className)));
|
|
3044
3083
|
let colonIdx2 = qualifiedName.indexOf(':');
|
|
3045
|
-
let modPart2 = ((colonIdx2
|
|
3084
|
+
let modPart2 = (__ball_ge(colonIdx2, 0) ? qualifiedName.substring(0, colonIdx2) : this._currentModule);
|
|
3046
3085
|
let staticKey = ((((__ball_to_string(modPart2) + '.') + __ball_to_string(qualifiedName)) + '.') + __ball_to_string(call.function));
|
|
3047
3086
|
let staticFunc = __ball_index(this._functions, staticKey);
|
|
3048
3087
|
if (!__ball_eq(staticFunc, null)) {
|
|
@@ -3398,7 +3437,7 @@ export class BallEngine {
|
|
|
3398
3437
|
});
|
|
3399
3438
|
}
|
|
3400
3439
|
let colonIdx = name.indexOf(':');
|
|
3401
|
-
if ((colonIdx
|
|
3440
|
+
if (__ball_ge(colonIdx, 0)) {
|
|
3402
3441
|
let bare = name.substring(__ball_add(colonIdx, 1));
|
|
3403
3442
|
let bareEntry = __ball_index(this._constructors, bare);
|
|
3404
3443
|
if (!__ball_eq(bareEntry, null)) {
|
|
@@ -3564,7 +3603,7 @@ export class BallEngine {
|
|
|
3564
3603
|
});
|
|
3565
3604
|
}
|
|
3566
3605
|
let colonIdx = qualifiedName.indexOf(':');
|
|
3567
|
-
let modPart = ((colonIdx
|
|
3606
|
+
let modPart = (__ball_ge(colonIdx, 0) ? qualifiedName.substring(0, colonIdx) : this._currentModule);
|
|
3568
3607
|
let staticKey = ((((__ball_to_string(modPart) + '.') + __ball_to_string(qualifiedName)) + '.') + __ball_to_string(fieldName));
|
|
3569
3608
|
let staticFunc = __ball_index(this._functions, staticKey);
|
|
3570
3609
|
if (!__ball_eq(staticFunc, null)) {
|
|
@@ -3835,7 +3874,7 @@ export class BallEngine {
|
|
|
3835
3874
|
return _sentinel;
|
|
3836
3875
|
}
|
|
3837
3876
|
let colonIdx = typeName.indexOf(':');
|
|
3838
|
-
let modPart = ((colonIdx
|
|
3877
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
3839
3878
|
let getterKey = ((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName));
|
|
3840
3879
|
let getterFunc = (__ball_index(this._getters, getterKey) ?? __ball_index(this._functions, getterKey));
|
|
3841
3880
|
if ((!__ball_eq(getterFunc, null) && this._isGetter(getterFunc))) {
|
|
@@ -3847,8 +3886,8 @@ export class BallEngine {
|
|
|
3847
3886
|
let superType = __ball_index(superMap, '__type__');
|
|
3848
3887
|
if (!__ball_eq(superType, null)) {
|
|
3849
3888
|
let sColonIdx = superType.indexOf(':');
|
|
3850
|
-
let sModPart = ((sColonIdx
|
|
3851
|
-
let sTypeName = ((sColonIdx
|
|
3889
|
+
let sModPart = (__ball_ge(sColonIdx, 0) ? superType.substring(0, sColonIdx) : modPart);
|
|
3890
|
+
let sTypeName = (__ball_ge(sColonIdx, 0) ? superType : ((__ball_to_string(sModPart) + ':') + __ball_to_string(superType)));
|
|
3852
3891
|
let superGetterKey = ((((__ball_to_string(sModPart) + '.') + __ball_to_string(sTypeName)) + '.') + __ball_to_string(fieldName));
|
|
3853
3892
|
let superGetterFunc = (__ball_index(this._getters, superGetterKey) ?? __ball_index(this._functions, superGetterKey));
|
|
3854
3893
|
if ((!__ball_eq(superGetterFunc, null) && this._isGetter(superGetterFunc))) {
|
|
@@ -3896,7 +3935,7 @@ export class BallEngine {
|
|
|
3896
3935
|
return _sentinel;
|
|
3897
3936
|
}
|
|
3898
3937
|
let colonIdx = typeName.indexOf(':');
|
|
3899
|
-
let modPart = ((colonIdx
|
|
3938
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
3900
3939
|
let setterKey = (((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName)) + '=');
|
|
3901
3940
|
let setterKeyNoEq = ((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName));
|
|
3902
3941
|
let setterFunc = ((__ball_index(this._setters, setterKey) ?? __ball_index(this._setters, setterKeyNoEq)) ?? __ball_index(this._functions, setterKey));
|
|
@@ -3911,8 +3950,8 @@ export class BallEngine {
|
|
|
3911
3950
|
let superType = __ball_index(superMap, '__type__');
|
|
3912
3951
|
if (!__ball_eq(superType, null)) {
|
|
3913
3952
|
let sColonIdx = superType.indexOf(':');
|
|
3914
|
-
let sModPart = ((sColonIdx
|
|
3915
|
-
let sTypeName = ((sColonIdx
|
|
3953
|
+
let sModPart = (__ball_ge(sColonIdx, 0) ? superType.substring(0, sColonIdx) : modPart);
|
|
3954
|
+
let sTypeName = (__ball_ge(sColonIdx, 0) ? superType : ((__ball_to_string(sModPart) + ':') + __ball_to_string(superType)));
|
|
3916
3955
|
let superSetterKey = (((((__ball_to_string(sModPart) + '.') + __ball_to_string(sTypeName)) + '.') + __ball_to_string(fieldName)) + '=');
|
|
3917
3956
|
let superSetterKeyNoEq = ((((__ball_to_string(sModPart) + '.') + __ball_to_string(sTypeName)) + '.') + __ball_to_string(fieldName));
|
|
3918
3957
|
let superSetterFunc = ((__ball_index(this._setters, superSetterKey) ?? __ball_index(this._setters, superSetterKeyNoEq)) ?? __ball_index(this._functions, superSetterKey));
|
|
@@ -4010,7 +4049,7 @@ export class BallEngine {
|
|
|
4010
4049
|
if ((!__ball_eq(ctorEntry, null) && hasMetadata(ctorEntry.func))) {
|
|
4011
4050
|
let params = this._extractParams(ctorEntry.func.metadata);
|
|
4012
4051
|
let paramsMeta = this._extractParamsMeta(ctorEntry.func.metadata);
|
|
4013
|
-
for (let i = 0; (i
|
|
4052
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
4014
4053
|
let param = __ball_index(params, i);
|
|
4015
4054
|
let value = __no_init__;
|
|
4016
4055
|
if ((param in fields)) {
|
|
@@ -4020,11 +4059,11 @@ export class BallEngine {
|
|
|
4020
4059
|
value = __ball_index(fields, ('arg' + __ball_to_string(i)));
|
|
4021
4060
|
}
|
|
4022
4061
|
}
|
|
4023
|
-
if (((__ball_eq(value, null) && (i
|
|
4062
|
+
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
|
|
4024
4063
|
value = __ball_index(__ball_index(paramsMeta, i), 'default');
|
|
4025
4064
|
}
|
|
4026
4065
|
resolvedParams[param] = value;
|
|
4027
|
-
let isThis = ((i
|
|
4066
|
+
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
4028
4067
|
if ((isThis || allFieldNames.includes(param))) {
|
|
4029
4068
|
instanceFields[param] = value;
|
|
4030
4069
|
} else {
|
|
@@ -4155,7 +4194,7 @@ export class BallEngine {
|
|
|
4155
4194
|
let selfType = __ball_index(selfObjMap, '__type__');
|
|
4156
4195
|
if (!__ball_eq(selfType, null)) {
|
|
4157
4196
|
let colonIdx = msg.typeName.indexOf(':');
|
|
4158
|
-
let methodName = ((colonIdx
|
|
4197
|
+
let methodName = (__ball_ge(colonIdx, 0) ? msg.typeName.substring(__ball_add(colonIdx, 1)) : msg.typeName);
|
|
4159
4198
|
let resolved = this._resolveMethod(selfType, methodName);
|
|
4160
4199
|
if (!__ball_eq(resolved, null)) {
|
|
4161
4200
|
fields['self'] = selfObj;
|
|
@@ -4286,7 +4325,7 @@ export class BallEngine {
|
|
|
4286
4325
|
if ((__ball_eq(trimmed, '""') || __ball_eq(trimmed, '\'\''))) {
|
|
4287
4326
|
return '';
|
|
4288
4327
|
}
|
|
4289
|
-
if ((((trimmed.length
|
|
4328
|
+
if (((__ball_ge(trimmed.length, 2) && trimmed.startsWith('[')) && trimmed.endsWith(']'))) {
|
|
4290
4329
|
let inner = trimmed.substring(1, __ball_sub(trimmed.length, 1)).trim();
|
|
4291
4330
|
if ((inner.length === 0)) {
|
|
4292
4331
|
return [];
|
|
@@ -4312,7 +4351,7 @@ export class BallEngine {
|
|
|
4312
4351
|
if (!__ball_eq(doubleVal, null)) {
|
|
4313
4352
|
return doubleVal;
|
|
4314
4353
|
}
|
|
4315
|
-
if (((trimmed.length
|
|
4354
|
+
if ((__ball_ge(trimmed.length, 2) && ((trimmed.startsWith('\'') && trimmed.endsWith('\'')) || (trimmed.startsWith('"') && trimmed.endsWith('"'))))) {
|
|
4316
4355
|
return trimmed.substring(1, __ball_sub(trimmed.length, 1));
|
|
4317
4356
|
}
|
|
4318
4357
|
return trimmed;
|
|
@@ -4332,7 +4371,7 @@ export class BallEngine {
|
|
|
4332
4371
|
return names;
|
|
4333
4372
|
}
|
|
4334
4373
|
let colonIdx = typeName.indexOf(':');
|
|
4335
|
-
let modPart = ((colonIdx
|
|
4374
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
4336
4375
|
let superclass = typeDef.superclass;
|
|
4337
4376
|
if ((!__ball_eq(superclass, null) && !(superclass.length === 0))) {
|
|
4338
4377
|
let qualifiedSuper = (superclass.includes(':') ? superclass : ((__ball_to_string(modPart) + ':') + __ball_to_string(superclass)));
|
|
@@ -4388,7 +4427,7 @@ export class BallEngine {
|
|
|
4388
4427
|
});
|
|
4389
4428
|
methods[func.name] = closure;
|
|
4390
4429
|
let dotIdx = func.name.lastIndexOf('.');
|
|
4391
|
-
if ((dotIdx
|
|
4430
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
4392
4431
|
methods[func.name.substring(__ball_add(dotIdx, 1))] = closure;
|
|
4393
4432
|
}
|
|
4394
4433
|
continue;
|
|
@@ -4396,7 +4435,7 @@ export class BallEngine {
|
|
|
4396
4435
|
}
|
|
4397
4436
|
let funcName = func.name;
|
|
4398
4437
|
let dotIdx = funcName.lastIndexOf('.');
|
|
4399
|
-
if ((dotIdx
|
|
4438
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
4400
4439
|
let prefix = funcName.substring(0, dotIdx);
|
|
4401
4440
|
let suffix = funcName.substring(__ball_add(dotIdx, 1));
|
|
4402
4441
|
if (__ball_eq(suffix, 'new')) {
|
|
@@ -4426,7 +4465,7 @@ export class BallEngine {
|
|
|
4426
4465
|
const input = typeName;
|
|
4427
4466
|
let methods = {};
|
|
4428
4467
|
let colonIdx = typeName.indexOf(':');
|
|
4429
|
-
let modPart = ((colonIdx
|
|
4468
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
4430
4469
|
let typeDef = this._findTypeDef(typeName);
|
|
4431
4470
|
if (((!__ball_eq(typeDef, null) && !__ball_eq(typeDef.superclass, null)) && !(typeDef.superclass.length === 0))) {
|
|
4432
4471
|
let qualSuper = (typeDef.superclass.includes(':') ? typeDef.superclass : ((__ball_to_string(modPart) + ':') + __ball_to_string(typeDef.superclass)));
|
|
@@ -4514,7 +4553,7 @@ export class BallEngine {
|
|
|
4514
4553
|
}
|
|
4515
4554
|
}
|
|
4516
4555
|
if (!(paramNames.length === 0)) {
|
|
4517
|
-
for (let i = 0; (i
|
|
4556
|
+
for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
|
|
4518
4557
|
let p = __ball_index(paramNames, i);
|
|
4519
4558
|
if (!lambdaScope.has(p)) {
|
|
4520
4559
|
if ((p in inputMap)) {
|
|
@@ -5044,7 +5083,7 @@ export class BallEngine {
|
|
|
5044
5083
|
|
|
5045
5084
|
_matchSwitchPattern(subject: any, pattern: any): any {
|
|
5046
5085
|
let dotIdx = pattern.indexOf('.');
|
|
5047
|
-
if ((dotIdx
|
|
5086
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
5048
5087
|
let enumType = pattern.substring(0, dotIdx);
|
|
5049
5088
|
let enumValue = pattern.substring(__ball_add(dotIdx, 1));
|
|
5050
5089
|
let subjectMap = this._cfAsMap(subject);
|
|
@@ -5052,7 +5091,7 @@ export class BallEngine {
|
|
|
5052
5091
|
let typeName = __ball_index(subjectMap, '__type__');
|
|
5053
5092
|
if (!__ball_eq(typeName, null)) {
|
|
5054
5093
|
let colonIdx = typeName.indexOf(':');
|
|
5055
|
-
let bareType = ((colonIdx
|
|
5094
|
+
let bareType = (__ball_ge(colonIdx, 0) ? typeName.substring(__ball_add(colonIdx, 1)) : typeName);
|
|
5056
5095
|
if ((__ball_eq(bareType, enumType) && __ball_eq(__ball_index(subjectMap, 'name'), enumValue))) {
|
|
5057
5096
|
return true;
|
|
5058
5097
|
}
|
|
@@ -5126,13 +5165,13 @@ export class BallEngine {
|
|
|
5126
5165
|
if ((e instanceof BallException)) {
|
|
5127
5166
|
let eType = e['typeName'];
|
|
5128
5167
|
let eColonIdx = eType.indexOf(':');
|
|
5129
|
-
let eBare = ((eColonIdx
|
|
5168
|
+
let eBare = (__ball_ge(eColonIdx, 0) ? eType.substring(__ball_add(eColonIdx, 1)) : eType);
|
|
5130
5169
|
matches = (__ball_eq(eType, catchType) || __ball_eq(eBare, catchType));
|
|
5131
5170
|
} else {
|
|
5132
5171
|
if (((typeof e === 'object' && e !== null && !Array.isArray(e) && !(e instanceof BallDouble) && !(e instanceof Set)) && !__ball_eq(__ball_index(e, '__type__'), null))) {
|
|
5133
5172
|
let eType = __ball_to_string(__ball_index(e, '__type__'));
|
|
5134
5173
|
let eColonIdx = eType.indexOf(':');
|
|
5135
|
-
let eBare = ((eColonIdx
|
|
5174
|
+
let eBare = (__ball_ge(eColonIdx, 0) ? eType.substring(__ball_add(eColonIdx, 1)) : eType);
|
|
5136
5175
|
matches = (__ball_eq(eType, catchType) || __ball_eq(eBare, catchType));
|
|
5137
5176
|
} else {
|
|
5138
5177
|
matches = __ball_eq(__ball_to_string(e['runtimeType']), catchType);
|
|
@@ -6085,15 +6124,15 @@ export class BallEngine {
|
|
|
6085
6124
|
else if ((__sw === 'sort')) {
|
|
6086
6125
|
if ((typeof arg0 === 'function')) {
|
|
6087
6126
|
let sorted = [...self];
|
|
6088
|
-
for (let j = 1; (j
|
|
6127
|
+
for (let j = 1; __ball_lt(j, sorted.length); (j++)) {
|
|
6089
6128
|
let key = __ball_index(sorted, j);
|
|
6090
6129
|
let k = __ball_sub(j, 1);
|
|
6091
|
-
while ((k
|
|
6130
|
+
while (__ball_ge(k, 0)) {
|
|
6092
6131
|
let r = arg0({ ['arg0']: __ball_index(sorted, k), ['arg1']: key, ['a']: __ball_index(sorted, k), ['b']: key, ['left']: __ball_index(sorted, k), ['right']: key });
|
|
6093
6132
|
if ((r != null)) {
|
|
6094
6133
|
r = await r;
|
|
6095
6134
|
}
|
|
6096
|
-
if (((typeof r === 'number' || r instanceof BallDouble) && (r
|
|
6135
|
+
if (((typeof r === 'number' || r instanceof BallDouble) && __ball_gt(r, 0))) {
|
|
6097
6136
|
sorted[__ball_add(k, 1)] = __ball_index(sorted, k);
|
|
6098
6137
|
(k--);
|
|
6099
6138
|
} else {
|
|
@@ -6626,14 +6665,14 @@ export class BallEngine {
|
|
|
6626
6665
|
}
|
|
6627
6666
|
let typeName = __ball_index(leftMap, '__type__');
|
|
6628
6667
|
let colonIdx = typeName.indexOf(':');
|
|
6629
|
-
let modPart = ((colonIdx
|
|
6668
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
6630
6669
|
let current = leftMap;
|
|
6631
6670
|
while (!__ball_eq(current, null)) {
|
|
6632
6671
|
let curType = __ball_index(current, '__type__');
|
|
6633
6672
|
if (!__ball_eq(curType, null)) {
|
|
6634
6673
|
let cColonIdx = curType.indexOf(':');
|
|
6635
|
-
let cModPart = ((cColonIdx
|
|
6636
|
-
let cTypeName = ((cColonIdx
|
|
6674
|
+
let cModPart = (__ball_ge(cColonIdx, 0) ? curType.substring(0, cColonIdx) : modPart);
|
|
6675
|
+
let cTypeName = (__ball_ge(cColonIdx, 0) ? curType : ((__ball_to_string(cModPart) + ':') + __ball_to_string(curType)));
|
|
6637
6676
|
let opSymbol = __ball_index(_stdFunctionToOperatorSymbol, function_);
|
|
6638
6677
|
let method = __ball_index(this._functions, ((((__ball_to_string(cModPart) + '.') + __ball_to_string(cTypeName)) + '.') + __ball_to_string(op)));
|
|
6639
6678
|
method ??= (__ball_eq(opSymbol, null) ? null : __ball_index(this._functions, ((((__ball_to_string(cModPart) + '.') + __ball_to_string(cTypeName)) + '.') + __ball_to_string(opSymbol))));
|
|
@@ -6760,22 +6799,22 @@ export class BallEngine {
|
|
|
6760
6799
|
}), ['less_than']: ((i) => {
|
|
6761
6800
|
const input = i;
|
|
6762
6801
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
6763
|
-
return (a
|
|
6802
|
+
return __ball_lt(a, b);
|
|
6764
6803
|
}));
|
|
6765
6804
|
}), ['greater_than']: ((i) => {
|
|
6766
6805
|
const input = i;
|
|
6767
6806
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
6768
|
-
return (a
|
|
6807
|
+
return __ball_gt(a, b);
|
|
6769
6808
|
}));
|
|
6770
6809
|
}), ['lte']: ((i) => {
|
|
6771
6810
|
const input = i;
|
|
6772
6811
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
6773
|
-
return (a
|
|
6812
|
+
return __ball_le(a, b);
|
|
6774
6813
|
}));
|
|
6775
6814
|
}), ['gte']: ((i) => {
|
|
6776
6815
|
const input = i;
|
|
6777
6816
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
6778
|
-
return (a
|
|
6817
|
+
return __ball_ge(a, b);
|
|
6779
6818
|
}));
|
|
6780
6819
|
}), ['and']: ((i) => {
|
|
6781
6820
|
const input = i;
|
|
@@ -6887,7 +6926,7 @@ export class BallEngine {
|
|
|
6887
6926
|
}
|
|
6888
6927
|
let a = this._toNum(v);
|
|
6889
6928
|
let b = this._toNum(other);
|
|
6890
|
-
return ((a
|
|
6929
|
+
return (__ball_lt(a, b) ? __ball_negate(1) : ((__ball_gt(a, b) ? 1 : 0)));
|
|
6891
6930
|
}), ['to_string_as_fixed']: ((i) => {
|
|
6892
6931
|
const input = i;
|
|
6893
6932
|
let m = (this._stdAsMap(i) ?? { ['value']: i });
|
|
@@ -6895,7 +6934,7 @@ export class BallEngine {
|
|
|
6895
6934
|
let digits = (__ball_index(m, 'digits') ?? __ball_index(m, 'fractionDigits'));
|
|
6896
6935
|
let n = this._toNum(v);
|
|
6897
6936
|
let s = (+(n)).toFixed(this._toInt(digits));
|
|
6898
|
-
if (((__ball_eq(n, 0) && (new BallDouble(Number(new BallDouble(1)) / Number(n))
|
|
6937
|
+
if (((__ball_eq(n, 0) && __ball_lt(new BallDouble(Number(new BallDouble(1)) / Number(n)), 0)) && !s.startsWith('-'))) {
|
|
6899
6938
|
return ('-' + __ball_to_string(s));
|
|
6900
6939
|
}
|
|
6901
6940
|
return s;
|
|
@@ -7181,16 +7220,16 @@ export class BallEngine {
|
|
|
7181
7220
|
}));
|
|
7182
7221
|
return sorted;
|
|
7183
7222
|
}
|
|
7184
|
-
for (let j = 1; (j
|
|
7223
|
+
for (let j = 1; __ball_lt(j, sorted.length); (j++)) {
|
|
7185
7224
|
let key = __ball_index(sorted, j);
|
|
7186
7225
|
let k = __ball_sub(j, 1);
|
|
7187
|
-
while ((k
|
|
7226
|
+
while (__ball_ge(k, 0)) {
|
|
7188
7227
|
let r = cb({ ['left']: __ball_index(sorted, k), ['right']: key, ['arg0']: __ball_index(sorted, k), ['arg1']: key, ['a']: __ball_index(sorted, k), ['b']: key });
|
|
7189
7228
|
if ((r != null)) {
|
|
7190
7229
|
r = await r;
|
|
7191
7230
|
}
|
|
7192
7231
|
let cmp = ((typeof r === 'number' && Number.isInteger(r)) ? r : __ball_to_int(r));
|
|
7193
|
-
if ((cmp
|
|
7232
|
+
if (__ball_le(cmp, 0)) {
|
|
7194
7233
|
break;
|
|
7195
7234
|
}
|
|
7196
7235
|
sorted[__ball_add(k, 1)] = __ball_index(sorted, k);
|
|
@@ -7242,7 +7281,7 @@ export class BallEngine {
|
|
|
7242
7281
|
} else {
|
|
7243
7282
|
if (('value' in m)) {
|
|
7244
7283
|
let v = __ball_index(m, 'value');
|
|
7245
|
-
if ((Array.isArray(v) && (v.length
|
|
7284
|
+
if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
|
|
7246
7285
|
s = this._toInt(__ball_index(v, 0));
|
|
7247
7286
|
e = this._toInt(__ball_index(v, 1));
|
|
7248
7287
|
} else {
|
|
@@ -7288,7 +7327,7 @@ export class BallEngine {
|
|
|
7288
7327
|
let m = this._stdAsMap(i);
|
|
7289
7328
|
let a = this._stdAsList(__ball_index(m, 'list'));
|
|
7290
7329
|
let b = this._stdAsList(__ball_index(m, 'value'));
|
|
7291
|
-
let len = ((a.length
|
|
7330
|
+
let len = (__ball_lt(a.length, b.length) ? a.length : b.length);
|
|
7292
7331
|
this._trackMemoryAllocation(__ball_mul(len, _ballPointerBytes));
|
|
7293
7332
|
return List.generate(len, ((j) => {
|
|
7294
7333
|
const input = j;
|
|
@@ -7929,12 +7968,12 @@ export class BallEngine {
|
|
|
7929
7968
|
}), ['math_min']: ((i) => {
|
|
7930
7969
|
const input = i;
|
|
7931
7970
|
return this._stdBinary(i, ((a, b) => {
|
|
7932
|
-
return ((a
|
|
7971
|
+
return (__ball_lt(a, b) ? a : b);
|
|
7933
7972
|
}));
|
|
7934
7973
|
}), ['math_max']: ((i) => {
|
|
7935
7974
|
const input = i;
|
|
7936
7975
|
return this._stdBinary(i, ((a, b) => {
|
|
7937
|
-
return ((a
|
|
7976
|
+
return (__ball_gt(a, b) ? a : b);
|
|
7938
7977
|
}));
|
|
7939
7978
|
}), ['math_clamp']: this._stdMathClamp.bind(this), ['math_pi']: ((_) => {
|
|
7940
7979
|
const input = _;
|
|
@@ -8003,7 +8042,7 @@ export class BallEngine {
|
|
|
8003
8042
|
}), ['sleep_ms']: (async (i) => {
|
|
8004
8043
|
const input = i;
|
|
8005
8044
|
let ms = ((typeof i === 'number' || i instanceof BallDouble) ? __ball_to_int(i) : 0);
|
|
8006
|
-
if ((ms
|
|
8045
|
+
if (__ball_gt(ms, 0)) {
|
|
8007
8046
|
await Future.delayed(new Duration({ milliseconds: ms }));
|
|
8008
8047
|
}
|
|
8009
8048
|
}), ['timestamp_ms']: ((_) => {
|
|
@@ -8181,7 +8220,7 @@ export class BallEngine {
|
|
|
8181
8220
|
_manualReverse(list: any): any {
|
|
8182
8221
|
const input = list;
|
|
8183
8222
|
let result = [];
|
|
8184
|
-
for (let i = __ball_sub(list.length, 1); (i
|
|
8223
|
+
for (let i = __ball_sub(list.length, 1); __ball_ge(i, 0); (i--)) {
|
|
8185
8224
|
result = (result.push(__ball_index(list, i)), result);
|
|
8186
8225
|
}
|
|
8187
8226
|
return result;
|
|
@@ -8189,7 +8228,7 @@ export class BallEngine {
|
|
|
8189
8228
|
|
|
8190
8229
|
_resolveMethod(typeName: any, methodName: any): any {
|
|
8191
8230
|
let colonIdx = typeName.indexOf(':');
|
|
8192
|
-
let modPart = ((colonIdx
|
|
8231
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
8193
8232
|
let methodKey = ((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(methodName));
|
|
8194
8233
|
let method = __ball_index(this._functions, methodKey);
|
|
8195
8234
|
if ((!__ball_eq(method, null) && !method.isBase)) {
|
|
@@ -8439,7 +8478,7 @@ export class BallEngine {
|
|
|
8439
8478
|
}
|
|
8440
8479
|
this._trackMemoryAllocation(__ball_mul(length, _ballPointerBytes));
|
|
8441
8480
|
let result = [];
|
|
8442
|
-
for (let index = 0; (index
|
|
8481
|
+
for (let index = 0; __ball_lt(index, length); (index++)) {
|
|
8443
8482
|
let value = generator(index);
|
|
8444
8483
|
if ((value != null)) {
|
|
8445
8484
|
value = await value;
|
|
@@ -8589,7 +8628,7 @@ export class BallEngine {
|
|
|
8589
8628
|
}
|
|
8590
8629
|
}
|
|
8591
8630
|
if (__ball_eq(objTypeArgs.length, typeArgs.length)) {
|
|
8592
|
-
for (let i = 0; (i
|
|
8631
|
+
for (let i = 0; __ball_lt(i, typeArgs.length); (i++)) {
|
|
8593
8632
|
if (!__ball_eq(__ball_index(objTypeArgs, i), __ball_index(typeArgs, i))) {
|
|
8594
8633
|
return false;
|
|
8595
8634
|
}
|
|
@@ -8672,7 +8711,7 @@ export class BallEngine {
|
|
|
8672
8711
|
}
|
|
8673
8712
|
let objColon = objType.indexOf(':');
|
|
8674
8713
|
let checkColon = checkType.indexOf(':');
|
|
8675
|
-
if (((objColon
|
|
8714
|
+
if ((__ball_ge(objColon, 0) && __ball_ge(checkColon, 0))) {
|
|
8676
8715
|
return __ball_eq(objType.substring(__ball_add(objColon, 1)), checkType.substring(__ball_add(checkColon, 1)));
|
|
8677
8716
|
}
|
|
8678
8717
|
return false;
|
|
@@ -8683,7 +8722,7 @@ export class BallEngine {
|
|
|
8683
8722
|
let args = [];
|
|
8684
8723
|
let depth = 0;
|
|
8685
8724
|
let start = 0;
|
|
8686
|
-
for (let i = 0; (i
|
|
8725
|
+
for (let i = 0; __ball_lt(i, str.length); (i++)) {
|
|
8687
8726
|
if (__ball_eq(__ball_index(str, i), '<')) {
|
|
8688
8727
|
(depth++);
|
|
8689
8728
|
}
|
|
@@ -8854,7 +8893,7 @@ export class BallEngine {
|
|
|
8854
8893
|
let rhsStr = relMatch.group(2).trim();
|
|
8855
8894
|
let rhs = num.tryParse(rhsStr);
|
|
8856
8895
|
if (!__ball_eq(rhs, null)) {
|
|
8857
|
-
return ((op === '==') ? (__ball_eq(value, rhs)) : ((op === '!=') ? (!__ball_eq(value, rhs)) : ((op === '>') ? ((value
|
|
8896
|
+
return ((op === '==') ? (__ball_eq(value, rhs)) : ((op === '!=') ? (!__ball_eq(value, rhs)) : ((op === '>') ? (__ball_gt(value, rhs)) : ((op === '<') ? (__ball_lt(value, rhs)) : ((op === '>=') ? (__ball_ge(value, rhs)) : ((op === '<=') ? (__ball_le(value, rhs)) : false))))));
|
|
8858
8897
|
}
|
|
8859
8898
|
}
|
|
8860
8899
|
if (this._matchesTypePattern(value, trimmed)) {
|
|
@@ -8917,10 +8956,10 @@ export class BallEngine {
|
|
|
8917
8956
|
if ((__ball_eq(restIndex, __ball_negate(1)) && !__ball_eq(listVal.length, fixedCount))) {
|
|
8918
8957
|
return false;
|
|
8919
8958
|
}
|
|
8920
|
-
if ((!__ball_eq(restIndex, __ball_negate(1)) && (listVal.length
|
|
8959
|
+
if ((!__ball_eq(restIndex, __ball_negate(1)) && __ball_lt(listVal.length, fixedCount))) {
|
|
8921
8960
|
return false;
|
|
8922
8961
|
}
|
|
8923
|
-
for (let i = 0; (i
|
|
8962
|
+
for (let i = 0; __ball_lt(i, elements.length); (i++)) {
|
|
8924
8963
|
let elem = __ball_index(elements, i);
|
|
8925
8964
|
let elemMap = this._stdAsMap(elem);
|
|
8926
8965
|
if ((!__ball_eq(elemMap, null) && __ball_eq(this._patternKind(elemMap), 'rest'))) {
|
|
@@ -8931,7 +8970,7 @@ export class BallEngine {
|
|
|
8931
8970
|
}
|
|
8932
8971
|
continue;
|
|
8933
8972
|
}
|
|
8934
|
-
let valueIndex = ((__ball_eq(restIndex, __ball_negate(1)) || (i
|
|
8973
|
+
let valueIndex = ((__ball_eq(restIndex, __ball_negate(1)) || __ball_lt(i, restIndex)) ? i : __ball_sub(listVal.length, __ball_sub(elements.length, i)));
|
|
8935
8974
|
if (!this._matchPattern(__ball_index(listVal, valueIndex), elem, bindings)) {
|
|
8936
8975
|
return false;
|
|
8937
8976
|
}
|
|
@@ -9100,7 +9139,7 @@ export class BallEngine {
|
|
|
9100
9139
|
if (__ball_eq(operator, null)) {
|
|
9101
9140
|
return false;
|
|
9102
9141
|
}
|
|
9103
|
-
return ((operator === '==') ? (this._ballEquals(value, operand)) : ((operator === '!=') ? (!this._ballEquals(value, operand)) : ((operator === '>') ? ((((typeof value === 'number' || value instanceof BallDouble) && (typeof operand === 'number' || operand instanceof BallDouble)) && (value
|
|
9142
|
+
return ((operator === '==') ? (this._ballEquals(value, operand)) : ((operator === '!=') ? (!this._ballEquals(value, operand)) : ((operator === '>') ? ((((typeof value === 'number' || value instanceof BallDouble) && (typeof operand === 'number' || operand instanceof BallDouble)) && __ball_gt(value, operand))) : ((operator === '<') ? ((((typeof value === 'number' || value instanceof BallDouble) && (typeof operand === 'number' || operand instanceof BallDouble)) && __ball_lt(value, operand))) : ((operator === '>=') ? ((((typeof value === 'number' || value instanceof BallDouble) && (typeof operand === 'number' || operand instanceof BallDouble)) && __ball_ge(value, operand))) : ((operator === '<=') ? ((((typeof value === 'number' || value instanceof BallDouble) && (typeof operand === 'number' || operand instanceof BallDouble)) && __ball_le(value, operand))) : false))))));
|
|
9104
9143
|
}
|
|
9105
9144
|
|
|
9106
9145
|
_matchesObjectType(value: any, patternType: any): any {
|
|
@@ -9176,7 +9215,7 @@ export class BallEngine {
|
|
|
9176
9215
|
|
|
9177
9216
|
_matchesTypePattern(value: any, pattern: any): any {
|
|
9178
9217
|
let p = ((typeof pattern === 'string') ? pattern : this._ballToStringSimple(pattern));
|
|
9179
|
-
if ((((p.length
|
|
9218
|
+
if (((__ball_gt(p.length, 1) && p.endsWith('?')) && !p.includes(' '))) {
|
|
9180
9219
|
if ((__ball_eq(value, null) || (value == null))) {
|
|
9181
9220
|
return true;
|
|
9182
9221
|
}
|
|
@@ -9242,7 +9281,7 @@ export class BallEngine {
|
|
|
9242
9281
|
|
|
9243
9282
|
_repeatString(s: any, count: any): any {
|
|
9244
9283
|
let out = '';
|
|
9245
|
-
for (let k = 0; (k
|
|
9284
|
+
for (let k = 0; __ball_lt(k, count); (k++)) {
|
|
9246
9285
|
out = (__ball_to_string(out) + __ball_to_string(s));
|
|
9247
9286
|
}
|
|
9248
9287
|
return out;
|
|
@@ -10003,14 +10042,14 @@ function _ballDoubleToInt64(value: any): any {
|
|
|
10003
10042
|
return value.value;
|
|
10004
10043
|
}
|
|
10005
10044
|
let d = (((typeof value === 'number' || value instanceof BallDouble) ? value.value : new BallDouble(Number(value))));
|
|
10006
|
-
if ((d
|
|
10045
|
+
if (__ball_ge(d, new BallDouble(9223372036854776000))) {
|
|
10007
10046
|
return 9223372036854775807n;
|
|
10008
10047
|
}
|
|
10009
|
-
if ((d
|
|
10048
|
+
if (__ball_le(d, __ball_negate(new BallDouble(9223372036854776000)))) {
|
|
10010
10049
|
return __ball_negate(0);
|
|
10011
10050
|
}
|
|
10012
10051
|
let r = __ball_to_int(d);
|
|
10013
|
-
if (((d
|
|
10052
|
+
if ((__ball_gt(d, new BallDouble(0)) && __ball_lt(r, 0))) {
|
|
10014
10053
|
return 9223372036854775807n;
|
|
10015
10054
|
}
|
|
10016
10055
|
return r;
|