@ball-lang/engine 1.60.0 → 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.
@@ -1178,6 +1178,28 @@ function __ball_require_map(v: any, opName: string): any {
1178
1178
  return v;
1179
1179
  }
1180
1180
 
1181
+ // map_contains_key. The obvious lowering, "key in map", walks the PROTOTYPE
1182
+ // CHAIN -- and this preamble installs the whole Dart-SDK method surface
1183
+ // (putIfAbsent, addAll, toList, firstWhere, ...) onto Object.prototype, so
1184
+ // "'putIfAbsent' in {}" is true for EVERY object. That made
1185
+ // map.containsKey(name) answer true for any Dart-SDK method name (and for
1186
+ // 'toString'/'constructor'/'hasOwnProperty'), which in the self-hosted engine
1187
+ // made _Scope.has(name) claim every such identifier was a bound variable and
1188
+ // then hand back the polyfill instead of the user's own function or method
1189
+ // (issue #494's fixture 416 hit this on a user method named putIfAbsent).
1190
+ // A hit that exists ONLY as an own property of Object.prototype is prototype
1191
+ // pollution, not a map entry.
1192
+ function __ball_map_has(v: any, opName: string, k: any): boolean {
1193
+ const m = __ball_require_map(v, opName);
1194
+ if (m instanceof Map) return m.has(k);
1195
+ if (!(k in m)) return false;
1196
+ if (Object.prototype.hasOwnProperty.call(Object.prototype, k) &&
1197
+ !Object.prototype.hasOwnProperty.call(m, k)) {
1198
+ return false;
1199
+ }
1200
+ return true;
1201
+ }
1202
+
1181
1203
  // ── Protobuf Struct/Value compatibility ─────────────────────────
1182
1204
  //
1183
1205
  // Dart's protobuf runtime wraps google.protobuf.Struct as a class
