@ball-lang/engine 1.59.12 → 1.60.1

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.
@@ -1369,6 +1369,29 @@ function __ball_require_map(v, opName) {
1369
1369
  }
1370
1370
  return v;
1371
1371
  }
1372
+ // map_contains_key. The obvious lowering, "key in map", walks the PROTOTYPE
1373
+ // CHAIN -- and this preamble installs the whole Dart-SDK method surface
1374
+ // (putIfAbsent, addAll, toList, firstWhere, ...) onto Object.prototype, so
1375
+ // "'putIfAbsent' in {}" is true for EVERY object. That made
1376
+ // map.containsKey(name) answer true for any Dart-SDK method name (and for
1377
+ // 'toString'/'constructor'/'hasOwnProperty'), which in the self-hosted engine
1378
+ // made _Scope.has(name) claim every such identifier was a bound variable and
1379
+ // then hand back the polyfill instead of the user's own function or method
1380
+ // (issue #494's fixture 416 hit this on a user method named putIfAbsent).
1381
+ // A hit that exists ONLY as an own property of Object.prototype is prototype
1382
+ // pollution, not a map entry.
1383
+ function __ball_map_has(v, opName, k) {
1384
+ const m = __ball_require_map(v, opName);
1385
+ if (m instanceof Map)
1386
+ return m.has(k);
1387
+ if (!(k in m))
1388
+ return false;
1389
+ if (Object.prototype.hasOwnProperty.call(Object.prototype, k) &&
1390
+ !Object.prototype.hasOwnProperty.call(m, k)) {
1391
+ return false;
1392
+ }
1393
+ return true;
1394
+ }
1372
1395
  // ── Protobuf Struct/Value compatibility ─────────────────────────
1373
1396
  //
1374
1397
  // Dart's protobuf runtime wraps google.protobuf.Struct as a class
@@ -2142,7 +2165,7 @@ export class BallEngine {
2142
2165
  }
2143
2166
  _resolveInstanceMethodDispatch(typeName, methodName) {
2144
2167
  let cacheKey = BallEngine._typeMethodKey(typeName, methodName);
2145
- if ((cacheKey in __ball_require_map(this._instanceMethodCache, 'map_contains_key'))) {
2168
+ if (__ball_map_has(this._instanceMethodCache, 'map_contains_key', cacheKey)) {
2146
2169
  return __ball_index(this._instanceMethodCache, cacheKey);
2147
2170
  }
2148
2171
  let resolved = (this._resolveMethod(typeName, methodName) ?? this._lookupTypeMethodWithInheritance(typeName, methodName));
@@ -2312,7 +2335,7 @@ export class BallEngine {
2312
2335
  let dotIdx = func.name.indexOf('.');
2313
2336
  let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
2314
2337
  let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
2315
- if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in __ball_require_map(constructorInput, 'map_contains_key')))) && !__ball_eq(this._findTypeDef(typeName), null))) {
2338
+ if (((!isFactory && (__ball_eq(constructorInput, null) || !__ball_map_has(constructorInput, 'map_contains_key', 'self'))) && !__ball_eq(this._findTypeDef(typeName), null))) {
2316
2339
  return await this._callObjectConstructor(moduleName, func, input);
2317
2340
  }
2318
2341
  }
@@ -2325,12 +2348,12 @@ export class BallEngine {
2325
2348
  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) : [])));
2326
2349
  let inputMap = this._asMap(input);
2327
2350
  if (!(params.length === 0)) {
2328
- if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key'))))) {
2329
- if ((!__ball_eq(inputMap, null) && (__ball_index(params, 0) in __ball_require_map(inputMap, 'map_contains_key')))) {
2351
+ if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'self')))) {
2352
+ if ((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', __ball_index(params, 0)))) {
2330
2353
  scope.bind(__ball_index(params, 0), __ball_index(inputMap, __ball_index(params, 0)));
2331
2354
  }
2332
2355
  else {
2333
- 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')))) {
2356
+ if (((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'arg0')) && !__ball_map_has(inputMap, 'map_contains_key', __ball_index(params, 0)))) {
2334
2357
  scope.bind(__ball_index(params, 0), __ball_index(inputMap, 'arg0'));
2335
2358
  }
2336
2359
  else {
@@ -2342,15 +2365,15 @@ export class BallEngine {
2342
2365
  if (!__ball_eq(inputMap, null)) {
2343
2366
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2344
2367
  let p = __ball_index(params, i);
2345
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
2368
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
2346
2369
  scope.bind(p, __ball_index(inputMap, p));
2347
2370
  }
2348
2371
  else {
2349
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2372
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
2350
2373
  scope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
2351
2374
  }
2352
2375
  else {
2353
- if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && ('value' in __ball_require_map(inputMap, 'map_contains_key'))) && this._isSetter(func))) {
2376
+ if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && __ball_map_has(inputMap, 'map_contains_key', 'value')) && this._isSetter(func))) {
2354
2377
  scope.bind(p, __ball_index(inputMap, 'value'));
2355
2378
  }
