@ball-lang/engine 1.59.9 → 1.59.11

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.
@@ -3153,7 +3153,7 @@ export class BallEngine {
3153
3153
  this._checkExecutionTimeout();
3154
3154
  this._checkExpressionDepth();
3155
3155
  try {
3156
- let result = ((whichExpr(expr) === Expression_Expr.call) ? (await this._evalCall(expr.call, scope)) : ((whichExpr(expr) === Expression_Expr.literal) ? (await this._evalLiteral(expr.literal, scope)) : ((whichExpr(expr) === Expression_Expr.reference) ? (await this._evalReference(expr.reference, scope)) : ((whichExpr(expr) === Expression_Expr.fieldAccess) ? (await this._evalFieldAccess(expr.fieldAccess, scope)) : ((whichExpr(expr) === Expression_Expr.messageCreation) ? (await this._evalMessageCreation(expr.messageCreation, scope)) : ((whichExpr(expr) === Expression_Expr.block) ? (await this._evalBlock(expr.block, scope)) : ((whichExpr(expr) === Expression_Expr.lambda) ? (this._evalLambda(expr.lambda, scope)) : ((whichExpr(expr) === Expression_Expr.notSet) ? (null) : undefined))))))));
3156
+ let result = ((whichExpr(expr) === Expression_Expr.call) ? (await this._evalCall(expr.call, scope)) : ((whichExpr(expr) === Expression_Expr.literal) ? (await this._evalLiteral(expr.literal, scope)) : ((whichExpr(expr) === Expression_Expr.reference) ? (await this._evalReference(expr.reference, scope)) : ((whichExpr(expr) === Expression_Expr.fieldAccess) ? (await this._evalFieldAccess(expr.fieldAccess, scope)) : ((whichExpr(expr) === Expression_Expr.messageCreation) ? (await this._evalMessageCreation(expr.messageCreation, scope)) : ((whichExpr(expr) === Expression_Expr.block) ? (await this._evalBlock(expr.block, scope)) : ((whichExpr(expr) === Expression_Expr.lambda) ? (this._evalLambda(expr.lambda, scope)) : ((whichExpr(expr) === Expression_Expr.notSet) ? (null) : (() => { throw 'Non-exhaustive switch expression'; })()))))))));
3157
3157
  return this._consumeGeneratorFlow(result);
3158
3158
  } catch (__ball_active_error) {
3159
3159
  throw __ball_active_error;
@@ -3375,7 +3375,7 @@ export class BallEngine {
3375
3375
  }
3376
3376
 
3377
3377
  async _evalLiteral(lit: any, scope: any): Promise<any> {
3378
- return ((whichValue(lit) === Literal_Value.intValue) ? (__ball_to_int(lit.intValue)) : ((whichValue(lit) === Literal_Value.doubleValue) ? (new BallDouble(lit.doubleValue)) : ((whichValue(lit) === Literal_Value.stringValue) ? (this._trackStringAllocation(lit.stringValue)) : ((whichValue(lit) === Literal_Value.boolValue) ? (lit.boolValue) : ((whichValue(lit) === Literal_Value.bytesValue) ? (this._trackByteListAllocation([...lit.bytesValue])) : ((whichValue(lit) === Literal_Value.listValue) ? (await this._evalListLiteral(lit.listValue, scope)) : ((whichValue(lit) === Literal_Value.notSet) ? (null) : undefined)))))));
3378
+ return ((whichValue(lit) === Literal_Value.intValue) ? (__ball_to_int(lit.intValue)) : ((whichValue(lit) === Literal_Value.doubleValue) ? (new BallDouble(lit.doubleValue)) : ((whichValue(lit) === Literal_Value.stringValue) ? (this._trackStringAllocation(lit.stringValue)) : ((whichValue(lit) === Literal_Value.boolValue) ? (lit.boolValue) : ((whichValue(lit) === Literal_Value.bytesValue) ? (this._trackByteListAllocation([...lit.bytesValue])) : ((whichValue(lit) === Literal_Value.listValue) ? (await this._evalListLiteral(lit.listValue, scope)) : ((whichValue(lit) === Literal_Value.notSet) ? (null) : (() => { throw 'Non-exhaustive switch expression'; })())))))));
3379
3379
  }
3380
3380
 
3381
3381
  async _evalListLiteral(listVal: any, scope: any): Promise<any> {
@@ -831,6 +831,12 @@ export function createEngineSetup(mod: EngineModule) {
831
831
  _r('list_reversed', (i: any) => { const m = _m(i); const l = m['list'] ?? m['collection'] ?? []; return Array.isArray(l) ? [...l].reverse() : []; });
832
832
  _r('list_sublist', (i: any) => { const m = _m(i); const l = m['list'] ?? m['collection'] ?? []; const s = Number(m['start'] ?? m['arg0'] ?? 0); const e = m['end'] ?? m['arg1']; return Array.isArray(l) ? l.slice(s, e != null ? Number(e) : undefined) : []; });
833
833
  _r('list_index_of', (i: any) => { const m = _m(i); const l = m['list'] ?? m['collection'] ?? []; const v = m['value'] ?? m['element']; if (typeof l === 'string') return l.indexOf(String(v)); return Array.isArray(l) ? l.indexOf(v) : -1; });
834
+ // LEGACY ALIAS (#489): `list_add` is not a canonical Ball base function —
835
+ // dart/shared/lib/std_collections.dart declares `list_push`. It was added
836
+ // here ad hoc so the TS encoder's (non-canonical) output would run on this
837
+ // engine, which is precisely why the encoder/compiler vocabulary drift went
838
+ // unnoticed. The encoder now emits `list_push`; this registration is kept
839
+ // only so Ball programs encoded by an older @ball-lang/encoder still run.
834
840
  _r('list_add', (i: any) => { const m = _m(i); const l = m['list'] ?? m['collection']; const v = m['value'] ?? m['element']; if (l instanceof Set) { l.add(v); return null; } if (Array.isArray(l)) l.push(v); return null; });
835
841
  _r('list_add_all', (i: any) => { const m = _m(i); const l = m['list'] ?? m['collection']; const o = m['other'] ?? m['elements'] ?? []; if (Array.isArray(l) && Array.isArray(o)) l.push(...o); return null; });
836
842
  _r('list_remove_at', (i: any) => { const m = _m(i); const l = m['list'] ?? m['collection']; const idx = Number(m['index'] ?? 0); return Array.isArray(l) ? l.splice(idx, 1)[0] : null; });
@@ -963,6 +969,10 @@ export function createEngineSetup(mod: EngineModule) {
963
969
  _r('string_contains', (i: any) => { const m = _m(i); return String(m['value'] ?? m['string'] ?? '').includes(String(m['substring'] ?? m['pattern'] ?? m['other'] ?? '')); });
964
970
  _r('string_length', (i: any) => { const m = _m(i); return String(m['value'] ?? m['string'] ?? '').length; });
965
971
  _r('string_index_of', (i: any) => { const m = _m(i); return String(m['value'] ?? m['string'] ?? m['left'] ?? m['arg0'] ?? '').indexOf(String(m['substring'] ?? m['pattern'] ?? m['right'] ?? m['arg1'] ?? '')); });
972
+ // LEGACY ALIASES (#489), same story as `list_add` above: the canonical
973
+ // names are `string_to_upper`/`string_to_lower` (dart/shared/lib/std.dart),
974
+ // which the encoder now emits. Kept for programs encoded by an older
975
+ // @ball-lang/encoder.
966
976
  _r('string_to_upper_case', (i: any) => { const m = _m(i); return String(m['value'] ?? m['string'] ?? '').toUpperCase(); });
967
977
  _r('string_to_lower_case', (i: any) => { const m = _m(i); return String(m['value'] ?? m['string'] ?? '').toLowerCase(); });
968
978
  _r('string_trim', (i: any) => { const m = _m(i); return String(m['value'] ?? m['string'] ?? '').trim(); });