@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.
@@ -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);
@@ -4170,6 +4192,9 @@ export class BallEngine {
4170
4192
  if (__ball_eq(typeName, null)) {
4171
4193
  return _sentinel;
4172
4194
  }
4195
+ if (__ball_map_has(object, 'map_contains_key', fieldName)) {
4196
+ return _sentinel;
4197
+ }
4173
4198
  let colonIdx = typeName.indexOf(':');
4174
4199
  let modPart = (__ball_ge(colonIdx, 0) ? typeName.substring(0, colonIdx) : this._currentModule);
4175
4200
  let setterKey = (((((__ball_to_string(modPart) + '.') + __ball_to_string(typeName)) + '.') + __ball_to_string(fieldName)) + '=');
@@ -4208,11 +4233,11 @@ export class BallEngine {
4208
4233
  return;
4209
4234
  }
4210
4235
  let backing = ('_' + __ball_to_string(fieldName));
4211
- if ((backing in __ball_require_map(object, 'map_contains_key'))) {
4236
+ if (__ball_map_has(object, 'map_contains_key', backing)) {
4212
4237
  ballObjectSetField(object, backing, assignedValue);
4213
4238
  return;
4214
4239
  }
4215
- if (('_celsius' in __ball_require_map(object, 'map_contains_key'))) {
4240
+ if (__ball_map_has(object, 'map_contains_key', '_celsius')) {
4216
4241
  ballObjectSetField(object, '_celsius', assignedValue);
4217
4242
  }
4218
4243
  }
@@ -4228,7 +4253,7 @@ export class BallEngine {
4228
4253
  let superObj = __ball_index(selfMap, '__super__');
4229
4254
  let superMap = this._asMap(superObj);
4230
4255
  while (!__ball_eq(superMap, null)) {
4231
- if ((fieldName in __ball_require_map(superMap, 'map_contains_key'))) {
4256
+ if (__ball_map_has(superMap, 'map_contains_key', fieldName)) {
4232
4257
  ballObjectSetField(superObj, fieldName, val);
4233
4258
  }
4234
4259
  superObj = __ball_index(superMap, '__super__');
@@ -4243,7 +4268,7 @@ export class BallEngine {
4243
4268
  let fields = {};
4244
4269
  for (const pair of msg.fields) {
4245
4270
  let val = await this._evalExpression(pair.value, scope);
4246
- if ((pair.name in __ball_require_map(fields, 'map_contains_key'))) {
4271
+ if (__ball_map_has(fields, 'map_contains_key', pair.name)) {
4247
4272
  let existing = __ball_index(fields, pair.name);
4248
4273
  if (Array.isArray(existing)) {
4249
4274
  let merged = ([...existing]);
@@ -4276,7 +4301,7 @@ export class BallEngine {
4276
4301
  }
4277
4302
  this._initFieldDefaults(msg.typeName, instanceFields);
4278
4303
  for (const fieldName of typeDef.fieldNames) {
4279
- if (!(fieldName in __ball_require_map(instanceFields, 'map_contains_key'))) {
4304
+ if (!__ball_map_has(instanceFields, 'map_contains_key', fieldName)) {
4280
4305
  instanceFields[fieldName] = null;
4281
4306
  }
4282
4307
  }
@@ -4288,14 +4313,14 @@ export class BallEngine {
4288
4313
  for (let i = 0; __ball_lt(i, params.length); (i++)) {
4289
4314
  let param = __ball_index(params, i);
4290
4315
  let value;
4291
- if ((param in __ball_require_map(fields, 'map_contains_key'))) {
4316
+ if (__ball_map_has(fields, 'map_contains_key', param)) {
4292
4317
  value = __ball_index(fields, param);
4293
4318
  } else {
4294
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(fields, 'map_contains_key'))) {
4319
+ if (__ball_map_has(fields, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
4295
4320
  value = __ball_index(fields, ('arg' + __ball_to_string(i)));
4296
4321
  }
4297
4322
  }
4298
- if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && ('default' in __ball_require_map(__ball_index(paramsMeta, i), 'map_contains_key')))) {
4323
+ if (((__ball_eq(value, null) && __ball_lt(i, paramsMeta.length)) && __ball_map_has(__ball_index(paramsMeta, i), 'map_contains_key', 'default'))) {
4299
4324
  value = __ball_index(__ball_index(paramsMeta, i), 'default');
4300
4325
  }
4301
4326
  resolvedParams[param] = value;
@@ -4318,7 +4343,7 @@ export class BallEngine {
4318
4343
  superObject = (__ball_eq(ctorEntry, null) ? null : await this._invokeSuperConstructor(ctorEntry.func, superclass, resolvedParams));
4319
4344
  superObject ??= this._buildSuperObject(superclass, instanceFields);
4320
4345
  }
4321
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4346
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4322
4347
  let metaTypeArgs = BallEngine._extractMetadataTypeArgs(msg);
4323
4348
  if (!__ball_eq(metaTypeArgs, null)) {
4324
4349
  instanceFields['__type_args__'] = metaTypeArgs;
@@ -4356,7 +4381,7 @@ export class BallEngine {
4356
4381
  })();
4357
4382
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4358
4383
  let constructedMap = this._asMap(constructed);
4359
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4384
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4360
4385
  return constructed;
4361
4386
  }
4362
4387
  return instance;
@@ -4377,7 +4402,7 @@ export class BallEngine {
4377
4402
  instanceFields[entry.key] = entry.value;
4378
4403
  }
4379
4404
  }
4380
- if (!('__type_args__' in __ball_require_map(instanceFields, 'map_contains_key'))) {
4405
+ if (!__ball_map_has(instanceFields, 'map_contains_key', '__type_args__')) {
4381
4406
  let metaTA = BallEngine._extractMetadataTypeArgs(msg);
4382
4407
  if (!__ball_eq(metaTA, null)) {
4383
4408
  instanceFields['__type_args__'] = metaTA;
@@ -4393,13 +4418,13 @@ export class BallEngine {
4393
4418
  })();
4394
4419
  let constructed = await this._callFunction(ctorEntry.module, ctorEntry.func, ctorInput);
4395
4420
  let constructedMap = this._asMap(constructed);
4396
- if ((!__ball_eq(constructedMap, null) && ('__type__' in __ball_require_map(constructedMap, 'map_contains_key')))) {
4421
+ if ((!__ball_eq(constructedMap, null) && __ball_map_has(constructedMap, 'map_contains_key', '__type__'))) {
4397
4422
  return constructed;
4398
4423
  }
4399
4424
  return instance;
4400
4425
  }
4401
4426
  fields['__type__'] = msg.typeName;
4402
- if (!('__type_args__' in __ball_require_map(fields, 'map_contains_key'))) {
4427
+ if (!__ball_map_has(fields, 'map_contains_key', '__type_args__')) {
4403
4428
  let metaTA2 = BallEngine._extractMetadataTypeArgs(msg);
4404
4429
  if (!__ball_eq(metaTA2, null)) {
4405
4430
  fields['__type_args__'] = metaTA2;
@@ -4521,7 +4546,7 @@ export class BallEngine {
4521
4546
  let __naa_10 = __ball_index(fv.structValue.fields, 'name');
4522
4547
  return (__ball_eq(__naa_10, null) ? null : __naa_10.stringValue);
4523
4548
  })();
4524
- if ((__ball_eq(fname, null) || (fname in __ball_require_map(fields, 'map_contains_key')))) {
4549
+ if ((__ball_eq(fname, null) || __ball_map_has(fields, 'map_contains_key', fname))) {
4525
4550
  continue;
4526
4551
  }
4527
4552
  let init = (() => {
@@ -4627,13 +4652,13 @@ export class BallEngine {
4627
4652
  let parentTypeDef = this._findTypeDef(superclass);
4628
4653
  if (!__ball_eq(parentTypeDef, null)) {
4629
4654
  for (const fname of parentTypeDef.fieldNames) {
4630
- if ((fname in __ball_require_map(childFields, 'map_contains_key'))) {
4655
+ if (__ball_map_has(childFields, 'map_contains_key', fname)) {
4631
4656
  superFields[fname] = __ball_index(childFields, fname);
4632
4657
  }
4633
4658
  }
4634
4659
  this._initFieldDefaults(superclass, superFields);
4635
4660
  for (const fname of parentTypeDef.fieldNames) {
4636
- if (!(fname in __ball_require_map(superFields, 'map_contains_key'))) {
4661
+ if (!__ball_map_has(superFields, 'map_contains_key', fname)) {
4637
4662
  superFields[fname] = null;
4638
4663
  }
4639
4664
  }
@@ -4792,10 +4817,10 @@ export class BallEngine {
4792
4817
  for (let i = 0; __ball_lt(i, paramNames.length); (i++)) {
4793
4818
  let p = __ball_index(paramNames, i);
4794
4819
  if (!lambdaScope.has(p)) {
4795
- if ((p in __ball_require_map(inputMap, 'map_contains_key'))) {
4820
+ if (__ball_map_has(inputMap, 'map_contains_key', p)) {
4796
4821
  lambdaScope.bind(p, __ball_index(inputMap, p));
4797
4822
  } else {
4798
- if ((('arg' + __ball_to_string(i)) in __ball_require_map(inputMap, 'map_contains_key'))) {
4823
+ if (__ball_map_has(inputMap, 'map_contains_key', ('arg' + __ball_to_string(i)))) {
4799
4824
  lambdaScope.bind(p, __ball_index(inputMap, ('arg' + __ball_to_string(i))));
4800
4825
  }
4801
4826
  }
@@ -4976,7 +5001,7 @@ export class BallEngine {
4976
5001
  propVal = obj.length;
4977
5002
  } else {
4978
5003
  let map = this._cfAsMap(obj);
4979
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5004
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
4980
5005
  let v = __ball_index(map, prop);
4981
5006
  if ((typeof v === 'number' || v instanceof BallDouble)) {
4982
5007
  propVal = v;
@@ -5046,7 +5071,7 @@ export class BallEngine {
5046
5071
  return obj.length;
5047
5072
  }
5048
5073
  let map = this._cfAsMap(obj);
5049
- if ((!__ball_eq(map, null) && (prop in __ball_require_map(map, 'map_contains_key')))) {
5074
+ if ((!__ball_eq(map, null) && __ball_map_has(map, 'map_contains_key', prop))) {
5050
5075
  return __ball_index(map, prop);
5051
5076
  }
5052
5077
  }
@@ -5362,7 +5387,7 @@ export class BallEngine {
5362
5387
  }
5363
5388
  }
5364
5389
  let enumVals = __ball_index(this._enumValues, enumType);
5365
- if ((!__ball_eq(enumVals, null) && (enumValue in __ball_require_map(enumVals, 'map_contains_key')))) {
5390
+ if ((!__ball_eq(enumVals, null) && __ball_map_has(enumVals, 'map_contains_key', enumValue))) {
5366
5391
  let resolved = __ball_index(enumVals, enumValue);
5367
5392
  let resolvedMap = this._cfAsMap(resolved);
5368
5393
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -5371,7 +5396,7 @@ export class BallEngine {
5371
5396
  }
5372
5397
  let qualifiedEnumType = ((__ball_to_string(this._currentModule) + ':') + __ball_to_string(enumType));
5373
5398
  let qualEnumVals = __ball_index(this._enumValues, qualifiedEnumType);
5374
- if ((!__ball_eq(qualEnumVals, null) && (enumValue in __ball_require_map(qualEnumVals, 'map_contains_key')))) {
5399
+ if ((!__ball_eq(qualEnumVals, null) && __ball_map_has(qualEnumVals, 'map_contains_key', enumValue))) {
5375
5400
  let resolved = __ball_index(qualEnumVals, enumValue);
5376
5401
  let resolvedMap = this._cfAsMap(resolved);
5377
5402
  if ((!__ball_eq(subjectMap, null) && !__ball_eq(resolvedMap, null))) {
@@ -6542,13 +6567,13 @@ export class BallEngine {
6542
6567
  let seen = {};
6543
6568
  let result = [];
6544
6569
  for (const item of self) {
6545
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6570
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6546
6571
  seen[item] = item;
6547
6572
  result = (result.push(item), result);
6548
6573
  }
6549
6574
  }
6550
6575
  for (const item of other) {
6551
- if (!(item in __ball_require_map(seen, 'map_contains_key'))) {
6576
+ if (!__ball_map_has(seen, 'map_contains_key', item)) {
6552
6577
  seen[item] = item;
6553
6578
  result = (result.push(item), result);
6554
6579
  }
@@ -6805,7 +6830,7 @@ export class BallEngine {
6805
6830
  } while (false);
6806
6831
  }
6807
6832
  let selfMap = this._cfAsMap(self);
6808
- if ((!__ball_eq(selfMap, null) && ('__type__' in __ball_require_map(selfMap, 'map_contains_key')))) {
6833
+ if ((!__ball_eq(selfMap, null) && __ball_map_has(selfMap, 'map_contains_key', '__type__'))) {
6809
6834
  let typeName = __ball_index(selfMap, '__type__');
6810
6835
  if ((!__ball_eq(typeName, null) && (typeName.endsWith(':StringBuffer') || __ball_eq(typeName, 'StringBuffer')))) {
6811
6836
  do {
@@ -6921,7 +6946,7 @@ export class BallEngine {
6921
6946
  right = __ball_index(m, 'right');
6922
6947
  }
6923
6948
  let leftMap = this._stdAsMap(left);
6924
- if ((__ball_eq(leftMap, null) || !('__type__' in __ball_require_map(leftMap, 'map_contains_key')))) {
6949
+ if ((__ball_eq(leftMap, null) || !__ball_map_has(leftMap, 'map_contains_key', '__type__'))) {
6925
6950
  return null;
6926
6951
  }
6927
6952
  let typeName = __ball_index(leftMap, '__type__');
@@ -6988,7 +7013,7 @@ export class BallEngine {
6988
7013
  }
6989
7014
 
6990
7015
  async _callBaseFunction(module: any, function_: any, input: any): Promise<any> {
6991
- if ((function_ in __ball_require_map(_stdFunctionToOperator, 'map_contains_key'))) {
7016
+ if (__ball_map_has(_stdFunctionToOperator, 'map_contains_key', function_)) {
6992
7017
  let override = await this._tryOperatorOverride(function_, input);
6993
7018
  if (!__ball_eq(override, null)) {
6994
7019
  return this._consumeGeneratorFlow(override);
@@ -7532,15 +7557,15 @@ export class BallEngine {
7532
7557
  let list = this._stdAsList(__ball_index(m, 'list'));
7533
7558
  let s;
7534
7559
  let e;
7535
- if (('start' in __ball_require_map(m, 'map_contains_key'))) {
7560
+ if (__ball_map_has(m, 'map_contains_key', 'start')) {
7536
7561
  s = this._toInt(__ball_index(m, 'start'));
7537
7562
  e = (!__ball_eq(__ball_index(m, 'end'), null) ? this._toInt(__ball_index(m, 'end')) : null);
7538
7563
  } else {
7539
- if ((('arg0' in __ball_require_map(m, 'map_contains_key')) && ('arg1' in __ball_require_map(m, 'map_contains_key')))) {
7564
+ if ((__ball_map_has(m, 'map_contains_key', 'arg0') && __ball_map_has(m, 'map_contains_key', 'arg1'))) {
7540
7565
  s = this._toInt(__ball_index(m, 'arg0'));
7541
7566
  e = this._toInt(__ball_index(m, 'arg1'));
7542
7567
  } else {
7543
- if (('value' in __ball_require_map(m, 'map_contains_key'))) {
7568
+ if (__ball_map_has(m, 'map_contains_key', 'value')) {
7544
7569
  let v = __ball_index(m, 'value');
7545
7570
  if ((Array.isArray(v) && __ball_ge(v.length, 2))) {
7546
7571
  s = this._toInt(__ball_index(v, 0));
@@ -7743,7 +7768,7 @@ export class BallEngine {
7743
7768
  let m = this._stdAsMap(i);
7744
7769
  let map = (this._stdAsMap(__ball_index(m, 'map')) ?? __ball_index(m, 'map'));
7745
7770
  let key = __ball_index(m, 'key');
7746
- if (!(key in __ball_require_map(map, 'map_contains_key'))) {
7771
+ if (!__ball_map_has(map, 'map_contains_key', key)) {
7747
7772
  this._trackMemoryAllocation(_ballMapEntryBytes);
7748
7773
  let val = __ball_index(m, 'value');
7749
7774
  map[key] = ((typeof val === 'function') ? val() : val);
@@ -7937,7 +7962,7 @@ export class BallEngine {
7937
7962
  let valMap = this._stdAsMap(val);
7938
7963
  if (!__ball_eq(valMap, null)) {
7939
7964
  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')))) {
7965
+ if ((!__ball_map_has(valMap, 'map_contains_key', 'message') && __ball_map_has(valMap, 'map_contains_key', 'arg0'))) {
7941
7966
  valMap['message'] = __ball_index(valMap, 'arg0');
7942
7967
  }
7943
7968
  }
@@ -8541,7 +8566,7 @@ export class BallEngine {
8541
8566
 
8542
8567
  async _stdPrint(input: any): Promise<any> {
8543
8568
  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'))))) {
8569
+ 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
8570
  let message = ((__ball_index(m, 'message') ?? __ball_index(m, 'arg0')) ?? __ball_index(m, 'value'));
8546
8571
  this.stdout(await this._ballToStringAsync(message));
8547
8572
  return null;
@@ -8634,7 +8659,7 @@ export class BallEngine {
8634
8659
  }
8635
8660
  return (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8636
8661
  }
8637
- if (('__tostring_guard__' in __ball_require_map(map, 'map_contains_key'))) {
8662
+ if (__ball_map_has(map, 'map_contains_key', '__tostring_guard__')) {
8638
8663
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
8639
8664
  return (__ball_to_string(shortType) + '{...}');
8640
8665
  }
@@ -9258,7 +9283,7 @@ export class BallEngine {
9258
9283
  return false;
9259
9284
  }
9260
9285
  let key = __ball_index(entryMap, 'key');
9261
- if (!(key in __ball_require_map(rawMap, 'map_contains_key'))) {
9286
+ if (!__ball_map_has(rawMap, 'map_contains_key', key)) {
9262
9287
  return false;
9263
9288
  }
9264
9289
  if (!this._matchPattern(__ball_index(rawMap, key), __ball_index(entryMap, 'value'), bindings)) {
@@ -9298,7 +9323,7 @@ export class BallEngine {
9298
9323
  return false;
9299
9324
  }
9300
9325
  for (const entry of recFields.entries) {
9301
- if (!(entry.key in __ball_require_map(recMap, 'map_contains_key'))) {
9326
+ if (!__ball_map_has(recMap, 'map_contains_key', entry.key)) {
9302
9327
  return false;
9303
9328
  }
9304
9329
  let fieldVal = __ball_index(recMap, entry.key);
@@ -9463,7 +9488,7 @@ export class BallEngine {
9463
9488
  let map = this._stdAsMap(v);
9464
9489
  if (!__ball_eq(map, null)) {
9465
9490
  let typeName = __ball_index(map, '__type__');
9466
- if ((!__ball_eq(typeName, null) && (typeName in __ball_require_map(this._enumValues, 'map_contains_key')))) {
9491
+ if ((!__ball_eq(typeName, null) && __ball_map_has(this._enumValues, 'map_contains_key', typeName))) {
9467
9492
  let shortType = (typeName.includes(':') ? typeName.substring(__ball_add(typeName.lastIndexOf(':'), 1)) : typeName);
9468
9493
  let valName = __ball_index(map, 'name');
9469
9494
  if (!__ball_eq(valName, null)) {
@@ -10089,7 +10114,7 @@ export class _Scope {
10089
10114
 
10090
10115
  lookup(name: any): any {
10091
10116
  const input = name;
10092
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10117
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10093
10118
  return __ball_index(this._bindings, name);
10094
10119
  }
10095
10120
  if (!__ball_eq(this._parent, null)) {
@@ -10104,14 +10129,14 @@ export class _Scope {
10104
10129
 
10105
10130
  has(name: any): any {
10106
10131
  const input = name;
10107
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10132
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10108
10133
  return true;
10109
10134
  }
10110
10135
  return ((__ball_eq(this._parent, null) ? null : this._parent.has(name)) ?? false);
10111
10136
  }
10112
10137
 
10113
10138
  set(name: any, value: any): any {
10114
- if ((name in __ball_require_map(this._bindings, 'map_contains_key'))) {
10139
+ if (__ball_map_has(this._bindings, 'map_contains_key', name)) {
10115
10140
  this._bindings[name] = value;
10116
10141
  return;
10117
10142
  }
@@ -10229,7 +10254,7 @@ export class StdModuleHandler extends BallModuleHandler {
10229
10254
  if (this._tombstones.includes(entry.key)) {
10230
10255
  continue;
10231
10256
  }
10232
- if ((entry.key in __ball_require_map(this._composedDispatch, 'map_contains_key'))) {
10257
+ if (__ball_map_has(this._composedDispatch, 'map_contains_key', entry.key)) {
10233
10258
  continue;
10234
10259
  }
10235
10260
  if ((!__ball_eq(allowlist, null) && !allowlist.includes(entry.key))) {
@@ -10342,7 +10367,7 @@ function _ballToDouble(value: any): any {
10342
10367
 
10343
10368
  function _ballValueIsSet(v: any): any {
10344
10369
  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')));
10370
+ return ((typeof v === 'object' && v !== null && !Array.isArray(v) && !(v instanceof BallDouble) && !(v instanceof Set)) && __ball_map_has(v, 'map_contains_key', _kBallSetTag));
10346
10371
  }
10347
10372
 
10348
10373
  function _ballIsInt(v: any): any {
@@ -10419,7 +10444,7 @@ function _ballMapValuesDyn(map: any): any {
10419
10444
  function _ballMapContainsKeyDyn(map: any, key: any): any {
10420
10445
  let handle = _ballMapHandleEntries(map);
10421
10446
  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'));
10447
+ return __ball_map_has(handle, 'map_contains_key', key);
10423
10448
  }
10424
10449
  return false;
10425
10450
  }
@@ -10437,12 +10462,12 @@ function ballObjectSetField(target: any, fieldName: any, val: any): any {
10437
10462
  return;
10438
10463
  }
10439
10464
  if (false /* BallMap is Map in TS */) {
10440
- if (('__type__' in __ball_require_map(target.entries, 'map_contains_key'))) {
10465
+ if (__ball_map_has(target.entries, 'map_contains_key', '__type__')) {
10441
10466
  target[fieldName] = val;
10442
10467
  }
10443
10468
  return;
10444
10469
  }
10445
- if ((__ball_is_type(target, "Map<String, Object?>") && ('__type__' in __ball_require_map(target, 'map_contains_key')))) {
10470
+ if ((__ball_is_type(target, "Map<String, Object?>") && __ball_map_has(target, 'map_contains_key', '__type__'))) {
10446
10471
  target[fieldName] = val;
10447
10472
  }
10448
10473
  }
@@ -10543,7 +10568,7 @@ function _unwrapBallFuture(value: any): any {
10543
10568
  const input = value;
10544
10569
  if (_isBallFuture(value)) {
10545
10570
  let map = value;
10546
- if (('error' in __ball_require_map(map, 'map_contains_key'))) {
10571
+ if (__ball_map_has(map, 'map_contains_key', 'error')) {
10547
10572
  let error = __ball_index(map, 'error');
10548
10573
  if ((error instanceof BallException)) {
10549
10574
  throw error;