2356
2379
  }
@@ -2366,7 +2389,7 @@ export class BallEngine {
2366
2389
  }
2367
2390
  }
2368
2391
  }
2369
- if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
2392
+ if ((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'self'))) {
2370
2393
  let self = __ball_index(inputMap, 'self');
2371
2394
  scope.bind('self', self);
2372
2395
  let selfMap = this._asMap(self);
@@ -2431,7 +2454,7 @@ export class BallEngine {
2431
2454
  else {
2432
2455
  let result = await this._evalExpression(func.body, scope);
2433
2456
  this._currentModule = prevModule;
2434
- if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
2457
+ if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && __ball_map_has(inputMap, 'map_contains_key', 'self'))) {
2435
2458
  let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
2436
2459
  if (((result instanceof _FlowSignal) && __ball_eq(result.kind, 'return'))) {
2437
2460
  finalResult = result.value;
@@ -2506,15 +2529,15 @@ export class BallEngine {
2506
2529
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2507
2530
  let param = __ball_index(params, i);
2508
2531
  let value;
2509
- if ((param in __ball_require_map(inputMap, 'map_contains_key'))) {
2532
+ if (__ball_map_has(inputMap, 'map_contains_key', param)) {
2510
2533
  value = __ball_index(inputMap, param);
2511
2534
  }
2512
2535
  else {
2513
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2536
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
2514
2537
  value = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
2515
2538
  }
2516
2539
  }
2517
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
2540
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && __ball_map_has(__ball_index(paramsMeta, i), 'map_contains_key', 'default'))) {
2518
2541
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
2519
2542
  }
2520
2543
  resolvedParams[param] = value;
@@ -2546,7 +2569,7 @@ export class BallEngine {
2546
2569
  })();
2547
2570
  let constructed = await this._callFunction(moduleName, func, ctorInput);
2548
2571
  let constructedMap = this._asMap(constructed);
2549
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
2572
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
2550
2573
  return constructed;
2551
2574
  }
2552
2575
  return instance;
@@ -2643,11 +2666,11 @@ export class BallEngine {
2643
2666
  let p = __ball_index(params, i);
2644
2667
  let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
2645
2668
  let val;
2646
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
2669
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
2647
2670
  val = __ball_index(inputMap, p);
2648
2671
  }
2649
2672
  else {
2650
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2673
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
2651
2674
  val = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
2652
2675
  }
