@ball-lang/engine 1.7.8 → 1.7.10

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.
@@ -98,12 +98,26 @@ globalThis.BallObject = BallObject;
98
98
  // (e.g. 42.0 not 42). Used by the compiled Dart engine's _toDouble.
99
99
  class BallDouble {
100
100
  value;
101
- constructor(v) { this.value = v; }
101
+ // Collapse nested wrapping down to the innermost raw number instead of
102
+ // storing a BallDouble that holds another BallDouble. The concrete source of
103
+ // nested wrapping was string_to_double's engine handler wrapping the result
104
+ // of the already-wrapping compiled parse path from issue 222; that redundant
105
+ // wrap was removed at its root in issue 237, so this guard is now purely
106
+ // defensive (verified: the full TS engine suite stays green without it). It is
107
+ // kept as a cheap, idempotent belt-and-suspenders against any other caller
108
+ // that might wrap an already-wrapped value: a doubly-wrapped BallDouble makes
109
+ // Number/valueOf coercion throw "Cannot convert object to primitive value".
110
+ // For a plain-number caller the instanceof check is a no-op.
111
+ constructor(v) { this.value = v instanceof BallDouble ? v.value : v; }
102
112
  valueOf() { return this.value; }
103
113
  get isNaN() { return Number.isNaN(this.value); }
104
114
  get isFinite() { return Number.isFinite(this.value); }
105
115
  get isInfinite() { return !Number.isFinite(this.value) && !Number.isNaN(this.value); }
106
116
  get isNegative() { return this.value < 0 || (this.value === 0 && 1 / this.value === -Infinity); }
117
+ // Mirrors the Number.prototype.remainder polyfill below (truncating
118
+ // remainder, matching JS % and Dart's num.remainder) — BallDouble wraps
119
+ // a JS number so it never inherits Number.prototype and needs its own.
120
+ remainder(other) { return this.value % Number(other); }
107
121
  toString() {
108
122
  const v = this.value;
109
123
  if (!isFinite(v))
@@ -252,11 +266,22 @@ function __ball_to_string(v) {
252
266
  }
253
267
  if (v instanceof Map) {
254
268
  const parts = [];
255
- for (const [k, val] of v.entries()) {
269
+ // v.entries() as a method call would hit the Dart-property-style
270
+ // getter of the same name (installed further down in this file) and
271
+ // try to invoke its return value -- an array -- as a function.
272
+ // _nativeMapEntries is the real, un-shadowed method (issue #259).
273
+ for (const [k, val] of _nativeMapEntries.call(v)) {
256
274
  parts.push(__ball_to_string(k) + ': ' + __ball_to_string(val));
257
275
  }
258
276
  return '{' + parts.join(', ') + '}';
259
277
  }
278
+ if (v instanceof Set) {
279
+ // A Set is a plain object from typeof's perspective (falls through to
280
+ // the generic branch below, which reads Object.keys — always [] for a
281
+ // Set's internal slots), so every Set printed as the empty "{}" no
282
+ // matter its contents until this dedicated case was added (#219).
283
+ return '{' + [...v].map(__ball_to_string).join(', ') + '}';
284
+ }
260
285
  if (typeof v === 'object' && !Array.isArray(v)) {
261
286
  // StringBuffer-like objects
262
287
  if (v['__buffer__'] && Array.isArray(v['__buffer__'])) {
@@ -313,17 +338,30 @@ function __ball_to_int(v) {
313
338
  }
314
339
  return t;
315
340
  }
341
+ // Returns a BallDouble (not a bare number) so a whole-valued result (e.g.
342
+ // double.parse('7.0')) still prints "7.0", not "7" — JS numbers erase the
343
+ // int/double distinction that the wrapper exists to preserve (#67/#222).
316
344
  function __ball_parse_double(s) {
317
345
  const n = parseFloat(s);
318
346
  if (Number.isNaN(n))
319
347
  throw new Error('FormatException: ' + s);
320
- return n;
348
+ return new BallDouble(n);
321
349
  }
322
350
  function __ball_double_to_string(n) {
323
351
  if (Number.isInteger(n))
324
352
  return n.toFixed(1);
325
353
  return n.toString();
326
354
  }
355
+ // num.toStringAsFixed(digits). JS Number.prototype.toFixed drops the sign of
356
+ // -0 (returns "0.00" not "-0.00"); Dart's toStringAsFixed keeps it, matching
357
+ // the -0 handling __ball_to_string/BallDouble.toString already do.
358
+ function __ball_to_fixed(v, digits) {
359
+ const n = Number(v);
360
+ const s = n.toFixed(digits);
361
+ if (n === 0 && 1 / n === -Infinity && !s.startsWith('-'))
362
+ return '-' + s;
363
+ return s;
364
+ }
327
365
  // Polymorphic concat / merge used for std.list_concat. The encoder emits
328
366
  // list_concat both for Dart list concat AND for Map.addAll(...) (encoded as
329
367
  // m = list_concat(m, other)). Arrays concat positionally; plain objects
@@ -369,11 +407,11 @@ function __ball_push_all(target, items) {
369
407
  // demotes back to Number when the result fits in MAX_SAFE_INTEGER.
370
408
  const __I64_MAX = 9223372036854775807n;
371
409
  const __I64_MIN = -9223372036854775808n;
372
- const __I64_MOD = 18446744073709551616n;
373
410
  function __i64_wrap(v) {
374
- v = ((v % __I64_MOD) + __I64_MOD) % __I64_MOD;
375
- if (v > __I64_MAX)
376
- v = v - __I64_MOD;
411
+ // Two's-complement wrap to the signed 64-bit range — BigInt.asIntN(64, v)
412
+ // is the idiomatic builtin for exactly this (equivalent to the old manual
413
+ // modulo-then-resign, verified against it across boundary/overflow cases).
414
+ v = BigInt.asIntN(64, v);
377
415
  if (v >= -9007199254740991n && v <= 9007199254740991n)
378
416
  return Number(v);
379
417
  return v;
@@ -381,16 +419,73 @@ function __i64_wrap(v) {
381
419
  function __to_bigint(v) {
382
420
  if (typeof v === 'bigint')
383
421
  return v;
422
+ // Matches the reference Dart engine's _toInt (engine_std.dart), which
423
+ // falls through to 0 for anything that isn't an int/BallInt/double/
424
+ // BallDouble/String/bool -- including null. NaN is deliberately NOT
425
+ // special-cased here: Dart's double.toInt() throws on NaN (via
426
+ // _ballDoubleToInt64), and BigInt(NaN) already throws for the same
427
+ // reason (RangeError: not an integer), so that path already fails loud
428
+ // consistently with the reference engine without any extra handling.
429
+ if (v === null || v === undefined)
430
+ return 0n;
384
431
  if (v instanceof BallDouble)
385
432
  return BigInt(Math.trunc(v.value));
386
433
  return BigInt(v);
387
434
  }
388
- function __ball_bitand(a, b) { return __i64_wrap(__to_bigint(a) & __to_bigint(b)); }
389
- function __ball_bitor(a, b) { return __i64_wrap(__to_bigint(a) | __to_bigint(b)); }
390
- function __ball_bitxor(a, b) { return __i64_wrap(__to_bigint(a) ^ __to_bigint(b)); }
391
- function __ball_bitnot(a) { return __i64_wrap(~__to_bigint(a)); }
435
+ // Fast-path guard: true when v is a plain (non-bigint, non-BallDouble)
436
+ // integer within the signed 32-bit range. AND/OR/XOR/NOT never grow a
437
+ // result past its operands' bit width, so when both operands fit in 32
438
+ // bits, JS's native 32-bit bitwise operators give a result numerically
439
+ // IDENTICAL to the full 64-bit BigInt path (sign-extending a 32-bit value
440
+ // to 64 bits before AND/OR/XOR/NOT never changes the low 32 result bits,
441
+ // and — verified across the full boundary range — never changes whether
442
+ // the high bits are the correct sign-extension of them either). Left/right
443
+ // shift are NOT given this fast path: shifting can grow a result past 32
444
+ // bits even when the input operand fits (e.g. large_int << 40), so their
445
+ // overflow behavior isn't safely 32-bit-local the way AND/OR/XOR/NOT is.
446
+ function __fits32(v) {
447
+ return typeof v === 'number' && Number.isInteger(v) && v >= -2147483648 && v <= 2147483647;
448
+ }
449
+ function __ball_bitand(a, b) {
450
+ if (__fits32(a) && __fits32(b))
451
+ return a & b;
452
+ return __i64_wrap(__to_bigint(a) & __to_bigint(b));
453
+ }
454
+ function __ball_bitor(a, b) {
455
+ if (__fits32(a) && __fits32(b))
456
+ return a | b;
457
+ return __i64_wrap(__to_bigint(a) | __to_bigint(b));
458
+ }
459
+ function __ball_bitxor(a, b) {
460
+ if (__fits32(a) && __fits32(b))
461
+ return a ^ b;
462
+ return __i64_wrap(__to_bigint(a) ^ __to_bigint(b));
463
+ }
464
+ function __ball_bitnot(a) {
465
+ if (__fits32(a))
466
+ return ~a;
467
+ return __i64_wrap(~__to_bigint(a));
468
+ }
392
469
  function __ball_shl(a, b) { return __i64_wrap(__to_bigint(a) << __to_bigint(b)); }
393
470
  function __ball_shr(a, b) { return __i64_wrap(__to_bigint(a) >> __to_bigint(b)); }
471
+ // Unsigned/logical shift: reinterpret a as an unsigned 64-bit value (add
472
+ // 2^64 if negative) before shifting, so zeros fill from the left instead of
473
+ // the sign bit — unlike >>> on raw JS numbers, which is only 32-bit.
474
+ function __ball_ushr(a, b) {
475
+ const unsigned = BigInt.asUintN(64, __to_bigint(a));
476
+ return __i64_wrap(unsigned >> __to_bigint(b));
477
+ }
478
+ // json_encode (dart:convert's jsonEncode) on a bigint-range int64 must not
479
+ // crash -- JSON.stringify throws "Do not know how to serialize a BigInt"
480
+ // without a toJSON. This is NOT proto3-JSON (which quotes int64 as a
481
+ // string) -- Ball's dart:convert-style jsonEncode matches Dart's own
482
+ // dart:convert (a bare, unquoted JSON number) and the C++ self-host's
483
+ // _ball_json_encode (std::to_string(int64_t), also unquoted). JSON.rawJSON
484
+ // embeds the exact decimal digits as a raw number token, avoiding the
485
+ // precision loss Number(this) would introduce for values past 2^53.
486
+ BigInt.prototype.toJSON = function () {
487
+ return JSON.rawJSON(this.toString());
488
+ };
394
489
  function __ball_negate(a) {
395
490
  if (typeof a === 'bigint')
396
491
  return __i64_wrap(-a);
@@ -465,14 +560,6 @@ function __dart_mod(a, b) {
465
560
  }
466
561
  // Active exception for rethrow. Catch bodies shadow with a local.
467
562
  let __ball_active_error = undefined;
468
- // Safe own-property lookup. Returns undefined if key is not an own property.
469
- // Avoids triggering Object.prototype getters (entries, keys, values) on
470
- // plain objects that aren't meant to be Dart Maps.
471
- function __ball_own(obj, key) {
472
- if (obj == null || typeof obj !== 'object')
473
- return undefined;
474
- return Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
475
- }
476
563
  // Dart-style index access. Dart's List '[]' operator throws RangeError on
477
564
  // out-of-bounds access, whereas JS array indexing silently returns undefined.
478
565
  // To make 'on RangeError' catch clauses behave like Dart we bounds-check list
@@ -731,6 +818,19 @@ function __ball_cascade(target, ops) {
731
818
  // ── Dart \u2192 JS method-name polyfills ────────────────────────────────
732
819
  //
733
820
  // Idempotent: guarded so multiple preamble inclusions don't double-install.
821
+ // Native Map.prototype.entries/keys/values, captured BEFORE the
822
+ // installBallPolyfills IIFE below shadows them with Dart-property-style
823
+ // getters of the same name. Top-level (not IIFE-scoped) so every internal
824
+ // call site that needs the REAL iterator method -- not the property-style
825
+ // getter -- can reach it: the getters themselves (which must call the
826
+ // original to avoid recursing into themselves), __ball_to_string's Map
827
+ // printer, the Map-like constructor copy sites, and the map_keys/values/
828
+ // entries base-function helpers (issue #259 -- calling .entries()/etc.
829
+ // as a METHOD on a real Map after the shadow is installed throws, since
830
+ // the getter's return value -- an array -- isn't itself callable).
831
+ const _nativeMapEntries = Map.prototype.entries;
832
+ const _nativeMapKeys = Map.prototype.keys;
833
+ const _nativeMapValues = Map.prototype.values;
734
834
  (function installBallPolyfills() {
735
835
  const mp = Map.prototype;
736
836
  if (!mp.containsKey)
@@ -745,7 +845,9 @@ function __ball_cascade(target, ops) {
745
845
  if (!mp.addAll) {
746
846
  mp.addAll = function (other) {
747
847
  if (other instanceof Map) {
748
- for (const [k, v] of other.entries())
848
+ // _nativeMapEntries, not other.entries() -- see __ball_to_string's
849
+ // Map printer above for why (issue #259).
850
+ for (const [k, v] of _nativeMapEntries.call(other))
749
851
  this.set(k, v);
750
852
  }
751
853
  else if (other && typeof other === 'object') {
@@ -915,6 +1017,9 @@ function __ball_cascade(target, ops) {
915
1017
  Object.defineProperty(_ballNp, 'isInfinite', {
916
1018
  configurable: true, get() { const n = Number(this); return n === Infinity || n === -Infinity; },
917
1019
  });
1020
+ Object.defineProperty(_ballNp, 'isNegative', {
1021
+ configurable: true, get() { const n = Number(this); return n < 0 || (n === 0 && 1 / n === -Infinity); },
1022
+ });
918
1023
  if (!_ballNp.abs)
919
1024
  _ballNp.abs = function () { return Math.abs(Number(this)); };
920
1025
  if (!_ballNp.ceil)
@@ -934,7 +1039,7 @@ function __ball_cascade(target, ops) {
934
1039
  if (!_ballNp.compareTo)
935
1040
  _ballNp.compareTo = function (other) { const a = Number(this), b = Number(other); return a < b ? -1 : a > b ? 1 : 0; };
936
1041
  if (!_ballNp.toStringAsFixed)
937
- _ballNp.toStringAsFixed = function (digits) { return Number(this).toFixed(digits); };
1042
+ _ballNp.toStringAsFixed = function (digits) { return __ball_to_fixed(this, digits); };
938
1043
  if (!_ballNp.remainder)
939
1044
  _ballNp.remainder = function (other) { return Number(this) % Number(other); };
940
1045
  // Object.prototype polyfills — used by the compiled engine when
@@ -975,7 +1080,8 @@ function __ball_cascade(target, ops) {
975
1080
  value: function (other) {
976
1081
  if (this instanceof Map) {
977
1082
  if (other instanceof Map) {
978
- for (const [k, v] of other.entries())
1083
+ // _nativeMapEntries, not other.entries() (issue #259).
1084
+ for (const [k, v] of _nativeMapEntries.call(other))
979
1085
  this.set(k, v);
980
1086
  }
981
1087
  else if (other && typeof other === 'object') {
@@ -1041,9 +1147,9 @@ function __ball_cascade(target, ops) {
1041
1147
  // JS Map has them as METHODS (need parens). The compiled engine
1042
1148
  // accesses map.entries as a getter. Shadow BOTH Map.prototype AND
1043
1149
  // Object.prototype so Map and plain-object dispatch tables work.
1044
- const _nativeMapEntries = Map.prototype.entries;
1045
- const _nativeMapKeys = Map.prototype.keys;
1046
- const _nativeMapValues = Map.prototype.values;
1150
+ // (_nativeMapEntries/_nativeMapKeys/_nativeMapValues are captured at
1151
+ // top level above, not here, so other call sites outside this IIFE
1152
+ // can reach them too -- issue #259.)
1047
1153
  // Shadow Map.prototype.entries with a getter (Dart uses it as a getter).
1048
1154
  Object.defineProperty(Map.prototype, 'entries', {
1049
1155
  configurable: true, enumerable: false,
@@ -1074,25 +1180,44 @@ function __ball_cascade(target, ops) {
1074
1180
  },
1075
1181
  });
1076
1182
  }
1183
+ // .entries/.keys/.values on a non-Map must FAIL LOUD (throw a catchable
1184
+ // error), not silently return [] — the silent-degradation class of bug
1185
+ // that hid issue #55 (mirrors the fix already applied to the Dart/C++
1186
+ // compilers). .entries used to be the odd one out here, silently
1187
+ // returning [] instead of throwing — same bug family as #218.
1188
+ //
1189
+ // A getter installed on Object.prototype is invoked in "sloppy" (non-strict)
1190
+ // script contexts with this auto-boxed to a Number/String/Boolean WRAPPER
1191
+ // object for a primitive receiver (e.g. (42).keys boxes this to a Number
1192
+ // instance) — typeof this is then 'object', not 'number', so a bare
1193
+ // __ball_is_type(this, 'Map') (which only excludes Array/BallDouble/Set)
1194
+ // would wrongly treat a boxed int/string as Map-like. Exclude the wrapper
1195
+ // types explicitly instead of widening the shared type-check.
1196
+ const __isGenuineMap = (v) => typeof v === 'object' && v !== null && !Array.isArray(v) &&
1197
+ !(v instanceof BallDouble) && !(v instanceof Set) &&
1198
+ !(v instanceof Number) && !(v instanceof String) && !(v instanceof Boolean);
1077
1199
  defDartGetter('entries', function () {
1078
1200
  if (this instanceof Map)
1079
1201
  return [..._nativeMapEntries.call(this)].map(([k, v]) => ({ key: k, value: v }));
1080
- if (this == null || typeof this !== 'object')
1081
- return [];
1202
+ if (!__isGenuineMap(this)) {
1203
+ throw new Error('type \'' + __ball_to_string(this) + '\' has no .entries getter (not a Map)');
1204
+ }
1082
1205
  return Object.entries(this).map(([k, v]) => ({ key: k, value: v }));
1083
1206
  });
1084
1207
  defDartGetter('keys', function () {
1085
1208
  if (this instanceof Map)
1086
1209
  return [..._nativeMapKeys.call(this)];
1087
- if (this == null || typeof this !== 'object')
1088
- return [];
1210
+ if (!__isGenuineMap(this)) {
1211
+ throw new Error('type \'' + __ball_to_string(this) + '\' has no .keys getter (not a Map)');
1212
+ }
1089
1213
  return Object.keys(this);
1090
1214
  });
1091
1215
  defDartGetter('values', function () {
1092
1216
  if (this instanceof Map)
1093
1217
  return [..._nativeMapValues.call(this)];
1094
- if (this == null || typeof this !== 'object')
1095
- return [];
1218
+ if (!__isGenuineMap(this)) {
1219
+ throw new Error('type \'' + __ball_to_string(this) + '\' has no .values getter (not a Map)');
1220
+ }
1096
1221
  return Object.values(this);
1097
1222
  });
1098
1223
  defDartGetter('length', function () {
@@ -1155,6 +1280,67 @@ function __ball_cascade(target, ops) {
1155
1280
  get() { return 'bool'; },
1156
1281
  });
1157
1282
  })();
1283
+ // std.map_keys/std.map_values/std.map_entries (the base-function-call form,
1284
+ // as opposed to the .keys/.values/.entries DART-GETTER-STYLE property
1285
+ // access the defDartGetter block above already guards) must ALSO fail loud
1286
+ // on a non-Map receiver instead of silently returning [] — same "genuine
1287
+ // Map" check, exposed as top-level helpers so compileStdCall's emitted code
1288
+ // can call them (#218).
1289
+ function __ball_map_keys(m) {
1290
+ // _nativeMapKeys, not m.keys() -- m.keys() would hit the Dart-property-
1291
+ // style getter shadowing Map.prototype.keys and try to invoke its
1292
+ // return value (an array) as a function (issue #259).
1293
+ if (m instanceof Map)
1294
+ return [..._nativeMapKeys.call(m)];
1295
+ if (typeof m !== 'object' || m === null || Array.isArray(m) ||
1296
+ m instanceof BallDouble || m instanceof Set ||
1297
+ m instanceof Number || m instanceof String || m instanceof Boolean) {
1298
+ throw new Error('type \'' + __ball_to_string(m) + '\' has no .keys getter (not a Map)');
1299
+ }
1300
+ return Object.keys(m);
1301
+ }
1302
+ function __ball_map_values(m) {
1303
+ // _nativeMapValues, not m.values() (issue #259 -- see __ball_map_keys).
1304
+ if (m instanceof Map)
1305
+ return [..._nativeMapValues.call(m)];
1306
+ if (typeof m !== 'object' || m === null || Array.isArray(m) ||
1307
+ m instanceof BallDouble || m instanceof Set ||
1308
+ m instanceof Number || m instanceof String || m instanceof Boolean) {
1309
+ throw new Error('type \'' + __ball_to_string(m) + '\' has no .values getter (not a Map)');
1310
+ }
1311
+ return Object.values(m);
1312
+ }
1313
+ function __ball_map_entries(m) {
1314
+ // _nativeMapEntries, not m.entries() (issue #259 -- see __ball_map_keys).
1315
+ if (m instanceof Map)
1316
+ return [..._nativeMapEntries.call(m)].map(([k, v]) => ({ key: k, value: v }));
1317
+ if (typeof m !== 'object' || m === null || Array.isArray(m) ||
1318
+ m instanceof BallDouble || m instanceof Set ||
1319
+ m instanceof Number || m instanceof String || m instanceof Boolean) {
1320
+ throw new Error('type \'' + __ball_to_string(m) + '\' has no .entries getter (not a Map)');
1321
+ }
1322
+ return Object.entries(m).map(([k, v]) => ({ key: k, value: v }));
1323
+ }
1324
+ // Shared guard for the REMAINING map_* base-function-call cases
1325
+ // (map_get/map_set/map_delete/map_merge/map_length/map_is_empty/
1326
+ // map_contains_key/map_contains_value/map_foreach) that used to route a
1327
+ // bare map[key], Object.keys/values(map), or key in map straight to the
1328
+ // receiver with no type check at all -- silently returning undefined,
1329
+ // no-opping, or checking array-index membership instead of throwing on a
1330
+ // non-Map (issue #55's silent-degradation class, same family as #218's
1331
+ // map_keys/map_values/map_entries). Returns the validated Map/plain-object
1332
+ // itself (not a boolean) so a call site can keep using it directly, e.g.
1333
+ // __ball_require_map(x, 'map_get')[key].
1334
+ function __ball_require_map(v, opName) {
1335
+ if (v instanceof Map)
1336
+ return v;
1337
+ if (typeof v !== 'object' || v === null || Array.isArray(v) ||
1338
+ v instanceof BallDouble || v instanceof Set ||
1339
+ v instanceof Number || v instanceof String || v instanceof Boolean) {
1340
+ throw new Error('type \'' + __ball_to_string(v) + '\' is not a Map (' + opName + ')');
1341
+ }
1342
+ return v;
1343
+ }
1158
1344
  // ── Protobuf Struct/Value compatibility ─────────────────────────
1159
1345
  //
1160
1346
  // Dart's protobuf runtime wraps google.protobuf.Struct as a class
@@ -1851,7 +2037,7 @@ export class BallEngine {
1851
2037
  }
1852
2038
  if (hasMetadata(func)) {
1853
2039
  let params = this._extractParams(func.metadata);
1854
- if (!(params.length === 0)) {
2040
+ if ((!(params.length === 0) && !(func.name.length === 0))) {
1855
2041
  this._paramCache[key] = params;
1856
2042
  }
1857
2043
  let kindField = __ball_index(func.metadata.fields, 'kind');
@@ -1928,7 +2114,7 @@ export class BallEngine {
1928
2114
  }
1929
2115
  _resolveInstanceMethodDispatch(typeName, methodName) {
1930
2116
  let cacheKey = BallEngine._typeMethodKey(typeName, methodName);
1931
- if ((cacheKey in this._instanceMethodCache)) {
2117
+ if ((cacheKey in __ball_require_map(this._instanceMethodCache, 'map_contains_key'))) {
1932
2118
  return __ball_index(this._instanceMethodCache, cacheKey);
1933
2119
  }
1934
2120
  let resolved = (this._resolveMethod(typeName, methodName) ?? this._lookupTypeMethodWithInheritance(typeName, methodName));
@@ -2098,7 +2284,7 @@ export class BallEngine {
2098
2284
  let dotIdx = func.name.indexOf('.');
2099
2285
  let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
2100
2286
  let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
2101
- if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in constructorInput))) && !__ball_eq(this._findTypeDef(typeName), null))) {
2287
+ if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in __ball_require_map(constructorInput, 'map_contains_key')))) && !__ball_eq(this._findTypeDef(typeName), null))) {
2102
2288
  return this._callObjectConstructor(moduleName, func, input);
2103
2289
  }
2104
2290
  }
@@ -2108,15 +2294,15 @@ export class BallEngine {
2108
2294
  if ((!(func.inputType.length === 0) && !__ball_eq(input, null))) {
2109
2295
  scope.bind('input', input);
2110
2296
  }
2111
- let params = (__ball_index(this._paramCache, ((__ball_to_string(moduleName) + '.') + __ball_to_string(func.name))) ?? ((hasMetadata(func) ? this._extractParams(func.metadata) : [])));
2297
+ 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) : [])));
2112
2298
  let inputMap = this._asMap(input);
2113
2299
  if (!(params.length === 0)) {
2114
- if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && ('self' in inputMap)))) {
2115
- if ((!__ball_eq(inputMap, null) && (__ball_index(params, 0) in inputMap))) {
2300
+ if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key'))))) {
2301
+ if ((!__ball_eq(inputMap, null) && (__ball_index(params, 0) in __ball_require_map(inputMap, 'map_contains_key')))) {
2116
2302
  scope.bind(__ball_index(params, 0), __ball_index(inputMap, __ball_index(params, 0)));
2117
2303
  }
2118
2304
  else {
2119
- if (((!__ball_eq(inputMap, null) && ('arg0' in inputMap)) && !(__ball_index(params, 0) in inputMap))) {
2305
+ 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')))) {
2120
2306
  scope.bind(__ball_index(params, 0), __ball_index(inputMap, 'arg0'));
2121
2307
  }
2122
2308
  else {
@@ -2128,15 +2314,15 @@ export class BallEngine {
2128
2314
  if (!__ball_eq(inputMap, null)) {
2129
2315
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2130
2316
  let p = __ball_index(params, i);
2131
- if ((p in inputMap)) {
2317
+ if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
2132
2318
  scope.bind(p, __ball_index(inputMap, p));
2133
2319
  }
2134
2320
  else {
2135
- if ((('arg' + __ball_to_string(i)) in inputMap)) {
2321
+ if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2136
2322
  scope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
2137
2323
  }
2138
2324
  else {
2139
- if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && ('value' in inputMap)) && this._isSetter(func))) {
2325
+ if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && ('value' in __ball_require_map(inputMap, 'map_contains_key'))) && this._isSetter(func))) {
2140
2326
  scope.bind(p, __ball_index(inputMap, 'value'));
2141
2327
  }
2142
2328
  }
@@ -2152,7 +2338,7 @@ export class BallEngine {
2152
2338
  }
2153
2339
  }
2154
2340
  }
2155
- if ((!__ball_eq(inputMap, null) && ('self' in inputMap))) {
2341
+ if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
2156
2342
  let self = __ball_index(inputMap, 'self');
2157
2343
  scope.bind('self', self);
2158
2344
  let selfMap = this._asMap(self);
@@ -2187,7 +2373,7 @@ export class BallEngine {
2187
2373
  let isAsyncStar = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_async_star')));
2188
2374
  let isGenerator = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_generator')));
2189
2375
  let isGenFunc = ((isSyncStar || isAsyncStar) || isGenerator);
2190
- let generator = __no_init__;
2376
+ let generator;
2191
2377
  if (isGenFunc) {
2192
2378
  generator = _ballNewGenerator();
2193
2379
  scope.bind('__generator__', generator);
@@ -2196,7 +2382,7 @@ export class BallEngine {
2196
2382
  this._activeGeneratorScope = scope;
2197
2383
  }
2198
2384
  let isAsync = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_async')));
2199
- let finalResult = __no_init__;
2385
+ let finalResult;
2200
2386
  if ((isAsync && !isGenFunc)) {
2201
2387
  try {
2202
2388
  let result = await this._evalExpression(func.body, scope);
@@ -2217,7 +2403,7 @@ export class BallEngine {
2217
2403
  else {
2218
2404
  let result = await this._evalExpression(func.body, scope);
2219
2405
  this._currentModule = prevModule;
2220
- if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && ('self' in inputMap))) {
2406
+ if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
2221
2407
  let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
2222
2408
  if (((result instanceof _FlowSignal) && __ball_eq(result.kind, 'return'))) {
2223
2409
  finalResult = result.value;
@@ -2291,16 +2477,16 @@ export class BallEngine {
2291
2477
  let resolvedParams = {};
2292
2478
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2293
2479
  let param = __ball_index(params, i);
2294
- let value = __no_init__;
2295
- if ((param in inputMap)) {
2480
+ let value;
2481
+ if ((param in __ball_require_map(inputMap, 'map_contains_key'))) {
2296
2482
  value = __ball_index(inputMap, param);
2297
2483
  }
2298
2484
  else {
2299
- if ((('arg' + __ball_to_string(i)) in inputMap)) {
2485
+ if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2300
2486
  value = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
2301
2487
  }
2302
2488
  }
2303
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
2489
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
2304
2490
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
2305
2491
  }
2306
2492
  resolvedParams[param] = value;
@@ -2316,7 +2502,7 @@ export class BallEngine {
2316
2502
  }
2317
2503
  this._initFieldDefaults(typeName, instanceFields);
2318
2504
  let superclass = this._getMetaString(typeDef, 'superclass');
2319
- let superObject = __no_init__;
2505
+ let superObject;
2320
2506
  if ((!__ball_eq(superclass, null) && !(superclass.length === 0))) {
2321
2507
  superObject = await this._invokeSuperConstructor(func, superclass, resolvedParams);
2322
2508
  superObject ??= this._buildSuperObject(superclass, instanceFields);
@@ -2332,7 +2518,7 @@ export class BallEngine {
2332
2518
  })();
2333
2519
  let constructed = await this._callFunction(moduleName, func, ctorInput);
2334
2520
  let constructedMap = this._asMap(constructed);
2335
- if ((!__ball_eq(constructedMap, null) && ('__type__' in constructedMap))) {
2521
+ if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
2336
2522
  return constructed;
2337
2523
  }
2338
2524
  return instance;
@@ -2428,12 +2614,12 @@ export class BallEngine {
2428
2614
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2429
2615
  let p = __ball_index(params, i);
2430
2616
  let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
2431
- let val = __no_init__;
2432
- if ((p in inputMap)) {
2617
+ let val;
2618
+ if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
2433
2619
  val = __ball_index(inputMap, p);
2434
2620
  }
2435
2621
  else {
2436
- if ((('arg' + __ball_to_string(i)) in inputMap)) {
2622
+ if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2437
2623
  val = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
2438
2624
  }
2439
2625
  else {
@@ -2471,7 +2657,7 @@ export class BallEngine {
2471
2657
  if (!__ball_eq(superMap, null)) {
2472
2658
  instance['__super__'] = superInstance;
2473
2659
  for (const e of superMap.entries) {
2474
- if ((!e.key.startsWith('__') && !(e.key in instance))) {
2660
+ if ((!e.key.startsWith('__') && !(e.key in __ball_require_map(instance, 'map_contains_key')))) {
2475
2661
  instance[e.key] = e.value;
2476
2662
  }
2477
2663
  }
@@ -2514,7 +2700,7 @@ export class BallEngine {
2514
2700
  let superInput = {};
2515
2701
  for (let i = 0; __ball_lt(i, argNames.length); (i++)) {
2516
2702
  let token = __ball_index(argNames, i);
2517
- if ((token in resolvedParams)) {
2703
+ if ((token in __ball_require_map(resolvedParams, 'map_contains_key'))) {
2518
2704
  superInput[('arg' + __ball_to_string(i))] = __ball_index(resolvedParams, token);
2519
2705
  }
2520
2706
  else {
@@ -3139,7 +3325,7 @@ export class BallEngine {
3139
3325
  }
3140
3326
  if (hasMetadata(func)) {
3141
3327
  let params = this._extractParams(func.metadata);
3142
- if (!(params.length === 0)) {
3328
+ if ((!(params.length === 0) && !(func.name.length === 0))) {
3143
3329
  this._paramCache[key] = params;
3144
3330
  }
3145
3331
  let kindField = __ball_index(func.metadata.fields, 'kind');
@@ -3171,7 +3357,7 @@ export class BallEngine {
3171
3357
  }
3172
3358
  static _extractMetadataTypeArgs(msg) {
3173
3359
  const input = msg;
3174
- if ((!hasMetadata(msg) || !('type_args' in msg.metadata.fields))) {
3360
+ if ((!hasMetadata(msg) || !('type_args' in __ball_require_map(msg.metadata.fields, 'map_contains_key')))) {
3175
3361
  return null;
3176
3362
  }
3177
3363
  return [...__ball_index(msg.metadata.fields, 'type_args').listValue.values.map(BallEngine._typeRefValueToString)];
@@ -3355,7 +3541,7 @@ export class BallEngine {
3355
3541
  }
3356
3542
  }
3357
3543
  let inputMap = this._asMap(input);
3358
- if ((!__ball_eq(inputMap, null) && ('self' in inputMap))) {
3544
+ if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
3359
3545
  let self = __ball_index(inputMap, 'self');
3360
3546
  let selfMap = this._asMap(self);
3361
3547
  if (!__ball_eq(selfMap, null)) {
@@ -3392,7 +3578,7 @@ export class BallEngine {
3392
3578
  let methodOwner = selfMap;
3393
3579
  while (!__ball_eq(methodOwner, null)) {
3394
3580
  let methods = __ball_index(methodOwner, '__methods__');
3395
- if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (call.function in methods))) {
3581
+ 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')))) {
3396
3582
  let method = __ball_index(methods, call.function);
3397
3583
  if ((typeof method === 'function')) {
3398
3584
  let result = method(input);
@@ -3416,7 +3602,7 @@ export class BallEngine {
3416
3602
  }
3417
3603
  }
3418
3604
  let fallbackMap = this._asMap(input);
3419
- if ((!__ball_eq(fallbackMap, null) && ('self' in fallbackMap))) {
3605
+ if ((!__ball_eq(fallbackMap, null) && ('self' in __ball_require_map(fallbackMap, 'map_contains_key')))) {
3420
3606
  let selfFallback = __ball_index(fallbackMap, 'self');
3421
3607
  let selfFallbackMap = this._asMap(selfFallback);
3422
3608
  if (!__ball_eq(selfFallbackMap, null)) {
@@ -3693,7 +3879,7 @@ export class BallEngine {
3693
3879
  async _evalReference(ref, scope) {
3694
3880
  let name = ref.name;
3695
3881
  if (__ball_eq(name, 'super')) {
3696
- let selfRef = __no_init__;
3882
+ let selfRef;
3697
3883
  try {
3698
3884
  selfRef = scope.lookup('self');
3699
3885
  }
@@ -3736,12 +3922,12 @@ export class BallEngine {
3736
3922
  }
3737
3923
  if (!_builtinTypeNames.includes(name)) {
3738
3924
  let qualifiedName = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(name));
3739
- let hasCtor = ((name in this._constructors) || (qualifiedName in this._constructors));
3925
+ let hasCtor = ((name in __ball_require_map(this._constructors, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._constructors, 'map_contains_key')));
3740
3926
  let hasStaticMethods = this._functions.keys.some(((k) => {
3741
3927
  const input = k;
3742
3928
  return (k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(qualifiedName)) + '.')) || k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(name)) + '.')));
3743
3929
  }));
3744
- let typeExists = ((name in this._types) || (qualifiedName in this._types));
3930
+ let typeExists = ((name in __ball_require_map(this._types, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._types, 'map_contains_key')));
3745
3931
  if ((typeExists && (hasCtor || hasStaticMethods))) {
3746
3932
  return { ['__class_ref__']: name, ['__type__']: '__class__' };
3747
3933
  }
@@ -3751,7 +3937,7 @@ export class BallEngine {
3751
3937
  if ((!__ball_eq(getterFunc, null) && this._isGetter(getterFunc))) {
3752
3938
  return this._callFunction(this._currentModule, getterFunc, null);
3753
3939
  }
3754
- let selfForGetter = __no_init__;
3940
+ let selfForGetter;
3755
3941
  try {
3756
3942
  selfForGetter = scope.lookup('self');
3757
3943
  }
@@ -3762,7 +3948,7 @@ export class BallEngine {
3762
3948
  if (!__ball_eq(selfForGetter, null)) {
3763
3949
  let selfMap = this._asMap(selfForGetter);
3764
3950
  if (!__ball_eq(selfMap, null)) {
3765
- if ((name in selfMap)) {
3951
+ if ((name in __ball_require_map(selfMap, 'map_contains_key'))) {
3766
3952
  let direct = __ball_index(selfMap, name);
3767
3953
  if (!__ball_eq(direct, null)) {
3768
3954
  return direct;
@@ -3771,7 +3957,7 @@ export class BallEngine {
3771
3957
  let superObj = __ball_index(selfMap, '__super__');
3772
3958
  let superMap = this._asMap(superObj);
3773
3959
  while (!__ball_eq(superMap, null)) {
3774
- if ((name in superMap)) {
3960
+ if ((name in __ball_require_map(superMap, 'map_contains_key'))) {
3775
3961
  let inherited = __ball_index(superMap, name);
3776
3962
  if (!__ball_eq(inherited, null)) {
3777
3963
  return inherited;
@@ -3896,25 +4082,25 @@ export class BallEngine {
3896
4082
  });
3897
4083
  }
3898
4084
  let enumVals = (__ball_index(this._enumValues, className) ?? __ball_index(this._enumValues, qualifiedName));
3899
- if ((!__ball_eq(enumVals, null) && (fieldName in enumVals))) {
4085
+ if ((!__ball_eq(enumVals, null) && (fieldName in __ball_require_map(enumVals, 'map_contains_key')))) {
3900
4086
  return __ball_index(enumVals, fieldName);
3901
4087
  }
3902
4088
  }
3903
4089
  if (!__ball_eq(objectMap, null)) {
3904
- if ((fieldName in objectMap)) {
4090
+ if ((fieldName in __ball_require_map(objectMap, 'map_contains_key'))) {
3905
4091
  return __ball_index(objectMap, fieldName);
3906
4092
  }
3907
4093
  let superObj = __ball_index(objectMap, '__super__');
3908
4094
  let superMap = this._asMap(superObj);
3909
4095
  while (!__ball_eq(superMap, null)) {
3910
- if ((fieldName in superMap)) {
4096
+ if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
3911
4097
  return __ball_index(superMap, fieldName);
3912
4098
  }
3913
4099
  superObj = __ball_index(superMap, '__super__');
3914
4100
  superMap = this._asMap(superObj);
3915
4101
  }
3916
4102
  let methods = __ball_index(objectMap, '__methods__');
3917
- if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (fieldName in methods))) {
4103
+ if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (fieldName in __ball_require_map(methods, 'map_contains_key')))) {
3918
4104
  let method = __ball_index(methods, fieldName);
3919
4105
  if ((typeof method === 'function')) {
3920
4106
  return method;
@@ -3924,7 +4110,7 @@ export class BallEngine {
3924
4110
  superMap = this._asMap(superObj);
3925
4111
  while (!__ball_eq(superMap, null)) {
3926
4112
  let superMethods = __ball_index(superMap, '__methods__');
3927
- if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && (fieldName in superMethods))) {
4113
+ if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && (fieldName in __ball_require_map(superMethods, 'map_contains_key')))) {
3928
4114
  let method = __ball_index(superMethods, fieldName);
3929
4115
  if ((typeof method === 'function')) {
3930
4116
  return method;
@@ -3952,7 +4138,7 @@ export class BallEngine {
3952
4138
  }))];
3953
4139
  if ((!(vals.length === 0) && vals.every(((v) => {
3954
4140
  const input = v;
3955
- return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && ('index' in v)) && ('__type__' in v));
4141
+ 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')));
3956
4142
  })))) {
3957
4143
  vals = [...vals].sort(((a, b) => {
3958
4144
  return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
@@ -4069,7 +4255,7 @@ export class BallEngine {
4069
4255
  }))];
4070
4256
  if ((!(vals.length === 0) && vals.every(((v) => {
4071
4257
  const input = v;
4072
- return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && ('index' in v)) && ('__type__' in v));
4258
+ 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')));
4073
4259
  })))) {
4074
4260
  vals = [...vals].sort(((a, b) => {
4075
4261
  return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
@@ -4251,11 +4437,11 @@ export class BallEngine {
4251
4437
  return;
4252
4438
  }
4253
4439
  let backing = ('_' + __ball_to_string(fieldName));
4254
- if ((backing in object)) {
4440
+ if ((backing in __ball_require_map(object, 'map_contains_key'))) {
4255
4441
  ballObjectSetField(object, backing, assignedValue);
4256
4442
  return;
4257
4443
  }
4258
- if (('_celsius' in object)) {
4444
+ if (('_celsius' in __ball_require_map(object, 'map_contains_key'))) {
4259
4445
  ballObjectSetField(object, '_celsius', assignedValue);
4260
4446
  }
4261
4447
  }
@@ -4270,7 +4456,7 @@ export class BallEngine {
4270
4456
  let superObj = __ball_index(selfMap, '__super__');
4271
4457
  let superMap = this._asMap(superObj);
4272
4458
  while (!__ball_eq(superMap, null)) {
4273
- if ((fieldName in superMap)) {
4459
+ if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
4274
4460
  ballObjectSetField(superObj, fieldName, val);
4275
4461
  }
4276
4462
  superObj = __ball_index(superMap, '__super__');
@@ -4285,7 +4471,7 @@ export class BallEngine {
4285
4471
  let fields = {};
4286
4472
  for (const pair of msg.fields) {
4287
4473
  let val = await this._evalExpression(pair.value, scope);
4288
- if ((pair.name in fields)) {
4474
+ if ((pair.name in __ball_require_map(fields, 'map_contains_key'))) {
4289
4475
  let existing = __ball_index(fields, pair.name);
4290
4476
  if (Array.isArray(existing)) {
4291
4477
  let merged = ([...existing]);
@@ -4320,7 +4506,7 @@ export class BallEngine {
4320
4506
  }
4321
4507
  this._initFieldDefaults(msg.typeName, instanceFields);
4322
4508
  for (const fieldName of typeDef.fieldNames) {
4323
- if (!(fieldName in instanceFields)) {
4509
+ if (!(fieldName in __ball_require_map(instanceFields, 'map_contains_key'))) {
4324
4510
  instanceFields[fieldName] = null;
4325
4511
  }
4326
4512
  }
@@ -4331,16 +4517,16 @@ export class BallEngine {
4331
4517
  let paramsMeta = this._extractParamsMeta(ctorEntry.func.metadata);
4332
4518
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
4333
4519
  let param = __ball_index(params, i);
4334
- let value = __no_init__;
4335
- if ((param in fields)) {
4520
+ let value;
4521
+ if ((param in __ball_require_map(fields, 'map_contains_key'))) {
4336
4522
  value = __ball_index(fields, param);
4337
4523
  }
4338
4524
  else {
4339
- if ((('arg' + __ball_to_string(i)) in fields)) {
4525
+ if ((('arg' + __ball_to_string(i)) in __ball_require_map(fields, 'map_contains_key'))) {
4340
4526
  value = __ball_index(fields, ('arg' + __ball_to_string(i)));
4341
4527
  }
4342
4528
  }
4343
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_index(paramsMeta, i)))) {
4529
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
4344
4530
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
4345
4531
  }
4346
4532
  resolvedParams[param] = value;
@@ -4359,12 +4545,12 @@ export class BallEngine {
4359
4545
  this._applyConstructorInitializers(ctorEntry.func, instanceFields, resolvedParams, true);
4360
4546
  }
4361
4547
  let superclass = this._getMetaString(typeDef, 'superclass');
4362
- let superObject = __no_init__;
4548
+ let superObject;
4363
4549
  if ((!__ball_eq(superclass, null) && !(superclass.length === 0))) {
4364
4550
  superObject = (__ball_eq(ctorEntry, null) ? null : await this._invokeSuperConstructor(ctorEntry.func, superclass, resolvedParams));
4365
4551
  superObject ??= this._buildSuperObject(superclass, instanceFields);
4366
4552
  }
4367
- if (!('__type_args__' in instanceFields)) {
4553
+ if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4368
4554
  let metaTypeArgs = BallEngine._extractMetadataTypeArgs(msg);
4369
4555
  if (!__ball_eq(metaTypeArgs, null)) {
4370
4556
  instanceFields['__type_args__'] = metaTypeArgs;
@@ -4402,7 +4588,7 @@ export class BallEngine {
4402
4588
  })();
4403
4589
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4404
4590
  let constructedMap = this._asMap(constructed);
4405
- if ((!__ball_eq(constructedMap, null) && ('__type__' in constructedMap))) {
4591
+ if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4406
4592
  return constructed;
4407
4593
  }
4408
4594
  return instance;
@@ -4424,7 +4610,7 @@ export class BallEngine {
4424
4610
  instanceFields[entry.key] = entry.value;
4425
4611
  }
4426
4612
  }
4427
- if (!('__type_args__' in instanceFields)) {
4613
+ if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4428
4614
  let metaTA = BallEngine._extractMetadataTypeArgs(msg);
4429
4615
  if (!__ball_eq(metaTA, null)) {
4430
4616
  instanceFields['__type_args__'] = metaTA;
@@ -4440,13 +4626,13 @@ export class BallEngine {
4440
4626
  })();
4441
4627
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4442
4628
  let constructedMap = this._asMap(constructed);
4443
- if ((!__ball_eq(constructedMap, null) && ('__type__' in constructedMap))) {
4629
+ if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4444
4630
  return constructed;
4445
4631
  }
4446
4632
  return instance;
4447
4633
  }
4448
4634
  fields['__type__'] = msg.typeName;
4449
- if (!('__type_args__' in fields)) {
4635
+ if (!('__type_args__' in __ball_require_map(fields, 'map_contains_key'))) {
4450
4636
  let metaTA2 = BallEngine._extractMetadataTypeArgs(msg);
4451
4637
  if (!__ball_eq(metaTA2, null)) {
4452
4638
  fields['__type_args__'] = metaTA2;
@@ -4518,7 +4704,7 @@ export class BallEngine {
4518
4704
  for (const module of this.program.modules) {
4519
4705
  for (const td of module.typeDefs) {
4520
4706
  if ((__ball_eq(td.name, typeName) || td.name.endsWith((':' + __ball_to_string(typeName))))) {
4521
- let superclass = __no_init__;
4707
+ let superclass;
4522
4708
  if (hasMetadata(td)) {
4523
4709
  let sc = __ball_index(td.metadata.fields, 'superclass');
4524
4710
  if ((!__ball_eq(sc, null) && hasStringValue(sc))) {
@@ -4567,7 +4753,7 @@ export class BallEngine {
4567
4753
  let __naa_10 = __ball_index(fv.structValue.fields, 'name');
4568
4754
  return (__ball_eq(__naa_10, null) ? null : __naa_10.stringValue);
4569
4755
  })();
4570
- if ((__ball_eq(fname, null) || (fname in fields))) {
4756
+ if ((__ball_eq(fname, null) || (fname in __ball_require_map(fields, 'map_contains_key')))) {
4571
4757
  continue;
4572
4758
  }
4573
4759
  let init = (() => {
@@ -4669,20 +4855,20 @@ export class BallEngine {
4669
4855
  let parentTypeDef = this._findTypeDef(superclass);
4670
4856
  if (!__ball_eq(parentTypeDef, null)) {
4671
4857
  for (const fname of parentTypeDef.fieldNames) {
4672
- if ((fname in childFields)) {
4858
+ if ((fname in __ball_require_map(childFields, 'map_contains_key'))) {
4673
4859
  superFields[fname] = __ball_index(childFields, fname);
4674
4860
  }
4675
4861
  }
4676
4862
  this._initFieldDefaults(superclass, superFields);
4677
4863
  for (const fname of parentTypeDef.fieldNames) {
4678
- if (!(fname in superFields)) {
4864
+ if (!(fname in __ball_require_map(superFields, 'map_contains_key'))) {
4679
4865
  superFields[fname] = null;
4680
4866
  }
4681
4867
  }
4682
4868
  let parentMethods = this._resolveTypeMethods(qualifiedSuperclass);
4683
4869
  let parentMethodsMap = parentMethods.cast();
4684
4870
  let grandparent = parentTypeDef.superclass;
4685
- let grandparentObject = __no_init__;
4871
+ let grandparentObject;
4686
4872
  if ((!__ball_eq(grandparent, null) && !(grandparent.length === 0))) {
4687
4873
  grandparentObject = this._buildSuperObject(grandparent, childFields);
4688
4874
  }
@@ -4757,7 +4943,7 @@ export class BallEngine {
4757
4943
  }
4758
4944
  async _evalBlock(block, scope) {
4759
4945
  let blockScope = scope.child();
4760
- let flowResult = __no_init__;
4946
+ let flowResult;
4761
4947
  for (const stmt of block.statements) {
4762
4948
  let result = await this._evalStatement(stmt, blockScope);
4763
4949
  if ((result instanceof _FlowSignal)) {
@@ -4777,7 +4963,7 @@ export class BallEngine {
4777
4963
  const __sw = whichStmt(stmt);
4778
4964
  if ((__sw === Statement_Stmt.let)) {
4779
4965
  let letValue = stmt.let.value;
4780
- let value = __no_init__;
4966
+ let value;
4781
4967
  if ((__ball_eq(whichExpr(letValue), Expression_Expr.reference) && __ball_eq(letValue.reference.name, '__no_init__'))) {
4782
4968
  value = null;
4783
4969
  }
@@ -4831,11 +5017,11 @@ export class BallEngine {
4831
5017
  for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
4832
5018
  let p = __ball_index(paramNames, i);
4833
5019
  if (!lambdaScope.has(p)) {
4834
- if ((p in inputMap)) {
5020
+ if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
4835
5021
  lambdaScope.bind(p, __ball_index(inputMap, p));
4836
5022
  }
4837
5023
  else {
4838
- if ((('arg' + __ball_to_string(i)) in inputMap)) {
5024
+ if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
4839
5025
  lambdaScope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
4840
5026
  }
4841
5027
  }
@@ -4957,7 +5143,7 @@ export class BallEngine {
4957
5143
  let rawVal = match.group(2).trim();
4958
5144
  let intParsed = int.tryParse(rawVal);
4959
5145
  let doubleParsed = (__ball_eq(intParsed, null) ? double.tryParse(rawVal) : null);
4960
- let parsed = __no_init__;
5146
+ let parsed;
4961
5147
  if (!__ball_eq(intParsed, null)) {
4962
5148
  parsed = intParsed;
4963
5149
  }
@@ -4997,7 +5183,7 @@ export class BallEngine {
4997
5183
  let operand = __ball_parse_int(propOpNum.group(4));
4998
5184
  if (scope.has(ref)) {
4999
5185
  let obj = scope.lookup(ref);
5000
- let propVal = __no_init__;
5186
+ let propVal;
5001
5187
  if (((typeof obj === 'string') && __ball_eq(prop, 'length'))) {
5002
5188
  propVal = obj.value.length;
5003
5189
  }
@@ -5023,7 +5209,7 @@ export class BallEngine {
5023
5209
  }
5024
5210
  else {
5025
5211
  let map = this._cfAsMap(obj);
5026
- if ((!__ball_eq(map, null) && (prop in map))) {
5212
+ if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5027
5213
  let v = __ball_index(map, prop);
5028
5214
  if ((typeof v === 'number' || v instanceof BallDouble)) {
5029
5215
  propVal = v;
@@ -5045,8 +5231,8 @@ export class BallEngine {
5045
5231
  let left = varOpVar.group(1);
5046
5232
  let op = varOpVar.group(2);
5047
5233
  let right = varOpVar.group(3);
5048
- let leftVal = __no_init__;
5049
- let rightVal = __no_init__;
5234
+ let leftVal;
5235
+ let rightVal;
5050
5236
  if (scope.has(left)) {
5051
5237
  let v = scope.lookup(left);
5052
5238
  if ((typeof v === 'number' || v instanceof BallDouble)) {
@@ -5094,7 +5280,7 @@ export class BallEngine {
5094
5280
  return obj.length;
5095
5281
  }
5096
5282
  let map = this._cfAsMap(obj);
5097
- if ((!__ball_eq(map, null) && (prop in map))) {
5283
+ if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5098
5284
  return __ball_index(map, prop);
5099
5285
  }
5100
5286
  }
@@ -5199,7 +5385,7 @@ export class BallEngine {
5199
5385
  if ((!__ball_eq(whichExpr(cases), Expression_Expr.literal) || !__ball_eq(whichValue(cases.literal), Literal_Value.listValue))) {
5200
5386
  return null;
5201
5387
  }
5202
- let defaultBody = __no_init__;
5388
+ let defaultBody;
5203
5389
  let matched = false;
5204
5390
  for (const caseExpr of cases.literal.listValue.elements) {
5205
5391
  if (!__ball_eq(whichExpr(caseExpr), Expression_Expr.messageCreation)) {
@@ -5259,7 +5445,7 @@ export class BallEngine {
5259
5445
  if ((!__ball_eq(whichExpr(cases), Expression_Expr.literal) || !__ball_eq(whichValue(cases.literal), Literal_Value.listValue))) {
5260
5446
  return null;
5261
5447
  }
5262
- let defaultBody = __no_init__;
5448
+ let defaultBody;
5263
5449
  for (const caseExpr of cases.literal.listValue.elements) {
5264
5450
  if (!__ball_eq(whichExpr(caseExpr), Expression_Expr.messageCreation)) {
5265
5451
  continue;
@@ -5375,7 +5561,7 @@ export class BallEngine {
5375
5561
  }
5376
5562
  }
5377
5563
  let enumVals = __ball_index(this._enumValues, enumType);
5378
- if ((!__ball_eq(enumVals, null) && (enumValue in enumVals))) {
5564
+ if ((!__ball_eq(enumVals, null) && (enumValue in __ball_require_map(enumVals, 'map_contains_key')))) {
5379
5565
  let resolved = __ball_index(enumVals, enumValue);
5380
5566
  let resolvedMap = this._cfAsMap(resolved);
5381
5567
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -5384,7 +5570,7 @@ export class BallEngine {
5384
5570
  }
5385
5571
  let qualifiedEnumType = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(enumType));
5386
5572
  let qualEnumVals = __ball_index(this._enumValues, qualifiedEnumType);
5387
- if ((!__ball_eq(qualEnumVals, null) && (enumValue in qualEnumVals))) {
5573
+ if ((!__ball_eq(qualEnumVals, null) && (enumValue in __ball_require_map(qualEnumVals, 'map_contains_key')))) {
5388
5574
  let resolved = __ball_index(qualEnumVals, enumValue);
5389
5575
  let resolvedMap = this._cfAsMap(resolved);
5390
5576
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -5415,7 +5601,7 @@ export class BallEngine {
5415
5601
  let body = __ball_index(fields, 'body');
5416
5602
  let catches = __ball_index(fields, 'catches');
5417
5603
  let finallyBlock = __ball_index(fields, 'finally');
5418
- let result = __no_init__;
5604
+ let result;
5419
5605
  try {
5420
5606
  result = (!__ball_eq(body, null) ? await this._evalExpression(body, scope) : null);
5421
5607
  }
@@ -5435,7 +5621,7 @@ export class BallEngine {
5435
5621
  }
5436
5622
  let catchType = this._stringFieldVal(cf, 'type');
5437
5623
  if ((!__ball_eq(catchType, null) && !(catchType.length === 0))) {
5438
- let matches = __no_init__;
5624
+ let matches;
5439
5625
  if ((e instanceof BallException)) {
5440
5626
  let eType = e['typeName'];
5441
5627
  let eColonIdx = eType.indexOf(':');
@@ -5652,7 +5838,7 @@ export class BallEngine {
5652
5838
  this._cfWritebackIndexed(indexTarget, list, scope);
5653
5839
  }
5654
5840
  if (((!__ball_eq(op, null) && !(op.length === 0)) && !__ball_eq(op, '='))) {
5655
- let computed = __no_init__;
5841
+ let computed;
5656
5842
  let didSet = false;
5657
5843
  if ((false /* BallList is List in TS */ && (typeof idx === 'number' && Number.isInteger(idx)))) {
5658
5844
  computed = this._applyCompoundOp(op, __ball_index(list.items, idx), val);
@@ -5881,7 +6067,7 @@ export class BallEngine {
5881
6067
  }))) : ((op === '>>=') ? (this._intOp(current, val, ((a, b) => {
5882
6068
  return __ball_shr(a, b);
5883
6069
  }))) : ((op === '>>>=') ? (this._intOp(current, val, ((a, b) => {
5884
- return (a >>> b);
6070
+ return __ball_ushr(a, b);
5885
6071
  }))) : ((op === '??=') ? ((current ?? val)) : val)))))))))))));
5886
6072
  }
5887
6073
  _numOp(a, b, op) {
@@ -6153,7 +6339,7 @@ export class BallEngine {
6153
6339
  if (__ball_eq(body, null)) {
6154
6340
  return null;
6155
6341
  }
6156
- let result = __no_init__;
6342
+ let result;
6157
6343
  let repeat = true;
6158
6344
  while (repeat) {
6159
6345
  repeat = false;
@@ -6241,7 +6427,7 @@ export class BallEngine {
6241
6427
  let args = (inputMap ?? {});
6242
6428
  let arg0 = (__ball_index(args, 'arg0') ?? __ball_index(args, 'value'));
6243
6429
  let wasBallList = false /* BallList is List in TS */;
6244
- let unwrappedSelf = __no_init__;
6430
+ let unwrappedSelf;
6245
6431
  if (false /* BallList is List in TS */) {
6246
6432
  unwrappedSelf = self.items;
6247
6433
  }
@@ -6500,7 +6686,7 @@ export class BallEngine {
6500
6686
  else if ((__sw === 'reduce')) {
6501
6687
  if ((typeof arg0 === 'function')) {
6502
6688
  let seeded = false;
6503
- let acc = __no_init__;
6689
+ let acc;
6504
6690
  for (const item of self) {
6505
6691
  if (!seeded) {
6506
6692
  acc = item;
@@ -6556,13 +6742,13 @@ export class BallEngine {
6556
6742
  let seen = {};
6557
6743
  let result = [];
6558
6744
  for (const item of self) {
6559
- if (!(item in seen)) {
6745
+ if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6560
6746
  seen[item] = item;
6561
6747
  result = (result.push(item), result);
6562
6748
  }
6563
6749
  }
6564
6750
  for (const item of other) {
6565
- if (!(item in seen)) {
6751
+ if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6566
6752
  seen[item] = item;
6567
6753
  result = (result.push(item), result);
6568
6754
  }
@@ -6638,15 +6824,15 @@ export class BallEngine {
6638
6824
  do {
6639
6825
  const __sw = method;
6640
6826
  if ((__sw === 'union')) {
6641
- let otherU = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set(['Object?']))));
6827
+ let otherU = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set())));
6642
6828
  return self.union(otherU);
6643
6829
  }
6644
6830
  else if ((__sw === 'intersection')) {
6645
- let otherI = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set(['Object?']))));
6831
+ let otherI = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set())));
6646
6832
  return self.intersection(otherI);
6647
6833
  }
6648
6834
  else if ((__sw === 'difference')) {
6649
- let otherD = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set(['Object?']))));
6835
+ let otherD = ((arg0 instanceof Set) ? arg0 : ((Array.isArray(arg0) ? arg0.toSet() : new Set())));
6650
6836
  return self.difference(otherD);
6651
6837
  }
6652
6838
  else if ((__sw === 'add')) {
@@ -6708,7 +6894,7 @@ export class BallEngine {
6708
6894
  }
6709
6895
  else if ((__sw === 'where') || (__sw === 'filter')) {
6710
6896
  if ((typeof arg0 === 'function')) {
6711
- let result = new Set(['Object?']);
6897
+ let result = new Set();
6712
6898
  for (const item of self) {
6713
6899
  let r = arg0(item);
6714
6900
  if ((r != null)) {
@@ -6796,7 +6982,7 @@ export class BallEngine {
6796
6982
  return await this._ballToStringAsync(self);
6797
6983
  }
6798
6984
  else if ((__sw === 'toStringAsFixed')) {
6799
- return (+(self)).toFixed(this._toInt(arg0));
6985
+ return __ball_to_fixed(self, this._toInt(arg0));
6800
6986
  }
6801
6987
  else if ((__sw === 'abs')) {
6802
6988
  return __ball_math_abs(self);
@@ -6825,7 +7011,7 @@ export class BallEngine {
6825
7011
  } while (false);
6826
7012
  }
6827
7013
  let selfMap = this._cfAsMap(self);
6828
- if ((!__ball_eq(selfMap, null) && ('__type__' in selfMap))) {
7014
+ if ((!__ball_eq(selfMap, null) && ('__type__' in __ball_require_map(selfMap, 'map_contains_key')))) {
6829
7015
  let typeName = __ball_index(selfMap, '__type__');
6830
7016
  if ((!__ball_eq(typeName, null) && (typeName.endsWith(':StringBuffer') || __ball_eq(typeName, 'StringBuffer')))) {
6831
7017
  do {
@@ -6925,8 +7111,8 @@ export class BallEngine {
6925
7111
  if (__ball_eq(m, null)) {
6926
7112
  return null;
6927
7113
  }
6928
- let left = __no_init__;
6929
- let right = __no_init__;
7114
+ let left;
7115
+ let right;
6930
7116
  if (__ball_eq(function_, 'index')) {
6931
7117
  left = __ball_index(m, 'target');
6932
7118
  right = __ball_index(m, 'index');
@@ -6936,7 +7122,7 @@ export class BallEngine {
6936
7122
  right = __ball_index(m, 'right');
6937
7123
  }
6938
7124
  let leftMap = this._stdAsMap(left);
6939
- if ((__ball_eq(leftMap, null) || !('__type__' in leftMap))) {
7125
+ if ((__ball_eq(leftMap, null) || !('__type__' in __ball_require_map(leftMap, 'map_contains_key')))) {
6940
7126
  return null;
6941
7127
  }
6942
7128
  let typeName = __ball_index(leftMap, '__type__');
@@ -7001,7 +7187,7 @@ export class BallEngine {
7001
7187
  } while (false);
7002
7188
  }
7003
7189
  async _callBaseFunction(module, function_, input) {
7004
- if ((function_ in _stdFunctionToOperator)) {
7190
+ if ((function_ in __ball_require_map(_stdFunctionToOperator, 'map_contains_key'))) {
7005
7191
  let override = await this._tryOperatorOverride(function_, input);
7006
7192
  if (!__ball_eq(override, null)) {
7007
7193
  return this._consumeGeneratorFlow(override);
@@ -7133,7 +7319,7 @@ export class BallEngine {
7133
7319
  }), ['unsigned_right_shift']: ((i) => {
7134
7320
  const input = i;
7135
7321
  return this._stdBinaryInt(i, ((a, b) => {
7136
- return (a >>> b);
7322
+ return __ball_ushr(a, b);
7137
7323
  }));
7138
7324
  }), ['pre_increment']: ((i) => {
7139
7325
  const input = i;
@@ -7175,7 +7361,7 @@ export class BallEngine {
7175
7361
  const input = i;
7176
7362
  return this._stdConvert(i, ((v) => {
7177
7363
  const input = v;
7178
- return new BallDouble(__ball_parse_double(v));
7364
+ return __ball_parse_double(v);
7179
7365
  }));
7180
7366
  }), ['to_double']: ((i) => {
7181
7367
  const input = i;
@@ -7206,7 +7392,7 @@ export class BallEngine {
7206
7392
  let v = (__ball_index(m, 'value') ?? __ball_index(m, 'left'));
7207
7393
  let digits = (__ball_index(m, 'digits') ?? __ball_index(m, 'fractionDigits'));
7208
7394
  let n = this._toNum(v);
7209
- let s = (+(n)).toFixed(this._toInt(digits));
7395
+ let s = __ball_to_fixed(n, this._toInt(digits));
7210
7396
  if (((__ball_eq(n, 0) && __ball_lt(new BallDouble(Number(new BallDouble(1)) / Number(n)), 0)) && !s.startsWith('-'))) {
7211
7397
  return ('-' + __ball_to_string(s));
7212
7398
  }
@@ -7404,7 +7590,7 @@ export class BallEngine {
7404
7590
  let list = this._stdAsList(__ball_index(m, 'list'));
7405
7591
  let cb = ((__ball_index(m, 'callback') ?? __ball_index(m, 'function')) ?? __ball_index(m, 'value'));
7406
7592
  let seeded = false;
7407
- let acc = __no_init__;
7593
+ let acc;
7408
7594
  for (const e of list) {
7409
7595
  if (!seeded) {
7410
7596
  acc = e;
@@ -7544,19 +7730,19 @@ export class BallEngine {
7544
7730
  const input = i;
7545
7731
  let m = this._stdAsMap(i);
7546
7732
  let list = this._stdAsList(__ball_index(m, 'list'));
7547
- let s = __no_init__;
7548
- let e = __no_init__;
7549
- if (('start' in m)) {
7733
+ let s;
7734
+ let e;
7735
+ if (('start' in __ball_require_map(m, 'map_contains_key'))) {
7550
7736
  s = this._toInt(__ball_index(m, 'start'));
7551
7737
  e = (!__ball_eq(__ball_index(m, 'end'), null) ? this._toInt(__ball_index(m, 'end')) : null);
7552
7738
  }
7553
7739
  else {
7554
- if ((('arg0' in m) && ('arg1' in m))) {
7740
+ if ((('arg0' in __ball_require_map(m, 'map_contains_key')) && ('arg1' in __ball_require_map(m, 'map_contains_key')))) {
7555
7741
  s = this._toInt(__ball_index(m, 'arg0'));
7556
7742
  e = this._toInt(__ball_index(m, 'arg1'));
7557
7743
  }
7558
7744
  else {
7559
- if (('value' in m)) {
7745
+ if (('value' in __ball_require_map(m, 'map_contains_key'))) {
7560
7746
  let v = __ball_index(m, 'value');
7561
7747
  if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
7562
7748
  s = this._toInt(__ball_index(v, 0));
@@ -7764,13 +7950,13 @@ export class BallEngine {
7764
7950
  let m = this._stdAsMap(i);
7765
7951
  let raw = __ball_index(m, 'map');
7766
7952
  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 : {})));
7767
- return Object.values(map).includes(__ball_index(m, 'value'));
7953
+ return Object.values(__ball_require_map(map, 'map_contains_value')).includes(__ball_index(m, 'value'));
7768
7954
  }), ['map_put_if_absent']: ((i) => {
7769
7955
  const input = i;
7770
7956
  let m = this._stdAsMap(i);
7771
7957
  let map = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
7772
7958
  let key = __ball_index(m, 'key');
7773
- if (!(key in map)) {
7959
+ if (!(key in __ball_require_map(map, 'map_contains_key'))) {
7774
7960
  this._trackMemoryAllocation(_ballMapEntryBytes);
7775
7961
  let val = __ball_index(m, 'value');
7776
7962
  map[key] = ((typeof val === 'function') ? val() : val);
@@ -7976,7 +8162,7 @@ export class BallEngine {
7976
8162
  let valMap = this._stdAsMap(val);
7977
8163
  if (!__ball_eq(valMap, null)) {
7978
8164
  typeName = ((__ball_index(valMap, '__type__') ?? __ball_index(valMap, '__type')) ?? 'Exception');
7979
- if ((!('message' in valMap) && ('arg0' in valMap))) {
8165
+ if ((!('message' in __ball_require_map(valMap, 'map_contains_key')) && ('arg0' in __ball_require_map(valMap, 'map_contains_key')))) {
7980
8166
  valMap['message'] = __ball_index(valMap, 'arg0');
7981
8167
  }
7982
8168
  }
@@ -8575,7 +8761,7 @@ export class BallEngine {
8575
8761
  }
8576
8762
  async _stdPrint(input) {
8577
8763
  let m = this._stdAsMap(input);
8578
- if ((!__ball_eq(m, null) && ((('message' in m) || ('arg0' in m)) || ('value' in m)))) {
8764
+ 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'))))) {
8579
8765
  let message = ((__ball_index(m, 'message') ?? __ball_index(m, 'arg0')) ?? __ball_index(m, 'value'));
8580
8766
  this.stdout(await this._ballToStringAsync(message));
8581
8767
  return null;
@@ -8667,7 +8853,7 @@ export class BallEngine {
8667
8853
  }
8668
8854
  return (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8669
8855
  }
8670
- if (('__tostring_guard__' in map)) {
8856
+ if (('__tostring_guard__' in __ball_require_map(map, 'map_contains_key'))) {
8671
8857
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8672
8858
  return (__ball_to_string(shortType) + '{...}');
8673
8859
  }
@@ -8805,7 +8991,7 @@ export class BallEngine {
8805
8991
  __cascade_self__.remove('__type__');
8806
8992
  return __cascade_self__;
8807
8993
  })();
8808
- let result = __no_init__;
8994
+ let result;
8809
8995
  if (__ball_eq(args.length, 1)) {
8810
8996
  result = Function.apply(callee, [args.values.first]);
8811
8997
  }
@@ -9092,7 +9278,7 @@ export class BallEngine {
9092
9278
  if (__ball_eq(cases, null)) {
9093
9279
  return null;
9094
9280
  }
9095
- let defaultBody = __no_init__;
9281
+ let defaultBody;
9096
9282
  for (const c of cases) {
9097
9283
  let cMap = this._stdAsMap(c);
9098
9284
  if (__ball_eq(cMap, null)) {
@@ -9278,7 +9464,7 @@ export class BallEngine {
9278
9464
  return false;
9279
9465
  }
9280
9466
  let key = __ball_index(entryMap, 'key');
9281
- if (!(key in rawMap)) {
9467
+ if (!(key in __ball_require_map(rawMap, 'map_contains_key'))) {
9282
9468
  return false;
9283
9469
  }
9284
9470
  if (!this._matchPattern(__ball_index(rawMap, key), __ball_index(entryMap, 'value'), bindings)) {
@@ -9318,7 +9504,7 @@ export class BallEngine {
9318
9504
  return false;
9319
9505
  }
9320
9506
  for (const entry of recFields.entries) {
9321
- if (!(entry.key in recMap)) {
9507
+ if (!(entry.key in __ball_require_map(recMap, 'map_contains_key'))) {
9322
9508
  return false;
9323
9509
  }
9324
9510
  let fieldVal = __ball_index(recMap, entry.key);
@@ -9478,7 +9664,7 @@ export class BallEngine {
9478
9664
  let map = this._stdAsMap(v);
9479
9665
  if (!__ball_eq(map, null)) {
9480
9666
  let typeName = __ball_index(map, '__type__');
9481
- if ((!__ball_eq(typeName, null) && (typeName in this._enumValues))) {
9667
+ if ((!__ball_eq(typeName, null) && (typeName in __ball_require_map(this._enumValues, 'map_contains_key')))) {
9482
9668
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
9483
9669
  let valName = __ball_index(map, 'name');
9484
9670
  if (!__ball_eq(valName, null)) {
@@ -9897,9 +10083,9 @@ export class BallEngine {
9897
10083
  throw new BallRuntimeError('Expected message');
9898
10084
  }
9899
10085
  let rawValue = __ball_index(m, 'value');
9900
- let value = __no_init__;
9901
- let min = __no_init__;
9902
- let max = __no_init__;
10086
+ let value;
10087
+ let min;
10088
+ let max;
9903
10089
  if ((__ball_is_type(rawValue, "Map<String, Object?>") || false /* BallMap is Map in TS */)) {
9904
10090
  value = this._toNum(__ball_index(m, 'min'));
9905
10091
  min = this._toNum(__ball_index(m, 'max'));
@@ -10072,7 +10258,7 @@ export class _Scope {
10072
10258
  }
10073
10259
  lookup(name) {
10074
10260
  const input = name;
10075
- if ((name in this._bindings)) {
10261
+ if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10076
10262
  return __ball_index(this._bindings, name);
10077
10263
  }
10078
10264
  if (!__ball_eq(this._parent, null)) {
@@ -10085,13 +10271,13 @@ export class _Scope {
10085
10271
  }
10086
10272
  has(name) {
10087
10273
  const input = name;
10088
- if ((name in this._bindings)) {
10274
+ if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10089
10275
  return true;
10090
10276
  }
10091
10277
  return ((__ball_eq(this._parent, null) ? null : this._parent.has(name)) ?? false);
10092
10278
  }
10093
10279
  set(name, value) {
10094
- if ((name in this._bindings)) {
10280
+ if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10095
10281
  this._bindings[name] = value;
10096
10282
  return;
10097
10283
  }
@@ -10190,7 +10376,7 @@ export class StdModuleHandler extends BallModuleHandler {
10190
10376
  if (this._tombstones.includes(entry.key)) {
10191
10377
  continue;
10192
10378
  }
10193
- if ((entry.key in this._composedDispatch)) {
10379
+ if ((entry.key in __ball_require_map(this._composedDispatch, 'map_contains_key'))) {
10194
10380
  continue;
10195
10381
  }
10196
10382
  if ((!__ball_eq(allowlist, null) && !allowlist.includes(entry.key))) {
@@ -10293,7 +10479,7 @@ function _ballToDouble(value) {
10293
10479
  }
10294
10480
  function _ballValueIsSet(v) {
10295
10481
  const input = v;
10296
- return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && (_kBallSetTag in v));
10482
+ return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && (_kBallSetTag in __ball_require_map(v, 'map_contains_key')));
10297
10483
  }
10298
10484
  function _ballIsInt(v) {
10299
10485
  const input = v;
@@ -10357,7 +10543,7 @@ function _ballMapValuesDyn(map) {
10357
10543
  function _ballMapContainsKeyDyn(map, key) {
10358
10544
  let handle = _ballMapHandleEntries(map);
10359
10545
  if ((typeof handle === 'object' && handle !== null && !Array.isArray(handle) && !(handle instanceof BallDouble) && !(handle instanceof Set))) {
10360
- return (key in handle);
10546
+ return (key in __ball_require_map(handle, 'map_contains_key'));
10361
10547
  }
10362
10548
  return false;
10363
10549
  }
@@ -10373,12 +10559,12 @@ function ballObjectSetField(target, fieldName, val) {
10373
10559
  return;
10374
10560
  }
10375
10561
  if (false /* BallMap is Map in TS */) {
10376
- if (('__type__' in target.entries)) {
10562
+ if (('__type__' in __ball_require_map(target.entries, 'map_contains_key'))) {
10377
10563
  target[fieldName] = val;
10378
10564
  }
10379
10565
  return;
10380
10566
  }
10381
- if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in target))) {
10567
+ if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in __ball_require_map(target, 'map_contains_key')))) {
10382
10568
  target[fieldName] = val;
10383
10569
  }
10384
10570
  }
@@ -10471,7 +10657,7 @@ function _unwrapBallFuture(value) {
10471
10657
  const input = value;
10472
10658
  if (_isBallFuture(value)) {
10473
10659
  let map = value;
10474
- if (('error' in map)) {
10660
+ if (('error' in __ball_require_map(map, 'map_contains_key'))) {
10475
10661
  let error = __ball_index(map, 'error');
10476
10662
  if ((error instanceof BallException)) {
10477
10663
  throw error;