@ball-lang/engine 1.7.9 → 1.7.11
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 +344 -158
- package/dist/compiled_engine.js.map +1 -1
- package/dist/engine_setup.d.ts.map +1 -1
- package/dist/engine_setup.js +8 -1
- package/dist/engine_setup.js.map +1 -1
- package/package.json +1 -1
- package/src/compiled_engine.ts +344 -158
- package/src/engine_setup.ts +8 -1
package/src/compiled_engine.ts
CHANGED
|
@@ -97,12 +97,26 @@ class BallObject extends BallMap {
|
|
|
97
97
|
// (e.g. 42.0 not 42). Used by the compiled Dart engine's _toDouble.
|
|
98
98
|
class BallDouble {
|
|
99
99
|
readonly value: number;
|
|
100
|
-
|
|
100
|
+
// Collapse nested wrapping down to the innermost raw number instead of
|
|
101
|
+
// storing a BallDouble that holds another BallDouble. The concrete source of
|
|
102
|
+
// nested wrapping was string_to_double's engine handler wrapping the result
|
|
103
|
+
// of the already-wrapping compiled parse path from issue 222; that redundant
|
|
104
|
+
// wrap was removed at its root in issue 237, so this guard is now purely
|
|
105
|
+
// defensive (verified: the full TS engine suite stays green without it). It is
|
|
106
|
+
// kept as a cheap, idempotent belt-and-suspenders against any other caller
|
|
107
|
+
// that might wrap an already-wrapped value: a doubly-wrapped BallDouble makes
|
|
108
|
+
// Number/valueOf coercion throw "Cannot convert object to primitive value".
|
|
109
|
+
// For a plain-number caller the instanceof check is a no-op.
|
|
110
|
+
constructor(v: number) { this.value = v instanceof BallDouble ? v.value : v; }
|
|
101
111
|
valueOf(): number { return this.value; }
|
|
102
112
|
get isNaN(): boolean { return Number.isNaN(this.value); }
|
|
103
113
|
get isFinite(): boolean { return Number.isFinite(this.value); }
|
|
104
114
|
get isInfinite(): boolean { return !Number.isFinite(this.value) && !Number.isNaN(this.value); }
|
|
105
115
|
get isNegative(): boolean { return this.value < 0 || (this.value === 0 && 1/this.value === -Infinity); }
|
|
116
|
+
// Mirrors the Number.prototype.remainder polyfill below (truncating
|
|
117
|
+
// remainder, matching JS % and Dart's num.remainder) — BallDouble wraps
|
|
118
|
+
// a JS number so it never inherits Number.prototype and needs its own.
|
|
119
|
+
remainder(other: any): number { return this.value % Number(other); }
|
|
106
120
|
toString(): string {
|
|
107
121
|
const v = this.value;
|
|
108
122
|
if (!isFinite(v)) return v.toString();
|
|
@@ -222,11 +236,22 @@ function __ball_to_string(v: any): string {
|
|
|
222
236
|
}
|
|
223
237
|
if (v instanceof Map) {
|
|
224
238
|
const parts: string[] = [];
|
|
225
|
-
|
|
239
|
+
// v.entries() as a method call would hit the Dart-property-style
|
|
240
|
+
// getter of the same name (installed further down in this file) and
|
|
241
|
+
// try to invoke its return value -- an array -- as a function.
|
|
242
|
+
// _nativeMapEntries is the real, un-shadowed method (issue #259).
|
|
243
|
+
for (const [k, val] of _nativeMapEntries.call(v)) {
|
|
226
244
|
parts.push(__ball_to_string(k) + ': ' + __ball_to_string(val));
|
|
227
245
|
}
|
|
228
246
|
return '{' + parts.join(', ') + '}';
|
|
229
247
|
}
|
|
248
|
+
if (v instanceof Set) {
|
|
249
|
+
// A Set is a plain object from typeof's perspective (falls through to
|
|
250
|
+
// the generic branch below, which reads Object.keys — always [] for a
|
|
251
|
+
// Set's internal slots), so every Set printed as the empty "{}" no
|
|
252
|
+
// matter its contents until this dedicated case was added (#219).
|
|
253
|
+
return '{' + [...v].map(__ball_to_string).join(', ') + '}';
|
|
254
|
+
}
|
|
230
255
|
if (typeof v === 'object' && !Array.isArray(v)) {
|
|
231
256
|
// StringBuffer-like objects
|
|
232
257
|
if (v['__buffer__'] && Array.isArray(v['__buffer__'])) {
|
|
@@ -279,10 +304,13 @@ function __ball_to_int(v: any): any {
|
|
|
279
304
|
return t;
|
|
280
305
|
}
|
|
281
306
|
|
|
282
|
-
|
|
307
|
+
// Returns a BallDouble (not a bare number) so a whole-valued result (e.g.
|
|
308
|
+
// double.parse('7.0')) still prints "7.0", not "7" — JS numbers erase the
|
|
309
|
+
// int/double distinction that the wrapper exists to preserve (#67/#222).
|
|
310
|
+
function __ball_parse_double(s: string): BallDouble {
|
|
283
311
|
const n = parseFloat(s);
|
|
284
312
|
if (Number.isNaN(n)) throw new Error('FormatException: ' + s);
|
|
285
|
-
return n;
|
|
313
|
+
return new BallDouble(n);
|
|
286
314
|
}
|
|
287
315
|
|
|
288
316
|
function __ball_double_to_string(n: number): string {
|
|
@@ -290,6 +318,16 @@ function __ball_double_to_string(n: number): string {
|
|
|
290
318
|
return n.toString();
|
|
291
319
|
}
|
|
292
320
|
|
|
321
|
+
// num.toStringAsFixed(digits). JS Number.prototype.toFixed drops the sign of
|
|
322
|
+
// -0 (returns "0.00" not "-0.00"); Dart's toStringAsFixed keeps it, matching
|
|
323
|
+
// the -0 handling __ball_to_string/BallDouble.toString already do.
|
|
324
|
+
function __ball_to_fixed(v: any, digits: any): string {
|
|
325
|
+
const n = Number(v);
|
|
326
|
+
const s = n.toFixed(digits);
|
|
327
|
+
if (n === 0 && 1 / n === -Infinity && !s.startsWith('-')) return '-' + s;
|
|
328
|
+
return s;
|
|
329
|
+
}
|
|
330
|
+
|
|
293
331
|
// Polymorphic concat / merge used for std.list_concat. The encoder emits
|
|
294
332
|
// list_concat both for Dart list concat AND for Map.addAll(...) (encoded as
|
|
295
333
|
// m = list_concat(m, other)). Arrays concat positionally; plain objects
|
|
@@ -333,24 +371,77 @@ function __ball_push_all(target: any, items: any): void {
|
|
|
333
371
|
// demotes back to Number when the result fits in MAX_SAFE_INTEGER.
|
|
334
372
|
const __I64_MAX = 9223372036854775807n;
|
|
335
373
|
const __I64_MIN = -9223372036854775808n;
|
|
336
|
-
const __I64_MOD = 18446744073709551616n;
|
|
337
374
|
function __i64_wrap(v: bigint): any {
|
|
338
|
-
|
|
339
|
-
|
|
375
|
+
// Two's-complement wrap to the signed 64-bit range — BigInt.asIntN(64, v)
|
|
376
|
+
// is the idiomatic builtin for exactly this (equivalent to the old manual
|
|
377
|
+
// modulo-then-resign, verified against it across boundary/overflow cases).
|
|
378
|
+
v = BigInt.asIntN(64, v);
|
|
340
379
|
if (v >= -9007199254740991n && v <= 9007199254740991n) return Number(v);
|
|
341
380
|
return v;
|
|
342
381
|
}
|
|
343
382
|
function __to_bigint(v: any): bigint {
|
|
344
383
|
if (typeof v === 'bigint') return v;
|
|
384
|
+
// Matches the reference Dart engine's _toInt (engine_std.dart), which
|
|
385
|
+
// falls through to 0 for anything that isn't an int/BallInt/double/
|
|
386
|
+
// BallDouble/String/bool -- including null. NaN is deliberately NOT
|
|
387
|
+
// special-cased here: Dart's double.toInt() throws on NaN (via
|
|
388
|
+
// _ballDoubleToInt64), and BigInt(NaN) already throws for the same
|
|
389
|
+
// reason (RangeError: not an integer), so that path already fails loud
|
|
390
|
+
// consistently with the reference engine without any extra handling.
|
|
391
|
+
if (v === null || v === undefined) return 0n;
|
|
345
392
|
if (v instanceof BallDouble) return BigInt(Math.trunc(v.value));
|
|
346
393
|
return BigInt(v);
|
|
347
394
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
395
|
+
// Fast-path guard: true when v is a plain (non-bigint, non-BallDouble)
|
|
396
|
+
// integer within the signed 32-bit range. AND/OR/XOR/NOT never grow a
|
|
397
|
+
// result past its operands' bit width, so when both operands fit in 32
|
|
398
|
+
// bits, JS's native 32-bit bitwise operators give a result numerically
|
|
399
|
+
// IDENTICAL to the full 64-bit BigInt path (sign-extending a 32-bit value
|
|
400
|
+
// to 64 bits before AND/OR/XOR/NOT never changes the low 32 result bits,
|
|
401
|
+
// and — verified across the full boundary range — never changes whether
|
|
402
|
+
// the high bits are the correct sign-extension of them either). Left/right
|
|
403
|
+
// shift are NOT given this fast path: shifting can grow a result past 32
|
|
404
|
+
// bits even when the input operand fits (e.g. large_int << 40), so their
|
|
405
|
+
// overflow behavior isn't safely 32-bit-local the way AND/OR/XOR/NOT is.
|
|
406
|
+
function __fits32(v: any): boolean {
|
|
407
|
+
return typeof v === 'number' && Number.isInteger(v) && v >= -2147483648 && v <= 2147483647;
|
|
408
|
+
}
|
|
409
|
+
function __ball_bitand(a: any, b: any): any {
|
|
410
|
+
if (__fits32(a) && __fits32(b)) return a & b;
|
|
411
|
+
return __i64_wrap(__to_bigint(a) & __to_bigint(b));
|
|
412
|
+
}
|
|
413
|
+
function __ball_bitor(a: any, b: any): any {
|
|
414
|
+
if (__fits32(a) && __fits32(b)) return a | b;
|
|
415
|
+
return __i64_wrap(__to_bigint(a) | __to_bigint(b));
|
|
416
|
+
}
|
|
417
|
+
function __ball_bitxor(a: any, b: any): any {
|
|
418
|
+
if (__fits32(a) && __fits32(b)) return a ^ b;
|
|
419
|
+
return __i64_wrap(__to_bigint(a) ^ __to_bigint(b));
|
|
420
|
+
}
|
|
421
|
+
function __ball_bitnot(a: any): any {
|
|
422
|
+
if (__fits32(a)) return ~a;
|
|
423
|
+
return __i64_wrap(~__to_bigint(a));
|
|
424
|
+
}
|
|
352
425
|
function __ball_shl(a: any, b: any): any { return __i64_wrap(__to_bigint(a) << __to_bigint(b)); }
|
|
353
426
|
function __ball_shr(a: any, b: any): any { return __i64_wrap(__to_bigint(a) >> __to_bigint(b)); }
|
|
427
|
+
// Unsigned/logical shift: reinterpret a as an unsigned 64-bit value (add
|
|
428
|
+
// 2^64 if negative) before shifting, so zeros fill from the left instead of
|
|
429
|
+
// the sign bit — unlike >>> on raw JS numbers, which is only 32-bit.
|
|
430
|
+
function __ball_ushr(a: any, b: any): any {
|
|
431
|
+
const unsigned = BigInt.asUintN(64, __to_bigint(a));
|
|
432
|
+
return __i64_wrap(unsigned >> __to_bigint(b));
|
|
433
|
+
}
|
|
434
|
+
// json_encode (dart:convert's jsonEncode) on a bigint-range int64 must not
|
|
435
|
+
// crash -- JSON.stringify throws "Do not know how to serialize a BigInt"
|
|
436
|
+
// without a toJSON. This is NOT proto3-JSON (which quotes int64 as a
|
|
437
|
+
// string) -- Ball's dart:convert-style jsonEncode matches Dart's own
|
|
438
|
+
// dart:convert (a bare, unquoted JSON number) and the C++ self-host's
|
|
439
|
+
// _ball_json_encode (std::to_string(int64_t), also unquoted). JSON.rawJSON
|
|
440
|
+
// embeds the exact decimal digits as a raw number token, avoiding the
|
|
441
|
+
// precision loss Number(this) would introduce for values past 2^53.
|
|
442
|
+
(BigInt.prototype as any).toJSON = function (this: bigint) {
|
|
443
|
+
return (JSON as any).rawJSON(this.toString());
|
|
444
|
+
};
|
|
354
445
|
function __ball_negate(a: any): any {
|
|
355
446
|
if (typeof a === 'bigint') return __i64_wrap(-a);
|
|
356
447
|
if (a instanceof BallDouble) return new BallDouble(-a.value);
|
|
@@ -414,14 +505,6 @@ function __dart_mod(a: any, b: any): any {
|
|
|
414
505
|
// Active exception for rethrow. Catch bodies shadow with a local.
|
|
415
506
|
let __ball_active_error: any = undefined;
|
|
416
507
|
|
|
417
|
-
// Safe own-property lookup. Returns undefined if key is not an own property.
|
|
418
|
-
// Avoids triggering Object.prototype getters (entries, keys, values) on
|
|
419
|
-
// plain objects that aren't meant to be Dart Maps.
|
|
420
|
-
function __ball_own(obj: any, key: any): any {
|
|
421
|
-
if (obj == null || typeof obj !== 'object') return undefined;
|
|
422
|
-
return Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
508
|
// Dart-style index access. Dart's List '[]' operator throws RangeError on
|
|
426
509
|
// out-of-bounds access, whereas JS array indexing silently returns undefined.
|
|
427
510
|
// To make 'on RangeError' catch clauses behave like Dart we bounds-check list
|
|
@@ -629,6 +712,21 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
629
712
|
// ── Dart \u2192 JS method-name polyfills ────────────────────────────────
|
|
630
713
|
//
|
|
631
714
|
// Idempotent: guarded so multiple preamble inclusions don't double-install.
|
|
715
|
+
|
|
716
|
+
// Native Map.prototype.entries/keys/values, captured BEFORE the
|
|
717
|
+
// installBallPolyfills IIFE below shadows them with Dart-property-style
|
|
718
|
+
// getters of the same name. Top-level (not IIFE-scoped) so every internal
|
|
719
|
+
// call site that needs the REAL iterator method -- not the property-style
|
|
720
|
+
// getter -- can reach it: the getters themselves (which must call the
|
|
721
|
+
// original to avoid recursing into themselves), __ball_to_string's Map
|
|
722
|
+
// printer, the Map-like constructor copy sites, and the map_keys/values/
|
|
723
|
+
// entries base-function helpers (issue #259 -- calling .entries()/etc.
|
|
724
|
+
// as a METHOD on a real Map after the shadow is installed throws, since
|
|
725
|
+
// the getter's return value -- an array -- isn't itself callable).
|
|
726
|
+
const _nativeMapEntries = Map.prototype.entries;
|
|
727
|
+
const _nativeMapKeys = Map.prototype.keys;
|
|
728
|
+
const _nativeMapValues = Map.prototype.values;
|
|
729
|
+
|
|
632
730
|
(function installBallPolyfills() {
|
|
633
731
|
const mp: any = Map.prototype;
|
|
634
732
|
if (!mp.containsKey) mp.containsKey = function (k: any) { return this.has(k); };
|
|
@@ -641,7 +739,9 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
641
739
|
if (!mp.addAll) {
|
|
642
740
|
mp.addAll = function (other: any) {
|
|
643
741
|
if (other instanceof Map) {
|
|
644
|
-
|
|
742
|
+
// _nativeMapEntries, not other.entries() -- see __ball_to_string's
|
|
743
|
+
// Map printer above for why (issue #259).
|
|
744
|
+
for (const [k, v] of _nativeMapEntries.call(other)) this.set(k, v);
|
|
645
745
|
} else if (other && typeof other === 'object') {
|
|
646
746
|
for (const k of Object.keys(other)) this.set(k, other[k]);
|
|
647
747
|
}
|
|
@@ -769,6 +869,9 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
769
869
|
Object.defineProperty(_ballNp, 'isInfinite', {
|
|
770
870
|
configurable: true, get() { const n = Number(this); return n === Infinity || n === -Infinity; },
|
|
771
871
|
});
|
|
872
|
+
Object.defineProperty(_ballNp, 'isNegative', {
|
|
873
|
+
configurable: true, get() { const n = Number(this); return n < 0 || (n === 0 && 1 / n === -Infinity); },
|
|
874
|
+
});
|
|
772
875
|
if (!_ballNp.abs) _ballNp.abs = function () { return Math.abs(Number(this)); };
|
|
773
876
|
if (!_ballNp.ceil) _ballNp.ceil = function () { return Math.ceil(Number(this)); };
|
|
774
877
|
if (!_ballNp.floor) _ballNp.floor = function () { return Math.floor(Number(this)); };
|
|
@@ -778,7 +881,7 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
778
881
|
if (!_ballNp.toDouble) _ballNp.toDouble = function () { return Number(this); };
|
|
779
882
|
if (!_ballNp.clamp) _ballNp.clamp = function (lo: any, hi: any) { const n = Number(this); return n < lo ? lo : n > hi ? hi : n; };
|
|
780
883
|
if (!_ballNp.compareTo) _ballNp.compareTo = function (other: any) { const a = Number(this), b = Number(other); return a < b ? -1 : a > b ? 1 : 0; };
|
|
781
|
-
if (!_ballNp.toStringAsFixed) _ballNp.toStringAsFixed = function (digits: any) { return
|
|
884
|
+
if (!_ballNp.toStringAsFixed) _ballNp.toStringAsFixed = function (digits: any) { return __ball_to_fixed(this, digits); };
|
|
782
885
|
if (!_ballNp.remainder) _ballNp.remainder = function (other: any) { return Number(this) % Number(other); };
|
|
783
886
|
|
|
784
887
|
// Object.prototype polyfills — used by the compiled engine when
|
|
@@ -815,7 +918,8 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
815
918
|
value: function (other: any) {
|
|
816
919
|
if (this instanceof Map) {
|
|
817
920
|
if (other instanceof Map) {
|
|
818
|
-
|
|
921
|
+
// _nativeMapEntries, not other.entries() (issue #259).
|
|
922
|
+
for (const [k, v] of _nativeMapEntries.call(other)) this.set(k, v);
|
|
819
923
|
} else if (other && typeof other === 'object') {
|
|
820
924
|
for (const k of Object.keys(other)) this.set(k, other[k]);
|
|
821
925
|
}
|
|
@@ -868,9 +972,9 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
868
972
|
// JS Map has them as METHODS (need parens). The compiled engine
|
|
869
973
|
// accesses map.entries as a getter. Shadow BOTH Map.prototype AND
|
|
870
974
|
// Object.prototype so Map and plain-object dispatch tables work.
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
975
|
+
// (_nativeMapEntries/_nativeMapKeys/_nativeMapValues are captured at
|
|
976
|
+
// top level above, not here, so other call sites outside this IIFE
|
|
977
|
+
// can reach them too -- issue #259.)
|
|
874
978
|
// Shadow Map.prototype.entries with a getter (Dart uses it as a getter).
|
|
875
979
|
Object.defineProperty(Map.prototype, 'entries', {
|
|
876
980
|
configurable: true, enumerable: false,
|
|
@@ -901,19 +1005,42 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
901
1005
|
},
|
|
902
1006
|
});
|
|
903
1007
|
}
|
|
1008
|
+
// .entries/.keys/.values on a non-Map must FAIL LOUD (throw a catchable
|
|
1009
|
+
// error), not silently return [] — the silent-degradation class of bug
|
|
1010
|
+
// that hid issue #55 (mirrors the fix already applied to the Dart/C++
|
|
1011
|
+
// compilers). .entries used to be the odd one out here, silently
|
|
1012
|
+
// returning [] instead of throwing — same bug family as #218.
|
|
1013
|
+
//
|
|
1014
|
+
// A getter installed on Object.prototype is invoked in "sloppy" (non-strict)
|
|
1015
|
+
// script contexts with this auto-boxed to a Number/String/Boolean WRAPPER
|
|
1016
|
+
// object for a primitive receiver (e.g. (42).keys boxes this to a Number
|
|
1017
|
+
// instance) — typeof this is then 'object', not 'number', so a bare
|
|
1018
|
+
// __ball_is_type(this, 'Map') (which only excludes Array/BallDouble/Set)
|
|
1019
|
+
// would wrongly treat a boxed int/string as Map-like. Exclude the wrapper
|
|
1020
|
+
// types explicitly instead of widening the shared type-check.
|
|
1021
|
+
const __isGenuineMap = (v: any) =>
|
|
1022
|
+
typeof v === 'object' && v !== null && !Array.isArray(v) &&
|
|
1023
|
+
!(v instanceof BallDouble) && !(v instanceof Set) &&
|
|
1024
|
+
!(v instanceof Number) && !(v instanceof String) && !(v instanceof Boolean);
|
|
904
1025
|
defDartGetter('entries', function (this: any) {
|
|
905
1026
|
if (this instanceof Map) return [..._nativeMapEntries.call(this)].map(([k, v]: any) => ({ key: k, value: v }));
|
|
906
|
-
if (this
|
|
1027
|
+
if (!__isGenuineMap(this)) {
|
|
1028
|
+
throw new Error('type \'' + __ball_to_string(this) + '\' has no .entries getter (not a Map)');
|
|
1029
|
+
}
|
|
907
1030
|
return Object.entries(this).map(([k, v]: any) => ({ key: k, value: v }));
|
|
908
1031
|
});
|
|
909
1032
|
defDartGetter('keys', function (this: any) {
|
|
910
1033
|
if (this instanceof Map) return [..._nativeMapKeys.call(this)];
|
|
911
|
-
if (this
|
|
1034
|
+
if (!__isGenuineMap(this)) {
|
|
1035
|
+
throw new Error('type \'' + __ball_to_string(this) + '\' has no .keys getter (not a Map)');
|
|
1036
|
+
}
|
|
912
1037
|
return Object.keys(this);
|
|
913
1038
|
});
|
|
914
1039
|
defDartGetter('values', function (this: any) {
|
|
915
1040
|
if (this instanceof Map) return [..._nativeMapValues.call(this)];
|
|
916
|
-
if (this
|
|
1041
|
+
if (!__isGenuineMap(this)) {
|
|
1042
|
+
throw new Error('type \'' + __ball_to_string(this) + '\' has no .values getter (not a Map)');
|
|
1043
|
+
}
|
|
917
1044
|
return Object.values(this);
|
|
918
1045
|
});
|
|
919
1046
|
defDartGetter('length', function (this: any) {
|
|
@@ -964,6 +1091,65 @@ function __ball_cascade(target: any, ops: any[]): any {
|
|
|
964
1091
|
});
|
|
965
1092
|
})();
|
|
966
1093
|
|
|
1094
|
+
// std.map_keys/std.map_values/std.map_entries (the base-function-call form,
|
|
1095
|
+
// as opposed to the .keys/.values/.entries DART-GETTER-STYLE property
|
|
1096
|
+
// access the defDartGetter block above already guards) must ALSO fail loud
|
|
1097
|
+
// on a non-Map receiver instead of silently returning [] — same "genuine
|
|
1098
|
+
// Map" check, exposed as top-level helpers so compileStdCall's emitted code
|
|
1099
|
+
// can call them (#218).
|
|
1100
|
+
function __ball_map_keys(m: any): any {
|
|
1101
|
+
// _nativeMapKeys, not m.keys() -- m.keys() would hit the Dart-property-
|
|
1102
|
+
// style getter shadowing Map.prototype.keys and try to invoke its
|
|
1103
|
+
// return value (an array) as a function (issue #259).
|
|
1104
|
+
if (m instanceof Map) return [..._nativeMapKeys.call(m)];
|
|
1105
|
+
if (typeof m !== 'object' || m === null || Array.isArray(m) ||
|
|
1106
|
+
m instanceof BallDouble || m instanceof Set ||
|
|
1107
|
+
m instanceof Number || m instanceof String || m instanceof Boolean) {
|
|
1108
|
+
throw new Error('type \'' + __ball_to_string(m) + '\' has no .keys getter (not a Map)');
|
|
1109
|
+
}
|
|
1110
|
+
return Object.keys(m);
|
|
1111
|
+
}
|
|
1112
|
+
function __ball_map_values(m: any): any {
|
|
1113
|
+
// _nativeMapValues, not m.values() (issue #259 -- see __ball_map_keys).
|
|
1114
|
+
if (m instanceof Map) return [..._nativeMapValues.call(m)];
|
|
1115
|
+
if (typeof m !== 'object' || m === null || Array.isArray(m) ||
|
|
1116
|
+
m instanceof BallDouble || m instanceof Set ||
|
|
1117
|
+
m instanceof Number || m instanceof String || m instanceof Boolean) {
|
|
1118
|
+
throw new Error('type \'' + __ball_to_string(m) + '\' has no .values getter (not a Map)');
|
|
1119
|
+
}
|
|
1120
|
+
return Object.values(m);
|
|
1121
|
+
}
|
|
1122
|
+
function __ball_map_entries(m: any): any {
|
|
1123
|
+
// _nativeMapEntries, not m.entries() (issue #259 -- see __ball_map_keys).
|
|
1124
|
+
if (m instanceof Map) return [..._nativeMapEntries.call(m)].map(([k, v]) => ({ key: k, value: v }));
|
|
1125
|
+
if (typeof m !== 'object' || m === null || Array.isArray(m) ||
|
|
1126
|
+
m instanceof BallDouble || m instanceof Set ||
|
|
1127
|
+
m instanceof Number || m instanceof String || m instanceof Boolean) {
|
|
1128
|
+
throw new Error('type \'' + __ball_to_string(m) + '\' has no .entries getter (not a Map)');
|
|
1129
|
+
}
|
|
1130
|
+
return Object.entries(m).map(([k, v]) => ({ key: k, value: v }));
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
// Shared guard for the REMAINING map_* base-function-call cases
|
|
1134
|
+
// (map_get/map_set/map_delete/map_merge/map_length/map_is_empty/
|
|
1135
|
+
// map_contains_key/map_contains_value/map_foreach) that used to route a
|
|
1136
|
+
// bare map[key], Object.keys/values(map), or key in map straight to the
|
|
1137
|
+
// receiver with no type check at all -- silently returning undefined,
|
|
1138
|
+
// no-opping, or checking array-index membership instead of throwing on a
|
|
1139
|
+
// non-Map (issue #55's silent-degradation class, same family as #218's
|
|
1140
|
+
// map_keys/map_values/map_entries). Returns the validated Map/plain-object
|
|
1141
|
+
// itself (not a boolean) so a call site can keep using it directly, e.g.
|
|
1142
|
+
// __ball_require_map(x, 'map_get')[key].
|
|
1143
|
+
function __ball_require_map(v: any, opName: string): any {
|
|
1144
|
+
if (v instanceof Map) return v;
|
|
1145
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v) ||
|
|
1146
|
+
v instanceof BallDouble || v instanceof Set ||
|
|
1147
|
+
v instanceof Number || v instanceof String || v instanceof Boolean) {
|
|
1148
|
+
throw new Error('type \'' + __ball_to_string(v) + '\' is not a Map (' + opName + ')');
|
|
1149
|
+
}
|
|
1150
|
+
return v;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
967
1153
|
// ── Protobuf Struct/Value compatibility ─────────────────────────
|
|
968
1154
|
//
|
|
969
1155
|
// Dart's protobuf runtime wraps google.protobuf.Struct as a class
|
|
@@ -1635,7 +1821,7 @@ export class BallEngine {
|
|
|
1635
1821
|
}
|
|
1636
1822
|
if (hasMetadata(func)) {
|
|
1637
1823
|
let params = this._extractParams(func.metadata);
|
|
1638
|
-
if (!(params.length === 0)) {
|
|
1824
|
+
if ((!(params.length === 0) && !(func.name.length === 0))) {
|
|
1639
1825
|
this._paramCache[key] = params;
|
|
1640
1826
|
}
|
|
1641
1827
|
let kindField = __ball_index(func.metadata.fields, 'kind');
|
|
@@ -1715,7 +1901,7 @@ export class BallEngine {
|
|
|
1715
1901
|
|
|
1716
1902
|
_resolveInstanceMethodDispatch(typeName: any, methodName: any): any {
|
|
1717
1903
|
let cacheKey = BallEngine._typeMethodKey(typeName, methodName);
|
|
1718
|
-
if ((cacheKey in this._instanceMethodCache)) {
|
|
1904
|
+
if ((cacheKey in __ball_require_map(this._instanceMethodCache, 'map_contains_key'))) {
|
|
1719
1905
|
return __ball_index(this._instanceMethodCache, cacheKey);
|
|
1720
1906
|
}
|
|
1721
1907
|
let resolved = (this._resolveMethod(typeName, methodName) ?? this._lookupTypeMethodWithInheritance(typeName, methodName));
|
|
@@ -1892,7 +2078,7 @@ export class BallEngine {
|
|
|
1892
2078
|
let dotIdx = func.name.indexOf('.');
|
|
1893
2079
|
let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
|
|
1894
2080
|
let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
|
|
1895
|
-
if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in constructorInput))) && !__ball_eq(this._findTypeDef(typeName), null))) {
|
|
2081
|
+
if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in __ball_require_map(constructorInput, 'map_contains_key')))) && !__ball_eq(this._findTypeDef(typeName), null))) {
|
|
1896
2082
|
return this._callObjectConstructor(moduleName, func, input);
|
|
1897
2083
|
}
|
|
1898
2084
|
}
|
|
@@ -1902,14 +2088,14 @@ export class BallEngine {
|
|
|
1902
2088
|
if ((!(func.inputType.length === 0) && !__ball_eq(input, null))) {
|
|
1903
2089
|
scope.bind('input', input);
|
|
1904
2090
|
}
|
|
1905
|
-
let params = (__ball_index(this._paramCache, ((__ball_to_string(moduleName) + '.') + __ball_to_string(func.name))) ?? ((hasMetadata(func) ? this._extractParams(func.metadata) : [])));
|
|
2091
|
+
let params = (!(func.name.length === 0) ? (__ball_index(this._paramCache, ((__ball_to_string(moduleName) + '.') + __ball_to_string(func.name))) ?? ((hasMetadata(func) ? this._extractParams(func.metadata) : []))) : ((hasMetadata(func) ? this._extractParams(func.metadata) : [])));
|
|
1906
2092
|
let inputMap = this._asMap(input);
|
|
1907
2093
|
if (!(params.length === 0)) {
|
|
1908
|
-
if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && ('self' in inputMap)))) {
|
|
1909
|
-
if ((!__ball_eq(inputMap, null) && (__ball_index(params, 0) in inputMap))) {
|
|
2094
|
+
if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key'))))) {
|
|
2095
|
+
if ((!__ball_eq(inputMap, null) && (__ball_index(params, 0) in __ball_require_map(inputMap, 'map_contains_key')))) {
|
|
1910
2096
|
scope.bind(__ball_index(params, 0), __ball_index(inputMap, __ball_index(params, 0)));
|
|
1911
2097
|
} else {
|
|
1912
|
-
if (((!__ball_eq(inputMap, null) && ('arg0' in inputMap)) && !(__ball_index(params, 0) in inputMap))) {
|
|
2098
|
+
if (((!__ball_eq(inputMap, null) && ('arg0' in __ball_require_map(inputMap, 'map_contains_key'))) && !(__ball_index(params, 0) in __ball_require_map(inputMap, 'map_contains_key')))) {
|
|
1913
2099
|
scope.bind(__ball_index(params, 0), __ball_index(inputMap, 'arg0'));
|
|
1914
2100
|
} else {
|
|
1915
2101
|
scope.bind(__ball_index(params, 0), input);
|
|
@@ -1919,13 +2105,13 @@ export class BallEngine {
|
|
|
1919
2105
|
if (!__ball_eq(inputMap, null)) {
|
|
1920
2106
|
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
1921
2107
|
let p = __ball_index(params, i);
|
|
1922
|
-
if ((p in inputMap)) {
|
|
2108
|
+
if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
1923
2109
|
scope.bind(p, __ball_index(inputMap, p));
|
|
1924
2110
|
} else {
|
|
1925
|
-
if ((('arg' + __ball_to_string(i)) in inputMap)) {
|
|
2111
|
+
if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
1926
2112
|
scope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
|
|
1927
2113
|
} else {
|
|
1928
|
-
if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && ('value' in inputMap)) && this._isSetter(func))) {
|
|
2114
|
+
if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && ('value' in __ball_require_map(inputMap, 'map_contains_key'))) && this._isSetter(func))) {
|
|
1929
2115
|
scope.bind(p, __ball_index(inputMap, 'value'));
|
|
1930
2116
|
}
|
|
1931
2117
|
}
|
|
@@ -1940,7 +2126,7 @@ export class BallEngine {
|
|
|
1940
2126
|
}
|
|
1941
2127
|
}
|
|
1942
2128
|
}
|
|
1943
|
-
if ((!__ball_eq(inputMap, null) && ('self' in inputMap))) {
|
|
2129
|
+
if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
|
|
1944
2130
|
let self = __ball_index(inputMap, 'self');
|
|
1945
2131
|
scope.bind('self', self);
|
|
1946
2132
|
let selfMap = this._asMap(self);
|
|
@@ -1975,7 +2161,7 @@ export class BallEngine {
|
|
|
1975
2161
|
let isAsyncStar = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_async_star')));
|
|
1976
2162
|
let isGenerator = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_generator')));
|
|
1977
2163
|
let isGenFunc = ((isSyncStar || isAsyncStar) || isGenerator);
|
|
1978
|
-
let generator
|
|
2164
|
+
let generator;
|
|
1979
2165
|
if (isGenFunc) {
|
|
1980
2166
|
generator = _ballNewGenerator();
|
|
1981
2167
|
scope.bind('__generator__', generator);
|
|
@@ -1984,7 +2170,7 @@ export class BallEngine {
|
|
|
1984
2170
|
this._activeGeneratorScope = scope;
|
|
1985
2171
|
}
|
|
1986
2172
|
let isAsync = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_async')));
|
|
1987
|
-
let finalResult
|
|
2173
|
+
let finalResult;
|
|
1988
2174
|
if ((isAsync && !isGenFunc)) {
|
|
1989
2175
|
try {
|
|
1990
2176
|
let result = await this._evalExpression(func.body, scope);
|
|
@@ -2002,7 +2188,7 @@ export class BallEngine {
|
|
|
2002
2188
|
} else {
|
|
2003
2189
|
let result = await this._evalExpression(func.body, scope);
|
|
2004
2190
|
this._currentModule = prevModule;
|
|
2005
|
-
if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && ('self' in inputMap))) {
|
|
2191
|
+
if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
|
|
2006
2192
|
let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
|
|
2007
2193
|
if (((result instanceof _FlowSignal) && __ball_eq(result.kind, 'return'))) {
|
|
2008
2194
|
finalResult = result.value;
|
|
@@ -2069,15 +2255,15 @@ export class BallEngine {
|
|
|
2069
2255
|
let resolvedParams = {};
|
|
2070
2256
|
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2071
2257
|
let param = __ball_index(params, i);
|
|
2072
|
-
let value
|
|
2073
|
-
if ((param in inputMap)) {
|
|
2258
|
+
let value;
|
|
2259
|
+
if ((param in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
2074
2260
|
value = __ball_index(inputMap, param);
|
|
2075
2261
|
} else {
|
|
2076
|
-
if ((('arg' + __ball_to_string(i)) in inputMap)) {
|
|
2262
|
+
if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
2077
2263
|
value = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
|
|
2078
2264
|
}
|
|
2079
2265
|
}
|
|
2080
|
-
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
|
|
2266
|
+
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
|
|
2081
2267
|
value = __ball_index(__ball_index(paramsMeta, i), 'default');
|
|
2082
2268
|
}
|
|
2083
2269
|
resolvedParams[param] = value;
|
|
@@ -2092,7 +2278,7 @@ export class BallEngine {
|
|
|
2092
2278
|
}
|
|
2093
2279
|
this._initFieldDefaults(typeName, instanceFields);
|
|
2094
2280
|
let superclass = this._getMetaString(typeDef, 'superclass');
|
|
2095
|
-
let superObject
|
|
2281
|
+
let superObject;
|
|
2096
2282
|
if ((!__ball_eq(superclass, null) && !(superclass.length === 0))) {
|
|
2097
2283
|
superObject = await this._invokeSuperConstructor(func, superclass, resolvedParams);
|
|
2098
2284
|
superObject ??= this._buildSuperObject(superclass, instanceFields);
|
|
@@ -2108,7 +2294,7 @@ export class BallEngine {
|
|
|
2108
2294
|
})();
|
|
2109
2295
|
let constructed = await this._callFunction(moduleName, func, ctorInput);
|
|
2110
2296
|
let constructedMap = this._asMap(constructed);
|
|
2111
|
-
if ((!__ball_eq(constructedMap, null) && ('__type__' in constructedMap))) {
|
|
2297
|
+
if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
|
|
2112
2298
|
return constructed;
|
|
2113
2299
|
}
|
|
2114
2300
|
return instance;
|
|
@@ -2198,11 +2384,11 @@ export class BallEngine {
|
|
|
2198
2384
|
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
2199
2385
|
let p = __ball_index(params, i);
|
|
2200
2386
|
let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
|
|
2201
|
-
let val
|
|
2202
|
-
if ((p in inputMap)) {
|
|
2387
|
+
let val;
|
|
2388
|
+
if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
2203
2389
|
val = __ball_index(inputMap, p);
|
|
2204
2390
|
} else {
|
|
2205
|
-
if ((('arg' + __ball_to_string(i)) in inputMap)) {
|
|
2391
|
+
if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
2206
2392
|
val = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
|
|
2207
2393
|
} else {
|
|
2208
2394
|
val = (__ball_lt(i, paramsMeta.length) ? __ball_index(__ball_index(paramsMeta, i), 'default') : null);
|
|
@@ -2238,7 +2424,7 @@ export class BallEngine {
|
|
|
2238
2424
|
if (!__ball_eq(superMap, null)) {
|
|
2239
2425
|
instance['__super__'] = superInstance;
|
|
2240
2426
|
for (const e of superMap.entries) {
|
|
2241
|
-
if ((!e.key.startsWith('__') && !(e.key in instance))) {
|
|
2427
|
+
if ((!e.key.startsWith('__') && !(e.key in __ball_require_map(instance, 'map_contains_key')))) {
|
|
2242
2428
|
instance[e.key] = e.value;
|
|
2243
2429
|
}
|
|
2244
2430
|
}
|
|
@@ -2281,7 +2467,7 @@ export class BallEngine {
|
|
|
2281
2467
|
let superInput = {};
|
|
2282
2468
|
for (let i = 0; __ball_lt(i, argNames.length); (i++)) {
|
|
2283
2469
|
let token = __ball_index(argNames, i);
|
|
2284
|
-
if ((token in resolvedParams)) {
|
|
2470
|
+
if ((token in __ball_require_map(resolvedParams, 'map_contains_key'))) {
|
|
2285
2471
|
superInput[('arg' + __ball_to_string(i))] = __ball_index(resolvedParams, token);
|
|
2286
2472
|
} else {
|
|
2287
2473
|
if (((token.startsWith('\'') && token.endsWith('\'')) || (token.startsWith('"') && token.endsWith('"')))) {
|
|
@@ -2850,7 +3036,7 @@ export class BallEngine {
|
|
|
2850
3036
|
}
|
|
2851
3037
|
if (hasMetadata(func)) {
|
|
2852
3038
|
let params = this._extractParams(func.metadata);
|
|
2853
|
-
if (!(params.length === 0)) {
|
|
3039
|
+
if ((!(params.length === 0) && !(func.name.length === 0))) {
|
|
2854
3040
|
this._paramCache[key] = params;
|
|
2855
3041
|
}
|
|
2856
3042
|
let kindField = __ball_index(func.metadata.fields, 'kind');
|
|
@@ -2884,7 +3070,7 @@ export class BallEngine {
|
|
|
2884
3070
|
|
|
2885
3071
|
static _extractMetadataTypeArgs(msg: any): any {
|
|
2886
3072
|
const input = msg;
|
|
2887
|
-
if ((!hasMetadata(msg) || !('type_args' in msg.metadata.fields))) {
|
|
3073
|
+
if ((!hasMetadata(msg) || !('type_args' in __ball_require_map(msg.metadata.fields, 'map_contains_key')))) {
|
|
2888
3074
|
return null;
|
|
2889
3075
|
}
|
|
2890
3076
|
return [...__ball_index(msg.metadata.fields, 'type_args').listValue.values.map(BallEngine._typeRefValueToString)];
|
|
@@ -3067,7 +3253,7 @@ export class BallEngine {
|
|
|
3067
3253
|
}
|
|
3068
3254
|
}
|
|
3069
3255
|
let inputMap = this._asMap(input);
|
|
3070
|
-
if ((!__ball_eq(inputMap, null) && ('self' in inputMap))) {
|
|
3256
|
+
if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
|
|
3071
3257
|
let self = __ball_index(inputMap, 'self');
|
|
3072
3258
|
let selfMap = this._asMap(self);
|
|
3073
3259
|
if (!__ball_eq(selfMap, null)) {
|
|
@@ -3104,7 +3290,7 @@ export class BallEngine {
|
|
|
3104
3290
|
let methodOwner = selfMap;
|
|
3105
3291
|
while (!__ball_eq(methodOwner, null)) {
|
|
3106
3292
|
let methods = __ball_index(methodOwner, '__methods__');
|
|
3107
|
-
if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (call.function in methods))) {
|
|
3293
|
+
if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (call.function in __ball_require_map(methods, 'map_contains_key')))) {
|
|
3108
3294
|
let method = __ball_index(methods, call.function);
|
|
3109
3295
|
if ((typeof method === 'function')) {
|
|
3110
3296
|
let result = method(input);
|
|
@@ -3128,7 +3314,7 @@ export class BallEngine {
|
|
|
3128
3314
|
}
|
|
3129
3315
|
}
|
|
3130
3316
|
let fallbackMap = this._asMap(input);
|
|
3131
|
-
if ((!__ball_eq(fallbackMap, null) && ('self' in fallbackMap))) {
|
|
3317
|
+
if ((!__ball_eq(fallbackMap, null) && ('self' in __ball_require_map(fallbackMap, 'map_contains_key')))) {
|
|
3132
3318
|
let selfFallback = __ball_index(fallbackMap, 'self');
|
|
3133
3319
|
let selfFallbackMap = this._asMap(selfFallback);
|
|
3134
3320
|
if (!__ball_eq(selfFallbackMap, null)) {
|
|
@@ -3416,7 +3602,7 @@ export class BallEngine {
|
|
|
3416
3602
|
async _evalReference(ref: any, scope: any): Promise<any> {
|
|
3417
3603
|
let name = ref.name;
|
|
3418
3604
|
if (__ball_eq(name, 'super')) {
|
|
3419
|
-
let selfRef
|
|
3605
|
+
let selfRef;
|
|
3420
3606
|
try {
|
|
3421
3607
|
selfRef = scope.lookup('self');
|
|
3422
3608
|
} catch (__ball_active_error) {
|
|
@@ -3458,12 +3644,12 @@ export class BallEngine {
|
|
|
3458
3644
|
}
|
|
3459
3645
|
if (!_builtinTypeNames.includes(name)) {
|
|
3460
3646
|
let qualifiedName = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(name));
|
|
3461
|
-
let hasCtor = ((name in this._constructors) || (qualifiedName in this._constructors));
|
|
3647
|
+
let hasCtor = ((name in __ball_require_map(this._constructors, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._constructors, 'map_contains_key')));
|
|
3462
3648
|
let hasStaticMethods = this._functions.keys.some(((k) => {
|
|
3463
3649
|
const input = k;
|
|
3464
3650
|
return (k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(qualifiedName)) + '.')) || k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(name)) + '.')));
|
|
3465
3651
|
}));
|
|
3466
|
-
let typeExists = ((name in this._types) || (qualifiedName in this._types));
|
|
3652
|
+
let typeExists = ((name in __ball_require_map(this._types, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._types, 'map_contains_key')));
|
|
3467
3653
|
if ((typeExists && (hasCtor || hasStaticMethods))) {
|
|
3468
3654
|
return { ['__class_ref__']: name, ['__type__']: '__class__' };
|
|
3469
3655
|
}
|
|
@@ -3473,7 +3659,7 @@ export class BallEngine {
|
|
|
3473
3659
|
if ((!__ball_eq(getterFunc, null) && this._isGetter(getterFunc))) {
|
|
3474
3660
|
return this._callFunction(this._currentModule, getterFunc, null);
|
|
3475
3661
|
}
|
|
3476
|
-
let selfForGetter
|
|
3662
|
+
let selfForGetter;
|
|
3477
3663
|
try {
|
|
3478
3664
|
selfForGetter = scope.lookup('self');
|
|
3479
3665
|
} catch (__ball_active_error) {
|
|
@@ -3483,7 +3669,7 @@ export class BallEngine {
|
|
|
3483
3669
|
if (!__ball_eq(selfForGetter, null)) {
|
|
3484
3670
|
let selfMap = this._asMap(selfForGetter);
|
|
3485
3671
|
if (!__ball_eq(selfMap, null)) {
|
|
3486
|
-
if ((name in selfMap)) {
|
|
3672
|
+
if ((name in __ball_require_map(selfMap, 'map_contains_key'))) {
|
|
3487
3673
|
let direct = __ball_index(selfMap, name);
|
|
3488
3674
|
if (!__ball_eq(direct, null)) {
|
|
3489
3675
|
return direct;
|
|
@@ -3492,7 +3678,7 @@ export class BallEngine {
|
|
|
3492
3678
|
let superObj = __ball_index(selfMap, '__super__');
|
|
3493
3679
|
let superMap = this._asMap(superObj);
|
|
3494
3680
|
while (!__ball_eq(superMap, null)) {
|
|
3495
|
-
if ((name in superMap)) {
|
|
3681
|
+
if ((name in __ball_require_map(superMap, 'map_contains_key'))) {
|
|
3496
3682
|
let inherited = __ball_index(superMap, name);
|
|
3497
3683
|
if (!__ball_eq(inherited, null)) {
|
|
3498
3684
|
return inherited;
|
|
@@ -3618,25 +3804,25 @@ export class BallEngine {
|
|
|
3618
3804
|
});
|
|
3619
3805
|
}
|
|
3620
3806
|
let enumVals = (__ball_index(this._enumValues, className) ?? __ball_index(this._enumValues, qualifiedName));
|
|
3621
|
-
if ((!__ball_eq(enumVals, null) && (fieldName in enumVals))) {
|
|
3807
|
+
if ((!__ball_eq(enumVals, null) && (fieldName in __ball_require_map(enumVals, 'map_contains_key')))) {
|
|
3622
3808
|
return __ball_index(enumVals, fieldName);
|
|
3623
3809
|
}
|
|
3624
3810
|
}
|
|
3625
3811
|
if (!__ball_eq(objectMap, null)) {
|
|
3626
|
-
if ((fieldName in objectMap)) {
|
|
3812
|
+
if ((fieldName in __ball_require_map(objectMap, 'map_contains_key'))) {
|
|
3627
3813
|
return __ball_index(objectMap, fieldName);
|
|
3628
3814
|
}
|
|
3629
3815
|
let superObj = __ball_index(objectMap, '__super__');
|
|
3630
3816
|
let superMap = this._asMap(superObj);
|
|
3631
3817
|
while (!__ball_eq(superMap, null)) {
|
|
3632
|
-
if ((fieldName in superMap)) {
|
|
3818
|
+
if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
|
|
3633
3819
|
return __ball_index(superMap, fieldName);
|
|
3634
3820
|
}
|
|
3635
3821
|
superObj = __ball_index(superMap, '__super__');
|
|
3636
3822
|
superMap = this._asMap(superObj);
|
|
3637
3823
|
}
|
|
3638
3824
|
let methods = __ball_index(objectMap, '__methods__');
|
|
3639
|
-
if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (fieldName in methods))) {
|
|
3825
|
+
if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (fieldName in __ball_require_map(methods, 'map_contains_key')))) {
|
|
3640
3826
|
let method = __ball_index(methods, fieldName);
|
|
3641
3827
|
if ((typeof method === 'function')) {
|
|
3642
3828
|
return method;
|
|
@@ -3646,7 +3832,7 @@ export class BallEngine {
|
|
|
3646
3832
|
superMap = this._asMap(superObj);
|
|
3647
3833
|
while (!__ball_eq(superMap, null)) {
|
|
3648
3834
|
let superMethods = __ball_index(superMap, '__methods__');
|
|
3649
|
-
if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && (fieldName in superMethods))) {
|
|
3835
|
+
if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && (fieldName in __ball_require_map(superMethods, 'map_contains_key')))) {
|
|
3650
3836
|
let method = __ball_index(superMethods, fieldName);
|
|
3651
3837
|
if ((typeof method === 'function')) {
|
|
3652
3838
|
return method;
|
|
@@ -3674,7 +3860,7 @@ export class BallEngine {
|
|
|
3674
3860
|
}))];
|
|
3675
3861
|
if ((!(vals.length === 0) && vals.every(((v) => {
|
|
3676
3862
|
const input = v;
|
|
3677
|
-
return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && ('index' in v)) && ('__type__' in v));
|
|
3863
|
+
return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && ('index' in __ball_require_map(v, 'map_contains_key'))) && ('__type__' in __ball_require_map(v, 'map_contains_key')));
|
|
3678
3864
|
})))) {
|
|
3679
3865
|
vals = [...vals].sort(((a, b) => {
|
|
3680
3866
|
return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
|
|
@@ -3791,7 +3977,7 @@ export class BallEngine {
|
|
|
3791
3977
|
}))];
|
|
3792
3978
|
if ((!(vals.length === 0) && vals.every(((v) => {
|
|
3793
3979
|
const input = v;
|
|
3794
|
-
return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && ('index' in v)) && ('__type__' in v));
|
|
3980
|
+
return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && ('index' in __ball_require_map(v, 'map_contains_key'))) && ('__type__' in __ball_require_map(v, 'map_contains_key')));
|
|
3795
3981
|
})))) {
|
|
3796
3982
|
vals = [...vals].sort(((a, b) => {
|
|
3797
3983
|
return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
|
|
@@ -3978,11 +4164,11 @@ export class BallEngine {
|
|
|
3978
4164
|
return;
|
|
3979
4165
|
}
|
|
3980
4166
|
let backing = ('_' + __ball_to_string(fieldName));
|
|
3981
|
-
if ((backing in object)) {
|
|
4167
|
+
if ((backing in __ball_require_map(object, 'map_contains_key'))) {
|
|
3982
4168
|
ballObjectSetField(object, backing, assignedValue);
|
|
3983
4169
|
return;
|
|
3984
4170
|
}
|
|
3985
|
-
if (('_celsius' in object)) {
|
|
4171
|
+
if (('_celsius' in __ball_require_map(object, 'map_contains_key'))) {
|
|
3986
4172
|
ballObjectSetField(object, '_celsius', assignedValue);
|
|
3987
4173
|
}
|
|
3988
4174
|
}
|
|
@@ -3998,7 +4184,7 @@ export class BallEngine {
|
|
|
3998
4184
|
let superObj = __ball_index(selfMap, '__super__');
|
|
3999
4185
|
let superMap = this._asMap(superObj);
|
|
4000
4186
|
while (!__ball_eq(superMap, null)) {
|
|
4001
|
-
if ((fieldName in superMap)) {
|
|
4187
|
+
if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
|
|
4002
4188
|
ballObjectSetField(superObj, fieldName, val);
|
|
4003
4189
|
}
|
|
4004
4190
|
superObj = __ball_index(superMap, '__super__');
|
|
@@ -4013,7 +4199,7 @@ export class BallEngine {
|
|
|
4013
4199
|
let fields = {};
|
|
4014
4200
|
for (const pair of msg.fields) {
|
|
4015
4201
|
let val = await this._evalExpression(pair.value, scope);
|
|
4016
|
-
if ((pair.name in fields)) {
|
|
4202
|
+
if ((pair.name in __ball_require_map(fields, 'map_contains_key'))) {
|
|
4017
4203
|
let existing = __ball_index(fields, pair.name);
|
|
4018
4204
|
if (Array.isArray(existing)) {
|
|
4019
4205
|
let merged = ([...existing]);
|
|
@@ -4046,7 +4232,7 @@ export class BallEngine {
|
|
|
4046
4232
|
}
|
|
4047
4233
|
this._initFieldDefaults(msg.typeName, instanceFields);
|
|
4048
4234
|
for (const fieldName of typeDef.fieldNames) {
|
|
4049
|
-
if (!(fieldName in instanceFields)) {
|
|
4235
|
+
if (!(fieldName in __ball_require_map(instanceFields, 'map_contains_key'))) {
|
|
4050
4236
|
instanceFields[fieldName] = null;
|
|
4051
4237
|
}
|
|
4052
4238
|
}
|
|
@@ -4057,15 +4243,15 @@ export class BallEngine {
|
|
|
4057
4243
|
let paramsMeta = this._extractParamsMeta(ctorEntry.func.metadata);
|
|
4058
4244
|
for (let i = 0; __ball_lt(i, params.length); (i++)) {
|
|
4059
4245
|
let param = __ball_index(params, i);
|
|
4060
|
-
let value
|
|
4061
|
-
if ((param in fields)) {
|
|
4246
|
+
let value;
|
|
4247
|
+
if ((param in __ball_require_map(fields, 'map_contains_key'))) {
|
|
4062
4248
|
value = __ball_index(fields, param);
|
|
4063
4249
|
} else {
|
|
4064
|
-
if ((('arg' + __ball_to_string(i)) in fields)) {
|
|
4250
|
+
if ((('arg' + __ball_to_string(i)) in __ball_require_map(fields, 'map_contains_key'))) {
|
|
4065
4251
|
value = __ball_index(fields, ('arg' + __ball_to_string(i)));
|
|
4066
4252
|
}
|
|
4067
4253
|
}
|
|
4068
|
-
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
|
|
4254
|
+
if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
|
|
4069
4255
|
value = __ball_index(__ball_index(paramsMeta, i), 'default');
|
|
4070
4256
|
}
|
|
4071
4257
|
resolvedParams[param] = value;
|
|
@@ -4083,12 +4269,12 @@ export class BallEngine {
|
|
|
4083
4269
|
this._applyConstructorInitializers(ctorEntry.func, instanceFields, resolvedParams, true);
|
|
4084
4270
|
}
|
|
4085
4271
|
let superclass = this._getMetaString(typeDef, 'superclass');
|
|
4086
|
-
let superObject
|
|
4272
|
+
let superObject;
|
|
4087
4273
|
if ((!__ball_eq(superclass, null) && !(superclass.length === 0))) {
|
|
4088
4274
|
superObject = (__ball_eq(ctorEntry, null) ? null : await this._invokeSuperConstructor(ctorEntry.func, superclass, resolvedParams));
|
|
4089
4275
|
superObject ??= this._buildSuperObject(superclass, instanceFields);
|
|
4090
4276
|
}
|
|
4091
|
-
if (!('__type_args__' in instanceFields)) {
|
|
4277
|
+
if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
|
|
4092
4278
|
let metaTypeArgs = BallEngine._extractMetadataTypeArgs(msg);
|
|
4093
4279
|
if (!__ball_eq(metaTypeArgs, null)) {
|
|
4094
4280
|
instanceFields['__type_args__'] = metaTypeArgs;
|
|
@@ -4126,7 +4312,7 @@ export class BallEngine {
|
|
|
4126
4312
|
})();
|
|
4127
4313
|
let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
|
|
4128
4314
|
let constructedMap = this._asMap(constructed);
|
|
4129
|
-
if ((!__ball_eq(constructedMap, null) && ('__type__' in constructedMap))) {
|
|
4315
|
+
if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
|
|
4130
4316
|
return constructed;
|
|
4131
4317
|
}
|
|
4132
4318
|
return instance;
|
|
@@ -4147,7 +4333,7 @@ export class BallEngine {
|
|
|
4147
4333
|
instanceFields[entry.key] = entry.value;
|
|
4148
4334
|
}
|
|
4149
4335
|
}
|
|
4150
|
-
if (!('__type_args__' in instanceFields)) {
|
|
4336
|
+
if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
|
|
4151
4337
|
let metaTA = BallEngine._extractMetadataTypeArgs(msg);
|
|
4152
4338
|
if (!__ball_eq(metaTA, null)) {
|
|
4153
4339
|
instanceFields['__type_args__'] = metaTA;
|
|
@@ -4163,13 +4349,13 @@ export class BallEngine {
|
|
|
4163
4349
|
})();
|
|
4164
4350
|
let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
|
|
4165
4351
|
let constructedMap = this._asMap(constructed);
|
|
4166
|
-
if ((!__ball_eq(constructedMap, null) && ('__type__' in constructedMap))) {
|
|
4352
|
+
if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
|
|
4167
4353
|
return constructed;
|
|
4168
4354
|
}
|
|
4169
4355
|
return instance;
|
|
4170
4356
|
}
|
|
4171
4357
|
fields['__type__'] = msg.typeName;
|
|
4172
|
-
if (!('__type_args__' in fields)) {
|
|
4358
|
+
if (!('__type_args__' in __ball_require_map(fields, 'map_contains_key'))) {
|
|
4173
4359
|
let metaTA2 = BallEngine._extractMetadataTypeArgs(msg);
|
|
4174
4360
|
if (!__ball_eq(metaTA2, null)) {
|
|
4175
4361
|
fields['__type_args__'] = metaTA2;
|
|
@@ -4241,7 +4427,7 @@ export class BallEngine {
|
|
|
4241
4427
|
for (const module of this.program.modules) {
|
|
4242
4428
|
for (const td of module.typeDefs) {
|
|
4243
4429
|
if ((__ball_eq(td.name, typeName) || td.name.endsWith((':' + __ball_to_string(typeName))))) {
|
|
4244
|
-
let superclass
|
|
4430
|
+
let superclass;
|
|
4245
4431
|
if (hasMetadata(td)) {
|
|
4246
4432
|
let sc = __ball_index(td.metadata.fields, 'superclass');
|
|
4247
4433
|
if ((!__ball_eq(sc, null) && hasStringValue(sc))) {
|
|
@@ -4291,7 +4477,7 @@ export class BallEngine {
|
|
|
4291
4477
|
let __naa_10 = __ball_index(fv.structValue.fields, 'name');
|
|
4292
4478
|
return (__ball_eq(__naa_10, null) ? null : __naa_10.stringValue);
|
|
4293
4479
|
})();
|
|
4294
|
-
if ((__ball_eq(fname, null) || (fname in fields))) {
|
|
4480
|
+
if ((__ball_eq(fname, null) || (fname in __ball_require_map(fields, 'map_contains_key')))) {
|
|
4295
4481
|
continue;
|
|
4296
4482
|
}
|
|
4297
4483
|
let init = (() => {
|
|
@@ -4397,20 +4583,20 @@ export class BallEngine {
|
|
|
4397
4583
|
let parentTypeDef = this._findTypeDef(superclass);
|
|
4398
4584
|
if (!__ball_eq(parentTypeDef, null)) {
|
|
4399
4585
|
for (const fname of parentTypeDef.fieldNames) {
|
|
4400
|
-
if ((fname in childFields)) {
|
|
4586
|
+
if ((fname in __ball_require_map(childFields, 'map_contains_key'))) {
|
|
4401
4587
|
superFields[fname] = __ball_index(childFields, fname);
|
|
4402
4588
|
}
|
|
4403
4589
|
}
|
|
4404
4590
|
this._initFieldDefaults(superclass, superFields);
|
|
4405
4591
|
for (const fname of parentTypeDef.fieldNames) {
|
|
4406
|
-
if (!(fname in superFields)) {
|
|
4592
|
+
if (!(fname in __ball_require_map(superFields, 'map_contains_key'))) {
|
|
4407
4593
|
superFields[fname] = null;
|
|
4408
4594
|
}
|
|
4409
4595
|
}
|
|
4410
4596
|
let parentMethods = this._resolveTypeMethods(qualifiedSuperclass);
|
|
4411
4597
|
let parentMethodsMap = parentMethods.cast();
|
|
4412
4598
|
let grandparent = parentTypeDef.superclass;
|
|
4413
|
-
let grandparentObject
|
|
4599
|
+
let grandparentObject;
|
|
4414
4600
|
if ((!__ball_eq(grandparent, null) && !(grandparent.length === 0))) {
|
|
4415
4601
|
grandparentObject = this._buildSuperObject(grandparent, childFields);
|
|
4416
4602
|
}
|
|
@@ -4488,7 +4674,7 @@ export class BallEngine {
|
|
|
4488
4674
|
|
|
4489
4675
|
async _evalBlock(block: any, scope: any): Promise<any> {
|
|
4490
4676
|
let blockScope = scope.child();
|
|
4491
|
-
let flowResult
|
|
4677
|
+
let flowResult;
|
|
4492
4678
|
for (const stmt of block.statements) {
|
|
4493
4679
|
let result = await this._evalStatement(stmt, blockScope);
|
|
4494
4680
|
if ((result instanceof _FlowSignal)) {
|
|
@@ -4508,7 +4694,7 @@ export class BallEngine {
|
|
|
4508
4694
|
const __sw = whichStmt(stmt);
|
|
4509
4695
|
if ((__sw === Statement_Stmt.let)) {
|
|
4510
4696
|
let letValue = stmt.let.value;
|
|
4511
|
-
let value
|
|
4697
|
+
let value;
|
|
4512
4698
|
if ((__ball_eq(whichExpr(letValue), Expression_Expr.reference) && __ball_eq(letValue.reference.name, '__no_init__'))) {
|
|
4513
4699
|
value = null;
|
|
4514
4700
|
} else {
|
|
@@ -4562,10 +4748,10 @@ export class BallEngine {
|
|
|
4562
4748
|
for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
|
|
4563
4749
|
let p = __ball_index(paramNames, i);
|
|
4564
4750
|
if (!lambdaScope.has(p)) {
|
|
4565
|
-
if ((p in inputMap)) {
|
|
4751
|
+
if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
4566
4752
|
lambdaScope.bind(p, __ball_index(inputMap, p));
|
|
4567
4753
|
} else {
|
|
4568
|
-
if ((('arg' + __ball_to_string(i)) in inputMap)) {
|
|
4754
|
+
if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
|
|
4569
4755
|
lambdaScope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
|
|
4570
4756
|
}
|
|
4571
4757
|
}
|
|
@@ -4690,7 +4876,7 @@ export class BallEngine {
|
|
|
4690
4876
|
let rawVal = match.group(2).trim();
|
|
4691
4877
|
let intParsed = int.tryParse(rawVal);
|
|
4692
4878
|
let doubleParsed = (__ball_eq(intParsed, null) ? double.tryParse(rawVal) : null);
|
|
4693
|
-
let parsed
|
|
4879
|
+
let parsed;
|
|
4694
4880
|
if (!__ball_eq(intParsed, null)) {
|
|
4695
4881
|
parsed = intParsed;
|
|
4696
4882
|
} else {
|
|
@@ -4726,7 +4912,7 @@ export class BallEngine {
|
|
|
4726
4912
|
let operand = __ball_parse_int(propOpNum.group(4));
|
|
4727
4913
|
if (scope.has(ref)) {
|
|
4728
4914
|
let obj = scope.lookup(ref);
|
|
4729
|
-
let propVal
|
|
4915
|
+
let propVal;
|
|
4730
4916
|
if (((typeof obj === 'string') && __ball_eq(prop, 'length'))) {
|
|
4731
4917
|
propVal = obj.value.length;
|
|
4732
4918
|
} else {
|
|
@@ -4746,7 +4932,7 @@ export class BallEngine {
|
|
|
4746
4932
|
propVal = obj.length;
|
|
4747
4933
|
} else {
|
|
4748
4934
|
let map = this._cfAsMap(obj);
|
|
4749
|
-
if ((!__ball_eq(map, null) && (prop in map))) {
|
|
4935
|
+
if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
|
|
4750
4936
|
let v = __ball_index(map, prop);
|
|
4751
4937
|
if ((typeof v === 'number' || v instanceof BallDouble)) {
|
|
4752
4938
|
propVal = v;
|
|
@@ -4768,8 +4954,8 @@ export class BallEngine {
|
|
|
4768
4954
|
let left = varOpVar.group(1);
|
|
4769
4955
|
let op = varOpVar.group(2);
|
|
4770
4956
|
let right = varOpVar.group(3);
|
|
4771
|
-
let leftVal
|
|
4772
|
-
let rightVal
|
|
4957
|
+
let leftVal;
|
|
4958
|
+
let rightVal;
|
|
4773
4959
|
if (scope.has(left)) {
|
|
4774
4960
|
let v = scope.lookup(left);
|
|
4775
4961
|
if ((typeof v === 'number' || v instanceof BallDouble)) {
|
|
@@ -4816,7 +5002,7 @@ export class BallEngine {
|
|
|
4816
5002
|
return obj.length;
|
|
4817
5003
|
}
|
|
4818
5004
|
let map = this._cfAsMap(obj);
|
|
4819
|
-
if ((!__ball_eq(map, null) && (prop in map))) {
|
|
5005
|
+
if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
|
|
4820
5006
|
return __ball_index(map, prop);
|
|
4821
5007
|
}
|
|
4822
5008
|
}
|
|
@@ -4924,7 +5110,7 @@ export class BallEngine {
|
|
|
4924
5110
|
if ((!__ball_eq(whichExpr(cases), Expression_Expr.literal) || !__ball_eq(whichValue(cases.literal), Literal_Value.listValue))) {
|
|
4925
5111
|
return null;
|
|
4926
5112
|
}
|
|
4927
|
-
let defaultBody
|
|
5113
|
+
let defaultBody;
|
|
4928
5114
|
let matched = false;
|
|
4929
5115
|
for (const caseExpr of cases.literal.listValue.elements) {
|
|
4930
5116
|
if (!__ball_eq(whichExpr(caseExpr), Expression_Expr.messageCreation)) {
|
|
@@ -4985,7 +5171,7 @@ export class BallEngine {
|
|
|
4985
5171
|
if ((!__ball_eq(whichExpr(cases), Expression_Expr.literal) || !__ball_eq(whichValue(cases.literal), Literal_Value.listValue))) {
|
|
4986
5172
|
return null;
|
|
4987
5173
|
}
|
|
4988
|
-
let defaultBody
|
|
5174
|
+
let defaultBody;
|
|
4989
5175
|
for (const caseExpr of cases.literal.listValue.elements) {
|
|
4990
5176
|
if (!__ball_eq(whichExpr(caseExpr), Expression_Expr.messageCreation)) {
|
|
4991
5177
|
continue;
|
|
@@ -5107,7 +5293,7 @@ export class BallEngine {
|
|
|
5107
5293
|
}
|
|
5108
5294
|
}
|
|
5109
5295
|
let enumVals = __ball_index(this._enumValues, enumType);
|
|
5110
|
-
if ((!__ball_eq(enumVals, null) && (enumValue in enumVals))) {
|
|
5296
|
+
if ((!__ball_eq(enumVals, null) && (enumValue in __ball_require_map(enumVals, 'map_contains_key')))) {
|
|
5111
5297
|
let resolved = __ball_index(enumVals, enumValue);
|
|
5112
5298
|
let resolvedMap = this._cfAsMap(resolved);
|
|
5113
5299
|
if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
|
|
@@ -5116,7 +5302,7 @@ export class BallEngine {
|
|
|
5116
5302
|
}
|
|
5117
5303
|
let qualifiedEnumType = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(enumType));
|
|
5118
5304
|
let qualEnumVals = __ball_index(this._enumValues, qualifiedEnumType);
|
|
5119
|
-
if ((!__ball_eq(qualEnumVals, null) && (enumValue in qualEnumVals))) {
|
|
5305
|
+
if ((!__ball_eq(qualEnumVals, null) && (enumValue in __ball_require_map(qualEnumVals, 'map_contains_key')))) {
|
|
5120
5306
|
let resolved = __ball_index(qualEnumVals, enumValue);
|
|
5121
5307
|
let resolvedMap = this._cfAsMap(resolved);
|
|
5122
5308
|
if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
|
|
@@ -5148,7 +5334,7 @@ export class BallEngine {
|
|
|
5148
5334
|
let body = __ball_index(fields, 'body');
|
|
5149
5335
|
let catches = __ball_index(fields, 'catches');
|
|
5150
5336
|
let finallyBlock = __ball_index(fields, 'finally');
|
|
5151
|
-
let result
|
|
5337
|
+
let result;
|
|
5152
5338
|
try {
|
|
5153
5339
|
result = (!__ball_eq(body, null) ? await this._evalExpression(body, scope) : null);
|
|
5154
5340
|
} catch (__ball_active_error) {
|
|
@@ -5167,7 +5353,7 @@ export class BallEngine {
|
|
|
5167
5353
|
}
|
|
5168
5354
|
let catchType = this._stringFieldVal(cf, 'type');
|
|
5169
5355
|
if ((!__ball_eq(catchType, null) && !(catchType.length === 0))) {
|
|
5170
|
-
let matches
|
|
5356
|
+
let matches;
|
|
5171
5357
|
if ((e instanceof BallException)) {
|
|
5172
5358
|
let eType = e['typeName'];
|
|
5173
5359
|
let eColonIdx = eType.indexOf(':');
|
|
@@ -5385,7 +5571,7 @@ export class BallEngine {
|
|
|
5385
5571
|
this._cfWritebackIndexed(indexTarget, list, scope);
|
|
5386
5572
|
}
|
|
5387
5573
|
if (((!__ball_eq(op, null) && !(op.length === 0)) && !__ball_eq(op, '='))) {
|
|
5388
|
-
let computed
|
|
5574
|
+
let computed;
|
|
5389
5575
|
let didSet = false;
|
|
5390
5576
|
if ((false /* BallList is List in TS */ && (typeof idx === 'number' && Number.isInteger(idx)))) {
|
|
5391
5577
|
computed = this._applyCompoundOp(op, __ball_index(list.items, idx), val);
|
|
@@ -5611,7 +5797,7 @@ export class BallEngine {
|
|
|
5611
5797
|
}))) : ((op === '>>=') ? (this._intOp(current, val, ((a, b) => {
|
|
5612
5798
|
return __ball_shr(a, b);
|
|
5613
5799
|
}))) : ((op === '>>>=') ? (this._intOp(current, val, ((a, b) => {
|
|
5614
|
-
return (a
|
|
5800
|
+
return __ball_ushr(a, b);
|
|
5615
5801
|
}))) : ((op === '??=') ? ((current ?? val)) : val)))))))))))));
|
|
5616
5802
|
}
|
|
5617
5803
|
|
|
@@ -5890,7 +6076,7 @@ export class BallEngine {
|
|
|
5890
6076
|
if (__ball_eq(body, null)) {
|
|
5891
6077
|
return null;
|
|
5892
6078
|
}
|
|
5893
|
-
let result
|
|
6079
|
+
let result;
|
|
5894
6080
|
let repeat = true;
|
|
5895
6081
|
while (repeat) {
|
|
5896
6082
|
repeat = false;
|
|
@@ -5979,7 +6165,7 @@ export class BallEngine {
|
|
|
5979
6165
|
let args = (inputMap ?? {});
|
|
5980
6166
|
let arg0 = (__ball_index(args, 'arg0') ?? __ball_index(args, 'value'));
|
|
5981
6167
|
let wasBallList = false /* BallList is List in TS */;
|
|
5982
|
-
let unwrappedSelf
|
|
6168
|
+
let unwrappedSelf;
|
|
5983
6169
|
if (false /* BallList is List in TS */) {
|
|
5984
6170
|
unwrappedSelf = self.items;
|
|
5985
6171
|
} else {
|
|
@@ -6231,7 +6417,7 @@ export class BallEngine {
|
|
|
6231
6417
|
else if ((__sw === 'reduce')) {
|
|
6232
6418
|
if ((typeof arg0 === 'function')) {
|
|
6233
6419
|
let seeded = false;
|
|
6234
|
-
let acc
|
|
6420
|
+
let acc;
|
|
6235
6421
|
for (const item of self) {
|
|
6236
6422
|
if (!seeded) {
|
|
6237
6423
|
acc = item;
|
|
@@ -6287,13 +6473,13 @@ export class BallEngine {
|
|
|
6287
6473
|
let seen = {};
|
|
6288
6474
|
let result = [];
|
|
6289
6475
|
for (const item of self) {
|
|
6290
|
-
if (!(item in seen)) {
|
|
6476
|
+
if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
|
|
6291
6477
|
seen[item] = item;
|
|
6292
6478
|
result = (result.push(item), result);
|
|
6293
6479
|
}
|
|
6294
6480
|
}
|
|
6295
6481
|
for (const item of other) {
|
|
6296
|
-
if (!(item in seen)) {
|
|
6482
|
+
if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
|
|
6297
6483
|
seen[item] = item;
|
|
6298
6484
|
result = (result.push(item), result);
|
|
6299
6485
|
}
|
|
@@ -6363,15 +6549,15 @@ export class BallEngine {
|
|
|
6363
6549
|
do {
|
|
6364
6550
|
const __sw = method;
|
|
6365
6551
|
if ((__sw === 'union')) {
|
|
6366
|
-
let otherU = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set(
|
|
6552
|
+
let otherU = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set())));
|
|
6367
6553
|
return self.union(otherU);
|
|
6368
6554
|
}
|
|
6369
6555
|
else if ((__sw === 'intersection')) {
|
|
6370
|
-
let otherI = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set(
|
|
6556
|
+
let otherI = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set())));
|
|
6371
6557
|
return self.intersection(otherI);
|
|
6372
6558
|
}
|
|
6373
6559
|
else if ((__sw === 'difference')) {
|
|
6374
|
-
let otherD = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set(
|
|
6560
|
+
let otherD = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set())));
|
|
6375
6561
|
return self.difference(otherD);
|
|
6376
6562
|
}
|
|
6377
6563
|
else if ((__sw === 'add')) {
|
|
@@ -6433,7 +6619,7 @@ export class BallEngine {
|
|
|
6433
6619
|
}
|
|
6434
6620
|
else if ((__sw === 'where') || (__sw === 'filter')) {
|
|
6435
6621
|
if ((typeof arg0 === 'function')) {
|
|
6436
|
-
let result = new Set(
|
|
6622
|
+
let result = new Set();
|
|
6437
6623
|
for (const item of self) {
|
|
6438
6624
|
let r = arg0(item);
|
|
6439
6625
|
if ((r != null)) {
|
|
@@ -6521,7 +6707,7 @@ export class BallEngine {
|
|
|
6521
6707
|
return await this._ballToStringAsync(self);
|
|
6522
6708
|
}
|
|
6523
6709
|
else if ((__sw === 'toStringAsFixed')) {
|
|
6524
|
-
return (
|
|
6710
|
+
return __ball_to_fixed(self, this._toInt(arg0));
|
|
6525
6711
|
}
|
|
6526
6712
|
else if ((__sw === 'abs')) {
|
|
6527
6713
|
return __ball_math_abs(self);
|
|
@@ -6550,7 +6736,7 @@ export class BallEngine {
|
|
|
6550
6736
|
} while (false);
|
|
6551
6737
|
}
|
|
6552
6738
|
let selfMap = this._cfAsMap(self);
|
|
6553
|
-
if ((!__ball_eq(selfMap, null) && ('__type__' in selfMap))) {
|
|
6739
|
+
if ((!__ball_eq(selfMap, null) && ('__type__' in __ball_require_map(selfMap, 'map_contains_key')))) {
|
|
6554
6740
|
let typeName = __ball_index(selfMap, '__type__');
|
|
6555
6741
|
if ((!__ball_eq(typeName, null) && (typeName.endsWith(':StringBuffer') || __ball_eq(typeName, 'StringBuffer')))) {
|
|
6556
6742
|
do {
|
|
@@ -6656,8 +6842,8 @@ export class BallEngine {
|
|
|
6656
6842
|
if (__ball_eq(m, null)) {
|
|
6657
6843
|
return null;
|
|
6658
6844
|
}
|
|
6659
|
-
let left
|
|
6660
|
-
let right
|
|
6845
|
+
let left;
|
|
6846
|
+
let right;
|
|
6661
6847
|
if (__ball_eq(function_, 'index')) {
|
|
6662
6848
|
left = __ball_index(m, 'target');
|
|
6663
6849
|
right = __ball_index(m, 'index');
|
|
@@ -6666,7 +6852,7 @@ export class BallEngine {
|
|
|
6666
6852
|
right = __ball_index(m, 'right');
|
|
6667
6853
|
}
|
|
6668
6854
|
let leftMap = this._stdAsMap(left);
|
|
6669
|
-
if ((__ball_eq(leftMap, null) || !('__type__' in leftMap))) {
|
|
6855
|
+
if ((__ball_eq(leftMap, null) || !('__type__' in __ball_require_map(leftMap, 'map_contains_key')))) {
|
|
6670
6856
|
return null;
|
|
6671
6857
|
}
|
|
6672
6858
|
let typeName = __ball_index(leftMap, '__type__');
|
|
@@ -6733,7 +6919,7 @@ export class BallEngine {
|
|
|
6733
6919
|
}
|
|
6734
6920
|
|
|
6735
6921
|
async _callBaseFunction(module: any, function_: any, input: any): Promise<any> {
|
|
6736
|
-
if ((function_ in _stdFunctionToOperator)) {
|
|
6922
|
+
if ((function_ in __ball_require_map(_stdFunctionToOperator, 'map_contains_key'))) {
|
|
6737
6923
|
let override = await this._tryOperatorOverride(function_, input);
|
|
6738
6924
|
if (!__ball_eq(override, null)) {
|
|
6739
6925
|
return this._consumeGeneratorFlow(override);
|
|
@@ -6866,7 +7052,7 @@ export class BallEngine {
|
|
|
6866
7052
|
}), ['unsigned_right_shift']: ((i) => {
|
|
6867
7053
|
const input = i;
|
|
6868
7054
|
return this._stdBinaryInt(i, ((a, b) => {
|
|
6869
|
-
return (a
|
|
7055
|
+
return __ball_ushr(a, b);
|
|
6870
7056
|
}));
|
|
6871
7057
|
}), ['pre_increment']: ((i) => {
|
|
6872
7058
|
const input = i;
|
|
@@ -6908,7 +7094,7 @@ export class BallEngine {
|
|
|
6908
7094
|
const input = i;
|
|
6909
7095
|
return this._stdConvert(i, ((v) => {
|
|
6910
7096
|
const input = v;
|
|
6911
|
-
return
|
|
7097
|
+
return __ball_parse_double(v);
|
|
6912
7098
|
}));
|
|
6913
7099
|
}), ['to_double']: ((i) => {
|
|
6914
7100
|
const input = i;
|
|
@@ -6939,7 +7125,7 @@ export class BallEngine {
|
|
|
6939
7125
|
let v = (__ball_index(m, 'value') ?? __ball_index(m, 'left'));
|
|
6940
7126
|
let digits = (__ball_index(m, 'digits') ?? __ball_index(m, 'fractionDigits'));
|
|
6941
7127
|
let n = this._toNum(v);
|
|
6942
|
-
let s = (
|
|
7128
|
+
let s = __ball_to_fixed(n, this._toInt(digits));
|
|
6943
7129
|
if (((__ball_eq(n, 0) && __ball_lt(new BallDouble(Number(new BallDouble(1)) / Number(n)), 0)) && !s.startsWith('-'))) {
|
|
6944
7130
|
return ('-' + __ball_to_string(s));
|
|
6945
7131
|
}
|
|
@@ -7137,7 +7323,7 @@ export class BallEngine {
|
|
|
7137
7323
|
let list = this._stdAsList(__ball_index(m, 'list'));
|
|
7138
7324
|
let cb = ((__ball_index(m, 'callback') ?? __ball_index(m, 'function')) ?? __ball_index(m, 'value'));
|
|
7139
7325
|
let seeded = false;
|
|
7140
|
-
let acc
|
|
7326
|
+
let acc;
|
|
7141
7327
|
for (const e of list) {
|
|
7142
7328
|
if (!seeded) {
|
|
7143
7329
|
acc = e;
|
|
@@ -7275,17 +7461,17 @@ export class BallEngine {
|
|
|
7275
7461
|
const input = i;
|
|
7276
7462
|
let m = this._stdAsMap(i);
|
|
7277
7463
|
let list = this._stdAsList(__ball_index(m, 'list'));
|
|
7278
|
-
let s
|
|
7279
|
-
let e
|
|
7280
|
-
if (('start' in m)) {
|
|
7464
|
+
let s;
|
|
7465
|
+
let e;
|
|
7466
|
+
if (('start' in __ball_require_map(m, 'map_contains_key'))) {
|
|
7281
7467
|
s = this._toInt(__ball_index(m, 'start'));
|
|
7282
7468
|
e = (!__ball_eq(__ball_index(m, 'end'), null) ? this._toInt(__ball_index(m, 'end')) : null);
|
|
7283
7469
|
} else {
|
|
7284
|
-
if ((('arg0' in m) && ('arg1' in m))) {
|
|
7470
|
+
if ((('arg0' in __ball_require_map(m, 'map_contains_key')) && ('arg1' in __ball_require_map(m, 'map_contains_key')))) {
|
|
7285
7471
|
s = this._toInt(__ball_index(m, 'arg0'));
|
|
7286
7472
|
e = this._toInt(__ball_index(m, 'arg1'));
|
|
7287
7473
|
} else {
|
|
7288
|
-
if (('value' in m)) {
|
|
7474
|
+
if (('value' in __ball_require_map(m, 'map_contains_key'))) {
|
|
7289
7475
|
let v = __ball_index(m, 'value');
|
|
7290
7476
|
if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
|
|
7291
7477
|
s = this._toInt(__ball_index(v, 0));
|
|
@@ -7482,13 +7668,13 @@ export class BallEngine {
|
|
|
7482
7668
|
let m = this._stdAsMap(i);
|
|
7483
7669
|
let raw = __ball_index(m, 'map');
|
|
7484
7670
|
let map = (false /* BallMap is Map in TS */ ? raw.entries : (((typeof raw === 'object' && raw !== null && !Array.isArray(raw) && !(raw instanceof BallDouble) && !(raw instanceof Set)) ? raw : {})));
|
|
7485
|
-
return Object.values(map).includes(__ball_index(m, 'value'));
|
|
7671
|
+
return Object.values(__ball_require_map(map, 'map_contains_value')).includes(__ball_index(m, 'value'));
|
|
7486
7672
|
}), ['map_put_if_absent']: ((i) => {
|
|
7487
7673
|
const input = i;
|
|
7488
7674
|
let m = this._stdAsMap(i);
|
|
7489
7675
|
let map = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
|
|
7490
7676
|
let key = __ball_index(m, 'key');
|
|
7491
|
-
if (!(key in map)) {
|
|
7677
|
+
if (!(key in __ball_require_map(map, 'map_contains_key'))) {
|
|
7492
7678
|
this._trackMemoryAllocation(_ballMapEntryBytes);
|
|
7493
7679
|
let val = __ball_index(m, 'value');
|
|
7494
7680
|
map[key] = ((typeof val === 'function') ? val() : val);
|
|
@@ -7557,7 +7743,7 @@ export class BallEngine {
|
|
|
7557
7743
|
let m = this._stdAsMap(i);
|
|
7558
7744
|
let map1 = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
|
|
7559
7745
|
let map2 = (this._stdAsMap(__ball_index(m, 'value')) ?? __ball_index(m, 'value'));
|
|
7560
|
-
let result = (() => { const __r:
|
|
7746
|
+
let result = (() => { const __r: any = {}; { const __m = map1.cast(); for (const __k in __m) { __r[__k] = __m[__k]; } } { const __m = map2.cast(); for (const __k in __m) { __r[__k] = __m[__k]; } } return __r; })();
|
|
7561
7747
|
this._trackMemoryAllocation(__ball_mul(result.length, _ballMapEntryBytes));
|
|
7562
7748
|
return result;
|
|
7563
7749
|
}), ['map_map']: (async (i) => {
|
|
@@ -7682,7 +7868,7 @@ export class BallEngine {
|
|
|
7682
7868
|
let valMap = this._stdAsMap(val);
|
|
7683
7869
|
if (!__ball_eq(valMap, null)) {
|
|
7684
7870
|
typeName = ((__ball_index(valMap, '__type__') ?? __ball_index(valMap, '__type')) ?? 'Exception');
|
|
7685
|
-
if ((!('message' in valMap) && ('arg0' in valMap))) {
|
|
7871
|
+
if ((!('message' in __ball_require_map(valMap, 'map_contains_key')) && ('arg0' in __ball_require_map(valMap, 'map_contains_key')))) {
|
|
7686
7872
|
valMap['message'] = __ball_index(valMap, 'arg0');
|
|
7687
7873
|
}
|
|
7688
7874
|
}
|
|
@@ -8286,7 +8472,7 @@ export class BallEngine {
|
|
|
8286
8472
|
|
|
8287
8473
|
async _stdPrint(input: any): Promise<any> {
|
|
8288
8474
|
let m = this._stdAsMap(input);
|
|
8289
|
-
if ((!__ball_eq(m, null) && ((('message' in m) || ('arg0' in m)) || ('value' in m)))) {
|
|
8475
|
+
if ((!__ball_eq(m, null) && ((('message' in __ball_require_map(m, 'map_contains_key')) || ('arg0' in __ball_require_map(m, 'map_contains_key'))) || ('value' in __ball_require_map(m, 'map_contains_key'))))) {
|
|
8290
8476
|
let message = ((__ball_index(m, 'message') ?? __ball_index(m, 'arg0')) ?? __ball_index(m, 'value'));
|
|
8291
8477
|
this.stdout(await this._ballToStringAsync(message));
|
|
8292
8478
|
return null;
|
|
@@ -8379,7 +8565,7 @@ export class BallEngine {
|
|
|
8379
8565
|
}
|
|
8380
8566
|
return (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
|
|
8381
8567
|
}
|
|
8382
|
-
if (('__tostring_guard__' in map)) {
|
|
8568
|
+
if (('__tostring_guard__' in __ball_require_map(map, 'map_contains_key'))) {
|
|
8383
8569
|
let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
|
|
8384
8570
|
return (__ball_to_string(shortType) + '{...}');
|
|
8385
8571
|
}
|
|
@@ -8519,7 +8705,7 @@ export class BallEngine {
|
|
|
8519
8705
|
__cascade_self__.remove('__type__');
|
|
8520
8706
|
return __cascade_self__;
|
|
8521
8707
|
})();
|
|
8522
|
-
let result
|
|
8708
|
+
let result;
|
|
8523
8709
|
if (__ball_eq(args.length, 1)) {
|
|
8524
8710
|
result = Function.apply(callee, [args.values.first]);
|
|
8525
8711
|
} else {
|
|
@@ -8814,7 +9000,7 @@ export class BallEngine {
|
|
|
8814
9000
|
if (__ball_eq(cases, null)) {
|
|
8815
9001
|
return null;
|
|
8816
9002
|
}
|
|
8817
|
-
let defaultBody
|
|
9003
|
+
let defaultBody;
|
|
8818
9004
|
for (const c of cases) {
|
|
8819
9005
|
let cMap = this._stdAsMap(c);
|
|
8820
9006
|
if (__ball_eq(cMap, null)) {
|
|
@@ -9003,7 +9189,7 @@ export class BallEngine {
|
|
|
9003
9189
|
return false;
|
|
9004
9190
|
}
|
|
9005
9191
|
let key = __ball_index(entryMap, 'key');
|
|
9006
|
-
if (!(key in rawMap)) {
|
|
9192
|
+
if (!(key in __ball_require_map(rawMap, 'map_contains_key'))) {
|
|
9007
9193
|
return false;
|
|
9008
9194
|
}
|
|
9009
9195
|
if (!this._matchPattern(__ball_index(rawMap, key), __ball_index(entryMap, 'value'), bindings)) {
|
|
@@ -9043,7 +9229,7 @@ export class BallEngine {
|
|
|
9043
9229
|
return false;
|
|
9044
9230
|
}
|
|
9045
9231
|
for (const entry of recFields.entries) {
|
|
9046
|
-
if (!(entry.key in recMap)) {
|
|
9232
|
+
if (!(entry.key in __ball_require_map(recMap, 'map_contains_key'))) {
|
|
9047
9233
|
return false;
|
|
9048
9234
|
}
|
|
9049
9235
|
let fieldVal = __ball_index(recMap, entry.key);
|
|
@@ -9208,7 +9394,7 @@ export class BallEngine {
|
|
|
9208
9394
|
let map = this._stdAsMap(v);
|
|
9209
9395
|
if (!__ball_eq(map, null)) {
|
|
9210
9396
|
let typeName = __ball_index(map, '__type__');
|
|
9211
|
-
if ((!__ball_eq(typeName, null) && (typeName in this._enumValues))) {
|
|
9397
|
+
if ((!__ball_eq(typeName, null) && (typeName in __ball_require_map(this._enumValues, 'map_contains_key')))) {
|
|
9212
9398
|
let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
|
|
9213
9399
|
let valName = __ball_index(map, 'name');
|
|
9214
9400
|
if (!__ball_eq(valName, null)) {
|
|
@@ -9649,9 +9835,9 @@ export class BallEngine {
|
|
|
9649
9835
|
throw new BallRuntimeError('Expected message');
|
|
9650
9836
|
}
|
|
9651
9837
|
let rawValue = __ball_index(m, 'value');
|
|
9652
|
-
let value
|
|
9653
|
-
let min
|
|
9654
|
-
let max
|
|
9838
|
+
let value;
|
|
9839
|
+
let min;
|
|
9840
|
+
let max;
|
|
9655
9841
|
if ((__ball_is_type(rawValue, "Map<String, Object?>") || false /* BallMap is Map in TS */)) {
|
|
9656
9842
|
value = this._toNum(__ball_index(m, 'min'));
|
|
9657
9843
|
min = this._toNum(__ball_index(m, 'max'));
|
|
@@ -9699,10 +9885,10 @@ export class BallEngine {
|
|
|
9699
9885
|
}
|
|
9700
9886
|
let mapVal = this._stdAsMap(v);
|
|
9701
9887
|
if (!__ball_eq(mapVal, null)) {
|
|
9702
|
-
return (() => { const __r:
|
|
9888
|
+
return (() => { const __r: any = {}; for (const e of mapVal.entries) { if (!e.key.startsWith('__')) { __r[e.key] = this._toJsonSafe(e.value); } } return __r; })();
|
|
9703
9889
|
}
|
|
9704
9890
|
if ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set))) {
|
|
9705
|
-
return (() => { const __r:
|
|
9891
|
+
return (() => { const __r: any = {}; for (const e of v.entries) { if (((typeof e.key === 'string') && !e.key.startsWith('__'))) { __r[e.key] = this._toJsonSafe(e.value); } } return __r; })();
|
|
9706
9892
|
}
|
|
9707
9893
|
let listVal = this._stdAsList(v);
|
|
9708
9894
|
if (!__ball_eq(listVal, null)) {
|
|
@@ -9834,7 +10020,7 @@ export class _Scope {
|
|
|
9834
10020
|
|
|
9835
10021
|
lookup(name: any): any {
|
|
9836
10022
|
const input = name;
|
|
9837
|
-
if ((name in this._bindings)) {
|
|
10023
|
+
if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
|
|
9838
10024
|
return __ball_index(this._bindings, name);
|
|
9839
10025
|
}
|
|
9840
10026
|
if (!__ball_eq(this._parent, null)) {
|
|
@@ -9849,14 +10035,14 @@ export class _Scope {
|
|
|
9849
10035
|
|
|
9850
10036
|
has(name: any): any {
|
|
9851
10037
|
const input = name;
|
|
9852
|
-
if ((name in this._bindings)) {
|
|
10038
|
+
if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
|
|
9853
10039
|
return true;
|
|
9854
10040
|
}
|
|
9855
10041
|
return ((__ball_eq(this._parent, null) ? null : this._parent.has(name)) ?? false);
|
|
9856
10042
|
}
|
|
9857
10043
|
|
|
9858
10044
|
set(name: any, value: any): any {
|
|
9859
|
-
if ((name in this._bindings)) {
|
|
10045
|
+
if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
|
|
9860
10046
|
this._bindings[name] = value;
|
|
9861
10047
|
return;
|
|
9862
10048
|
}
|
|
@@ -9974,7 +10160,7 @@ export class StdModuleHandler extends BallModuleHandler {
|
|
|
9974
10160
|
if (this._tombstones.includes(entry.key)) {
|
|
9975
10161
|
continue;
|
|
9976
10162
|
}
|
|
9977
|
-
if ((entry.key in this._composedDispatch)) {
|
|
10163
|
+
if ((entry.key in __ball_require_map(this._composedDispatch, 'map_contains_key'))) {
|
|
9978
10164
|
continue;
|
|
9979
10165
|
}
|
|
9980
10166
|
if ((!__ball_eq(allowlist, null) && !allowlist.includes(entry.key))) {
|
|
@@ -10087,7 +10273,7 @@ function _ballToDouble(value: any): any {
|
|
|
10087
10273
|
|
|
10088
10274
|
function _ballValueIsSet(v: any): any {
|
|
10089
10275
|
const input = v;
|
|
10090
|
-
return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && (_kBallSetTag in v));
|
|
10276
|
+
return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && (_kBallSetTag in __ball_require_map(v, 'map_contains_key')));
|
|
10091
10277
|
}
|
|
10092
10278
|
|
|
10093
10279
|
function _ballIsInt(v: any): any {
|
|
@@ -10164,7 +10350,7 @@ function _ballMapValuesDyn(map: any): any {
|
|
|
10164
10350
|
function _ballMapContainsKeyDyn(map: any, key: any): any {
|
|
10165
10351
|
let handle = _ballMapHandleEntries(map);
|
|
10166
10352
|
if ((typeof handle === 'object' && handle !== null && !Array.isArray(handle) && !(handle instanceof BallDouble) && !(handle instanceof Set))) {
|
|
10167
|
-
return (key in handle);
|
|
10353
|
+
return (key in __ball_require_map(handle, 'map_contains_key'));
|
|
10168
10354
|
}
|
|
10169
10355
|
return false;
|
|
10170
10356
|
}
|
|
@@ -10182,12 +10368,12 @@ function ballObjectSetField(target: any, fieldName: any, val: any): any {
|
|
|
10182
10368
|
return;
|
|
10183
10369
|
}
|
|
10184
10370
|
if (false /* BallMap is Map in TS */) {
|
|
10185
|
-
if (('__type__' in target.entries)) {
|
|
10371
|
+
if (('__type__' in __ball_require_map(target.entries, 'map_contains_key'))) {
|
|
10186
10372
|
target[fieldName] = val;
|
|
10187
10373
|
}
|
|
10188
10374
|
return;
|
|
10189
10375
|
}
|
|
10190
|
-
if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in target))) {
|
|
10376
|
+
if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in __ball_require_map(target, 'map_contains_key')))) {
|
|
10191
10377
|
target[fieldName] = val;
|
|
10192
10378
|
}
|
|
10193
10379
|
}
|
|
@@ -10288,7 +10474,7 @@ function _unwrapBallFuture(value: any): any {
|
|
|
10288
10474
|
const input = value;
|
|
10289
10475
|
if (_isBallFuture(value)) {
|
|
10290
10476
|
let map = value;
|
|
10291
|
-
if (('error' in map)) {
|
|
10477
|
+
if (('error' in __ball_require_map(map, 'map_contains_key'))) {
|
|
10292
10478
|
let error = __ball_index(map, 'error');
|
|
10293
10479
|
if ((error instanceof BallException)) {
|
|
10294
10480
|
throw error;
|