2653
2676
  else {
@@ -2685,7 +2708,7 @@ export class BallEngine {
2685
2708
  if (!__ball_eq(superMap, null)) {
2686
2709
  instance['__super__'] = superInstance;
2687
2710
  for (const e of superMap.entries) {
2688
- if ((!e.key.startsWith('__') && !(e.key in __ball_require_map(instance, 'map_contains_key')))) {
2711
+ if ((!e.key.startsWith('__') && !__ball_map_has(instance, 'map_contains_key', e.key))) {
2689
2712
  instance[e.key] = e.value;
2690
2713
  }
2691
2714
  }
@@ -2728,7 +2751,7 @@ export class BallEngine {
2728
2751
  let superInput = {};
2729
2752
  for (let i = 0; __ball_lt(i, argNames.length); (i++)) {
2730
2753
  let token = __ball_index(argNames, i);
2731
- if ((token in __ball_require_map(resolvedParams, 'map_contains_key'))) {
2754
+ if (__ball_map_has(resolvedParams, 'map_contains_key', token)) {
2732
2755
  superInput[('arg' + __ball_to_string(i))] = __ball_index(resolvedParams, token);
2733
2756
  }
2734
2757
  else {
@@ -3402,7 +3425,7 @@ export class BallEngine {
3402
3425
  }
3403
3426
  static _extractMetadataTypeArgs(msg) {
3404
3427
  const input = msg;
3405
- if ((!hasMetadata(msg) || !('type_args' in __ball_require_map(msg.metadata.fields, 'map_contains_key')))) {
3428
+ if ((!hasMetadata(msg) || !__ball_map_has(msg.metadata.fields, 'map_contains_key', 'type_args'))) {
3406
3429
  return null;
3407
3430
  }
3408
3431
  return [...__ball_index(msg.metadata.fields, 'type_args').listValue.values.map(BallEngine._typeRefValueToString)];
@@ -3586,7 +3609,7 @@ export class BallEngine {
3586
3609
  }
3587
3610
  }
3588
3611
  let inputMap = this._asMap(input);
3589
- if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
3612
+ if ((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'self'))) {
3590
3613
  let self = __ball_index(inputMap, 'self');
3591
3614
  let selfMap = this._asMap(self);
3592
3615
  if (!__ball_eq(selfMap, null)) {
@@ -3623,7 +3646,7 @@ export class BallEngine {
3623
3646
  let methodOwner = selfMap;
3624
3647
  while (!__ball_eq(methodOwner, null)) {
3625
3648
  let methods = __ball_index(methodOwner, '__methods__');
3626
- 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')))) {
3649
+ if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && __ball_map_has(methods, 'map_contains_key', call.function))) {
3627
3650
  let method = __ball_index(methods, call.function);
3628
3651
  if ((typeof method === 'function')) {
3629
3652
  let result = method(input);
@@ -3647,7 +3670,7 @@ export class BallEngine {
3647
3670
  }
3648
3671
  }
3649
3672
  let fallbackMap = this._asMap(input);
3650
- if ((!__ball_eq(fallbackMap, null) && ('self' in __ball_require_map(fallbackMap, 'map_contains_key')))) {
3673
+ if ((!__ball_eq(fallbackMap, null) && __ball_map_has(fallbackMap, 'map_contains_key', 'self'))) {
3651
3674
  let selfFallback = __ball_index(fallbackMap, 'self');
3652
3675
  let selfFallbackMap = this._asMap(selfFallback);
3653
3676
  if (!__ball_eq(selfFallbackMap, null)) {
@@ -3967,12 +3990,12 @@ export class BallEngine {
3967
3990
  }
3968
3991
  if (!_builtinTypeNames.includes(name)) {
3969
3992
  let qualifiedName = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(name));
3970
- let hasCtor = ((name in __ball_require_map(this._constructors, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._constructors, 'map_contains_key')));
3993
+ let hasCtor = (__ball_map_has(this._constructors, 'map_contains_key', name) || __ball_map_has(this._constructors, 'map_contains_key', qualifiedName));
3971
3994
  let hasStaticMethods = this._functions.keys.some(((k) => {
3972
3995
  const input = k;
3973
3996
  return (k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(qualifiedName)) + '.')) || k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(name)) + '.')));
3974
3997
  }));
3975
- let typeExists = ((name in __ball_require_map(this._types, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._types, 'map_contains_key')));
3998
+ let typeExists = (__ball_map_has(this._types, 'map_contains_key', name) || __ball_map_has(this._types, 'map_contains_key', qualifiedName));
3976
3999
  if ((typeExists && (hasCtor || hasStaticMethods))) {
3977
4000
  return { ['__class_ref__']: name, ['__type__']: '__class__' };
3978
4001
  }
@@ -3993,7 +4016,7 @@ export class BallEngine {
3993
4016
  if (!__ball_eq(selfForGetter, null)) {
3994
4017
  let selfMap = this._asMap(selfForGetter);
3995
4018
  if (!__ball_eq(selfMap, null)) {
3996
- if ((name in __ball_require_map(selfMap, 'map_contains_key'))) {
4019
+ if (__ball_map_has(selfMap, 'map_contains_key', name)) {
3997
4020
  let direct = __ball_index(selfMap, name);
3998
4021
  if (!__ball_eq(direct, null)) {
3999
4022
  return direct;
@@ -4002,7 +4025,7 @@ export class BallEngine {
4002
4025
  let superObj = __ball_index(selfMap, '__super__');
4003
4026
  let superMap = this._asMap(superObj);
4004
4027
  while (!__ball_eq(superMap, null)) {
4005
- if ((name in __ball_require_map(superMap, 'map_contains_key'))) {
4028
+ if (__ball_map_has(superMap, 'map_contains_key', name)) {
4006
4029
  let inherited = __ball_index(superMap, name);
4007
4030
  if (!__ball_eq(inherited, null)) {
4008
4031
  return inherited;
@@ -4127,25 +4150,25 @@ export class BallEngine {
4127
4150
  });
4128
4151
  }
4129
4152
  let enumVals = (__ball_index(this._enumValues, className) ?? __ball_index(this._enumValues, qualifiedName));
4130
- if ((!__ball_eq(enumVals, null) && (fieldName in __ball_require_map(enumVals, 'map_contains_key')))) {
4153
+ if ((!__ball_eq(enumVals, null) && __ball_map_has(enumVals, 'map_contains_key', fieldName))) {
4131
4154
  return __ball_index(enumVals, fieldName);
4132
4155
  }
4133
4156
  }
4134
4157
  if (!__ball_eq(objectMap, null)) {
4135
- if ((fieldName in __ball_require_map(objectMap, 'map_contains_key'))) {
4158
+ if (__ball_map_has(objectMap, 'map_contains_key', fieldName)) {
4136
4159
  return __ball_index(objectMap, fieldName);
4137
4160
  }
4138
4161
  let superObj = __ball_index(objectMap, '__super__');
4139
4162
  let superMap = this._asMap(superObj);
4140
4163
  while (!__ball_eq(superMap, null)) {
4141
- if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
4164
+ if (__ball_map_has(superMap, 'map_contains_key', fieldName)) {
4142
4165
  return __ball_index(superMap, fieldName);
4143
4166
  }
4144
4167
  superObj = __ball_index(superMap, '__super__');
4145
4168
  superMap = this._asMap(superObj);
4146
4169
  }
4147
4170
  let methods = __ball_index(objectMap, '__methods__');
4148
- if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (fieldName in __ball_require_map(methods, 'map_contains_key')))) {
4171
+ if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && __ball_map_has(methods, 'map_contains_key', fieldName))) {
4149
4172
  let method = __ball_index(methods, fieldName);
4150
4173
  if ((typeof method === 'function')) {
4151
4174
  return method;
@@ -4155,7 +4178,7 @@ export class BallEngine {
4155
4178
  superMap = this._asMap(superObj);
4156
4179
  while (!__ball_eq(superMap, null)) {
4157
4180
  let superMethods = __ball_index(superMap, '__methods__');
4158
- if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && (fieldName in __ball_require_map(superMethods, 'map_contains_key')))) {
4181
+ if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && __ball_map_has(superMethods, 'map_contains_key', fieldName))) {
4159
4182
  let method = __ball_index(superMethods, fieldName);
4160
4183
  if ((typeof method === 'function')) {
4161
4184
  return method;
@@ -4183,7 +4206,7 @@ export class BallEngine {
4183
4206
  }))];
4184
4207
  if ((!(vals.length === 0) && vals.every(((v) => {
4185
4208
  const input = v;
4186
- 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')));
4209
+ return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && __ball_map_has(v, 'map_contains_key', 'index')) && __ball_map_has(v, 'map_contains_key', '__type__'));
4187
4210
  })))) {
4188
4211
  vals = [...vals].sort(((a, b) => {
4189
4212
  return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
@@ -4300,7 +4323,7 @@ export class BallEngine {
4300
4323
  }))];
4301
4324
  if ((!(vals.length === 0) && vals.every(((v) => {
4302
4325
  const input = v;
4303
- 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')));
4326
+ return (((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && __ball_map_has(v, 'map_contains_key', 'index')) && __ball_map_has(v, 'map_contains_key', '__type__'));
4304
4327
  })))) {
4305
4328
  vals = [...vals].sort(((a, b) => {
4306
4329
  return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
@@ -4482,11 +4505,11 @@ export class BallEngine {
4482
4505
  return;
4483
4506
  }
4484
4507
  let backing = ('_' + __ball_to_string(fieldName));
4485
- if ((backing in __ball_require_map(object, 'map_contains_key'))) {
4508
+ if (__ball_map_has(object, 'map_contains_key', backing)) {
4486
4509
  ballObjectSetField(object, backing, assignedValue);
4487
4510
  return;
4488
4511
  }
4489
- if (('_celsius' in __ball_require_map(object, 'map_contains_key'))) {
4512
+ if (__ball_map_has(object, 'map_contains_key', '_celsius')) {
4490
4513
  ballObjectSetField(object, '_celsius', assignedValue);
4491
4514
  }
4492
4515
  }
@@ -4501,7 +4524,7 @@ export class BallEngine {
4501
4524
  let superObj = __ball_index(selfMap, '__super__');
4502
4525
  let superMap = this._asMap(superObj);
4503
4526
  while (!__ball_eq(superMap, null)) {
4504
- if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
4527
+ if (__ball_map_has(superMap, 'map_contains_key', fieldName)) {
4505
4528
  ballObjectSetField(superObj, fieldName, val);
4506
4529
  }
4507
4530
  superObj = __ball_index(superMap, '__super__');
@@ -4516,7 +4539,7 @@ export class BallEngine {
4516
4539
  let fields = {};
4517
4540
  for (const pair of msg.fields) {
4518
4541
  let val = await this._evalExpression(pair.value, scope);
4519
- if ((pair.name in __ball_require_map(fields, 'map_contains_key'))) {
4542
+ if (__ball_map_has(fields, 'map_contains_key', pair.name)) {
4520
4543
  let existing = __ball_index(fields, pair.name);
4521
4544
  if (Array.isArray(existing)) {
4522
4545
  let merged = ([...existing]);
@@ -4551,7 +4574,7 @@ export class BallEngine {
4551
4574
  }
4552
4575
  this._initFieldDefaults(msg.typeName, instanceFields);
4553
4576
  for (const fieldName of typeDef.fieldNames) {
4554
- if (!(fieldName in __ball_require_map(instanceFields, 'map_contains_key'))) {
4577
+ if (!__ball_map_has(instanceFields, 'map_contains_key', fieldName)) {
4555
4578
  instanceFields[fieldName] = null;
4556
4579
  }
4557
4580
  }
@@ -4563,15 +4586,15 @@ export class BallEngine {
4563
4586
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
4564
4587
  let param = __ball_index(params, i);
4565
4588
  let value;
4566
- if ((param in __ball_require_map(fields, 'map_contains_key'))) {
4589
+ if (__ball_map_has(fields, 'map_contains_key', param)) {
4567
4590
  value = __ball_index(fields, param);
4568
4591
  }
4569
4592
  else {
4570
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(fields, 'map_contains_key'))) {
4593
+ if (__ball_map_has(fields, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
4571
4594
  value = __ball_index(fields, ('arg' + __ball_to_string(i)));
4572
4595
  }
4573
4596
  }
4574
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
4597
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && __ball_map_has(__ball_index(paramsMeta, i), 'map_contains_key', 'default'))) {
4575
4598
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
4576
4599
  }
4577
4600
  resolvedParams[param] = value;
@@ -4595,7 +4618,7 @@ export class BallEngine {
4595
4618
  superObject = (__ball_eq(ctorEntry, null) ? null : await this._invokeSuperConstructor(ctorEntry.func, superclass, resolvedParams));
4596
4619
  superObject ??= this._buildSuperObject(superclass, instanceFields);
4597
4620
  }
4598
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4621
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4599
4622
  let metaTypeArgs = BallEngine._extractMetadataTypeArgs(msg);
4600
4623
  if (!__ball_eq(metaTypeArgs, null)) {
4601
4624
  instanceFields['__type_args__'] = metaTypeArgs;
@@ -4633,7 +4656,7 @@ export class BallEngine {
4633
4656
  })();
4634
4657
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4635
4658
  let constructedMap = this._asMap(constructed);
4636
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4659
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4637
4660
  return constructed;
4638
4661
  }
4639
4662
  return instance;
@@ -4655,7 +4678,7 @@ export class BallEngine {
4655
4678
  instanceFields[entry.key] = entry.value;
4656
4679
  }
4657
4680
  }
4658
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4681
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4659
4682
  let metaTA = BallEngine._extractMetadataTypeArgs(msg);
4660
4683
  if (!__ball_eq(metaTA, null)) {
4661
4684
  instanceFields['__type_args__'] = metaTA;
@@ -4671,13 +4694,13 @@ export class BallEngine {
4671
4694
  })();
4672
4695
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4673
4696
  let constructedMap = this._asMap(constructed);
4674
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4697
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4675
4698
  return constructed;
4676
4699
  }
4677
4700
  return instance;
4678
4701
  }
4679
4702
  fields['__type__'] = msg.typeName;
4680
- if (!('__type_args__' in __ball_require_map(fields, 'map_contains_key'))) {
4703
+ if (!__ball_map_has(fields, 'map_contains_key', '__type_args__')) {
4681
4704
  let metaTA2 = BallEngine._extractMetadataTypeArgs(msg);
4682
4705
  if (!__ball_eq(metaTA2, null)) {
4683
4706
  fields['__type_args__'] = metaTA2;
@@ -4798,7 +4821,7 @@ export class BallEngine {
4798
4821
  let __naa_10 = __ball_index(fv.structValue.fields, 'name');
4799
4822
  return (__ball_eq(__naa_10, null) ? null : __naa_10.stringValue);
4800
4823
  })();
4801
- if ((__ball_eq(fname, null) || (fname in __ball_require_map(fields, 'map_contains_key')))) {
4824
+ if ((__ball_eq(fname, null) || __ball_map_has(fields, 'map_contains_key', fname))) {
4802
4825
  continue;
4803
4826
  }
4804
4827
  let init = (() => {
@@ -4900,13 +4923,13 @@ export class BallEngine {
4900
4923
  let parentTypeDef = this._findTypeDef(superclass);
4901
4924
  if (!__ball_eq(parentTypeDef, null)) {
4902
4925
  for (const fname of parentTypeDef.fieldNames) {
4903
- if ((fname in __ball_require_map(childFields, 'map_contains_key'))) {
4926
+ if (__ball_map_has(childFields, 'map_contains_key', fname)) {
4904
4927
  superFields[fname] = __ball_index(childFields, fname);
4905
4928
  }
4906
4929
  }
4907
4930
  this._initFieldDefaults(superclass, superFields);
4908
4931
  for (const fname of parentTypeDef.fieldNames) {
4909
- if (!(fname in __ball_require_map(superFields, 'map_contains_key'))) {
4932
+ if (!__ball_map_has(superFields, 'map_contains_key', fname)) {
4910
4933
  superFields[fname] = null;
4911
4934
  }
4912
4935
  }
@@ -5062,11 +5085,11 @@ export class BallEngine {
5062
5085
  for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
5063
5086
  let p = __ball_index(paramNames, i);
5064
5087
  if (!lambdaScope.has(p)) {
5065
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
5088
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
5066
5089
  lambdaScope.bind(p, __ball_index(inputMap, p));
5067
5090
  }
5068
5091
  else {
5069
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
5092
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
5070
5093
  lambdaScope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
5071
5094
  }
5072
5095
  }
@@ -5254,7 +5277,7 @@ export class BallEngine {
5254
5277
  }
5255
5278
  else {
5256
5279
  let map = this._cfAsMap(obj);
5257
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5280
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
5258
5281
  let v = __ball_index(map, prop);
5259
5282
  if ((typeof v === 'number' || v instanceof BallDouble)) {
5260
5283
  propVal = v;
@@ -5325,7 +5348,7 @@ export class BallEngine {
5325
5348
  return obj.length;
5326
5349
  }
5327
5350
  let map = this._cfAsMap(obj);
5328
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5351
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
5329
5352
  return __ball_index(map, prop);
5330
5353
  }
5331
5354
  }
@@ -5631,7 +5654,7 @@ export class BallEngine {
5631
5654
  }
5632
5655
  }
5633
5656
  let enumVals = __ball_index(this._enumValues, enumType);
5634
- if ((!__ball_eq(enumVals, null) && (enumValue in __ball_require_map(enumVals, 'map_contains_key')))) {
5657
+ if ((!__ball_eq(enumVals, null) && __ball_map_has(enumVals, 'map_contains_key', enumValue))) {
5635
5658
  let resolved = __ball_index(enumVals, enumValue);
5636
5659
  let resolvedMap = this._cfAsMap(resolved);
5637
5660
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -5640,7 +5663,7 @@ export class BallEngine {
5640
5663
  }
5641
5664
  let qualifiedEnumType = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(enumType));
5642
5665
  let qualEnumVals = __ball_index(this._enumValues, qualifiedEnumType);
5643
- if ((!__ball_eq(qualEnumVals, null) && (enumValue in __ball_require_map(qualEnumVals, 'map_contains_key')))) {
5666
+ if ((!__ball_eq(qualEnumVals, null) && __ball_map_has(qualEnumVals, 'map_contains_key', enumValue))) {
5644
5667
  let resolved = __ball_index(qualEnumVals, enumValue);
5645
5668
  let resolvedMap = this._cfAsMap(resolved);
5646
5669
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -6812,13 +6835,13 @@ export class BallEngine {
6812
6835
  let seen = {};
6813
6836
  let result = [];
6814
6837
  for (const item of self) {
6815
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6838
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6816
6839
  seen[item] = item;
6817
6840
  result = (result.push(item), result);
6818
6841
  }
6819
6842
  }
6820
6843
  for (const item of other) {
6821
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6844
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6822
6845
  seen[item] = item;
6823
6846
  result = (result.push(item), result);
6824
6847
  }
@@ -7081,7 +7104,7 @@ export class BallEngine {
7081
7104
  } while (false);
7082
7105
  }
7083
7106
  let selfMap = this._cfAsMap(self);
7084
- if ((!__ball_eq(selfMap, null) && ('__type__' in __ball_require_map(selfMap, 'map_contains_key')))) {
7107
+ if ((!__ball_eq(selfMap, null) && __ball_map_has(selfMap, 'map_contains_key', '__type__'))) {
7085
7108
  let typeName = __ball_index(selfMap, '__type__');
7086
7109
  if ((!__ball_eq(typeName, null) && (typeName.endsWith(':StringBuffer') || __ball_eq(typeName, 'StringBuffer')))) {
7087
7110
  do {
@@ -7192,7 +7215,7 @@ export class BallEngine {
7192
7215
  right = __ball_index(m, 'right');
7193
7216
  }
7194
7217
  let leftMap = this._stdAsMap(left);
7195
- if ((__ball_eq(leftMap, null) || !('__type__' in __ball_require_map(leftMap, 'map_contains_key')))) {
7218
+ if ((__ball_eq(leftMap, null) || !__ball_map_has(leftMap, 'map_contains_key', '__type__'))) {
7196
7219
  return null;
7197
7220
  }
7198
7221
  let typeName = __ball_index(leftMap, '__type__');
@@ -7257,7 +7280,7 @@ export class BallEngine {
7257
7280
  } while (false);
7258
7281
  }
7259
7282
  async _callBaseFunction(module, function_, input) {
7260
- if ((function_ in __ball_require_map(_stdFunctionToOperator, 'map_contains_key'))) {
7283
+ if (__ball_map_has(_stdFunctionToOperator, 'map_contains_key', function_)) {
7261
7284
  let override = await this._tryOperatorOverride(function_, input);
7262
7285
  if (!__ball_eq(override, null)) {
7263
7286
  return this._consumeGeneratorFlow(override);
@@ -7802,17 +7825,17 @@ export class BallEngine {
7802
7825
  let list = this._stdAsList(__ball_index(m, 'list'));
7803
7826
  let s;
7804
7827
  let e;
7805
- if (('start' in __ball_require_map(m, 'map_contains_key'))) {
7828
+ if (__ball_map_has(m, 'map_contains_key', 'start')) {
7806
7829
  s = this._toInt(__ball_index(m, 'start'));
7807
7830
  e = (!__ball_eq(__ball_index(m, 'end'), null) ? this._toInt(__ball_index(m, 'end')) : null);
7808
7831
  }
7809
7832
  else {
7810
- if ((('arg0' in __ball_require_map(m, 'map_contains_key')) && ('arg1' in __ball_require_map(m, 'map_contains_key')))) {
7833
+ if ((__ball_map_has(m, 'map_contains_key', 'arg0') && __ball_map_has(m, 'map_contains_key', 'arg1'))) {
7811
7834
  s = this._toInt(__ball_index(m, 'arg0'));
7812
7835
  e = this._toInt(__ball_index(m, 'arg1'));
7813
7836
  }
7814
7837
  else {
7815
- if (('value' in __ball_require_map(m, 'map_contains_key'))) {
7838
+ if (__ball_map_has(m, 'map_contains_key', 'value')) {
7816
7839
  let v = __ball_index(m, 'value');
7817
7840
  if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
7818
7841
  s = this._toInt(__ball_index(v, 0));
@@ -8026,7 +8049,7 @@ export class BallEngine {
8026
8049
  let m = this._stdAsMap(i);
8027
8050
  let map = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
8028
8051
  let key = __ball_index(m, 'key');
8029
- if (!(key in __ball_require_map(map, 'map_contains_key'))) {
8052
+ if (!__ball_map_has(map, 'map_contains_key', key)) {
8030
8053
  this._trackMemoryAllocation(_ballMapEntryBytes);
8031
8054
  let val = __ball_index(m, 'value');
8032
8055
  map[key] = ((typeof val === 'function') ? val() : val);
@@ -8232,7 +8255,7 @@ export class BallEngine {
8232
8255
  let valMap = this._stdAsMap(val);
8233
8256
  if (!__ball_eq(valMap, null)) {
8234
8257
  typeName = ((__ball_index(valMap, '__type__') ?? __ball_index(valMap, '__type')) ?? 'Exception');
8235
- if ((!('message' in __ball_require_map(valMap, 'map_contains_key')) && ('arg0' in __ball_require_map(valMap, 'map_contains_key')))) {
8258
+ if ((!__ball_map_has(valMap, 'map_contains_key', 'message') && __ball_map_has(valMap, 'map_contains_key', 'arg0'))) {
8236
8259
  valMap['message'] = __ball_index(valMap, 'arg0');
8237
8260
  }
8238
8261
  }
@@ -8831,7 +8854,7 @@ export class BallEngine {
8831
8854
  }
8832
8855
  async _stdPrint(input) {
8833
8856
  let m = this._stdAsMap(input);
8834
- 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'))))) {
8857
+ if ((!__ball_eq(m, null) && ((__ball_map_has(m, 'map_contains_key', 'message') || __ball_map_has(m, 'map_contains_key', 'arg0')) || __ball_map_has(m, 'map_contains_key', 'value')))) {
8835
8858
  let message = ((__ball_index(m, 'message') ?? __ball_index(m, 'arg0')) ?? __ball_index(m, 'value'));
8836
8859
  this.stdout(await this._ballToStringAsync(message));
8837
8860
  return null;
@@ -8923,7 +8946,7 @@ export class BallEngine {
8923
8946
  }
8924
8947
  return (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8925
8948
  }
8926
- if (('__tostring_guard__' in __ball_require_map(map, 'map_contains_key'))) {
8949
+ if (__ball_map_has(map, 'map_contains_key', '__tostring_guard__')) {
8927
8950
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8928
8951
  return (__ball_to_string(shortType) + '{...}');
8929
8952
  }
@@ -9534,7 +9557,7 @@ export class BallEngine {
9534
9557
  return false;
9535
9558
  }
9536
9559
  let key = __ball_index(entryMap, 'key');
9537
- if (!(key in __ball_require_map(rawMap, 'map_contains_key'))) {
9560
+ if (!__ball_map_has(rawMap, 'map_contains_key', key)) {
9538
9561
  return false;
9539
9562
  }
9540
9563
  if (!this._matchPattern(__ball_index(rawMap, key), __ball_index(entryMap, 'value'), bindings)) {
@@ -9574,7 +9597,7 @@ export class BallEngine {
9574
9597
  return false;
9575
9598
  }
9576
9599
  for (const entry of recFields.entries) {
9577
- if (!(entry.key in __ball_require_map(recMap, 'map_contains_key'))) {
9600
+ if (!__ball_map_has(recMap, 'map_contains_key', entry.key)) {
9578
9601
  return false;
9579
9602
  }
9580
9603
  let fieldVal = __ball_index(recMap, entry.key);
@@ -9734,7 +9757,7 @@ export class BallEngine {
9734
9757
  let map = this._stdAsMap(v);
9735
9758
  if (!__ball_eq(map, null)) {
9736
9759
  let typeName = __ball_index(map, '__type__');
9737
- if ((!__ball_eq(typeName, null) && (typeName in __ball_require_map(this._enumValues, 'map_contains_key')))) {
9760
+ if ((!__ball_eq(typeName, null) && __ball_map_has(this._enumValues, 'map_contains_key', typeName))) {
9738
9761
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
9739
9762
  let valName = __ball_index(map, 'name');
9740
9763
  if (!__ball_eq(valName, null)) {
@@ -10328,7 +10351,7 @@ export class _Scope {
10328
10351
  }
10329
10352
  lookup(name) {
10330
10353
  const input = name;
10331
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10354
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10332
10355
  return __ball_index(this._bindings, name);
10333
10356
  }
10334
10357
  if (!__ball_eq(this._parent, null)) {
@@ -10341,13 +10364,13 @@ export class _Scope {
10341
10364
  }
10342
10365
  has(name) {
10343
10366
  const input = name;
10344
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10367
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10345
10368
  return true;
10346
10369
  }
10347
10370
  return ((__ball_eq(this._parent, null) ? null : this._parent.has(name)) ?? false);
10348
10371
  }
10349
10372
  set(name, value) {
10350
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10373
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10351
10374
  this._bindings[name] = value;
10352
10375
  return;
10353
10376
  }
@@ -10446,7 +10469,7 @@ export class StdModuleHandler extends BallModuleHandler {
10446
10469
  if (this._tombstones.includes(entry.key)) {
10447
10470
  continue;
10448
10471
  }
10449
- if ((entry.key in __ball_require_map(this._composedDispatch, 'map_contains_key'))) {
10472
+ if (__ball_map_has(this._composedDispatch, 'map_contains_key', entry.key)) {
10450
10473
  continue;
10451
10474
  }
10452
10475
  if ((!__ball_eq(allowlist, null) && !allowlist.includes(entry.key))) {
@@ -10549,7 +10572,7 @@ function _ballToDouble(value) {
10549
10572
  }
10550
10573
  function _ballValueIsSet(v) {
10551
10574
  const input = v;
10552
- return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && (_kBallSetTag in __ball_require_map(v, 'map_contains_key')));
10575
+ return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && __ball_map_has(v, 'map_contains_key', _kBallSetTag));
10553
10576
  }
10554
10577
  function _ballIsInt(v) {
10555
10578
  const input = v;
@@ -10613,7 +10636,7 @@ function _ballMapValuesDyn(map) {
10613
10636
  function _ballMapContainsKeyDyn(map, key) {
10614
10637
  let handle = _ballMapHandleEntries(map);
10615
10638
  if ((typeof handle === 'object' && handle !== null && !Array.isArray(handle) && !(handle instanceof BallDouble) && !(handle instanceof Set))) {
10616
- return (key in __ball_require_map(handle, 'map_contains_key'));
10639
+ return __ball_map_has(handle, 'map_contains_key', key);
10617
10640
  }
10618
10641
  return false;
10619
10642
  }
@@ -10629,12 +10652,12 @@ function ballObjectSetField(target, fieldName, val) {
10629
10652
  return;
10630
10653
  }
10631
10654
  if (false /* BallMap is Map in TS */) {
10632
- if (('__type__' in __ball_require_map(target.entries, 'map_contains_key'))) {
10655
+ if (__ball_map_has(target.entries, 'map_contains_key', '__type__')) {
10633
10656
  target[fieldName] = val;
10634
10657
  }
10635
10658
  return;
10636
10659
  }
10637
- if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in __ball_require_map(target, 'map_contains_key')))) {
10660
+ if ((__ball_is_type(target, "Map<String, Object?>") && __ball_map_has(target, 'map_contains_key', '__type__'))) {
10638
10661
  target[fieldName] = val;
10639
10662
  }
10640
10663
  }
@@ -10727,7 +10750,7 @@ function _unwrapBallFuture(value) {
10727
10750
  const input = value;
10728
10751
  if (_isBallFuture(value)) {
10729
10752
  let map = value;
10730
- if (('error' in __ball_require_map(map, 'map_contains_key'))) {
10753
+ if (__ball_map_has(map, 'map_contains_key', 'error')) {
10731
10754
  let error = __ball_index(map, 'error');
10732
10755
  if ((error instanceof BallException)) {
10733
10756
  throw error;