@neocompose/cli 0.84.2 → 0.84.4

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.
@@ -3302,14 +3302,14 @@ function isNSFunctionContains(value) {
3302
3302
  if (v?.type !== "contains" /* contains */) return false;
3303
3303
  const info = v.info;
3304
3304
  if (typeof info !== "object" || info === null) return false;
3305
- return isNSPointer(info.collectionPointer) && isNSPointer(info.valuePointer) && isReferenceFlag(info.reference);
3305
+ return isNSPointer(info.collectionPointer) && isNSPointer(info.valuePointer) && isReferenceFlag(info.reference) && (info.float === void 0 || info.float === true) && (info.decimal === void 0 || info.decimal === true);
3306
3306
  }
3307
3307
  function isNSFunctionIndexOf(value) {
3308
3308
  const v = value;
3309
3309
  if (v?.type !== "indexOf" /* indexOf */) return false;
3310
3310
  const info = v.info;
3311
3311
  if (typeof info !== "object" || info === null) return false;
3312
- return isNSPointer(info.collectionPointer) && isNSPointer(info.valuePointer) && isReferenceFlag(info.reference);
3312
+ return isNSPointer(info.collectionPointer) && isNSPointer(info.valuePointer) && isReferenceFlag(info.reference) && (info.float === void 0 || info.float === true) && (info.decimal === void 0 || info.decimal === true);
3313
3313
  }
