@ball-lang/engine 1.60.0 → 1.60.2

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);
@@ -4445,6 +4468,9 @@ export class BallEngine {
4445
4468
  if (__ball_eq(typeName, null)) {
4446
4469
  return _sentinel;
4447
4470
  }
4471
+ if (__ball_map_has(object, 'map_contains_key', fieldName)) {
4472
+ return _sentinel;
4473
+ }
4448
4474
  let colonIdx = typeName.indexOf(':');
4449
4475
  let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
4450
4476
  let setterKey = (((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName)) + '=');
@@ -4482,11 +4508,11 @@ export class BallEngine {
4482
4508
  return;
4483
4509
  }
4484
4510
  let backing = ('_' + __ball_to_string(fieldName));
4485
- if ((backing in __ball_require_map(object, 'map_contains_key'))) {
4511
+ if (__ball_map_has(object, 'map_contains_key', backing)) {
4486
4512
  ballObjectSetField(object, backing, assignedValue);
4487
4513
  return;
4488
4514
  }
4489
- if (('_celsius' in __ball_require_map(object, 'map_contains_key'))) {
4515
+ if (__ball_map_has(object, 'map_contains_key', '_celsius')) {
4490
4516
  ballObjectSetField(object, '_celsius', assignedValue);
4491
4517
  }
4492
4518
  }
@@ -4501,7 +4527,7 @@ export class BallEngine {
4501
4527
  let superObj = __ball_index(selfMap, '__super__');
4502
4528
  let superMap = this._asMap(superObj);
4503
4529
  while (!__ball_eq(superMap, null)) {
4504
- if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
4530
+ if (__ball_map_has(superMap, 'map_contains_key', fieldName)) {
4505
4531
  ballObjectSetField(superObj, fieldName, val);
4506
4532
  }
4507
4533
  superObj = __ball_index(superMap, '__super__');
@@ -4516,7 +4542,7 @@ export class BallEngine {
4516
4542
  let fields = {};
4517
4543
  for (const pair of msg.fields) {
4518
4544
  let val = await this._evalExpression(pair.value, scope);
4519
- if ((pair.name in __ball_require_map(fields, 'map_contains_key'))) {
4545
+ if (__ball_map_has(fields, 'map_contains_key', pair.name)) {
4520
4546
  let existing = __ball_index(fields, pair.name);
4521
4547
  if (Array.isArray(existing)) {
4522
4548
  let merged = ([...existing]);
@@ -4551,7 +4577,7 @@ export class BallEngine {
4551
4577
  }
4552
4578
  this._initFieldDefaults(msg.typeName, instanceFields);
4553
4579
  for (const fieldName of typeDef.fieldNames) {
4554
- if (!(fieldName in __ball_require_map(instanceFields, 'map_contains_key'))) {
4580
+ if (!__ball_map_has(instanceFields, 'map_contains_key', fieldName)) {
4555
4581
  instanceFields[fieldName] = null;
4556
4582
  }
4557
4583
  }
@@ -4563,15 +4589,15 @@ export class BallEngine {
4563
4589
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
4564
4590
  let param = __ball_index(params, i);
4565
4591
  let value;
4566
- if ((param in __ball_require_map(fields, 'map_contains_key'))) {
4592
+ if (__ball_map_has(fields, 'map_contains_key', param)) {
4567
4593
  value = __ball_index(fields, param);
4568
4594
  }
4569
4595
  else {
4570
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(fields, 'map_contains_key'))) {
4596
+ if (__ball_map_has(fields, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
4571
4597
  value = __ball_index(fields, ('arg' + __ball_to_string(i)));
4572
4598
  }
4573
4599
  }
4574
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
4600
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && __ball_map_has(__ball_index(paramsMeta, i), 'map_contains_key', 'default'))) {
4575
4601
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
4576
4602
  }
4577
4603
  resolvedParams[param] = value;
@@ -4595,7 +4621,7 @@ export class BallEngine {
4595
4621
  superObject = (__ball_eq(ctorEntry, null) ? null : await this._invokeSuperConstructor(ctorEntry.func, superclass, resolvedParams));
4596
4622
  superObject ??= this._buildSuperObject(superclass, instanceFields);
4597
4623
  }
4598
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4624
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4599
4625
  let metaTypeArgs = BallEngine._extractMetadataTypeArgs(msg);
4600
4626
  if (!__ball_eq(metaTypeArgs, null)) {
4601
4627
  instanceFields['__type_args__'] = metaTypeArgs;
@@ -4633,7 +4659,7 @@ export class BallEngine {
4633
4659
  })();
4634
4660
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4635
4661
  let constructedMap = this._asMap(constructed);
4636
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4662
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4637
4663
  return constructed;
4638
4664
  }
4639
4665
  return instance;
@@ -4655,7 +4681,7 @@ export class BallEngine {
4655
4681
  instanceFields[entry.key] = entry.value;
4656
4682
  }
4657
4683
  }
4658
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4684
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4659
4685
  let metaTA = BallEngine._extractMetadataTypeArgs(msg);
4660
4686
  if (!__ball_eq(metaTA, null)) {
4661
4687
  instanceFields['__type_args__'] = metaTA;
@@ -4671,13 +4697,13 @@ export class BallEngine {
4671
4697
  })();
4672
4698
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4673
4699
  let constructedMap = this._asMap(constructed);
4674
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4700
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4675
4701
  return constructed;
4676
4702
  }
4677
4703
  return instance;
4678
4704
  }
4679
4705
  fields['__type__'] = msg.typeName;
4680
- if (!('__type_args__' in __ball_require_map(fields, 'map_contains_key'))) {
4706
+ if (!__ball_map_has(fields, 'map_contains_key', '__type_args__')) {
4681
4707
  let metaTA2 = BallEngine._extractMetadataTypeArgs(msg);
4682
4708
  if (!__ball_eq(metaTA2, null)) {
4683
4709
  fields['__type_args__'] = metaTA2;
@@ -4798,7 +4824,7 @@ export class BallEngine {
4798
4824
  let __naa_10 = __ball_index(fv.structValue.fields, 'name');
4799
4825
  return (__ball_eq(__naa_10, null) ? null : __naa_10.stringValue);
4800
4826
  })();
4801
- if ((__ball_eq(fname, null) || (fname in __ball_require_map(fields, 'map_contains_key')))) {
4827
+ if ((__ball_eq(fname, null) || __ball_map_has(fields, 'map_contains_key', fname))) {
4802
4828
  continue;
4803
4829
  }
4804
4830
  let init = (() => {
@@ -4900,13 +4926,13 @@ export class BallEngine {
4900
4926
  let parentTypeDef = this._findTypeDef(superclass);
4901
4927
  if (!__ball_eq(parentTypeDef, null)) {
4902
4928
  for (const fname of parentTypeDef.fieldNames) {
4903
- if ((fname in __ball_require_map(childFields, 'map_contains_key'))) {
4929
+ if (__ball_map_has(childFields, 'map_contains_key', fname)) {
4904
4930
  superFields[fname] = __ball_index(childFields, fname);
4905
4931
  }
4906
4932
  }
4907
4933
  this._initFieldDefaults(superclass, superFields);
4908
4934
  for (const fname of parentTypeDef.fieldNames) {
4909
- if (!(fname in __ball_require_map(superFields, 'map_contains_key'))) {
4935
+ if (!__ball_map_has(superFields, 'map_contains_key', fname)) {
4910
4936
  superFields[fname] = null;
4911
4937
  }
4912
4938
  }
@@ -5062,11 +5088,11 @@ export class BallEngine {
5062
5088
  for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
5063
5089
  let p = __ball_index(paramNames, i);
5064
5090
  if (!lambdaScope.has(p)) {
5065
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
5091
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
5066
5092
  lambdaScope.bind(p, __ball_index(inputMap, p));
5067
5093
  }
5068
5094
  else {
5069
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
5095
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
5070
5096
  lambdaScope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
5071
5097
  }
5072
5098
  }
@@ -5254,7 +5280,7 @@ export class BallEngine {
5254
5280
  }
5255
5281
  else {
5256
5282
  let map = this._cfAsMap(obj);
5257
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5283
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
5258
5284
  let v = __ball_index(map, prop);
5259
5285
  if ((typeof v === 'number' || v instanceof BallDouble)) {
5260
5286
  propVal = v;
@@ -5325,7 +5351,7 @@ export class BallEngine {
5325
5351
  return obj.length;
5326
5352
  }
5327
5353
  let map = this._cfAsMap(obj);
5328
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5354
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
5329
5355
  return __ball_index(map, prop);
5330
5356
  }
5331
5357
  }
@@ -5631,7 +5657,7 @@ export class BallEngine {
5631
5657
  }
5632
5658
  }
5633
5659
  let enumVals = __ball_index(this._enumValues, enumType);
5634
- if ((!__ball_eq(enumVals, null) && (enumValue in __ball_require_map(enumVals, 'map_contains_key')))) {
5660
+ if ((!__ball_eq(enumVals, null) && __ball_map_has(enumVals, 'map_contains_key', enumValue))) {
5635
5661
  let resolved = __ball_index(enumVals, enumValue);
5636
5662
  let resolvedMap = this._cfAsMap(resolved);
5637
5663
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -5640,7 +5666,7 @@ export class BallEngine {
5640
5666
  }
5641
5667
  let qualifiedEnumType = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(enumType));
5642
5668
  let qualEnumVals = __ball_index(this._enumValues, qualifiedEnumType);
5643
- if ((!__ball_eq(qualEnumVals, null) && (enumValue in __ball_require_map(qualEnumVals, 'map_contains_key')))) {
5669
+ if ((!__ball_eq(qualEnumVals, null) && __ball_map_has(qualEnumVals, 'map_contains_key', enumValue))) {
5644
5670
  let resolved = __ball_index(qualEnumVals, enumValue);
5645
5671
  let resolvedMap = this._cfAsMap(resolved);
5646
5672
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -6812,13 +6838,13 @@ export class BallEngine {
6812
6838
  let seen = {};
6813
6839
  let result = [];
6814
6840
  for (const item of self) {
6815
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6841
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6816
6842
  seen[item] = item;
6817
6843
  result = (result.push(item), result);
6818
6844
  }
6819
6845
  }
6820
6846
  for (const item of other) {
6821
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6847
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6822
6848
  seen[item] = item;
6823
6849
  result = (result.push(item), result);
6824
6850
  }
@@ -7081,7 +7107,7 @@ export class BallEngine {
7081
7107
  } while (false);
7082
7108
  }
7083
7109
  let selfMap = this._cfAsMap(self);
7084
- if ((!__ball_eq(selfMap, null) && ('__type__' in __ball_require_map(selfMap, 'map_contains_key')))) {
7110
+ if ((!__ball_eq(selfMap, null) && __ball_map_has(selfMap, 'map_contains_key', '__type__'))) {
7085
7111
  let typeName = __ball_index(selfMap, '__type__');
7086
7112
  if ((!__ball_eq(typeName, null) && (typeName.endsWith(':StringBuffer') || __ball_eq(typeName, 'StringBuffer')))) {
7087
7113
  do {
@@ -7192,7 +7218,7 @@ export class BallEngine {
7192
7218
  right = __ball_index(m, 'right');
7193
7219
  }
7194
7220
  let leftMap = this._stdAsMap(left);
7195
- if ((__ball_eq(leftMap, null) || !('__type__' in __ball_require_map(leftMap, 'map_contains_key')))) {
7221
+ if ((__ball_eq(leftMap, null) || !__ball_map_has(leftMap, 'map_contains_key', '__type__'))) {
7196
7222
  return null;
7197
7223
  }
7198
7224
  let typeName = __ball_index(leftMap, '__type__');
@@ -7257,7 +7283,7 @@ export class BallEngine {
7257
7283
  } while (false);
7258
7284
  }
7259
7285
  async _callBaseFunction(module, function_, input) {
7260
- if ((function_ in __ball_require_map(_stdFunctionToOperator, 'map_contains_key'))) {
7286
+ if (__ball_map_has(_stdFunctionToOperator, 'map_contains_key', function_)) {
7261
7287
  let override = await this._tryOperatorOverride(function_, input);
7262
7288
  if (!__ball_eq(override, null)) {
7263
7289
  return this._consumeGeneratorFlow(override);
@@ -7802,17 +7828,17 @@ export class BallEngine {
7802
7828
  let list = this._stdAsList(__ball_index(m, 'list'));
7803
7829
  let s;
7804
7830
  let e;
7805
- if (('start' in __ball_require_map(m, 'map_contains_key'))) {
7831
+ if (__ball_map_has(m, 'map_contains_key', 'start')) {
7806
7832
  s = this._toInt(__ball_index(m, 'start'));
7807
7833
  e = (!__ball_eq(__ball_index(m, 'end'), null) ? this._toInt(__ball_index(m, 'end')) : null);
7808
7834
  }
7809
7835
  else {
7810
- if ((('arg0' in __ball_require_map(m, 'map_contains_key')) && ('arg1' in __ball_require_map(m, 'map_contains_key')))) {
7836
+ if ((__ball_map_has(m, 'map_contains_key', 'arg0') && __ball_map_has(m, 'map_contains_key', 'arg1'))) {
7811
7837
  s = this._toInt(__ball_index(m, 'arg0'));
7812
7838
  e = this._toInt(__ball_index(m, 'arg1'));
7813
7839
  }
7814
7840
  else {
7815
- if (('value' in __ball_require_map(m, 'map_contains_key'))) {
7841
+ if (__ball_map_has(m, 'map_contains_key', 'value')) {
7816
7842
  let v = __ball_index(m, 'value');
7817
7843
  if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
7818
7844
  s = this._toInt(__ball_index(v, 0));
@@ -8026,7 +8052,7 @@ export class BallEngine {
8026
8052
  let m = this._stdAsMap(i);
8027
8053
  let map = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
8028
8054
  let key = __ball_index(m, 'key');
8029
- if (!(key in __ball_require_map(map, 'map_contains_key'))) {
8055
+ if (!__ball_map_has(map, 'map_contains_key', key)) {
8030
8056
  this._trackMemoryAllocation(_ballMapEntryBytes);
8031
8057
  let val = __ball_index(m, 'value');
8032
8058
  map[key] = ((typeof val === 'function') ? val() : val);
@@ -8232,7 +8258,7 @@ export class BallEngine {
8232
8258
  let valMap = this._stdAsMap(val);
8233
8259
  if (!__ball_eq(valMap, null)) {
8234
8260
  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')))) {
8261
+ if ((!__ball_map_has(valMap, 'map_contains_key', 'message') && __ball_map_has(valMap, 'map_contains_key', 'arg0'))) {
8236
8262
  valMap['message'] = __ball_index(valMap, 'arg0');
8237
8263
  }
8238
8264
  }
@@ -8831,7 +8857,7 @@ export class BallEngine {
8831
8857
  }
8832
8858
  async _stdPrint(input) {
8833
8859
  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'))))) {
8860
+ 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
8861
  let message = ((__ball_index(m, 'message') ?? __ball_index(m, 'arg0')) ?? __ball_index(m, 'value'));
8836
8862
  this.stdout(await this._ballToStringAsync(message));
8837
8863
  return null;
@@ -8923,7 +8949,7 @@ export class BallEngine {
8923
8949
  }
8924
8950
  return (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8925
8951
  }
8926
- if (('__tostring_guard__' in __ball_require_map(map, 'map_contains_key'))) {
8952
+ if (__ball_map_has(map, 'map_contains_key', '__tostring_guard__')) {
8927
8953
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8928
8954
  return (__ball_to_string(shortType) + '{...}');
8929
8955
  }
@@ -9534,7 +9560,7 @@ export class BallEngine {
9534
9560
  return false;
9535
9561
  }
9536
9562
  let key = __ball_index(entryMap, 'key');
9537
- if (!(key in __ball_require_map(rawMap, 'map_contains_key'))) {
9563
+ if (!__ball_map_has(rawMap, 'map_contains_key', key)) {
9538
9564
  return false;
9539
9565
  }
9540
9566
  if (!this._matchPattern(__ball_index(rawMap, key), __ball_index(entryMap, 'value'), bindings)) {
@@ -9574,7 +9600,7 @@ export class BallEngine {
9574
9600
  return false;
9575
9601
  }
9576
9602
  for (const entry of recFields.entries) {
9577
- if (!(entry.key in __ball_require_map(recMap, 'map_contains_key'))) {
9603
+ if (!__ball_map_has(recMap, 'map_contains_key', entry.key)) {
9578
9604
  return false;
9579
9605
  }
9580
9606
  let fieldVal = __ball_index(recMap, entry.key);
@@ -9734,7 +9760,7 @@ export class BallEngine {
9734
9760
  let map = this._stdAsMap(v);
9735
9761
  if (!__ball_eq(map, null)) {
9736
9762
  let typeName = __ball_index(map, '__type__');
9737
- if ((!__ball_eq(typeName, null) && (typeName in __ball_require_map(this._enumValues, 'map_contains_key')))) {
9763
+ if ((!__ball_eq(typeName, null) && __ball_map_has(this._enumValues, 'map_contains_key', typeName))) {
9738
9764
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
9739
9765
  let valName = __ball_index(map, 'name');
9740
9766
  if (!__ball_eq(valName, null)) {
@@ -10328,7 +10354,7 @@ export class _Scope {
10328
10354
  }
10329
10355
  lookup(name) {
10330
10356
  const input = name;
10331
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10357
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10332
10358
  return __ball_index(this._bindings, name);
10333
10359
  }
10334
10360
  if (!__ball_eq(this._parent, null)) {
@@ -10341,13 +10367,13 @@ export class _Scope {
10341
10367
  }
10342
10368
  has(name) {
10343
10369
  const input = name;
10344
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10370
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10345
10371
  return true;
10346
10372
  }
10347
10373
  return ((__ball_eq(this._parent, null) ? null : this._parent.has(name)) ?? false);
10348
10374
  }
10349
10375
  set(name, value) {
10350
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10376
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10351
10377
  this._bindings[name] = value;
10352
10378
  return;
10353
10379
  }
@@ -10446,7 +10472,7 @@ export class StdModuleHandler extends BallModuleHandler {
10446
10472
  if (this._tombstones.includes(entry.key)) {
10447
10473
  continue;
10448
10474
  }
10449
- if ((entry.key in __ball_require_map(this._composedDispatch, 'map_contains_key'))) {
10475
+ if (__ball_map_has(this._composedDispatch, 'map_contains_key', entry.key)) {
10450
10476
  continue;
10451
10477
  }
10452
10478
  if ((!__ball_eq(allowlist, null) && !allowlist.includes(entry.key))) {
@@ -10549,7 +10575,7 @@ function _ballToDouble(value) {
10549
10575
  }
10550
10576
  function _ballValueIsSet(v) {
10551
10577
  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')));
10578
+ return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && __ball_map_has(v, 'map_contains_key', _kBallSetTag));
10553
10579
  }
10554
10580
  function _ballIsInt(v) {
10555
10581
  const input = v;
@@ -10613,7 +10639,7 @@ function _ballMapValuesDyn(map) {
10613
10639
  function _ballMapContainsKeyDyn(map, key) {
10614
10640
  let handle = _ballMapHandleEntries(map);
10615
10641
  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'));
10642
+ return __ball_map_has(handle, 'map_contains_key', key);
10617
10643
  }
10618
10644
  return false;
10619
10645
  }
@@ -10629,12 +10655,12 @@ function ballObjectSetField(target, fieldName, val) {
10629
10655
  return;
10630
10656
  }
10631
10657
  if (false /* BallMap is Map in TS */) {
10632
- if (('__type__' in __ball_require_map(target.entries, 'map_contains_key'))) {
10658
+ if (__ball_map_has(target.entries, 'map_contains_key', '__type__')) {
10633
10659
  target[fieldName] = val;
10634
10660
  }
10635
10661
  return;
10636
10662
  }
10637
- if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in __ball_require_map(target, 'map_contains_key')))) {
10663
+ if ((__ball_is_type(target, "Map<String, Object?>") && __ball_map_has(target, 'map_contains_key', '__type__'))) {
10638
10664
  target[fieldName] = val;
10639
10665
  }
10640
10666
  }
@@ -10727,7 +10753,7 @@ function _unwrapBallFuture(value) {
10727
10753
  const input = value;
10728
10754
  if (_isBallFuture(value)) {
10729
10755
  let map = value;
10730
- if (('error' in __ball_require_map(map, 'map_contains_key'))) {
10756
+ if (__ball_map_has(map, 'map_contains_key', 'error')) {
10731
10757
  let error = __ball_index(map, 'error');
10732
10758
  if ((error instanceof BallException)) {
10733
10759
  throw error;