@@ -1929,7 +1951,7 @@ export class BallEngine {
1929
1951
 
1930
1952
  _resolveInstanceMethodDispatch(typeName: any, methodName: any): any {
1931
1953
  let cacheKey = BallEngine._typeMethodKey(typeName, methodName);
1932
- if ((cacheKey in __ball_require_map(this._instanceMethodCache, 'map_contains_key'))) {
1954
+ if (__ball_map_has(this._instanceMethodCache, 'map_contains_key', cacheKey)) {
1933
1955
  return __ball_index(this._instanceMethodCache, cacheKey);
1934
1956
  }
1935
1957
  let resolved = (this._resolveMethod(typeName, methodName) ?? this._lookupTypeMethodWithInheritance(typeName, methodName));
@@ -2106,7 +2128,7 @@ export class BallEngine {
2106
2128
  let dotIdx = func.name.indexOf('.');
2107
2129
  let typeName = (__ball_ge(dotIdx, 0) ? func.name.substring(0, dotIdx) : func.name);
2108
2130
  let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
2109
- if (((!isFactory && (__ball_eq(constructorInput, null) || !('self' in __ball_require_map(constructorInput, 'map_contains_key')))) && !__ball_eq(this._findTypeDef(typeName), null))) {
2131
+ if (((!isFactory && (__ball_eq(constructorInput, null) || !__ball_map_has(constructorInput, 'map_contains_key', 'self'))) && !__ball_eq(this._findTypeDef(typeName), null))) {
2110
2132
  return await this._callObjectConstructor(moduleName, func, input);
2111
2133
  }
2112
2134
  }
@@ -2119,11 +2141,11 @@ export class BallEngine {
2119
2141
  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) : [])));
2120
2142
  let inputMap = this._asMap(input);
2121
2143
  if (!(params.length === 0)) {
2122
- if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key'))))) {
2123
- if ((!__ball_eq(inputMap, null) && (__ball_index(params, 0) in __ball_require_map(inputMap, 'map_contains_key')))) {
2144
+ if ((__ball_eq(params.length, 1) && !(!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'self')))) {
2145
+ if ((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', __ball_index(params, 0)))) {
2124
2146
  scope.bind(__ball_index(params, 0), __ball_index(inputMap, __ball_index(params, 0)));
2125
2147
  } else {
2126
- 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')))) {
2148
+ if (((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'arg0')) && !__ball_map_has(inputMap, 'map_contains_key', __ball_index(params, 0)))) {
2127
2149
  scope.bind(__ball_index(params, 0), __ball_index(inputMap, 'arg0'));
2128
2150
  } else {
2129
2151
  scope.bind(__ball_index(params, 0), input);
@@ -2133,13 +2155,13 @@ export class BallEngine {
2133
2155
  if (!__ball_eq(inputMap, null)) {
2134
2156
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2135
2157
  let p = __ball_index(params, i);
2136
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
2158
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
2137
2159
  scope.bind(p, __ball_index(inputMap, p));
2138
2160
  } else {
2139
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2161
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
2140
2162
  scope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
2141
2163
  } else {
2142
- if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && ('value' in __ball_require_map(inputMap, 'map_contains_key'))) && this._isSetter(func))) {
2164
+ if ((((__ball_eq(i, 0) && __ball_eq(params.length, 1)) && __ball_map_has(inputMap, 'map_contains_key', 'value')) && this._isSetter(func))) {
2143
2165
  scope.bind(p, __ball_index(inputMap, 'value'));
2144
2166
  }
2145
2167
  }
@@ -2154,7 +2176,7 @@ export class BallEngine {
2154
2176
  }
2155
2177
  }
2156
2178
  }
2157
- if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
2179
+ if ((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'self'))) {
2158
2180
  let self = __ball_index(inputMap, 'self');
2159
2181
  scope.bind('self', self);
2160
2182
  let selfMap = this._asMap(self);
@@ -2216,7 +2238,7 @@ export class BallEngine {
2216
2238
  } else {
2217
2239
  let result = await this._evalExpression(func.body, scope);
2218
2240
  this._currentModule = prevModule;
2219
- if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
2241
+ if (((__ball_eq(kind, 'constructor') && !__ball_eq(inputMap, null)) && __ball_map_has(inputMap, 'map_contains_key', 'self'))) {
2220
2242
  let isFactory = (hasMetadata(func) && _metadataBool(__ball_index(func.metadata.fields, 'is_factory')));
2221
2243
  if (((result instanceof _FlowSignal) && __ball_eq(result.kind, 'return'))) {
2222
2244
  finalResult = result.value;
@@ -2284,14 +2306,14 @@ export class BallEngine {
2284
2306
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
2285
2307
  let param = __ball_index(params, i);
2286
2308
  let value;
2287
- if ((param in __ball_require_map(inputMap, 'map_contains_key'))) {
2309
+ if (__ball_map_has(inputMap, 'map_contains_key', param)) {
2288
2310
  value = __ball_index(inputMap, param);
2289
2311
  } else {
2290
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2312
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
2291
2313
  value = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
2292
2314
  }
2293
2315
  }
2294
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
2316
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && __ball_map_has(__ball_index(paramsMeta, i), 'map_contains_key', 'default'))) {
2295
2317
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
2296
2318
  }
2297
2319
  resolvedParams[param] = value;
@@ -2322,7 +2344,7 @@ export class BallEngine {
2322
2344
  })();
2323
2345
  let constructed = await this._callFunction(moduleName, func, ctorInput);
2324
2346
  let constructedMap = this._asMap(constructed);
2325
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
2347
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
2326
2348
  return constructed;
2327
2349
  }
2328
2350
  return instance;
@@ -2413,10 +2435,10 @@ export class BallEngine {
2413
2435
  let p = __ball_index(params, i);
2414
2436
  let isThis = (__ball_lt(i, paramsMeta.length) && __ball_eq(__ball_index(__ball_index(paramsMeta, i), 'is_this'), true));
2415
2437
  let val;
2416
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
2438
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
2417
2439
  val = __ball_index(inputMap, p);
2418
2440
  } else {
2419
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
2441
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
2420
2442
  val = __ball_index(inputMap, ('arg' + __ball_to_string(i)));
2421
2443
  } else {
2422
2444
  val = (__ball_lt(i, paramsMeta.length) ? __ball_index(__ball_index(paramsMeta, i), 'default') : null);
@@ -2452,7 +2474,7 @@ export class BallEngine {
2452
2474
  if (!__ball_eq(superMap, null)) {
2453
2475
  instance['__super__'] = superInstance;
2454
2476
  for (const e of superMap.entries) {
2455
- if ((!e.key.startsWith('__') && !(e.key in __ball_require_map(instance, 'map_contains_key')))) {
2477
+ if ((!e.key.startsWith('__') && !__ball_map_has(instance, 'map_contains_key', e.key))) {
2456
2478
  instance[e.key] = e.value;
2457
2479
  }
2458
2480
  }
@@ -2495,7 +2517,7 @@ export class BallEngine {
2495
2517
  let superInput = {};
2496
2518
  for (let i = 0; __ball_lt(i, argNames.length); (i++)) {
2497
2519
  let token = __ball_index(argNames, i);
2498
- if ((token in __ball_require_map(resolvedParams, 'map_contains_key'))) {
2520
+ if (__ball_map_has(resolvedParams, 'map_contains_key', token)) {
2499
2521
  superInput[('arg' + __ball_to_string(i))] = __ball_index(resolvedParams, token);
2500
2522
  } else {
2501
2523
  if (((token.startsWith('\'') && token.endsWith('\'')) || (token.startsWith('"') && token.endsWith('"')))) {
@@ -3114,7 +3136,7 @@ export class BallEngine {
3114
3136
 
3115
3137
  static _extractMetadataTypeArgs(msg: any): any {
3116
3138
  const input = msg;
3117
- if ((!hasMetadata(msg) || !('type_args' in __ball_require_map(msg.metadata.fields, 'map_contains_key')))) {
3139
+ if ((!hasMetadata(msg) || !__ball_map_has(msg.metadata.fields, 'map_contains_key', 'type_args'))) {
3118
3140
  return null;
3119
3141
  }
3120
3142
  return [...__ball_index(msg.metadata.fields, 'type_args').listValue.values.map(BallEngine._typeRefValueToString)];
@@ -3297,7 +3319,7 @@ export class BallEngine {
3297
3319
  }
3298
3320
  }
3299
3321
  let inputMap = this._asMap(input);
3300
- if ((!__ball_eq(inputMap, null) && ('self' in __ball_require_map(inputMap, 'map_contains_key')))) {
3322
+ if ((!__ball_eq(inputMap, null) && __ball_map_has(inputMap, 'map_contains_key', 'self'))) {
3301
3323
  let self = __ball_index(inputMap, 'self');
3302
3324
  let selfMap = this._asMap(self);
3303
3325
  if (!__ball_eq(selfMap, null)) {
@@ -3334,7 +3356,7 @@ export class BallEngine {
3334
3356
  let methodOwner = selfMap;
3335
3357
  while (!__ball_eq(methodOwner, null)) {
3336
3358
  let methods = __ball_index(methodOwner, '__methods__');
3337
- 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')))) {
3359
+ if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && __ball_map_has(methods, 'map_contains_key', call.function))) {
3338
3360
  let method = __ball_index(methods, call.function);
3339
3361
  if ((typeof method === 'function')) {
3340
3362
  let result = method(input);
@@ -3358,7 +3380,7 @@ export class BallEngine {
3358
3380
  }
3359
3381
  }
3360
3382
  let fallbackMap = this._asMap(input);
3361
- if ((!__ball_eq(fallbackMap, null) && ('self' in __ball_require_map(fallbackMap, 'map_contains_key')))) {
3383
+ if ((!__ball_eq(fallbackMap, null) && __ball_map_has(fallbackMap, 'map_contains_key', 'self'))) {
3362
3384
  let selfFallback = __ball_index(fallbackMap, 'self');
3363
3385
  let selfFallbackMap = this._asMap(selfFallback);
3364
3386
  if (!__ball_eq(selfFallbackMap, null)) {
@@ -3688,12 +3710,12 @@ export class BallEngine {
3688
3710
  }
3689
3711
  if (!_builtinTypeNames.includes(name)) {
3690
3712
  let qualifiedName = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(name));
3691
- let hasCtor = ((name in __ball_require_map(this._constructors, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._constructors, 'map_contains_key')));
3713
+ let hasCtor = (__ball_map_has(this._constructors, 'map_contains_key', name) || __ball_map_has(this._constructors, 'map_contains_key', qualifiedName));
3692
3714
  let hasStaticMethods = this._functions.keys.some(((k) => {
3693
3715
  const input = k;
3694
3716
  return (k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(qualifiedName)) + '.')) || k.startsWith((((__ball_to_string(this._currentModule) + '.') + __ball_to_string(name)) + '.')));
3695
3717
  }));
3696
- let typeExists = ((name in __ball_require_map(this._types, 'map_contains_key')) || (qualifiedName in __ball_require_map(this._types, 'map_contains_key')));
3718
+ let typeExists = (__ball_map_has(this._types, 'map_contains_key', name) || __ball_map_has(this._types, 'map_contains_key', qualifiedName));
3697
3719
  if ((typeExists && (hasCtor || hasStaticMethods))) {
3698
3720
  return { ['__class_ref__']: name, ['__type__']: '__class__' };
3699
3721
  }
@@ -3713,7 +3735,7 @@ export class BallEngine {
3713
3735
  if (!__ball_eq(selfForGetter, null)) {
3714
3736
  let selfMap = this._asMap(selfForGetter);
3715
3737
  if (!__ball_eq(selfMap, null)) {
3716
- if ((name in __ball_require_map(selfMap, 'map_contains_key'))) {
3738
+ if (__ball_map_has(selfMap, 'map_contains_key', name)) {
3717
3739
  let direct = __ball_index(selfMap, name);
3718
3740
  if (!__ball_eq(direct, null)) {
3719
3741
  return direct;
@@ -3722,7 +3744,7 @@ export class BallEngine {
3722
3744
  let superObj = __ball_index(selfMap, '__super__');
3723
3745
  let superMap = this._asMap(superObj);
3724
3746
  while (!__ball_eq(superMap, null)) {
3725
- if ((name in __ball_require_map(superMap, 'map_contains_key'))) {
3747
+ if (__ball_map_has(superMap, 'map_contains_key', name)) {
3726
3748
  let inherited = __ball_index(superMap, name);
3727
3749
  if (!__ball_eq(inherited, null)) {
3728
3750
  return inherited;
@@ -3848,25 +3870,25 @@ export class BallEngine {
3848
3870
  });
3849
3871
  }
3850
3872
  let enumVals = (__ball_index(this._enumValues, className) ?? __ball_index(this._enumValues, qualifiedName));
3851
- if ((!__ball_eq(enumVals, null) && (fieldName in __ball_require_map(enumVals, 'map_contains_key')))) {
3873
+ if ((!__ball_eq(enumVals, null) && __ball_map_has(enumVals, 'map_contains_key', fieldName))) {
3852
3874
  return __ball_index(enumVals, fieldName);
3853
3875
  }
3854
3876
  }
3855
3877
  if (!__ball_eq(objectMap, null)) {
3856
- if ((fieldName in __ball_require_map(objectMap, 'map_contains_key'))) {
3878
+ if (__ball_map_has(objectMap, 'map_contains_key', fieldName)) {
3857
3879
  return __ball_index(objectMap, fieldName);
3858
3880
  }
3859
3881
  let superObj = __ball_index(objectMap, '__super__');
3860
3882
  let superMap = this._asMap(superObj);
3861
3883
  while (!__ball_eq(superMap, null)) {
3862
- if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
3884
+ if (__ball_map_has(superMap, 'map_contains_key', fieldName)) {
3863
3885
  return __ball_index(superMap, fieldName);
3864
3886
  }
3865
3887
  superObj = __ball_index(superMap, '__super__');
3866
3888
  superMap = this._asMap(superObj);
3867
3889
  }
3868
3890
  let methods = __ball_index(objectMap, '__methods__');
3869
- if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && (fieldName in __ball_require_map(methods, 'map_contains_key')))) {
3891
+ if (((typeof methods === 'object' && methods !== null && !Array.isArray(methods) && !(methods instanceof BallDouble) && !(methods instanceof Set)) && __ball_map_has(methods, 'map_contains_key', fieldName))) {
3870
3892
  let method = __ball_index(methods, fieldName);
3871
3893
  if ((typeof method === 'function')) {
3872
3894
  return method;
@@ -3876,7 +3898,7 @@ export class BallEngine {
3876
3898
  superMap = this._asMap(superObj);
3877
3899
  while (!__ball_eq(superMap, null)) {
3878
3900
  let superMethods = __ball_index(superMap, '__methods__');
3879
- if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && (fieldName in __ball_require_map(superMethods, 'map_contains_key')))) {
3901
+ if (((typeof superMethods === 'object' && superMethods !== null && !Array.isArray(superMethods) && !(superMethods instanceof BallDouble) && !(superMethods instanceof Set)) && __ball_map_has(superMethods, 'map_contains_key', fieldName))) {
3880
3902
  let method = __ball_index(superMethods, fieldName);
3881
3903
  if ((typeof method === 'function')) {
3882
3904
  return method;
@@ -3904,7 +3926,7 @@ export class BallEngine {
3904
3926
  }))];
3905
3927
  if ((!(vals.length === 0) && vals.every(((v) => {
3906
3928
  const input = v;
3907
- 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')));
3929
+ 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__'));
3908
3930
  })))) {
3909
3931
  vals = [...vals].sort(((a, b) => {
3910
3932
  return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
@@ -4021,7 +4043,7 @@ export class BallEngine {
4021
4043
  }))];
4022
4044
  if ((!(vals.length === 0) && vals.every(((v) => {
4023
4045
  const input = v;
4024
- 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')));
4046
+ 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__'));
4025
4047
  })))) {
4026
4048
  vals = [...vals].sort(((a, b) => {
4027
4049
  return (__ball_index(a, 'index') < __ball_index(b, 'index') ? -1 : __ball_index(a, 'index') > __ball_index(b, 'index') ? 1 : 0);
@@ -4208,11 +4230,11 @@ export class BallEngine {
4208
4230
  return;
4209
4231
  }
4210
4232
  let backing = ('_' + __ball_to_string(fieldName));
4211
- if ((backing in __ball_require_map(object, 'map_contains_key'))) {
4233
+ if (__ball_map_has(object, 'map_contains_key', backing)) {
4212
4234
  ballObjectSetField(object, backing, assignedValue);
4213
4235
  return;
4214
4236
  }
4215
- if (('_celsius' in __ball_require_map(object, 'map_contains_key'))) {
4237
+ if (__ball_map_has(object, 'map_contains_key', '_celsius')) {
4216
4238
  ballObjectSetField(object, '_celsius', assignedValue);
4217
4239
  }
4218
4240
  }
@@ -4228,7 +4250,7 @@ export class BallEngine {
4228
4250
  let superObj = __ball_index(selfMap, '__super__');
4229
4251
  let superMap = this._asMap(superObj);
4230
4252
  while (!__ball_eq(superMap, null)) {
4231
- if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
4253
+ if (__ball_map_has(superMap, 'map_contains_key', fieldName)) {
4232
4254
  ballObjectSetField(superObj, fieldName, val);
4233
4255
  }
4234
4256
  superObj = __ball_index(superMap, '__super__');
@@ -4243,7 +4265,7 @@ export class BallEngine {
4243
4265
  let fields = {};
4244
4266
  for (const pair of msg.fields) {
4245
4267
  let val = await this._evalExpression(pair.value, scope);
4246
- if ((pair.name in __ball_require_map(fields, 'map_contains_key'))) {
4268
+ if (__ball_map_has(fields, 'map_contains_key', pair.name)) {
4247
4269
  let existing = __ball_index(fields, pair.name);
4248
4270
  if (Array.isArray(existing)) {
4249
4271
  let merged = ([...existing]);
@@ -4276,7 +4298,7 @@ export class BallEngine {
4276
4298
  }
4277
4299
  this._initFieldDefaults(msg.typeName, instanceFields);
4278
4300
  for (const fieldName of typeDef.fieldNames) {
4279
- if (!(fieldName in __ball_require_map(instanceFields, 'map_contains_key'))) {
4301
+ if (!__ball_map_has(instanceFields, 'map_contains_key', fieldName)) {
4280
4302
  instanceFields[fieldName] = null;
4281
4303
  }
4282
4304
  }
@@ -4288,14 +4310,14 @@ export class BallEngine {
4288
4310
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
4289
4311
  let param = __ball_index(params, i);
4290
4312
  let value;
4291
- if ((param in __ball_require_map(fields, 'map_contains_key'))) {
4313
+ if (__ball_map_has(fields, 'map_contains_key', param)) {
4292
4314
  value = __ball_index(fields, param);
4293
4315
  } else {
4294
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(fields, 'map_contains_key'))) {
4316
+ if (__ball_map_has(fields, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
4295
4317
  value = __ball_index(fields, ('arg' + __ball_to_string(i)));
4296
4318
  }
4297
4319
  }
4298
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
4320
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && __ball_map_has(__ball_index(paramsMeta, i), 'map_contains_key', 'default'))) {
4299
4321
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
4300
4322
  }
4301
4323
  resolvedParams[param] = value;
@@ -4318,7 +4340,7 @@ export class BallEngine {
4318
4340
  superObject = (__ball_eq(ctorEntry, null) ? null : await this._invokeSuperConstructor(ctorEntry.func, superclass, resolvedParams));
4319
4341
  superObject ??= this._buildSuperObject(superclass, instanceFields);
4320
4342
  }
4321
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4343
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4322
4344
  let metaTypeArgs = BallEngine._extractMetadataTypeArgs(msg);
4323
4345
  if (!__ball_eq(metaTypeArgs, null)) {
4324
4346
  instanceFields['__type_args__'] = metaTypeArgs;
@@ -4356,7 +4378,7 @@ export class BallEngine {
4356
4378
  })();
4357
4379
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4358
4380
  let constructedMap = this._asMap(constructed);
4359
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4381
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4360
4382
  return constructed;
4361
4383
  }
4362
4384
  return instance;
@@ -4377,7 +4399,7 @@ export class BallEngine {
4377
4399
  instanceFields[entry.key] = entry.value;
4378
4400
  }
4379
4401
  }
4380
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4402
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4381
4403
  let metaTA = BallEngine._extractMetadataTypeArgs(msg);
4382
4404
  if (!__ball_eq(metaTA, null)) {
4383
4405
  instanceFields['__type_args__'] = metaTA;
@@ -4393,13 +4415,13 @@ export class BallEngine {
4393
4415
  })();
4394
4416
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4395
4417
  let constructedMap = this._asMap(constructed);
4396
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4418
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4397
4419
  return constructed;
4398
4420
  }
4399
4421
  return instance;
4400
4422
  }
4401
4423
  fields['__type__'] = msg.typeName;
4402
- if (!('__type_args__' in __ball_require_map(fields, 'map_contains_key'))) {
4424
+ if (!__ball_map_has(fields, 'map_contains_key', '__type_args__')) {
4403
4425
  let metaTA2 = BallEngine._extractMetadataTypeArgs(msg);
4404
4426
  if (!__ball_eq(metaTA2, null)) {
4405
4427
  fields['__type_args__'] = metaTA2;
@@ -4521,7 +4543,7 @@ export class BallEngine {
4521
4543
  let __naa_10 = __ball_index(fv.structValue.fields, 'name');
4522
4544
  return (__ball_eq(__naa_10, null) ? null : __naa_10.stringValue);
4523
4545
  })();
4524
- if ((__ball_eq(fname, null) || (fname in __ball_require_map(fields, 'map_contains_key')))) {
4546
+ if ((__ball_eq(fname, null) || __ball_map_has(fields, 'map_contains_key', fname))) {
4525
4547
  continue;
4526
4548
  }
4527
4549
  let init = (() => {
@@ -4627,13 +4649,13 @@ export class BallEngine {
4627
4649
  let parentTypeDef = this._findTypeDef(superclass);
4628
4650
  if (!__ball_eq(parentTypeDef, null)) {
4629
4651
  for (const fname of parentTypeDef.fieldNames) {
4630
- if ((fname in __ball_require_map(childFields, 'map_contains_key'))) {
4652
+ if (__ball_map_has(childFields, 'map_contains_key', fname)) {
4631
4653
  superFields[fname] = __ball_index(childFields, fname);
4632
4654
  }
4633
4655
  }
4634
4656
  this._initFieldDefaults(superclass, superFields);
4635
4657
  for (const fname of parentTypeDef.fieldNames) {
4636
- if (!(fname in __ball_require_map(superFields, 'map_contains_key'))) {
4658
+ if (!__ball_map_has(superFields, 'map_contains_key', fname)) {
4637
4659
  superFields[fname] = null;
4638
4660
  }
4639
4661
  }
@@ -4792,10 +4814,10 @@ export class BallEngine {
4792
4814
  for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
4793
4815
  let p = __ball_index(paramNames, i);
4794
4816
  if (!lambdaScope.has(p)) {
4795
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
4817
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
4796
4818
  lambdaScope.bind(p, __ball_index(inputMap, p));
4797
4819
  } else {
4798
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
4820
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
4799
4821
  lambdaScope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
4800
4822
  }
4801
4823
  }
@@ -4976,7 +4998,7 @@ export class BallEngine {
4976
4998
  propVal = obj.length;
4977
4999
  } else {
4978
5000
  let map = this._cfAsMap(obj);
4979
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5001
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
4980
5002
  let v = __ball_index(map, prop);
4981
5003
  if ((typeof v === 'number' || v instanceof BallDouble)) {
4982
5004
  propVal = v;
@@ -5046,7 +5068,7 @@ export class BallEngine {
5046
5068
  return obj.length;
5047
5069
  }
5048
5070
  let map = this._cfAsMap(obj);
5049
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5071
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
5050
5072
  return __ball_index(map, prop);
5051
5073
  }
5052
5074
  }
@@ -5362,7 +5384,7 @@ export class BallEngine {
5362
5384
  }
5363
5385
  }
5364
5386
  let enumVals = __ball_index(this._enumValues, enumType);
5365
- if ((!__ball_eq(enumVals, null) && (enumValue in __ball_require_map(enumVals, 'map_contains_key')))) {
5387
+ if ((!__ball_eq(enumVals, null) && __ball_map_has(enumVals, 'map_contains_key', enumValue))) {
5366
5388
  let resolved = __ball_index(enumVals, enumValue);
5367
5389
  let resolvedMap = this._cfAsMap(resolved);
5368
5390
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -5371,7 +5393,7 @@ export class BallEngine {
5371
5393
  }
5372
5394
  let qualifiedEnumType = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(enumType));
5373
5395
  let qualEnumVals = __ball_index(this._enumValues, qualifiedEnumType);
5374
- if ((!__ball_eq(qualEnumVals, null) && (enumValue in __ball_require_map(qualEnumVals, 'map_contains_key')))) {
5396
+ if ((!__ball_eq(qualEnumVals, null) && __ball_map_has(qualEnumVals, 'map_contains_key', enumValue))) {
5375
5397
  let resolved = __ball_index(qualEnumVals, enumValue);
5376
5398
  let resolvedMap = this._cfAsMap(resolved);
5377
5399
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -6542,13 +6564,13 @@ export class BallEngine {
6542
6564
  let seen = {};
6543
6565
  let result = [];
6544
6566
  for (const item of self) {
6545
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6567
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6546
6568
  seen[item] = item;
6547
6569
  result = (result.push(item), result);
6548
6570
  }
6549
6571
  }
6550
6572
  for (const item of other) {
6551
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6573
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6552
6574
  seen[item] = item;
6553
6575
  result = (result.push(item), result);
6554
6576
  }
@@ -6805,7 +6827,7 @@ export class BallEngine {
6805
6827
  } while (false);
6806
6828
  }
6807
6829
  let selfMap = this._cfAsMap(self);
6808
- if ((!__ball_eq(selfMap, null) && ('__type__' in __ball_require_map(selfMap, 'map_contains_key')))) {
6830
+ if ((!__ball_eq(selfMap, null) && __ball_map_has(selfMap, 'map_contains_key', '__type__'))) {
6809
6831
  let typeName = __ball_index(selfMap, '__type__');
6810
6832
  if ((!__ball_eq(typeName, null) && (typeName.endsWith(':StringBuffer') || __ball_eq(typeName, 'StringBuffer')))) {
6811
6833
  do {
@@ -6921,7 +6943,7 @@ export class BallEngine {
6921
6943
  right = __ball_index(m, 'right');
6922
6944
  }
6923
6945
  let leftMap = this._stdAsMap(left);
6924
- if ((__ball_eq(leftMap, null) || !('__type__' in __ball_require_map(leftMap, 'map_contains_key')))) {
6946
+ if ((__ball_eq(leftMap, null) || !__ball_map_has(leftMap, 'map_contains_key', '__type__'))) {
6925
6947
  return null;
6926
6948
  }
6927
6949
  let typeName = __ball_index(leftMap, '__type__');
@@ -6988,7 +7010,7 @@ export class BallEngine {
6988
7010
  }
6989
7011
 
6990
7012
  async _callBaseFunction(module: any, function_: any, input: any): Promise<any> {
6991
- if ((function_ in __ball_require_map(_stdFunctionToOperator, 'map_contains_key'))) {
7013
+ if (__ball_map_has(_stdFunctionToOperator, 'map_contains_key', function_)) {
6992
7014
  let override = await this._tryOperatorOverride(function_, input);
6993
7015
  if (!__ball_eq(override, null)) {
6994
7016
  return this._consumeGeneratorFlow(override);
@@ -7532,15 +7554,15 @@ export class BallEngine {
7532
7554
  let list = this._stdAsList(__ball_index(m, 'list'));
7533
7555
  let s;
7534
7556
  let e;
7535
- if (('start' in __ball_require_map(m, 'map_contains_key'))) {
7557
+ if (__ball_map_has(m, 'map_contains_key', 'start')) {
7536
7558
  s = this._toInt(__ball_index(m, 'start'));
7537
7559
  e = (!__ball_eq(__ball_index(m, 'end'), null) ? this._toInt(__ball_index(m, 'end')) : null);
7538
7560
  } else {
7539
- if ((('arg0' in __ball_require_map(m, 'map_contains_key')) && ('arg1' in __ball_require_map(m, 'map_contains_key')))) {
7561
+ if ((__ball_map_has(m, 'map_contains_key', 'arg0') && __ball_map_has(m, 'map_contains_key', 'arg1'))) {
7540
7562
  s = this._toInt(__ball_index(m, 'arg0'));
7541
7563
  e = this._toInt(__ball_index(m, 'arg1'));
7542
7564
  } else {
7543
- if (('value' in __ball_require_map(m, 'map_contains_key'))) {
7565
+ if (__ball_map_has(m, 'map_contains_key', 'value')) {
7544
7566
  let v = __ball_index(m, 'value');
7545
7567
  if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
7546
7568
  s = this._toInt(__ball_index(v, 0));
@@ -7743,7 +7765,7 @@ export class BallEngine {
7743
7765
  let m = this._stdAsMap(i);
7744
7766
  let map = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
7745
7767
  let key = __ball_index(m, 'key');
7746
- if (!(key in __ball_require_map(map, 'map_contains_key'))) {
7768
+ if (!__ball_map_has(map, 'map_contains_key', key)) {
7747
7769
  this._trackMemoryAllocation(_ballMapEntryBytes);
7748
7770
  let val = __ball_index(m, 'value');
7749
7771
  map[key] = ((typeof val === 'function') ? val() : val);
@@ -7937,7 +7959,7 @@ export class BallEngine {
7937
7959
  let valMap = this._stdAsMap(val);
7938
7960
  if (!__ball_eq(valMap, null)) {
7939
7961
  typeName = ((__ball_index(valMap, '__type__') ?? __ball_index(valMap, '__type')) ?? 'Exception');
7940
- if ((!('message' in __ball_require_map(valMap, 'map_contains_key')) && ('arg0' in __ball_require_map(valMap, 'map_contains_key')))) {
7962
+ if ((!__ball_map_has(valMap, 'map_contains_key', 'message') && __ball_map_has(valMap, 'map_contains_key', 'arg0'))) {
7941
7963
  valMap['message'] = __ball_index(valMap, 'arg0');
7942
7964
  }
7943
7965
  }
@@ -8541,7 +8563,7 @@ export class BallEngine {
8541
8563
 
8542
8564
  async _stdPrint(input: any): Promise<any> {
8543
8565
  let m = this._stdAsMap(input);
8544
- 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'))))) {
8566
+ 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')))) {
8545
8567
  let message = ((__ball_index(m, 'message') ?? __ball_index(m, 'arg0')) ?? __ball_index(m, 'value'));
8546
8568
  this.stdout(await this._ballToStringAsync(message));
8547
8569
  return null;
@@ -8634,7 +8656,7 @@ export class BallEngine {
8634
8656
  }
8635
8657
  return (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8636
8658
  }
8637
- if (('__tostring_guard__' in __ball_require_map(map, 'map_contains_key'))) {
8659
+ if (__ball_map_has(map, 'map_contains_key', '__tostring_guard__')) {
8638
8660
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8639
8661
  return (__ball_to_string(shortType) + '{...}');
8640
8662
  }
@@ -9258,7 +9280,7 @@ export class BallEngine {
9258
9280
  return false;
9259
9281
  }
9260
9282
  let key = __ball_index(entryMap, 'key');
9261
- if (!(key in __ball_require_map(rawMap, 'map_contains_key'))) {
9283
+ if (!__ball_map_has(rawMap, 'map_contains_key', key)) {
9262
9284
  return false;
9263
9285
  }
9264
9286
  if (!this._matchPattern(__ball_index(rawMap, key), __ball_index(entryMap, 'value'), bindings)) {
@@ -9298,7 +9320,7 @@ export class BallEngine {
9298
9320
  return false;
9299
9321
  }
9300
9322
  for (const entry of recFields.entries) {
9301
- if (!(entry.key in __ball_require_map(recMap, 'map_contains_key'))) {
9323
+ if (!__ball_map_has(recMap, 'map_contains_key', entry.key)) {
9302
9324
  return false;
9303
9325
  }
9304
9326
  let fieldVal = __ball_index(recMap, entry.key);
@@ -9463,7 +9485,7 @@ export class BallEngine {
9463
9485
  let map = this._stdAsMap(v);
9464
9486
  if (!__ball_eq(map, null)) {
9465
9487
  let typeName = __ball_index(map, '__type__');
9466
- if ((!__ball_eq(typeName, null) && (typeName in __ball_require_map(this._enumValues, 'map_contains_key')))) {
9488
+ if ((!__ball_eq(typeName, null) && __ball_map_has(this._enumValues, 'map_contains_key', typeName))) {
9467
9489
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
9468
9490
  let valName = __ball_index(map, 'name');
9469
9491
  if (!__ball_eq(valName, null)) {
@@ -10089,7 +10111,7 @@ export class _Scope {
10089
10111
 
10090
10112
  lookup(name: any): any {
10091
10113
  const input = name;
10092
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10114
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10093
10115
  return __ball_index(this._bindings, name);
10094
10116
  }
10095
10117
  if (!__ball_eq(this._parent, null)) {
@@ -10104,14 +10126,14 @@ export class _Scope {
10104
10126
 
10105
10127
  has(name: any): any {
10106
10128
  const input = name;
10107
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10129
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10108
10130
  return true;
10109
10131
  }
10110
10132
  return ((__ball_eq(this._parent, null) ? null : this._parent.has(name)) ?? false);
10111
10133
  }
10112
10134
 
10113
10135
  set(name: any, value: any): any {
10114
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10136
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10115
10137
  this._bindings[name] = value;
10116
10138
  return;
10117
10139
  }
@@ -10229,7 +10251,7 @@ export class StdModuleHandler extends BallModuleHandler {
10229
10251
  if (this._tombstones.includes(entry.key)) {
10230
10252
  continue;
10231
10253
  }
10232
- if ((entry.key in __ball_require_map(this._composedDispatch, 'map_contains_key'))) {
10254
+ if (__ball_map_has(this._composedDispatch, 'map_contains_key', entry.key)) {
10233
10255
  continue;
10234
10256
  }
10235
10257
  if ((!__ball_eq(allowlist, null) && !allowlist.includes(entry.key))) {
@@ -10342,7 +10364,7 @@ function _ballToDouble(value: any): any {
10342
10364
 
10343
10365
  function _ballValueIsSet(v: any): any {
10344
10366
  const input = v;
10345
- return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && (_kBallSetTag in __ball_require_map(v, 'map_contains_key')));
10367
+ return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && __ball_map_has(v, 'map_contains_key', _kBallSetTag));
10346
10368
  }
10347
10369
 
10348
10370
  function _ballIsInt(v: any): any {
@@ -10419,7 +10441,7 @@ function _ballMapValuesDyn(map: any): any {
10419
10441
  function _ballMapContainsKeyDyn(map: any, key: any): any {
10420
10442
  let handle = _ballMapHandleEntries(map);
10421
10443
  if ((typeof handle === 'object' && handle !== null && !Array.isArray(handle) && !(handle instanceof BallDouble) && !(handle instanceof Set))) {
10422
- return (key in __ball_require_map(handle, 'map_contains_key'));
10444
+ return __ball_map_has(handle, 'map_contains_key', key);
10423
10445
  }
10424
10446
  return false;
10425
10447
  }
@@ -10437,12 +10459,12 @@ function ballObjectSetField(target: any, fieldName: any, val: any): any {
10437
10459
  return;
10438
10460
  }
10439
10461
  if (false /* BallMap is Map in TS */) {
10440
- if (('__type__' in __ball_require_map(target.entries, 'map_contains_key'))) {
10462
+ if (__ball_map_has(target.entries, 'map_contains_key', '__type__')) {
10441
10463
  target[fieldName] = val;
10442
10464
  }
10443
10465
  return;
10444
10466
  }
10445
- if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in __ball_require_map(target, 'map_contains_key')))) {
10467
+ if ((__ball_is_type(target, "Map<String, Object?>") && __ball_map_has(target, 'map_contains_key', '__type__'))) {
10446
10468
  target[fieldName] = val;
10447
10469
  }
10448
10470
  }
@@ -10543,7 +10565,7 @@ function _unwrapBallFuture(value: any): any {
10543
10565
  const input = value;
10544
10566
  if (_isBallFuture(value)) {
10545
10567
  let map = value;
10546
- if (('error' in __ball_require_map(map, 'map_contains_key'))) {
10568
+ if (__ball_map_has(map, 'map_contains_key', 'error')) {
10547
10569
  let error = __ball_index(map, 'error');
10548
10570
  if ((error instanceof BallException)) {
10549
10571
  throw error;