3314
3314
  var NS_STRING_OPS = [
3315
3315
  "toLower",
@@ -3483,7 +3483,7 @@ function isNSFunctionCollectionQuery(value) {
3483
3483
  case "Reverse":
3484
3484
  return true;
3485
3485
  case "ToSet":
3486
- return info.reference === void 0 || info.reference === true;
3486
+ return (info.reference === void 0 || info.reference === true) && (info.decimalEntries === void 0 || info.decimalEntries === true);
3487
3487
  default:
3488
3488
  return false;
3489
3489
  }
@@ -17029,16 +17029,18 @@ var UncompiledInitializerRuntimeError = class extends NSGetterRuntimeError {
17029
17029
 
17030
17030
  // ../packages/neoscript-runtime/src/neoscript/runtime-set.ts
17031
17031
  var RuntimeSet = class {
17032
- constructor(source, reference, enumEntries, slotReferences = null) {
17032
+ constructor(source, reference, enumEntries, slotReferences = null, decimalEntries = false) {
17033
17033
  this.source = source;
17034
17034
  this.reference = reference;
17035
17035
  this.enumEntries = enumEntries;
17036
17036
  this.slotReferences = slotReferences;
17037
+ this.decimalEntries = decimalEntries;
17037
17038
  }
17038
17039
  source;
17039
17040
  reference;
17040
17041
  enumEntries;
17041
17042
  slotReferences;
17043
+ decimalEntries;
17042
17044
  entries = /* @__PURE__ */ new Map();
17043
17045
  validations = /* @__PURE__ */ new Map();
17044
17046
  snapshot;
@@ -17048,6 +17050,9 @@ var RuntimeSet = class {
17048
17050
  has(key) {
17049
17051
  return this.entries.has(key);
17050
17052
  }
17053
+ *values() {
17054
+ for (const entry of this.entries.values()) yield entry.raw;
17055
+ }
17051
17056
  add(key, raw, reference) {
17052
17057
  if (this.entries.has(key)) return;
17053
17058
  this.entries.set(key, { raw, reference });
@@ -21257,6 +21262,7 @@ function createdSessionValuesSince(ctx, checkpoint) {
21257
21262
  return created;
21258
21263
  }
21259
21264
  function exportInitializerCollections(created, writes, ctx) {
21265
+ const inPlace = (value) => value instanceof RuntimeSet ? exportRuntimeSetValue(value, ctx) : value;
21260
21266
  const assignedValues = /* @__PURE__ */ new Set();
21261
21267
  const mutatedIds = /* @__PURE__ */ new Set();
21262
21268
  for (const write of writes) {
@@ -21264,83 +21270,134 @@ function exportInitializerCollections(created, writes, ctx) {
21264
21270
  if (destination !== void 0 && "containerValueId" in destination)
21265
21271
  mutatedIds.add(destination.containerValueId);
21266
21272
  if (write.kind === "assign" && write.valueId === void 0 && typeof write.value === "object" && write.value !== null) {
21267
- assignedValues.add(write.value);
21273
+ assignedValues.add(inPlace(write.value));
21268
21274
  }
21269
21275
  }
21270
21276
  const candidates = /* @__PURE__ */ new Set();
21277
+ const inlineFieldsByRowId = /* @__PURE__ */ new Map();
21271
21278
  for (const row of created) {
21272
- if (assignedValues.has(row.value) || row.classId === void 0 && mutatedIds.has(row.id) || Array.isArray(row.value) && row.value.length > 0 && ctx.__unorderedListProjections?.byContainerId.has(row.id)) {
21279
+ const inlineFields = inlineCollectionFields(row, ctx);
21280
+ if (inlineFields !== null) inlineFieldsByRowId.set(row.id, inlineFields);
21281
+ if (inlineFields !== null || assignedValues.has(inPlace(row.value)) || row.classId === void 0 && mutatedIds.has(row.id) || Array.isArray(row.value) && row.value.length > 0 && ctx.__unorderedListProjections?.byContainerId.has(row.id)) {
21273
21282
  candidates.add(row.id);
21274
21283
  }
21275
21284
  }
21276
21285
  if (candidates.size === 0) return created;
21277
21286
  invalidateEvaluatorIndexes(ctx, null);
21278
21287
  const extra = [];
21279
- const exported = created.map((row) => {
21280
- if (!candidates.has(row.id)) return row;
21281
- const member = memberForValueRow(row, ctx);
21282
- if (member === null) return row;
21283
- if (!isMemberWithEntries(member)) return row;
21284
- if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
21285
- return { ...row, value: [] };
21286
- }
21287
- if (!assignedValues.has(row.value) && !mutatedIds.has(row.id)) return row;
21288
- const values = [];
21288
+ const encode = (member, value, genericEnv, collectionOwnerId) => {
21289
+ const rows = [];
21289
21290
  const declarations = /* @__PURE__ */ new Map();
21290
- const genericEnv = runtimeGenericEnvForValueRow(row, ctx, /* @__PURE__ */ new Set());
21291
- overlayConcreteGenericEntries(
21292
- genericEnv,
21293
- envFromStamp(row.genericBindings)
21294
- );
21295
- const materialized = materializeConstructorArgumentValue({
21291
+ const root = materializeConstructorArgumentValue({
21296
21292
  member,
21297
- value: row.value,
21293
+ value,
21298
21294
  genericEnv,
21299
21295
  ctx,
21300
- createdValues: values,
21296
+ createdValues: rows,
21301
21297
  createdById: /* @__PURE__ */ new Map(),
21302
21298
  storageKeyDeclarations: declarations,
21303
- collectionEntriesAreReferences: assignedValues.has(row.value) ? false : void 0,
21304
- collectionOwnerId: row.id
21299
+ collectionEntriesAreReferences: assignedValues.has(value) ? false : void 0,
21300
+ collectionOwnerId
21305
21301
  });
21306
- const encoded = { ...row, value: materialized.value };
21307
- const children = values.filter((value) => value !== materialized);
21308
- declarations.delete(materialized.id);
21309
- const groupId = constructorGroupForRow(row.id, ctx);
21310
- retargetConstructorGroupDependencies(
21311
- materialized.id,
21312
- groupId ?? row.id,
21313
- ctx
21314
- );
21302
+ const children = rows.filter((row) => row !== root);
21303
+ return { root, children, declarations };
21304
+ };
21305
+ const adopt = (owner, rootId, rows, declarations) => {
21306
+ const groupId = constructorGroupForRow(owner.id, ctx);
21307
+ retargetConstructorGroupDependencies(rootId, groupId ?? owner.id, ctx);
21315
21308
  if (groupId !== null) {
21316
21309
  const state = ctx.__executionState;
21317
21310
  const group = state?.constructorGroups.get(groupId);
21318
- for (const child of children) {
21319
- retargetConstructorGroupDependencies(child.id, groupId, ctx);
21320
- group?.add(child.id);
21321
- state?.constructorGroupByRowId.set(child.id, groupId);
21311
+ for (const row of rows) {
21312
+ retargetConstructorGroupDependencies(row.id, groupId, ctx);
21313
+ group?.add(row.id);
21314
+ state?.constructorGroupByRowId.set(row.id, groupId);
21322
21315
  }
21323
21316
  }
21324
- stampCreatedValuesMapKey(children, row.mapKey);
21317
+ stampCreatedValuesMapKey(rows, owner.mapKey);
21325
21318
  applyDeclaredStorageKeyOverrides({
21326
- createdValues: [encoded, ...children],
21319
+ createdValues: [owner, ...rows],
21327
21320
  declarationByValueId: declarations
21328
21321
  });
21329
- for (const child of children) {
21330
- if (!isLiteralValueContent(child)) {
21322
+ for (const row of rows) {
21323
+ if (!isLiteralValueContent(row)) {
21331
21324
  throw new NSGetterRuntimeError(
21332
21325
  "Initializer collection produced an unevaluated row."
21333
21326
  );
21334
21327
  }
21335
- extra.push(child);
21328
+ extra.push(row);
21336
21329
  }
21337
21330
  for (const [id, declaration] of declarations) {
21338
21331
  ctx.__createdStorageKeyDeclarations?.set(id, declaration);
21339
21332
  }
21333
+ };
21334
+ const exported = created.map((row) => {
21335
+ if (!candidates.has(row.id)) return row;
21336
+ const inlineFields = inlineFieldsByRowId.get(row.id);
21337
+ if (inlineFields !== void 0) {
21338
+ const record4 = { ...inlineFields.record };
21339
+ const encoded2 = { ...row, value: record4 };
21340
+ for (const [key, member2] of inlineFields.members) {
21341
+ const { root: root2, children: children2, declarations: declarations2 } = encode(
21342
+ member2,
21343
+ inPlace(record4[key]),
21344
+ inlineFields.genericEnv
21345
+ );
21346
+ record4[key] = root2.id;
21347
+ adopt(encoded2, root2.id, [root2, ...children2], declarations2);
21348
+ }
21349
+ return encoded2;
21350
+ }
21351
+ const member = memberForValueRow(row, ctx);
21352
+ if (member === null) return row;
21353
+ if (!isMemberWithEntries(member)) return row;
21354
+ if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
21355
+ return { ...row, value: [] };
21356
+ }
21357
+ const value = inPlace(row.value);
21358
+ if (!assignedValues.has(value) && !mutatedIds.has(row.id)) return row;
21359
+ const { root, children, declarations } = encode(
21360
+ member,
21361
+ value,
21362
+ rowGenericEnv(row, ctx),
21363
+ row.id
21364
+ );
21365
+ const encoded = { ...row, value: root.value };
21366
+ declarations.delete(root.id);
21367
+ adopt(encoded, root.id, children, declarations);
21340
21368
  return encoded;
21341
21369
  });
21342
21370
  return [...exported, ...extra];
21343
21371
  }
21372
+ function inlineCollectionFields(row, ctx) {
21373
+ if (typeof row.classId !== "string") return null;
21374
+ if (!isPlainRecord(row.value)) return null;
21375
+ let fields = null;
21376
+ for (const key in row.value) {
21377
+ const value = row.value[key];
21378
+ if (typeof value !== "object" || value === null) continue;
21379
+ const rawMember = memberForCustomSchemaValue(row.classId, key, ctx);
21380
+ if (rawMember === null) continue;
21381
+ fields ??= {
21382
+ record: row.value,
21383
+ members: /* @__PURE__ */ new Map(),
21384
+ genericEnv: rowGenericEnv(row, ctx)
21385
+ };
21386
+ const member = substituteMember(
21387
+ rawMember,
21388
+ fields.genericEnv,
21389
+ ctx.vm.members,
21390
+ cachedResolvedMember(rawMember, ctx)
21391
+ );
21392
+ if (isMemberWithEntries(member)) fields.members.set(key, member);
21393
+ }
21394
+ return fields === null || fields.members.size === 0 ? null : fields;
21395
+ }
21396
+ function rowGenericEnv(row, ctx) {
21397
+ const genericEnv = runtimeGenericEnvForValueRow(row, ctx, /* @__PURE__ */ new Set());
21398
+ overlayConcreteGenericEntries(genericEnv, envFromStamp(row.genericBindings));
21399
+ return genericEnv;
21400
+ }
21344
21401
  function prepareSessionValueExport(ctx, checkpoint, writes) {
21345
21402
  const created = createdSessionValuesSince(ctx, checkpoint);
21346
21403
  if (created.length === 0) return;
@@ -21388,7 +21445,14 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
21388
21445
  for (let index = 0; index < argumentValues.length; index += 1) {
21389
21446
  const parameter3 = parameters[index];
21390
21447
  if (parameter3 === void 0) continue;
21391
- scope.setLocal(parameter3.id, argumentValues[index]);
21448
+ scope.setLocal(
21449
+ parameter3.id,
21450
+ coerceAssignmentValue(
21451
+ argumentValues[index],
21452
+ parameter3.typeInfo,
21453
+ "getter argument"
21454
+ )
21455
+ );
21392
21456
  }
21393
21457
  try {
21394
21458
  const result = evalBody(
@@ -21398,9 +21462,11 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
21398
21462
  evaluationOptions(runtimeCtx, false)
21399
21463
  );
21400
21464
  if (result.kind === "return") {
21401
- if (getter.typeInfo.type === 20 /* Decimal */ && typeof result.value === "number") {
21402
- result.value = coerceDecimalOperand(result.value, "return");
21403
- }
21465
+ result.value = coerceAssignmentValue(
21466
+ result.value,
21467
+ getter.typeInfo,
21468
+ "return"
21469
+ );
21404
21470
  if (ownsInvocationState) {
21405
21471
  flushRuntimeSets(runtimeCtx);
21406
21472
  result.value = exportRuntimeSetValue(result.value, runtimeCtx);
@@ -22272,7 +22338,11 @@ function executeCompiledFunction(action, ctx, args, allowFallthroughReturn, runt
22272
22338
  const parameter3 = action.parameters[index + 2];
22273
22339
  const runtimeTypeInfo = runtimeArgumentTypes[index];
22274
22340
  const value2 = asDeclaredRuntimeSet(
22275
- restoreExportedReferences(filledArgs[index], runtimeTypeInfo, ctx),
22341
+ coerceAssignmentValue(
22342
+ restoreExportedReferences(filledArgs[index], runtimeTypeInfo, ctx),
22343
+ runtimeTypeInfo,
22344
+ "function argument"
22345
+ ),
22276
22346
  runtimeTypeInfo,
22277
22347
  ctx
22278
22348
  );
@@ -22306,9 +22376,7 @@ function executeCompiledFunction(action, ctx, args, allowFallthroughReturn, runt
22306
22376
  }
22307
22377
  return null;
22308
22378
  }
22309
- if (runtimeReturnType.type === 20 /* Decimal */ && typeof value === "number") {
22310
- value = coerceDecimalOperand(value, "function return");
22311
- }
22379
+ value = coerceAssignmentValue(value, runtimeReturnType, "function return");
22312
22380
  if (!runtimeValueMatchesType(value, runtimeReturnType, ctx)) {
22313
22381
  throw new NSGetterRuntimeError(
22314
22382
  "NSFunction returned a value that does not match its compiled return type."
@@ -22650,9 +22718,11 @@ function evalInstructions(instructions, scope, ctx, options) {
22650
22718
  }
22651
22719
  case "variable" /* variable */: {
22652
22720
  let value = evalPointer(ins.variable.pointer, scope, ctx);
22653
- if (ins.variable.typeInfo.type === 20 /* Decimal */ && typeof value === "number") {
22654
- value = coerceDecimalOperand(value, "variable initialization");
22655
- }
22721
+ value = coerceAssignmentValue(
22722
+ value,
22723
+ ins.variable.typeInfo,
22724
+ "variable initialization"
22725
+ );
22656
22726
  value = asDeclaredRuntimeSet(value, ins.variable.typeInfo, ctx);
22657
22727
  scope.setLocal(ins.variable.id, value);
22658
22728
  break;
@@ -22688,9 +22758,11 @@ function evalInstructions(instructions, scope, ctx, options) {
22688
22758
  }
22689
22759
  case "assign" /* assign */: {
22690
22760
  let value = evalPointer(ins.pointer, scope, ctx);
22691
- if (ins.target.typeInfo.type === 20 /* Decimal */ && typeof value === "number") {
22692
- value = coerceDecimalOperand(value, "assignment");
22693
- }
22761
+ value = coerceAssignmentValue(
22762
+ value,
22763
+ ins.target.typeInfo,
22764
+ "assignment"
22765
+ );
22694
22766
  if (ins.target.pointer.type === "variable" /* variable */) {
22695
22767
  assertVariableBindingWritable(scope, ins.target.pointer.variableId);
22696
22768
  scope.setLocal(ins.target.pointer.variableId, value);
@@ -24472,6 +24544,21 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
24472
24544
  );
24473
24545
  }
24474
24546
  const args = ins.args.map((arg) => evalPointer(arg, scope, ctx));
24547
+ const decimalEntries = "entryTypeInfo" in ins.target.typeInfo && ins.target.typeInfo.entryTypeInfo.type === 20 /* Decimal */;
24548
+ let entryArgumentIndex = null;
24549
+ const dictionary = ins.target.typeInfo.type === 5 /* Dictionary */;
24550
+ if (ins.mutation === "Add" /* Add */)
24551
+ entryArgumentIndex = dictionary ? 1 : 0;
24552
+ if (ins.mutation === "Insert" /* Insert */) entryArgumentIndex = 1;
24553
+ if (ins.mutation === "Remove" /* Remove */ && !dictionary)
24554
+ entryArgumentIndex = 0;
24555
+ if (entryArgumentIndex !== null && "entryTypeInfo" in ins.target.typeInfo) {
24556
+ args[entryArgumentIndex] = coerceAssignmentValue(
24557
+ args[entryArgumentIndex],
24558
+ ins.target.typeInfo.entryTypeInfo,
24559
+ "collection mutation entry"
24560
+ );
24561
+ }
24475
24562
  const setEntryMember = mutatesLocalVariable ? null : storedSetEntryMember(targetValue, ctx);
24476
24563
  const isLookupSet = setEntryMember === null && ins.target.typeInfo.type === 9 /* Lookup */;
24477
24564
  if (isLookupSet && Array.isArray(targetValue)) {
@@ -24479,7 +24566,8 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
24479
24566
  targetValue,
24480
24567
  ins.reference === true,
24481
24568
  ins.target.typeInfo.type === 9 /* Lookup */ && (ins.target.typeInfo.entryTypeInfo.type === 8 /* Enum */ || ins.target.typeInfo.entryTypeInfo.type === 18 /* DialogueLookup */),
24482
- ctx
24569
+ ctx,
24570
+ decimalEntries
24483
24571
  );
24484
24572
  }
24485
24573
  const setMatch = setEntryMember !== null && Array.isArray(targetValue) && (ins.mutation === "Add" /* Add */ || ins.mutation === "Remove" /* Remove */) ? findStoredSetEntry(targetValue, args[0], setEntryMember, ctx) : null;
@@ -24498,7 +24586,8 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
24498
24586
  ctx,
24499
24587
  isLookupSet,
24500
24588
  false,
24501
- ins.reference === true
24589
+ ins.reference === true,
24590
+ decimalEntries
24502
24591
  );
24503
24592
  updateCollectionReferenceProvenance(
24504
24593
  targetValue,
@@ -24576,7 +24665,8 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
24576
24665
  ctx,
24577
24666
  isLookupSet,
24578
24667
  ins.reference !== true && ins.mutation === "Remove" /* Remove */ && isArrayCollection(targetValue) && setEntryMember === null && !isLookupSet && findKnownRowIdByValueReference(args[0], ctx) === null,
24579
- ins.reference === true
24668
+ ins.reference === true,
24669
+ setEntryMember === null && decimalEntries
24580
24670
  );
24581
24671
  updateCollectionReferenceProvenance(
24582
24672
  targetValue,
@@ -24852,21 +24942,28 @@ function asDeclaredRuntimeSet(value, type, ctx) {
24852
24942
  value,
24853
24943
  entry === 7 /* Class */ || entry === 22 /* Interface */ || entry === 6 /* List */ || entry === 5 /* Dictionary */ || entry === 9 /* Lookup */,
24854
24944
  entry === 8 /* Enum */ || entry === 18 /* DialogueLookup */,
24855
- ctx
24945
+ ctx,
24946
+ entry === 20 /* Decimal */
24856
24947
  );
24857
24948
  }
24858
24949
  function runtimeSetKey(value, set, ctx) {
24859
24950
  if (set.slotReferences !== null) return slotReferenceKey(value);
24860
24951
  if (set.enumEntries && Array.isArray(value) && value.length === 1)
24861
24952
  value = value[0];
24862
- return toSetEntryKey(value, null, set.reference, ctx);
24953
+ return toSetEntryKey(value, null, set.reference, ctx, set.decimalEntries);
24863
24954
  }
24864
- function runtimeSet(array2, reference, enumEntries, ctx) {
24955
+ function runtimeSet(array2, reference, enumEntries, ctx, decimalEntries = false) {
24865
24956
  const sets = ctx.__runtimeSets ??= /* @__PURE__ */ new WeakMap();
24866
24957
  ctx.__dirtyRuntimeSets ??= /* @__PURE__ */ new Set();
24867
24958
  const existing = sets.get(array2);
24868
24959
  if (existing !== void 0) return existing;
24869
- const set = new RuntimeSet(array2, reference, enumEntries);
24960
+ const set = new RuntimeSet(
24961
+ array2,
24962
+ reference,
24963
+ enumEntries,
24964
+ null,
24965
+ decimalEntries
24966
+ );
24870
24967
  const references = collectionReferences(array2, ctx);
24871
24968
  for (let index = 0; index < array2.length; index++) {
24872
24969
  const raw = array2[index];
@@ -24985,7 +25082,7 @@ function removableEntryRowIds(targetValue, mutation, args, ctx) {
24985
25082
  }
24986
25083
  return rowIds;
24987
25084
  }
24988
- function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique = false, resolveRemovalEntries = false, reference = false) {
25085
+ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique = false, resolveRemovalEntries = false, reference = false, decimal = false) {
24989
25086
  if (targetValue instanceof RuntimeSet) {
24990
25087
  (ctx.__dirtyRuntimeSets ??= /* @__PURE__ */ new Set()).add(targetValue);
24991
25088
  switch (mutation) {
@@ -25037,6 +25134,7 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
25037
25134
  case "Remove" /* Remove */:
25038
25135
  if (Array.isArray(targetValue)) {
25039
25136
  const references = resolveRemovalEntries ? collectionReferences(targetValue, ctx) : recordedReferenceEntries(targetValue, ctx) ?? 1 /* Values */;
25137
+ const targetKey = decimal ? decimalCollectionKey(args[0]) : args[0];
25040
25138
  let index = -1;
25041
25139
  for (let candidate = 0; candidate < targetValue.length; candidate += 1) {
25042
25140
  const entry = targetValue[candidate];
@@ -25047,10 +25145,8 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
25047
25145
  }
25048
25146
  continue;
25049
25147
  }
25050
- if (jsEqual(
25051
- typeof entry === "string" && isReferenceEntry(references, candidate) ? resolveValueIfId(entry, ctx) : entry,
25052
- args[0]
25053
- )) {
25148
+ const value = typeof entry === "string" && isReferenceEntry(references, candidate) ? resolveValueIfId(entry, ctx) : entry;
25149
+ if (jsEqual(decimal ? decimalCollectionKey(value) : value, targetKey)) {
25054
25150
  index = candidate;
25055
25151
  break;
25056
25152
  }
@@ -25537,12 +25633,22 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
25537
25633
  case "function" /* function */:
25538
25634
  return evalFunction(pointer.function, scope, ctx);
25539
25635
  case "listLiteral" /* listLiteral */:
25540
- return pointer.entries.map((e) => evalPointer(e, scope, ctx));
25636
+ return pointer.entries.map(
25637
+ (entry) => coerceAssignmentValue(
25638
+ evalPointer(entry, scope, ctx),
25639
+ pointer.typeInfo.entryTypeInfo,
25640
+ "list entry"
25641
+ )
25642
+ );
25541
25643
  case "dictLiteral" /* dictLiteral */: {
25542
25644
  const out = {};
25543
25645
  for (const e of pointer.entries) {
25544
25646
  const k = evalPointer(e.key, scope, ctx);
25545
- out[String(k)] = evalPointer(e.value, scope, ctx);
25647
+ out[String(k)] = coerceAssignmentValue(
25648
+ evalPointer(e.value, scope, ctx),
25649
+ pointer.typeInfo.entryTypeInfo,
25650
+ "dictionary entry"
25651
+ );
25546
25652
  }
25547
25653
  return out;
25548
25654
  }
@@ -27205,9 +27311,9 @@ function readRecordKey(receiver, k, memberId, ctx) {
27205
27311
  if (receiver === ctx.thisValue && typeof ctx.thisValueRowId === "string") {
27206
27312
  return ctx.thisValueRowId;
27207
27313
  }
27208
- const rowId = findKnownRowIdByValueReference(receiver, ctx);
27209
- if (rowId) return rowId;
27210
- throw new NSGetterRuntimeError("Class value has no backing row id.");
27314
+ const row = trackedRowForValueReference(receiver, ctx);
27315
+ if (row !== null && classIdForValueRow(row, ctx) !== void 0)
27316
+ return row.id;
27211
27317
  }
27212
27318
  const assetMember = resolveAssetRuntimeMember(receiver, k, ctx);
27213
27319
  if (assetMember.kind === "ok") return assetMember.value;
@@ -28638,7 +28744,11 @@ function evalDecimalMathOp(info, fn, scope, ctx) {
28638
28744
  }
28639
28745
  }
28640
28746
  function evalListRepeat(info, scope, ctx) {
28641
- const value = evalPointer(info.valuePointer, scope, ctx);
28747
+ const value = coerceAssignmentValue(
28748
+ evalPointer(info.valuePointer, scope, ctx),
28749
+ info.entryTypeInfo,
28750
+ "List.Repeat entry"
28751
+ );
28642
28752
  const count = numberArg(
28643
28753
  evalPointer(info.countPointer, scope, ctx),
28644
28754
  "List.Repeat count"
@@ -28726,13 +28836,18 @@ function jsEqual(a, b) {
28726
28836
  return a instanceof NSSlotReference && b instanceof NSSlotReference && a.targetId === b.targetId;
28727
28837
  }
28728
28838
  if (a === b) return true;
28729
- if (Array.isArray(a) && Array.isArray(b)) {
28730
- if (a.length !== b.length) return false;
28731
- for (let i = 0; i < a.length; i++) {
28732
- if (!jsEqual(a[i], b[i])) return false;
28839
+ if (Array.isArray(a) || a instanceof RuntimeSet) {
28840
+ if (!Array.isArray(b) && !(b instanceof RuntimeSet)) return false;
28841
+ const aSize = a instanceof RuntimeSet ? a.size : a.length;
28842
+ const bSize = b instanceof RuntimeSet ? b.size : b.length;
28843
+ if (aSize !== bSize) return false;
28844
+ const other = b.values();
28845
+ for (const entry of a.values()) {
28846
+ if (!jsEqual(entry, other.next().value)) return false;
28733
28847
  }
28734
28848
  return true;
28735
28849
  }
28850
+ if (b instanceof RuntimeSet) return false;
28736
28851
  if (typeof a === "object" && typeof b === "object" && a !== null && b !== null && !Array.isArray(a) && !Array.isArray(b)) {
28737
28852
  const aKeys = Object.keys(a);
28738
28853
  const bKeys = Object.keys(b);
@@ -29168,7 +29283,8 @@ function evalCollectionQuery(info, scope, ctx) {
29168
29283
  output,
29169
29284
  info.reference === true,
29170
29285
  info.enumEntries === true,
29171
- ctx
29286
+ ctx,
29287
+ info.decimalEntries === true
29172
29288
  ) : output;
29173
29289
  };
29174
29290
  if (info.op === "OrderBy" || info.op === "OrderByDescending") {
@@ -29220,7 +29336,8 @@ function evalCollectionQuery(info, scope, ctx) {
29220
29336
  entry,
29221
29337
  valueId,
29222
29338
  info.reference === true,
29223
- ctx
29339
+ ctx,
29340
+ info.decimalEntries === true
29224
29341
  );
29225
29342
  if (seenSetKeys.has(setKey)) return 0 /* Continue */;
29226
29343
  seenSetKeys.add(setKey);
@@ -29275,10 +29392,15 @@ function evalCollectionQuery(info, scope, ctx) {
29275
29392
  }
29276
29393
  return finish();
29277
29394
  }
29278
- function toSetEntryKey(entry, valueId, reference, ctx) {
29395
+ function toSetEntryKey(entry, valueId, reference, ctx, decimal = false) {
29279
29396
  if (reference) return valueId ?? referenceIdOf(entry, ctx) ?? entry;
29397
+ if (decimal) return decimalCollectionKey(entry);
29280
29398
  return typeof entry === "object" && entry !== null ? canonicalJsonStringify(entry) : entry;
29281
29399
  }
29400
+ function decimalCollectionKey(value) {
29401
+ if (value === null) return null;
29402
+ return decimalKey(coerceDecimalOperand(value, "decimal collection entry"));
29403
+ }
29282
29404
  function compareCollectionKeys(left, right, keyType) {
29283
29405
  if (left === null) return right === null ? 0 : -1;
29284
29406
  if (right === null) return 1;
@@ -29396,7 +29518,11 @@ function evalFunction(fn, scope, ctx) {
29396
29518
  }
29397
29519
  case "contains" /* contains */: {
29398
29520
  let c = evalPointer(fn.info.collectionPointer, scope, ctx);
29399
- const target = evalPointer(fn.info.valuePointer, scope, ctx);
29521
+ let target = evalPointer(fn.info.valuePointer, scope, ctx);
29522
+ if (fn.info.float === true && typeof target === "number")
29523
+ target = Math.fround(target);
29524
+ if (fn.info.decimal === true && target !== null)
29525
+ target = coerceDecimalOperand(target, "collection search");
29400
29526
  if (typeof c === "string") {
29401
29527
  if (typeof target !== "string") {
29402
29528
  throw new NSGetterRuntimeError(
@@ -29429,9 +29555,13 @@ function evalFunction(fn, scope, ctx) {
29429
29555
  return referenceIndexOf(c, target, ctx) !== null;
29430
29556
  }
29431
29557
  const targetReferenceId = typeof target === "string" ? null : findKnownRowIdByValueReference(target, ctx);
29558
+ const targetKey = fn.info.decimal ? decimalCollectionKey(target) : target;
29432
29559
  let containsResolvedEntry = false;
29433
29560
  iterateCollection(c, ctx, (entry, _key, valueId) => {
29434
- if (valueId !== null && valueId === targetReferenceId || jsEqual(entry, target)) {
29561
+ if (valueId !== null && valueId === targetReferenceId || jsEqual(
29562
+ fn.info.decimal ? decimalCollectionKey(entry) : entry,
29563
+ targetKey
29564
+ )) {
29435
29565
  containsResolvedEntry = true;
29436
29566
  return 1 /* Break */;
29437
29567
  }
@@ -29444,15 +29574,21 @@ function evalFunction(fn, scope, ctx) {
29444
29574
  evalPointer(fn.info.collectionPointer, scope, ctx),
29445
29575
  "IndexOf receiver"
29446
29576
  );
29447
- const target = evalPointer(fn.info.valuePointer, scope, ctx);
29577
+ let target = evalPointer(fn.info.valuePointer, scope, ctx);
29578
+ if (fn.info.float === true && typeof target === "number")
29579
+ target = Math.fround(target);
29448
29580
  if (fn.info.reference === true) {
29449
29581
  const index = referenceIndexOf(collection, target, ctx);
29450
29582
  return index === null ? -1 : numberArg(index, "IndexOf index");
29451
29583
  }
29452
29584
  const targetReferenceId = typeof target === "string" ? null : findKnownRowIdByValueReference(target, ctx);
29585
+ const targetKey = fn.info.decimal ? decimalCollectionKey(target) : target;
29453
29586
  let found = -1;
29454
29587
  iterateCollection(collection, ctx, (entry, key, valueId) => {
29455
- if (valueId !== null && valueId === targetReferenceId || jsEqual(entry, target)) {
29588
+ if (valueId !== null && valueId === targetReferenceId || jsEqual(
29589
+ fn.info.decimal ? decimalCollectionKey(entry) : entry,
29590
+ targetKey
29591
+ )) {
29456
29592
  found = numberArg(key, "IndexOf index");
29457
29593
  return 1 /* Break */;
29458
29594
  }
@@ -29660,7 +29796,19 @@ function evalFunction(fn, scope, ctx) {
29660
29796
  );
29661
29797
  iterateCollection(c, ctx, callback);
29662
29798
  }
29663
- if (found !== sentinel) return found;
29799
+ if (found !== sentinel) {
29800
+ if (typeof found === "string") {
29801
+ if (c instanceof RuntimeSet) {
29802
+ if (c.enumEntries) return [found];
29803
+ } else {
29804
+ const row = trackedRowForValueReference(c, ctx);
29805
+ const member = row === null ? null : memberForValueRow(row, ctx);
29806
+ if (member?.kind === 8 /* Enum */ || member?.kind === 18 /* DialogueLookup */)
29807
+ return [found];
29808
+ }
29809
+ }
29810
+ return found;
29811
+ }
29664
29812
  if (fn.type === "first" /* first */) {
29665
29813
  throw new NSGetterRuntimeError(
29666
29814
  innerFn ? "First() found no matching entry. Use FirstOrDefault() and handle null if no match is expected." : "First() called on an empty collection. Check that it has entries, or use FirstOrDefault() and handle null."
@@ -30874,10 +31022,19 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
30874
31022
  }
30875
31023
  return null;
30876
31024
  };
31025
+ const defaultScopeMemberId = (memberId) => walkExtendsMemberChain(
31026
+ memberId,
31027
+ ctx.vm.members,
31028
+ (declaration) => declaration.defaultValue === void 0 ? void 0 : declaration.id,
31029
+ {
31030
+ memberById: (id) => indexes4.schemaIndex.member(id) ?? null,
31031
+ maxHops: ctx.vm.members.length
31032
+ }
31033
+ );
30877
31034
  return (member, init, sourceValueId, genericEnv = instanceEnv) => {
30878
31035
  const memberId = Reflect.get(member, "id");
30879
31036
  const effectiveMemberId = typeof memberId === "string" ? memberId : null;
30880
- const scopeMemberId = indexes4.initializerScopeMemberIds.get(init) ?? (typeof sourceValueId !== "string" ? void 0 : indexes4.initializerScopeMemberIdsByValueId.get(sourceValueId)) ?? effectiveMemberId;
31037
+ const scopeMemberId = indexes4.initializerScopeMemberIds.get(init) ?? (typeof sourceValueId !== "string" ? void 0 : indexes4.initializerScopeMemberIdsByValueId.get(sourceValueId)) ?? (sourceValueId === void 0 && effectiveMemberId !== null ? defaultScopeMemberId(effectiveMemberId) : void 0) ?? effectiveMemberId;
30881
31038
  const compiled = ensureInitializerCompiled({
30882
31039
  init,
30883
31040
  member,
@@ -32875,6 +33032,7 @@ function clonedConstructorProvenance(source) {
32875
33032
  }
32876
33033
  function cloneConstructorLiteralValue(value) {
32877
33034
  if (typeof value !== "object" || value === null) return value;
33035
+ if (value instanceof NSSlotReference) return value.targetId;
32878
33036
  if (Array.isArray(value)) {
32879
33037
  return value.map((entry) => cloneConstructorLiteralValue(entry));
32880
33038
  }
@@ -37136,7 +37294,7 @@ var MaterializedValueGraphContext = class _MaterializedValueGraphContext {
37136
37294
  const typeInfo = parameterTypes.get(parameterId);
37137
37295
  return [
37138
37296
  parameterId,
37139
- typeInfo !== void 0 && isAggregateTypeInfo(typeInfo) && typeof argument2 === "string" ? rewriteId(argument2) : argument2
37297
+ typeInfo !== void 0 && (isAggregateTypeInfo(typeInfo) || typeInfo.type === 29 /* Reference */) && typeof argument2 === "string" ? rewriteId(argument2) : argument2
37140
37298
  ];
37141
37299
  }
37142
37300
  )
@@ -37172,6 +37330,41 @@ var MaterializedValueGraphContext = class _MaterializedValueGraphContext {
37172
37330
  ids.push(edge.targetValueId);
37173
37331
  return ids;
37174
37332
  }
37333
+ /** The targets a row's Reference creation data names (P112 §1.1). */
37334
+ referenceArgumentIds(row) {
37335
+ if (!isLiteralValueContent(row)) return [];
37336
+ const args = row.constructorArgs;
37337
+ if (args === void 0 || args === null) return [];
37338
+ const ids = [];
37339
+ for (const parameterId of this.referenceParameterIds(row)) {
37340
+ const argument2 = args[parameterId];
37341
+ if (typeof argument2 === "string") ids.push(argument2);
37342
+ }
37343
+ return ids;
37344
+ }
37345
+ /** Creation data with each Reference argument's target remapped (P112 §1.1). */
37346
+ remapReferenceArguments(row, remap, contextualMember) {
37347
+ const args = row.constructorArgs;
37348
+ if (args === void 0 || args === null) return args;
37349
+ let remapped;
37350
+ for (const parameterId of this.referenceParameterIds(
37351
+ row,
37352
+ contextualMember
37353
+ )) {
37354
+ const argument2 = args[parameterId];
37355
+ if (typeof argument2 !== "string") continue;
37356
+ const target = remap(argument2);
37357
+ if (target !== argument2) (remapped ??= { ...args })[parameterId] = target;
37358
+ }
37359
+ return remapped ?? args;
37360
+ }
37361
+ *referenceParameterIds(row, contextualMember) {
37362
+ for (const [parameterId, typeInfo] of this.constructorParameterTypes(
37363
+ row,
37364
+ contextualMember
37365
+ ))
37366
+ if (typeInfo.type === 29 /* Reference */) yield parameterId;
37367
+ }
37175
37368
  slotEntries(row) {
37176
37369
  const value = row.value;
37177
37370
  switch (this.referenceSlots(row.id, void 0, value)) {
@@ -38193,7 +38386,11 @@ function resolveVirtualInstanceGraph(args) {
38193
38386
  }
38194
38387
  }
38195
38388
  }
38196
- const virtualRow = rewriteExpandedRow(indexed, expansion);
38389
+ const virtualRow = rewriteExpandedRow(
38390
+ indexed,
38391
+ expansion,
38392
+ materializedGraph
38393
+ );
38197
38394
  const location = {
38198
38395
  id: effectiveId2,
38199
38396
  instanceRootId: args.instanceRoot.id,
@@ -39447,7 +39644,7 @@ function indexExpansion(args) {
39447
39644
  membersById
39448
39645
  };
39449
39646
  }
39450
- function rewriteExpandedRow(node, expansion) {
39647
+ function rewriteExpandedRow(node, expansion, graph) {
39451
39648
  const rewrite = (id) => expansion.nodesByExpandedId.get(id)?.virtualId ?? id;
39452
39649
  const row = cloneRow(node.expandedRow);
39453
39650
  row.id = node.virtualId;
@@ -39469,6 +39666,12 @@ function rewriteExpandedRow(node, expansion) {
39469
39666
  if (node.member.kind === 9 /* Lookup */) {
39470
39667
  row.value = remapLookupSelection(row.value, rewrite);
39471
39668
  }
39669
+ if (isLiteralValueContent(row) && row.constructorArgs !== void 0)
39670
+ row.constructorArgs = graph.remapReferenceArguments(
39671
+ row,
39672
+ rewrite,
39673
+ node.member
39674
+ );
39472
39675
  if (typeof row.containerId === "string") {
39473
39676
  row.containerId = rewrite(row.containerId);
39474
39677
  }
@@ -49971,7 +50174,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
49971
50174
  scope
49972
50175
  )
49973
50176
  );
49974
- const schemaClassInfo = toWireType(targetType, this.project);
50177
+ const schemaClassInfo = this.constructorWireType(targetType, expression);
49975
50178
  if (schemaClassInfo.type !== 7 /* Class */) {
49976
50179
  throw new Error(
49977
50180
  `NeoScript constructor ${className} has non-Class return type ${this.describe(signature.returnType)}.`
@@ -49989,6 +50192,16 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
49989
50192
  writability: "session" /* Session */
49990
50193
  };
49991
50194
  }
50195
+ /** Constructor storage arguments stay distinct from their expression read types. */
50196
+ constructorWireType(target, expression) {
50197
+ const typeArguments = expression.typeArguments?.map(
50198
+ (argument2) => resolveStoredReferenceTarget(argument2, this.context, this.project)
50199
+ );
50200
+ return toWireType(
50201
+ typeArguments === void 0 ? target : { ...target, typeArguments },
50202
+ this.project
50203
+ );
50204
+ }
49992
50205
  constructorTargetType(schemaClass2, expression, expected) {
49993
50206
  const typeArguments = expression.typeArguments?.map(
49994
50207
  (argument2) => this.resolveType(argument2)
@@ -50119,7 +50332,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
50119
50332
  scope
50120
50333
  );
50121
50334
  const classType = targetType;
50122
- const schemaClassInfo = toWireType(classType, this.project);
50335
+ const schemaClassInfo = this.constructorWireType(classType, expression);
50123
50336
  if (schemaClassInfo.type !== 7 /* Class */) {
50124
50337
  throw new Error(
50125
50338
  `NeoScript declared constructor ${className} projected a non-Class wire type.`
@@ -50982,6 +51195,8 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
50982
51195
  {
50983
51196
  collectionPointer: receiver.pointer,
50984
51197
  valuePointer: value.pointer,
51198
+ ...isPrimitive(expectedValueType, "float") ? { float: true } : {},
51199
+ ...isPrimitive(expectedValueType, "decimal") ? { decimal: true } : {},
50985
51200
  ...hasReferenceEquality(collection.valueType, this.project) ? { reference: true } : {}
50986
51201
  },
50987
51202
  { kind: "primitive", name: "int" }
@@ -51011,6 +51226,8 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
51011
51226
  {
51012
51227
  collectionPointer: receiver.pointer,
51013
51228
  valuePointer: value.pointer,
51229
+ ...isPrimitive(expectedValueType, "float") ? { float: true } : {},
51230
+ ...isPrimitive(expectedValueType, "decimal") ? { decimal: true } : {},
51014
51231
  ...hasReferenceEquality(collection.valueType, this.project) ? { reference: true } : {}
51015
51232
  },
51016
51233
  { kind: "primitive", name: "bool" }
@@ -51243,6 +51460,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
51243
51460
  info = {
51244
51461
  ...base,
51245
51462
  op: name,
51463
+ ...isPrimitive(collection.valueType, "decimal") ? { decimalEntries: true } : {},
51246
51464
  ...hasReferenceEquality(collection.valueType, this.project) ? { reference: true } : {}
51247
51465
  };
51248
51466
  resultType = {
@@ -64110,13 +64328,29 @@ function memberSavedForStorage(ctx, memberId, contextSaved, declarationClassId)
64110
64328
  if (isWritableConstraint(classStorage)) return true;
64111
64329
  if (classStorage === 1 /* Immutable */) return false;
64112
64330
  }
64113
- const effective = ctx.storageResolver.effectiveStorages(memberId);
64331
+ let effective = ctx.storageResolver.effectiveStorages(memberId);
64332
+ const visited = /* @__PURE__ */ new Set([memberId]);
64333
+ let currentId = memberId;
64334
+ let baseId = member?.extendsMemberId;
64335
+ while (effective.size === 0 && baseId !== void 0 && !visited.has(baseId)) {
64336
+ if (!isResolvedAbstract(ctx, currentId) && !isResolvedAbstract(ctx, baseId))
64337
+ break;
64338
+ visited.add(baseId);
64339
+ effective = ctx.storageResolver.effectiveStorages(baseId);
64340
+ currentId = baseId;
64341
+ baseId = ctx.exportData.members[baseId]?.extendsMemberId;
64342
+ }
64114
64343
  const hasWritable = effective.has(2 /* Save */) || effective.has(3 /* Session */);
64115
64344
  const hasStatic = effective.has(1 /* Immutable */);
64116
64345
  if (hasWritable && !hasStatic) return true;
64117
64346
  if (hasStatic && !hasWritable) return false;
64118
64347
  return contextSaved;
64119
64348
  }
64349
+ function isResolvedAbstract(ctx, memberId) {
64350
+ return isAbstractMember(
64351
+ resolveMemberById(ctx, memberId, `members.${memberId}`)
64352
+ );
64353
+ }
64120
64354
  function classAllowedStorage(ctx, classId) {
64121
64355
  return ctx.storageResolver.allowedStorage(classId);
64122
64356
  }
@@ -64998,7 +65232,7 @@ function typeInfoConstructedSuffix(ctx, typeInfo, saved, genericEnv, genericBind
64998
65232
  const argType = csharpTypeInfoValueType(
64999
65233
  ctx,
65000
65234
  argInfo,
65001
- saved,
65235
+ true,
65002
65236
  genericEnv,
65003
65237
  genericBindingSaved
65004
65238
  );