@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/dist/compiled_engine.js
CHANGED
|
@@ -124,9 +124,15 @@ class BallDouble {
|
|
|
124
124
|
globalThis.BallDouble = BallDouble;
|
|
125
125
|
// Arithmetic helpers that propagate BallDouble through operations.
|
|
126
126
|
// If either operand is BallDouble, the result is BallDouble (preserving .0).
|
|
127
|
+
//
|
|
128
|
+
// Operator-overload dispatch checks for __op_X__ methods (TRAILING double
|
|
129
|
+
// underscore) — this MUST match the Dart encoder's canonical operator naming
|
|
130
|
+
// (_canonicalOperatorName in dart/encoder/lib/encoder.dart), which always
|
|
131
|
+
// emits a trailing __. A single-underscore lookup (__op_mul) never matches,
|
|
132
|
+
// so overloaded operators silently fall through to raw JS arithmetic (#205).
|
|
127
133
|
function __ball_mul(a, b) {
|
|
128
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
129
|
-
return a.
|
|
134
|
+
if (a != null && typeof a === 'object' && typeof a.__op_mul__ === 'function')
|
|
135
|
+
return a.__op_mul__(b);
|
|
130
136
|
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
131
137
|
return __i64_wrap(__to_bigint(a) * __to_bigint(b));
|
|
132
138
|
const av = a instanceof BallDouble ? a.value : a;
|
|
@@ -135,8 +141,8 @@ function __ball_mul(a, b) {
|
|
|
135
141
|
return (a instanceof BallDouble || b instanceof BallDouble) ? new BallDouble(r) : r;
|
|
136
142
|
}
|
|
137
143
|
function __ball_add(a, b) {
|
|
138
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
139
|
-
return a.
|
|
144
|
+
if (a != null && typeof a === 'object' && typeof a.__op_add__ === 'function')
|
|
145
|
+
return a.__op_add__(b);
|
|
140
146
|
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
141
147
|
return __i64_wrap(__to_bigint(a) + __to_bigint(b));
|
|
142
148
|
const av = a instanceof BallDouble ? a.value : a;
|
|
@@ -145,8 +151,8 @@ function __ball_add(a, b) {
|
|
|
145
151
|
return (a instanceof BallDouble || b instanceof BallDouble) ? new BallDouble(r) : r;
|
|
146
152
|
}
|
|
147
153
|
function __ball_sub(a, b) {
|
|
148
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
149
|
-
return a.
|
|
154
|
+
if (a != null && typeof a === 'object' && typeof a.__op_sub__ === 'function')
|
|
155
|
+
return a.__op_sub__(b);
|
|
150
156
|
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
151
157
|
return __i64_wrap(__to_bigint(a) - __to_bigint(b));
|
|
152
158
|
const av = a instanceof BallDouble ? a.value : a;
|
|
@@ -156,8 +162,8 @@ function __ball_sub(a, b) {
|
|
|
156
162
|
}
|
|
157
163
|
// Dart equality: NaN != NaN, BallDouble value comparison, null == undefined.
|
|
158
164
|
function __ball_eq(a, b) {
|
|
159
|
-
if (a != null && typeof a === 'object' && typeof a.
|
|
160
|
-
return a.
|
|
165
|
+
if (a != null && typeof a === 'object' && typeof a.__op_eq__ === 'function')
|
|
166
|
+
return a.__op_eq__(b);
|
|
161
167
|
if (typeof a === 'bigint' || typeof b === 'bigint') {
|
|
162
168
|
if (typeof a === 'bigint' && typeof b === 'bigint')
|
|
163
169
|
return a === b;
|
|
@@ -180,6 +186,46 @@ function __ball_eq(a, b) {
|
|
|
180
186
|
return a == b;
|
|
181
187
|
return a === b;
|
|
182
188
|
}
|
|
189
|
+
// Relational operator-overload dispatch (less-than/greater-than/etc.),
|
|
190
|
+
// matching the __op_add__-style convention above. Unlike arithmetic,
|
|
191
|
+
// relational comparisons had NO overload attempt at all before #205 — every
|
|
192
|
+
// overloaded Vec2 < x etc. compiled straight to raw JS comparison.
|
|
193
|
+
function __ball_lt(a, b) {
|
|
194
|
+
if (a != null && typeof a === 'object' && typeof a.__op_lt__ === 'function')
|
|
195
|
+
return a.__op_lt__(b);
|
|
196
|
+
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
197
|
+
return __to_bigint(a) < __to_bigint(b);
|
|
198
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
199
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
200
|
+
return av < bv;
|
|
201
|
+
}
|
|
202
|
+
function __ball_gt(a, b) {
|
|
203
|
+
if (a != null && typeof a === 'object' && typeof a.__op_gt__ === 'function')
|
|
204
|
+
return a.__op_gt__(b);
|
|
205
|
+
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
206
|
+
return __to_bigint(a) > __to_bigint(b);
|
|
207
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
208
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
209
|
+
return av > bv;
|
|
210
|
+
}
|
|
211
|
+
function __ball_le(a, b) {
|
|
212
|
+
if (a != null && typeof a === 'object' && typeof a.__op_le__ === 'function')
|
|
213
|
+
return a.__op_le__(b);
|
|
214
|
+
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
215
|
+
return __to_bigint(a) <= __to_bigint(b);
|
|
216
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
217
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
218
|
+
return av <= bv;
|
|
219
|
+
}
|
|
220
|
+
function __ball_ge(a, b) {
|
|
221
|
+
if (a != null && typeof a === 'object' && typeof a.__op_ge__ === 'function')
|
|
222
|
+
return a.__op_ge__(b);
|
|
223
|
+
if (typeof a === 'bigint' || typeof b === 'bigint')
|
|
224
|
+
return __to_bigint(a) >= __to_bigint(b);
|
|
225
|
+
const av = a instanceof BallDouble ? a.value : a;
|
|
226
|
+
const bv = b instanceof BallDouble ? b.value : b;
|
|
227
|
+
return av >= bv;
|
|
228
|
+
}
|
|
183
229
|
function __ball_to_string(v) {
|
|
184
230
|
if (v === null || v === undefined)
|
|
185
231
|
return 'null';
|
|
@@ -1648,13 +1694,13 @@ export class BallEngine {
|
|
|
1648
1694
|
}
|
|
1649
1695
|
_validateProgramLimits() {
|
|
1650
1696
|
let moduleCount = this.program.modules.length;
|
|
1651
|
-
if ((moduleCount
|
|
1697
|
+
if (__ball_gt(moduleCount, this.maxModules)) {
|
|
1652
1698
|
throw new BallRuntimeError((((('Too many modules: ' + __ball_to_string(moduleCount)) + ' (max ') + __ball_to_string(this.maxModules)) + ')'));
|
|
1653
1699
|
}
|
|
1654
1700
|
let maxProgramBytes = this.maxProgramSizeBytes;
|
|
1655
1701
|
if (!__ball_eq(maxProgramBytes, null)) {
|
|
1656
1702
|
let programSizeBytes = this.program.writeToBuffer().length;
|
|
1657
|
-
if ((programSizeBytes
|
|
1703
|
+
if (__ball_gt(programSizeBytes, maxProgramBytes)) {
|
|
1658
1704
|
throw new BallRuntimeError((((('Program too large: ' + __ball_to_string(programSizeBytes)) + ' bytes (max ') + __ball_to_string(maxProgramBytes)) + ')'));
|
|
1659
1705
|
}
|
|
1660
1706
|
}
|
|
@@ -1675,7 +1721,7 @@ export class BallEngine {
|
|
|
1675
1721
|
while (!(stack.length === 0)) {
|
|
1676
1722
|
let current = stack.pop();
|
|
1677
1723
|
let depth = current.depth;
|
|
1678
|
-
if ((depth
|
|
1724
|
+
if (__ball_gt(depth, this.maxExpressionDepth)) {
|
|
1679
1725
|
throw new BallRuntimeError((((('Expression too deep: ' + __ball_to_string(depth)) + ' levels (max ') + __ball_to_string(this.maxExpressionDepth)) + ')'));
|
|
1680
1726
|
}
|
|
1681
1727
|
do {
|
|
@@ -1744,7 +1790,7 @@ export class BallEngine {
|
|
|
1744
1790
|
}
|
|
1745
1791
|
_checkExpressionDepth() {
|
|
1746
1792
|
this._expressionDepth += 1;
|
|
1747
|
-
if ((this._expressionDepth
|
|
1793
|
+
if (__ball_gt(this._expressionDepth, this.maxExpressionDepth)) {
|
|
1748
1794
|
throw new BallRuntimeError((((('Expression too deep: ' + __ball_to_string(this._expressionDepth)) + ' levels (max ') + __ball_to_string(this.maxExpressionDepth)) + ')'));
|
|
1749
1795
|
}
|
|
1750
1796
|
}
|
|
@@ -1757,7 +1803,7 @@ export class BallEngine {
|
|
|
1757
1803
|
if (hasDescriptor(td)) {
|
|
1758
1804
|
this._types[td.name] = td.descriptor;
|
|
1759
1805
|
let tc = td.name.indexOf(':');
|
|
1760
|
-
if ((tc
|
|
1806
|
+
if (__ball_ge(tc, 0)) {
|
|
1761
1807
|
this._types[td.name.substring(__ball_add(tc, 1))] = td.descriptor;
|
|
1762
1808
|
}
|
|
1763
1809
|
}
|
|
@@ -1766,14 +1812,14 @@ export class BallEngine {
|
|
|
1766
1812
|
let enumName = enumDesc.name;
|
|
1767
1813
|
let enumMap = {};
|
|
1768
1814
|
let enumValueList = enumDesc.value;
|
|
1769
|
-
for (let vi = 0; (vi
|
|
1815
|
+
for (let vi = 0; __ball_lt(vi, enumValueList.length); (vi++)) {
|
|
1770
1816
|
let v = __ball_index(enumValueList, vi);
|
|
1771
1817
|
let entry = { ['__type__']: enumName, ['name']: v.name, ['index']: v.number };
|
|
1772
1818
|
enumMap[v.name] = entry;
|
|
1773
1819
|
}
|
|
1774
1820
|
this._enumValues[enumName] = enumMap;
|
|
1775
1821
|
let ec = enumName.indexOf(':');
|
|
1776
|
-
if ((ec
|
|
1822
|
+
if (__ball_ge(ec, 0)) {
|
|
1777
1823
|
this._enumValues[enumName.substring(__ball_add(ec, 1))] = enumMap;
|
|
1778
1824
|
}
|
|
1779
1825
|
}
|
|
@@ -1812,7 +1858,7 @@ export class BallEngine {
|
|
|
1812
1858
|
if (__ball_eq((__ball_eq(kindField, null) ? null : kindField.stringValue), 'constructor')) {
|
|
1813
1859
|
let entry = { module: module.name, func: func };
|
|
1814
1860
|
let dotIdx = func.name.indexOf('.');
|
|
1815
|
-
if ((dotIdx
|
|
1861
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
1816
1862
|
let className = func.name.substring(0, dotIdx);
|
|
1817
1863
|
let ctorSuffix = func.name.substring(__ball_add(dotIdx, 1));
|
|
1818
1864
|
if (__ball_eq(ctorSuffix, 'new')) {
|
|
@@ -1846,7 +1892,7 @@ export class BallEngine {
|
|
|
1846
1892
|
}
|
|
1847
1893
|
if (__ball_eq(kind, 'static_field')) {
|
|
1848
1894
|
let dotIdx = func.name.lastIndexOf('.');
|
|
1849
|
-
if ((dotIdx
|
|
1895
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
1850
1896
|
let bareName = func.name.substring(__ball_add(dotIdx, 1));
|
|
1851
1897
|
(this._staticFieldRefs[bareName] ??= ((() => {
|
|
1852
1898
|
return { module: module.name, func: func, fullName: func.name };
|
|
@@ -1856,7 +1902,7 @@ export class BallEngine {
|
|
|
1856
1902
|
}
|
|
1857
1903
|
let funcName = func.name;
|
|
1858
1904
|
let dotIdx = funcName.lastIndexOf('.');
|
|
1859
|
-
if ((dotIdx
|
|
1905
|
+
if (__ball_lt(dotIdx, 0)) {
|
|
1860
1906
|
return;
|
|
1861
1907
|
}
|
|
1862
1908
|
let methodName = funcName.substring(__ball_add(dotIdx, 1));
|
|
@@ -1891,7 +1937,7 @@ export class BallEngine {
|
|
|
1891
1937
|
}
|
|
1892
1938
|
_lookupTypeMethodWithInheritance(typeName, methodName) {
|
|
1893
1939
|
let colonIdx = typeName.indexOf(':');
|
|
1894
|
-
let modPart = ((colonIdx
|
|
1940
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
1895
1941
|
let current = typeName;
|
|
1896
1942
|
while (!(current.length === 0)) {
|
|
1897
1943
|
let direct = __ball_index(this._typeMethodDispatch, BallEngine._typeMethodKey(current, methodName));
|
|
@@ -1899,7 +1945,7 @@ export class BallEngine {
|
|
|
1899
1945
|
return direct;
|
|
1900
1946
|
}
|
|
1901
1947
|
let currentColon = current.indexOf(':');
|
|
1902
|
-
if ((currentColon
|
|
1948
|
+
if (__ball_ge(currentColon, 0)) {
|
|
1903
1949
|
let bare = current.substring(__ball_add(currentColon, 1));
|
|
1904
1950
|
let bareHit = __ball_index(this._typeMethodDispatch, BallEngine._typeMethodKey(bare, methodName));
|
|
1905
1951
|
if (!__ball_eq(bareHit, null)) {
|
|
@@ -1921,7 +1967,7 @@ export class BallEngine {
|
|
|
1921
1967
|
return mixinHit;
|
|
1922
1968
|
}
|
|
1923
1969
|
let mixinColon = qualMixin.indexOf(':');
|
|
1924
|
-
if ((mixinColon
|
|
1970
|
+
if (__ball_ge(mixinColon, 0)) {
|
|
1925
1971
|
let bareMixin = qualMixin.substring(__ball_add(mixinColon, 1));
|
|
1926
1972
|
let bareMixinHit = __ball_index(this._typeMethodDispatch, BallEngine._typeMethodKey(bareMixin, methodName));
|
|
1927
1973
|
if (!__ball_eq(bareMixinHit, null)) {
|
|
@@ -1988,7 +2034,7 @@ export class BallEngine {
|
|
|
1988
2034
|
return;
|
|
1989
2035
|
}
|
|
1990
2036
|
let elapsed = __ball_sub(DateTime.now().millisecondsSinceEpoch, start);
|
|
1991
|
-
if ((elapsed
|
|
2037
|
+
if (__ball_gt(elapsed, timeout)) {
|
|
1992
2038
|
throw new BallRuntimeError('Execution timeout exceeded');
|
|
1993
2039
|
}
|
|
1994
2040
|
}
|
|
@@ -2005,10 +2051,10 @@ export class BallEngine {
|
|
|
2005
2051
|
_trackMemoryAllocation(bytes) {
|
|
2006
2052
|
const input = bytes;
|
|
2007
2053
|
let limit = this.maxMemoryBytes;
|
|
2008
|
-
if ((__ball_eq(limit, null) || (bytes
|
|
2054
|
+
if ((__ball_eq(limit, null) || __ball_le(bytes, 0))) {
|
|
2009
2055
|
return;
|
|
2010
2056
|
}
|
|
2011
|
-
if ((__ball_add(this._memoryUsedBytes, bytes)
|
|
2057
|
+
if (__ball_gt(__ball_add(this._memoryUsedBytes, bytes), limit)) {
|
|
2012
2058
|
throw new BallRuntimeError('Memory limit exceeded');
|
|
2013
2059
|
}
|
|
2014
2060
|
this._memoryUsedBytes += bytes;
|
|
@@ -2033,7 +2079,7 @@ export class BallEngine {
|
|
|
2033
2079
|
if (func.isBase) {
|
|
2034
2080
|
return this._callBaseFunction(moduleName, func.name, input);
|
|
2035
2081
|
}
|
|
2036
|
-
if ((this._recursionDepth
|
|
2082
|
+
if (__ball_ge(this._recursionDepth, this.maxRecursionDepth)) {
|
|
2037
2083
|
throw new BallRuntimeError(('Maximum recursion depth exceeded: ' + __ball_to_string(this.maxRecursionDepth)));
|
|
2038
2084
|
}
|
|
2039
2085
|
(this._recursionDepth++);
|
|
@@ -2050,7 +2096,7 @@ export class BallEngine {
|
|
|
2050
2096
|
if (__ball_eq(kind, 'constructor')) {
|
|
2051
2097
|
let constructorInput = this._asMap(input);
|
|
2052
2098
|
let dotIdx = func.name.indexOf('.');
|
|
2053
|
-
let typeName = ((dotIdx
|
|
2099
|
+
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
2054
2100
|
let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
|
|
2055
2101
|
if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in constructorInput))) && !__ball_eq(this._findTypeDef(typeName), null))) {
|
|
2056
2102
|
return this._callObjectConstructor(moduleName, func, input);
|
|
@@ -2080,7 +2126,7 @@ export class BallEngine {
|
|
|
2080
2126
|
}
|
|
2081
2127
|
else {
|
|
2082
2128
|
if (!__ball_eq(inputMap, null)) {
|
|
2083
|
-
for (let i = 0; (i
|
|
2129
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2084
2130
|
let p = __ball_index(params, i);
|
|
2085
2131
|
if ((p in inputMap)) {
|
|
2086
2132
|
scope.bind(p, __ball_index(inputMap, p));
|
|
@@ -2099,7 +2145,7 @@ export class BallEngine {
|
|
|
2099
2145
|
}
|
|
2100
2146
|
else {
|
|
2101
2147
|
if (Array.isArray(input)) {
|
|
2102
|
-
for (let i = 0; ((i
|
|
2148
|
+
for (let i = 0; (__ball_lt(i, params.length) && __ball_lt(i, input.length)); (i++)) {
|
|
2103
2149
|
scope.bind(__ball_index(params, i), __ball_index(input, i));
|
|
2104
2150
|
}
|
|
2105
2151
|
}
|
|
@@ -2229,7 +2275,7 @@ export class BallEngine {
|
|
|
2229
2275
|
}
|
|
2230
2276
|
async _callObjectConstructor(moduleName, func, input) {
|
|
2231
2277
|
let dotIdx = func.name.indexOf('.');
|
|
2232
|
-
let typeName = ((dotIdx
|
|
2278
|
+
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
2233
2279
|
let typeDef = this._findTypeDef(typeName);
|
|
2234
2280
|
if (__ball_eq(typeDef, null)) {
|
|
2235
2281
|
return null;
|
|
@@ -2243,7 +2289,7 @@ export class BallEngine {
|
|
|
2243
2289
|
let params = (hasMetadata(func) ? this._extractParams(func.metadata) : []);
|
|
2244
2290
|
let paramsMeta = (hasMetadata(func) ? this._extractParamsMeta(func.metadata) : []);
|
|
2245
2291
|
let resolvedParams = {};
|
|
2246
|
-
for (let i = 0; (i
|
|
2292
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2247
2293
|
let param = __ball_index(params, i);
|
|
2248
2294
|
let value = __no_init__;
|
|
2249
2295
|
if ((param in inputMap)) {
|
|
@@ -2254,11 +2300,11 @@ export class BallEngine {
|
|
|
2254
2300
|
value = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
|
|
2255
2301
|
}
|
|
2256
2302
|
}
|
|
2257
|
-
if (((__ball_eq(value, null) && (i
|
|
2303
|
+
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
|
|
2258
2304
|
value = __ball_index(__ball_index(paramsMeta, i), 'default');
|
|
2259
2305
|
}
|
|
2260
2306
|
resolvedParams[param] = value;
|
|
2261
|
-
let isThis = ((i
|
|
2307
|
+
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
2262
2308
|
if ((isThis || allFieldNames.includes(param))) {
|
|
2263
2309
|
instanceFields[param] = value;
|
|
2264
2310
|
}
|
|
@@ -2326,7 +2372,7 @@ export class BallEngine {
|
|
|
2326
2372
|
let idx = __ball_parse_int(indexMatch.group(2));
|
|
2327
2373
|
let rawArr = __ball_index(resolvedParams, arrName);
|
|
2328
2374
|
let arr = (false /* BallList is List in TS */ ? rawArr.items : rawArr);
|
|
2329
|
-
if ((Array.isArray(arr) && (idx
|
|
2375
|
+
if ((Array.isArray(arr) && __ball_lt(idx, arr.length))) {
|
|
2330
2376
|
targetFields[name] = __ball_index(arr, idx);
|
|
2331
2377
|
}
|
|
2332
2378
|
else {
|
|
@@ -2374,14 +2420,14 @@ export class BallEngine {
|
|
|
2374
2420
|
let paramsMeta = this._extractParamsMeta(func.metadata);
|
|
2375
2421
|
let instance = {};
|
|
2376
2422
|
let dotIdx = func.name.indexOf('.');
|
|
2377
|
-
let typeName = ((dotIdx
|
|
2423
|
+
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
2378
2424
|
instance['__type__'] = typeName;
|
|
2379
2425
|
let resolvedParams = {};
|
|
2380
2426
|
let inputMap = this._asMap(input);
|
|
2381
2427
|
if (!__ball_eq(inputMap, null)) {
|
|
2382
|
-
for (let i = 0; (i
|
|
2428
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2383
2429
|
let p = __ball_index(params, i);
|
|
2384
|
-
let isThis = ((i
|
|
2430
|
+
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
2385
2431
|
let val = __no_init__;
|
|
2386
2432
|
if ((p in inputMap)) {
|
|
2387
2433
|
val = __ball_index(inputMap, p);
|
|
@@ -2391,7 +2437,7 @@ export class BallEngine {
|
|
|
2391
2437
|
val = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
|
|
2392
2438
|
}
|
|
2393
2439
|
else {
|
|
2394
|
-
val = ((i
|
|
2440
|
+
val = (__ball_lt(i, paramsMeta.length) ? __ball_index(__ball_index(paramsMeta, i), 'default') : null);
|
|
2395
2441
|
}
|
|
2396
2442
|
}
|
|
2397
2443
|
resolvedParams[p] = val;
|
|
@@ -2460,7 +2506,7 @@ export class BallEngine {
|
|
|
2460
2506
|
})() ?? '');
|
|
2461
2507
|
let argNames = this._parseSuperArgs(argsStr);
|
|
2462
2508
|
let superInput = {};
|
|
2463
|
-
for (let i = 0; (i
|
|
2509
|
+
for (let i = 0; __ball_lt(i, argNames.length); (i++)) {
|
|
2464
2510
|
let token = __ball_index(argNames, i);
|
|
2465
2511
|
if ((token in resolvedParams)) {
|
|
2466
2512
|
superInput[('arg' + __ball_to_string(i))] = __ball_index(resolvedParams, token);
|
|
@@ -2498,7 +2544,7 @@ export class BallEngine {
|
|
|
2498
2544
|
let superCtorEntry = this._lookupConstructor(superclass);
|
|
2499
2545
|
if (!__ball_eq(superCtorEntry, null)) {
|
|
2500
2546
|
let superInput = {};
|
|
2501
|
-
for (let i = 0; (i
|
|
2547
|
+
for (let i = 0; __ball_lt(i, resolvedParams.length); (i++)) {
|
|
2502
2548
|
superInput[('arg' + __ball_to_string(i))] = resolvedParams.values.elementAt(i);
|
|
2503
2549
|
}
|
|
2504
2550
|
return this._callFunction(superCtorEntry.module, superCtorEntry.func, superInput);
|
|
@@ -2518,7 +2564,7 @@ export class BallEngine {
|
|
|
2518
2564
|
for (const entry of this._constructors.entries) {
|
|
2519
2565
|
let key = entry.key;
|
|
2520
2566
|
let colonIdx = key.indexOf(':');
|
|
2521
|
-
let bare = ((colonIdx
|
|
2567
|
+
let bare = (__ball_ge(colonIdx, 0) ? key.substring(__ball_add(colonIdx, 1)) : key);
|
|
2522
2568
|
if (__ball_eq(bare, name)) {
|
|
2523
2569
|
return entry.value;
|
|
2524
2570
|
}
|
|
@@ -3094,7 +3140,7 @@ export class BallEngine {
|
|
|
3094
3140
|
if (__ball_eq((__ball_eq(kindField, null) ? null : kindField.stringValue), 'constructor')) {
|
|
3095
3141
|
let entry = { module: module.name, func: func };
|
|
3096
3142
|
let dotIdx = func.name.indexOf('.');
|
|
3097
|
-
if ((dotIdx
|
|
3143
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
3098
3144
|
let className = func.name.substring(0, dotIdx);
|
|
3099
3145
|
let ctorSuffix = func.name.substring(__ball_add(dotIdx, 1));
|
|
3100
3146
|
if (__ball_eq(ctorSuffix, 'new')) {
|
|
@@ -3323,7 +3369,7 @@ export class BallEngine {
|
|
|
3323
3369
|
let className = __ball_index(selfMap, '__class_ref__');
|
|
3324
3370
|
let qualifiedName = (className.includes(':') ? className : ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(className)));
|
|
3325
3371
|
let colonIdx2 = qualifiedName.indexOf(':');
|
|
3326
|
-
let modPart2 = ((colonIdx2
|
|
3372
|
+
let modPart2 = (__ball_ge(colonIdx2, 0) ? qualifiedName.substring(0, colonIdx2) : this._currentModule);
|
|
3327
3373
|
let staticKey = ((((__ball_to_string(modPart2) + '.') + __ball_to_string(qualifiedName)) + '.') + __ball_to_string(call.function));
|
|
3328
3374
|
let staticFunc = __ball_index(this._functions, staticKey);
|
|
3329
3375
|
if (!__ball_eq(staticFunc, null)) {
|
|
@@ -3669,7 +3715,7 @@ export class BallEngine {
|
|
|
3669
3715
|
});
|
|
3670
3716
|
}
|
|
3671
3717
|
let colonIdx = name.indexOf(':');
|
|
3672
|
-
if ((colonIdx
|
|
3718
|
+
if (__ball_ge(colonIdx, 0)) {
|
|
3673
3719
|
let bare = name.substring(__ball_add(colonIdx, 1));
|
|
3674
3720
|
let bareEntry = __ball_index(this._constructors, bare);
|
|
3675
3721
|
if (!__ball_eq(bareEntry, null)) {
|
|
@@ -3835,7 +3881,7 @@ export class BallEngine {
|
|
|
3835
3881
|
});
|
|
3836
3882
|
}
|
|
3837
3883
|
let colonIdx = qualifiedName.indexOf(':');
|
|
3838
|
-
let modPart = ((colonIdx
|
|
3884
|
+
let modPart = (__ball_ge(colonIdx, 0) ? qualifiedName.substring(0, colonIdx) : this._currentModule);
|
|
3839
3885
|
let staticKey = ((((__ball_to_string(modPart) + '.') + __ball_to_string(qualifiedName)) + '.') + __ball_to_string(fieldName));
|
|
3840
3886
|
let staticFunc = __ball_index(this._functions, staticKey);
|
|
3841
3887
|
if (!__ball_eq(staticFunc, null)) {
|
|
@@ -4105,7 +4151,7 @@ export class BallEngine {
|
|
|
4105
4151
|
return _sentinel;
|
|
4106
4152
|
}
|
|
4107
4153
|
let colonIdx = typeName.indexOf(':');
|
|
4108
|
-
let modPart = ((colonIdx
|
|
4154
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
4109
4155
|
let getterKey = ((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName));
|
|
4110
4156
|
let getterFunc = (__ball_index(this._getters, getterKey) ?? __ball_index(this._functions, getterKey));
|
|
4111
4157
|
if ((!__ball_eq(getterFunc, null) && this._isGetter(getterFunc))) {
|
|
@@ -4117,8 +4163,8 @@ export class BallEngine {
|
|
|
4117
4163
|
let superType = __ball_index(superMap, '__type__');
|
|
4118
4164
|
if (!__ball_eq(superType, null)) {
|
|
4119
4165
|
let sColonIdx = superType.indexOf(':');
|
|
4120
|
-
let sModPart = ((sColonIdx
|
|
4121
|
-
let sTypeName = ((sColonIdx
|
|
4166
|
+
let sModPart = (__ball_ge(sColonIdx, 0) ? superType.substring(0, sColonIdx) : modPart);
|
|
4167
|
+
let sTypeName = (__ball_ge(sColonIdx, 0) ? superType : ((__ball_to_string(sModPart) + ':') + __ball_to_string(superType)));
|
|
4122
4168
|
let superGetterKey = ((((__ball_to_string(sModPart) + '.') + __ball_to_string(sTypeName)) + '.') + __ball_to_string(fieldName));
|
|
4123
4169
|
let superGetterFunc = (__ball_index(this._getters, superGetterKey) ?? __ball_index(this._functions, superGetterKey));
|
|
4124
4170
|
if ((!__ball_eq(superGetterFunc, null) && this._isGetter(superGetterFunc))) {
|
|
@@ -4163,7 +4209,7 @@ export class BallEngine {
|
|
|
4163
4209
|
return _sentinel;
|
|
4164
4210
|
}
|
|
4165
4211
|
let colonIdx = typeName.indexOf(':');
|
|
4166
|
-
let modPart = ((colonIdx
|
|
4212
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
4167
4213
|
let setterKey = (((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName)) + '=');
|
|
4168
4214
|
let setterKeyNoEq = ((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName));
|
|
4169
4215
|
let setterFunc = ((__ball_index(this._setters, setterKey) ?? __ball_index(this._setters, setterKeyNoEq)) ?? __ball_index(this._functions, setterKey));
|
|
@@ -4178,8 +4224,8 @@ export class BallEngine {
|
|
|
4178
4224
|
let superType = __ball_index(superMap, '__type__');
|
|
4179
4225
|
if (!__ball_eq(superType, null)) {
|
|
4180
4226
|
let sColonIdx = superType.indexOf(':');
|
|
4181
|
-
let sModPart = ((sColonIdx
|
|
4182
|
-
let sTypeName = ((sColonIdx
|
|
4227
|
+
let sModPart = (__ball_ge(sColonIdx, 0) ? superType.substring(0, sColonIdx) : modPart);
|
|
4228
|
+
let sTypeName = (__ball_ge(sColonIdx, 0) ? superType : ((__ball_to_string(sModPart) + ':') + __ball_to_string(superType)));
|
|
4183
4229
|
let superSetterKey = (((((__ball_to_string(sModPart) + '.') + __ball_to_string(sTypeName)) + '.') + __ball_to_string(fieldName)) + '=');
|
|
4184
4230
|
let superSetterKeyNoEq = ((((__ball_to_string(sModPart) + '.') + __ball_to_string(sTypeName)) + '.') + __ball_to_string(fieldName));
|
|
4185
4231
|
let superSetterFunc = ((__ball_index(this._setters, superSetterKey) ?? __ball_index(this._setters, superSetterKeyNoEq)) ?? __ball_index(this._functions, superSetterKey));
|
|
@@ -4277,7 +4323,7 @@ export class BallEngine {
|
|
|
4277
4323
|
if ((!__ball_eq(ctorEntry, null) && hasMetadata(ctorEntry.func))) {
|
|
4278
4324
|
let params = this._extractParams(ctorEntry.func.metadata);
|
|
4279
4325
|
let paramsMeta = this._extractParamsMeta(ctorEntry.func.metadata);
|
|
4280
|
-
for (let i = 0; (i
|
|
4326
|
+
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
4281
4327
|
let param = __ball_index(params, i);
|
|
4282
4328
|
let value = __no_init__;
|
|
4283
4329
|
if ((param in fields)) {
|
|
@@ -4288,11 +4334,11 @@ export class BallEngine {
|
|
|
4288
4334
|
value = __ball_index(fields, ('arg' + __ball_to_string(i)));
|
|
4289
4335
|
}
|
|
4290
4336
|
}
|
|
4291
|
-
if (((__ball_eq(value, null) && (i
|
|
4337
|
+
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
|
|
4292
4338
|
value = __ball_index(__ball_index(paramsMeta, i), 'default');
|
|
4293
4339
|
}
|
|
4294
4340
|
resolvedParams[param] = value;
|
|
4295
|
-
let isThis = ((i
|
|
4341
|
+
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
4296
4342
|
if ((isThis || allFieldNames.includes(param))) {
|
|
4297
4343
|
instanceFields[param] = value;
|
|
4298
4344
|
}
|
|
@@ -4426,7 +4472,7 @@ export class BallEngine {
|
|
|
4426
4472
|
let selfType = __ball_index(selfObjMap, '__type__');
|
|
4427
4473
|
if (!__ball_eq(selfType, null)) {
|
|
4428
4474
|
let colonIdx = msg.typeName.indexOf(':');
|
|
4429
|
-
let methodName = ((colonIdx
|
|
4475
|
+
let methodName = (__ball_ge(colonIdx, 0) ? msg.typeName.substring(__ball_add(colonIdx, 1)) : msg.typeName);
|
|
4430
4476
|
let resolved = this._resolveMethod(selfType, methodName);
|
|
4431
4477
|
if (!__ball_eq(resolved, null)) {
|
|
4432
4478
|
fields['self'] = selfObj;
|
|
@@ -4554,7 +4600,7 @@ export class BallEngine {
|
|
|
4554
4600
|
if ((__ball_eq(trimmed, '""') || __ball_eq(trimmed, '\'\''))) {
|
|
4555
4601
|
return '';
|
|
4556
4602
|
}
|
|
4557
|
-
if ((((trimmed.length
|
|
4603
|
+
if (((__ball_ge(trimmed.length, 2) && trimmed.startsWith('[')) && trimmed.endsWith(']'))) {
|
|
4558
4604
|
let inner = trimmed.substring(1, __ball_sub(trimmed.length, 1)).trim();
|
|
4559
4605
|
if ((inner.length === 0)) {
|
|
4560
4606
|
return [];
|
|
@@ -4580,7 +4626,7 @@ export class BallEngine {
|
|
|
4580
4626
|
if (!__ball_eq(doubleVal, null)) {
|
|
4581
4627
|
return doubleVal;
|
|
4582
4628
|
}
|
|
4583
|
-
if (((trimmed.length
|
|
4629
|
+
if ((__ball_ge(trimmed.length, 2) && ((trimmed.startsWith('\'') && trimmed.endsWith('\'')) || (trimmed.startsWith('"') && trimmed.endsWith('"'))))) {
|
|
4584
4630
|
return trimmed.substring(1, __ball_sub(trimmed.length, 1));
|
|
4585
4631
|
}
|
|
4586
4632
|
return trimmed;
|
|
@@ -4598,7 +4644,7 @@ export class BallEngine {
|
|
|
4598
4644
|
return names;
|
|
4599
4645
|
}
|
|
4600
4646
|
let colonIdx = typeName.indexOf(':');
|
|
4601
|
-
let modPart = ((colonIdx
|
|
4647
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
4602
4648
|
let superclass = typeDef.superclass;
|
|
4603
4649
|
if ((!__ball_eq(superclass, null) && !(superclass.length === 0))) {
|
|
4604
4650
|
let qualifiedSuper = (superclass.includes(':') ? superclass : ((__ball_to_string(modPart) + ':') + __ball_to_string(superclass)));
|
|
@@ -4652,7 +4698,7 @@ export class BallEngine {
|
|
|
4652
4698
|
});
|
|
4653
4699
|
methods[func.name] = closure;
|
|
4654
4700
|
let dotIdx = func.name.lastIndexOf('.');
|
|
4655
|
-
if ((dotIdx
|
|
4701
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
4656
4702
|
methods[func.name.substring(__ball_add(dotIdx, 1))] = closure;
|
|
4657
4703
|
}
|
|
4658
4704
|
continue;
|
|
@@ -4660,7 +4706,7 @@ export class BallEngine {
|
|
|
4660
4706
|
}
|
|
4661
4707
|
let funcName = func.name;
|
|
4662
4708
|
let dotIdx = funcName.lastIndexOf('.');
|
|
4663
|
-
if ((dotIdx
|
|
4709
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
4664
4710
|
let prefix = funcName.substring(0, dotIdx);
|
|
4665
4711
|
let suffix = funcName.substring(__ball_add(dotIdx, 1));
|
|
4666
4712
|
if (__ball_eq(suffix, 'new')) {
|
|
@@ -4689,7 +4735,7 @@ export class BallEngine {
|
|
|
4689
4735
|
const input = typeName;
|
|
4690
4736
|
let methods = {};
|
|
4691
4737
|
let colonIdx = typeName.indexOf(':');
|
|
4692
|
-
let modPart = ((colonIdx
|
|
4738
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
4693
4739
|
let typeDef = this._findTypeDef(typeName);
|
|
4694
4740
|
if (((!__ball_eq(typeDef, null) && !__ball_eq(typeDef.superclass, null)) && !(typeDef.superclass.length === 0))) {
|
|
4695
4741
|
let qualSuper = (typeDef.superclass.includes(':') ? typeDef.superclass : ((__ball_to_string(modPart) + ':') + __ball_to_string(typeDef.superclass)));
|
|
@@ -4776,7 +4822,7 @@ export class BallEngine {
|
|
|
4776
4822
|
}
|
|
4777
4823
|
}
|
|
4778
4824
|
if (!(paramNames.length === 0)) {
|
|
4779
|
-
for (let i = 0; (i
|
|
4825
|
+
for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
|
|
4780
4826
|
let p = __ball_index(paramNames, i);
|
|
4781
4827
|
if (!lambdaScope.has(p)) {
|
|
4782
4828
|
if ((p in inputMap)) {
|
|
@@ -5305,7 +5351,7 @@ export class BallEngine {
|
|
|
5305
5351
|
}
|
|
5306
5352
|
_matchSwitchPattern(subject, pattern) {
|
|
5307
5353
|
let dotIdx = pattern.indexOf('.');
|
|
5308
|
-
if ((dotIdx
|
|
5354
|
+
if (__ball_ge(dotIdx, 0)) {
|
|
5309
5355
|
let enumType = pattern.substring(0, dotIdx);
|
|
5310
5356
|
let enumValue = pattern.substring(__ball_add(dotIdx, 1));
|
|
5311
5357
|
let subjectMap = this._cfAsMap(subject);
|
|
@@ -5313,7 +5359,7 @@ export class BallEngine {
|
|
|
5313
5359
|
let typeName = __ball_index(subjectMap, '__type__');
|
|
5314
5360
|
if (!__ball_eq(typeName, null)) {
|
|
5315
5361
|
let colonIdx = typeName.indexOf(':');
|
|
5316
|
-
let bareType = ((colonIdx
|
|
5362
|
+
let bareType = (__ball_ge(colonIdx, 0) ? typeName.substring(__ball_add(colonIdx, 1)) : typeName);
|
|
5317
5363
|
if ((__ball_eq(bareType, enumType) && __ball_eq(__ball_index(subjectMap, 'name'), enumValue))) {
|
|
5318
5364
|
return true;
|
|
5319
5365
|
}
|
|
@@ -5387,14 +5433,14 @@ export class BallEngine {
|
|
|
5387
5433
|
if ((e instanceof BallException)) {
|
|
5388
5434
|
let eType = e['typeName'];
|
|
5389
5435
|
let eColonIdx = eType.indexOf(':');
|
|
5390
|
-
let eBare = ((eColonIdx
|
|
5436
|
+
let eBare = (__ball_ge(eColonIdx, 0) ? eType.substring(__ball_add(eColonIdx, 1)) : eType);
|
|
5391
5437
|
matches = (__ball_eq(eType, catchType) || __ball_eq(eBare, catchType));
|
|
5392
5438
|
}
|
|
5393
5439
|
else {
|
|
5394
5440
|
if (((typeof e === 'object' && e !== null && !Array.isArray(e) && !(e instanceof BallDouble) && !(e instanceof Set)) && !__ball_eq(__ball_index(e, '__type__'), null))) {
|
|
5395
5441
|
let eType = __ball_to_string(__ball_index(e, '__type__'));
|
|
5396
5442
|
let eColonIdx = eType.indexOf(':');
|
|
5397
|
-
let eBare = ((eColonIdx
|
|
5443
|
+
let eBare = (__ball_ge(eColonIdx, 0) ? eType.substring(__ball_add(eColonIdx, 1)) : eType);
|
|
5398
5444
|
matches = (__ball_eq(eType, catchType) || __ball_eq(eBare, catchType));
|
|
5399
5445
|
}
|
|
5400
5446
|
else {
|
|
@@ -6346,15 +6392,15 @@ export class BallEngine {
|
|
|
6346
6392
|
else if ((__sw === 'sort')) {
|
|
6347
6393
|
if ((typeof arg0 === 'function')) {
|
|
6348
6394
|
let sorted = [...self];
|
|
6349
|
-
for (let j = 1; (j
|
|
6395
|
+
for (let j = 1; __ball_lt(j, sorted.length); (j++)) {
|
|
6350
6396
|
let key = __ball_index(sorted, j);
|
|
6351
6397
|
let k = __ball_sub(j, 1);
|
|
6352
|
-
while ((k
|
|
6398
|
+
while (__ball_ge(k, 0)) {
|
|
6353
6399
|
let r = arg0({ ['arg0']: __ball_index(sorted, k), ['arg1']: key, ['a']: __ball_index(sorted, k), ['b']: key, ['left']: __ball_index(sorted, k), ['right']: key });
|
|
6354
6400
|
if ((r != null)) {
|
|
6355
6401
|
r = await r;
|
|
6356
6402
|
}
|
|
6357
|
-
if (((typeof r === 'number' || r instanceof BallDouble) && (r
|
|
6403
|
+
if (((typeof r === 'number' || r instanceof BallDouble) && __ball_gt(r, 0))) {
|
|
6358
6404
|
sorted[__ball_add(k, 1)] = __ball_index(sorted, k);
|
|
6359
6405
|
(k--);
|
|
6360
6406
|
}
|
|
@@ -6889,14 +6935,14 @@ export class BallEngine {
|
|
|
6889
6935
|
}
|
|
6890
6936
|
let typeName = __ball_index(leftMap, '__type__');
|
|
6891
6937
|
let colonIdx = typeName.indexOf(':');
|
|
6892
|
-
let modPart = ((colonIdx
|
|
6938
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
6893
6939
|
let current = leftMap;
|
|
6894
6940
|
while (!__ball_eq(current, null)) {
|
|
6895
6941
|
let curType = __ball_index(current, '__type__');
|
|
6896
6942
|
if (!__ball_eq(curType, null)) {
|
|
6897
6943
|
let cColonIdx = curType.indexOf(':');
|
|
6898
|
-
let cModPart = ((cColonIdx
|
|
6899
|
-
let cTypeName = ((cColonIdx
|
|
6944
|
+
let cModPart = (__ball_ge(cColonIdx, 0) ? curType.substring(0, cColonIdx) : modPart);
|
|
6945
|
+
let cTypeName = (__ball_ge(cColonIdx, 0) ? curType : ((__ball_to_string(cModPart) + ':') + __ball_to_string(curType)));
|
|
6900
6946
|
let opSymbol = __ball_index(_stdFunctionToOperatorSymbol, function_);
|
|
6901
6947
|
let method = __ball_index(this._functions, ((((__ball_to_string(cModPart) + '.') + __ball_to_string(cTypeName)) + '.') + __ball_to_string(op)));
|
|
6902
6948
|
method ??= (__ball_eq(opSymbol, null) ? null : __ball_index(this._functions, ((((__ball_to_string(cModPart) + '.') + __ball_to_string(cTypeName)) + '.') + __ball_to_string(opSymbol))));
|
|
@@ -7020,22 +7066,22 @@ export class BallEngine {
|
|
|
7020
7066
|
}), ['less_than']: ((i) => {
|
|
7021
7067
|
const input = i;
|
|
7022
7068
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
7023
|
-
return (a
|
|
7069
|
+
return __ball_lt(a, b);
|
|
7024
7070
|
}));
|
|
7025
7071
|
}), ['greater_than']: ((i) => {
|
|
7026
7072
|
const input = i;
|
|
7027
7073
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
7028
|
-
return (a
|
|
7074
|
+
return __ball_gt(a, b);
|
|
7029
7075
|
}));
|
|
7030
7076
|
}), ['lte']: ((i) => {
|
|
7031
7077
|
const input = i;
|
|
7032
7078
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
7033
|
-
return (a
|
|
7079
|
+
return __ball_le(a, b);
|
|
7034
7080
|
}));
|
|
7035
7081
|
}), ['gte']: ((i) => {
|
|
7036
7082
|
const input = i;
|
|
7037
7083
|
return this._stdBinaryComp(i, ((a, b) => {
|
|
7038
|
-
return (a
|
|
7084
|
+
return __ball_ge(a, b);
|
|
7039
7085
|
}));
|
|
7040
7086
|
}), ['and']: ((i) => {
|
|
7041
7087
|
const input = i;
|
|
@@ -7147,7 +7193,7 @@ export class BallEngine {
|
|
|
7147
7193
|
}
|
|
7148
7194
|
let a = this._toNum(v);
|
|
7149
7195
|
let b = this._toNum(other);
|
|
7150
|
-
return ((a
|
|
7196
|
+
return (__ball_lt(a, b) ? __ball_negate(1) : ((__ball_gt(a, b) ? 1 : 0)));
|
|
7151
7197
|
}), ['to_string_as_fixed']: ((i) => {
|
|
7152
7198
|
const input = i;
|
|
7153
7199
|
let m = (this._stdAsMap(i) ?? { ['value']: i });
|
|
@@ -7155,7 +7201,7 @@ export class BallEngine {
|
|
|
7155
7201
|
let digits = (__ball_index(m, 'digits') ?? __ball_index(m, 'fractionDigits'));
|
|
7156
7202
|
let n = this._toNum(v);
|
|
7157
7203
|
let s = (+(n)).toFixed(this._toInt(digits));
|
|
7158
|
-
if (((__ball_eq(n, 0) && (new BallDouble(Number(new BallDouble(1)) / Number(n))
|
|
7204
|
+
if (((__ball_eq(n, 0) && __ball_lt(new BallDouble(Number(new BallDouble(1)) / Number(n)), 0)) && !s.startsWith('-'))) {
|
|
7159
7205
|
return ('-' + __ball_to_string(s));
|
|
7160
7206
|
}
|
|
7161
7207
|
return s;
|
|
@@ -7441,16 +7487,16 @@ export class BallEngine {
|
|
|
7441
7487
|
}));
|
|
7442
7488
|
return sorted;
|
|
7443
7489
|
}
|
|
7444
|
-
for (let j = 1; (j
|
|
7490
|
+
for (let j = 1; __ball_lt(j, sorted.length); (j++)) {
|
|
7445
7491
|
let key = __ball_index(sorted, j);
|
|
7446
7492
|
let k = __ball_sub(j, 1);
|
|
7447
|
-
while ((k
|
|
7493
|
+
while (__ball_ge(k, 0)) {
|
|
7448
7494
|
let r = cb({ ['left']: __ball_index(sorted, k), ['right']: key, ['arg0']: __ball_index(sorted, k), ['arg1']: key, ['a']: __ball_index(sorted, k), ['b']: key });
|
|
7449
7495
|
if ((r != null)) {
|
|
7450
7496
|
r = await r;
|
|
7451
7497
|
}
|
|
7452
7498
|
let cmp = ((typeof r === 'number' && Number.isInteger(r)) ? r : __ball_to_int(r));
|
|
7453
|
-
if ((cmp
|
|
7499
|
+
if (__ball_le(cmp, 0)) {
|
|
7454
7500
|
break;
|
|
7455
7501
|
}
|
|
7456
7502
|
sorted[__ball_add(k, 1)] = __ball_index(sorted, k);
|
|
@@ -7506,7 +7552,7 @@ export class BallEngine {
|
|
|
7506
7552
|
else {
|
|
7507
7553
|
if (('value' in m)) {
|
|
7508
7554
|
let v = __ball_index(m, 'value');
|
|
7509
|
-
if ((Array.isArray(v) && (v.length
|
|
7555
|
+
if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
|
|
7510
7556
|
s = this._toInt(__ball_index(v, 0));
|
|
7511
7557
|
e = this._toInt(__ball_index(v, 1));
|
|
7512
7558
|
}
|
|
@@ -7556,7 +7602,7 @@ export class BallEngine {
|
|
|
7556
7602
|
let m = this._stdAsMap(i);
|
|
7557
7603
|
let a = this._stdAsList(__ball_index(m, 'list'));
|
|
7558
7604
|
let b = this._stdAsList(__ball_index(m, 'value'));
|
|
7559
|
-
let len = ((a.length
|
|
7605
|
+
let len = (__ball_lt(a.length, b.length) ? a.length : b.length);
|
|
7560
7606
|
this._trackMemoryAllocation(__ball_mul(len, _ballPointerBytes));
|
|
7561
7607
|
return List.generate(len, ((j) => {
|
|
7562
7608
|
const input = j;
|
|
@@ -8216,12 +8262,12 @@ export class BallEngine {
|
|
|
8216
8262
|
}), ['math_min']: ((i) => {
|
|
8217
8263
|
const input = i;
|
|
8218
8264
|
return this._stdBinary(i, ((a, b) => {
|
|
8219
|
-
return ((a
|
|
8265
|
+
return (__ball_lt(a, b) ? a : b);
|
|
8220
8266
|
}));
|
|
8221
8267
|
}), ['math_max']: ((i) => {
|
|
8222
8268
|
const input = i;
|
|
8223
8269
|
return this._stdBinary(i, ((a, b) => {
|
|
8224
|
-
return ((a
|
|
8270
|
+
return (__ball_gt(a, b) ? a : b);
|
|
8225
8271
|
}));
|
|
8226
8272
|
}), ['math_clamp']: this._stdMathClamp.bind(this), ['math_pi']: ((_) => {
|
|
8227
8273
|
const input = _;
|
|
@@ -8290,7 +8336,7 @@ export class BallEngine {
|
|
|
8290
8336
|
}), ['sleep_ms']: (async (i) => {
|
|
8291
8337
|
const input = i;
|
|
8292
8338
|
let ms = ((typeof i === 'number' || i instanceof BallDouble) ? __ball_to_int(i) : 0);
|
|
8293
|
-
if ((ms
|
|
8339
|
+
if (__ball_gt(ms, 0)) {
|
|
8294
8340
|
await Future.delayed(new Duration({ milliseconds: ms }));
|
|
8295
8341
|
}
|
|
8296
8342
|
}), ['timestamp_ms']: ((_) => {
|
|
@@ -8466,14 +8512,14 @@ export class BallEngine {
|
|
|
8466
8512
|
_manualReverse(list) {
|
|
8467
8513
|
const input = list;
|
|
8468
8514
|
let result = [];
|
|
8469
|
-
for (let i = __ball_sub(list.length, 1); (i
|
|
8515
|
+
for (let i = __ball_sub(list.length, 1); __ball_ge(i, 0); (i--)) {
|
|
8470
8516
|
result = (result.push(__ball_index(list, i)), result);
|
|
8471
8517
|
}
|
|
8472
8518
|
return result;
|
|
8473
8519
|
}
|
|
8474
8520
|
_resolveMethod(typeName, methodName) {
|
|
8475
8521
|
let colonIdx = typeName.indexOf(':');
|
|
8476
|
-
let modPart = ((colonIdx
|
|
8522
|
+
let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
|
|
8477
8523
|
let methodKey = ((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(methodName));
|
|
8478
8524
|
let method = __ball_index(this._functions, methodKey);
|
|
8479
8525
|
if ((!__ball_eq(method, null) && !method.isBase)) {
|
|
@@ -8720,7 +8766,7 @@ export class BallEngine {
|
|
|
8720
8766
|
}
|
|
8721
8767
|
this._trackMemoryAllocation(__ball_mul(length, _ballPointerBytes));
|
|
8722
8768
|
let result = [];
|
|
8723
|
-
for (let index = 0; (index
|
|
8769
|
+
for (let index = 0; __ball_lt(index, length); (index++)) {
|
|
8724
8770
|
let value = generator(index);
|
|
8725
8771
|
if ((value != null)) {
|
|
8726
8772
|
value = await value;
|
|
@@ -8868,7 +8914,7 @@ export class BallEngine {
|
|
|
8868
8914
|
}
|
|
8869
8915
|
}
|
|
8870
8916
|
if (__ball_eq(objTypeArgs.length, typeArgs.length)) {
|
|
8871
|
-
for (let i = 0; (i
|
|
8917
|
+
for (let i = 0; __ball_lt(i, typeArgs.length); (i++)) {
|
|
8872
8918
|
if (!__ball_eq(__ball_index(objTypeArgs, i), __ball_index(typeArgs, i))) {
|
|
8873
8919
|
return false;
|
|
8874
8920
|
}
|
|
@@ -8949,7 +8995,7 @@ export class BallEngine {
|
|
|
8949
8995
|
}
|
|
8950
8996
|
let objColon = objType.indexOf(':');
|
|
8951
8997
|
let checkColon = checkType.indexOf(':');
|
|
8952
|
-
if (((objColon
|
|
8998
|
+
if ((__ball_ge(objColon, 0) && __ball_ge(checkColon, 0))) {
|
|
8953
8999
|
return __ball_eq(objType.substring(__ball_add(objColon, 1)), checkType.substring(__ball_add(checkColon, 1)));
|
|
8954
9000
|
}
|
|
8955
9001
|
return false;
|
|
@@ -8959,7 +9005,7 @@ export class BallEngine {
|
|
|
8959
9005
|
let args = [];
|
|
8960
9006
|
let depth = 0;
|
|
8961
9007
|
let start = 0;
|
|
8962
|
-
for (let i = 0; (i
|
|
9008
|
+
for (let i = 0; __ball_lt(i, str.length); (i++)) {
|
|
8963
9009
|
if (__ball_eq(__ball_index(str, i), '<')) {
|
|
8964
9010
|
(depth++);
|
|
8965
9011
|
}
|
|
@@ -9123,7 +9169,7 @@ export class BallEngine {
|
|
|
9123
9169
|
let rhsStr = relMatch.group(2).trim();
|
|
9124
9170
|
let rhs = num.tryParse(rhsStr);
|
|
9125
9171
|
if (!__ball_eq(rhs, null)) {
|
|
9126
|
-
return ((op === '==') ? (__ball_eq(value, rhs)) : ((op === '!=') ? (!__ball_eq(value, rhs)) : ((op === '>') ? ((value
|
|
9172
|
+
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))))));
|
|
9127
9173
|
}
|
|
9128
9174
|
}
|
|
9129
9175
|
if (this._matchesTypePattern(value, trimmed)) {
|
|
@@ -9185,10 +9231,10 @@ export class BallEngine {
|
|
|
9185
9231
|
if ((__ball_eq(restIndex, __ball_negate(1)) && !__ball_eq(listVal.length, fixedCount))) {
|
|
9186
9232
|
return false;
|
|
9187
9233
|
}
|
|
9188
|
-
if ((!__ball_eq(restIndex, __ball_negate(1)) && (listVal.length
|
|
9234
|
+
if ((!__ball_eq(restIndex, __ball_negate(1)) && __ball_lt(listVal.length, fixedCount))) {
|
|
9189
9235
|
return false;
|
|
9190
9236
|
}
|
|
9191
|
-
for (let i = 0; (i
|
|
9237
|
+
for (let i = 0; __ball_lt(i, elements.length); (i++)) {
|
|
9192
9238
|
let elem = __ball_index(elements, i);
|
|
9193
9239
|
let elemMap = this._stdAsMap(elem);
|
|
9194
9240
|
if ((!__ball_eq(elemMap, null) && __ball_eq(this._patternKind(elemMap), 'rest'))) {
|
|
@@ -9199,7 +9245,7 @@ export class BallEngine {
|
|
|
9199
9245
|
}
|
|
9200
9246
|
continue;
|
|
9201
9247
|
}
|
|
9202
|
-
let valueIndex = ((__ball_eq(restIndex, __ball_negate(1)) || (i
|
|
9248
|
+
let valueIndex = ((__ball_eq(restIndex, __ball_negate(1)) || __ball_lt(i, restIndex)) ? i : __ball_sub(listVal.length, __ball_sub(elements.length, i)));
|
|
9203
9249
|
if (!this._matchPattern(__ball_index(listVal, valueIndex), elem, bindings)) {
|
|
9204
9250
|
return false;
|
|
9205
9251
|
}
|
|
@@ -9365,7 +9411,7 @@ export class BallEngine {
|
|
|
9365
9411
|
if (__ball_eq(operator, null)) {
|
|
9366
9412
|
return false;
|
|
9367
9413
|
}
|
|
9368
|
-
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
|
|
9414
|
+
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))))));
|
|
9369
9415
|
}
|
|
9370
9416
|
_matchesObjectType(value, patternType) {
|
|
9371
9417
|
let actual = (() => {
|
|
@@ -9438,7 +9484,7 @@ export class BallEngine {
|
|
|
9438
9484
|
}
|
|
9439
9485
|
_matchesTypePattern(value, pattern) {
|
|
9440
9486
|
let p = ((typeof pattern === 'string') ? pattern : this._ballToStringSimple(pattern));
|
|
9441
|
-
if ((((p.length
|
|
9487
|
+
if (((__ball_gt(p.length, 1) && p.endsWith('?')) && !p.includes(' '))) {
|
|
9442
9488
|
if ((__ball_eq(value, null) || (value == null))) {
|
|
9443
9489
|
return true;
|
|
9444
9490
|
}
|
|
@@ -9501,7 +9547,7 @@ export class BallEngine {
|
|
|
9501
9547
|
}
|
|
9502
9548
|
_repeatString(s, count) {
|
|
9503
9549
|
let out = '';
|
|
9504
|
-
for (let k = 0; (k
|
|
9550
|
+
for (let k = 0; __ball_lt(k, count); (k++)) {
|
|
9505
9551
|
out = (__ball_to_string(out) + __ball_to_string(s));
|
|
9506
9552
|
}
|
|
9507
9553
|
return out;
|
|
@@ -10205,14 +10251,14 @@ function _ballDoubleToInt64(value) {
|
|
|
10205
10251
|
return value.value;
|
|
10206
10252
|
}
|
|
10207
10253
|
let d = (((typeof value === 'number' || value instanceof BallDouble) ? value.value : new BallDouble(Number(value))));
|
|
10208
|
-
if ((d
|
|
10254
|
+
if (__ball_ge(d, new BallDouble(9223372036854776000))) {
|
|
10209
10255
|
return 9223372036854775807n;
|
|
10210
10256
|
}
|
|
10211
|
-
if ((d
|
|
10257
|
+
if (__ball_le(d, __ball_negate(new BallDouble(9223372036854776000)))) {
|
|
10212
10258
|
return __ball_negate(0);
|
|
10213
10259
|
}
|
|
10214
10260
|
let r = __ball_to_int(d);
|
|
10215
|
-
if (((d
|
|
10261
|
+
if ((__ball_gt(d, new BallDouble(0)) && __ball_lt(r, 0))) {
|
|
10216
10262
|
return 9223372036854775807n;
|
|
10217
10263
|
}
|
|
10218
10264
|
return r;
|