@tsplc/compiler 0.2.1 → 0.2.3

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.
package/dist/index.js CHANGED
@@ -3519,21 +3519,24 @@ class Specializer {
3519
3519
  return this.storedField(holder, step);
3520
3520
  return this.capturedConstant(value, holder.type?.symbol?.valueDeclaration ?? this.sources[0]);
3521
3521
  }
3522
+ fieldDeclaration(holder, name) {
3523
+ return holder.captured.kind === "instance" ? this.model.member(this.model.classOf(holder), name) : this.fieldSymbol(holder, name)?.valueDeclaration;
3524
+ }
3522
3525
  fieldIec(holder, name) {
3523
- if (holder.captured.kind === "instance")
3524
- return this.layouts.iecName(this.model.member(this.model.classOf(holder), name));
3525
- return this.layouts.iecName(this.fieldSymbol(holder, name)?.valueDeclaration);
3526
+ return this.layouts.iecName(this.fieldDeclaration(holder, name));
3527
+ }
3528
+ elementIec(declaration) {
3529
+ const node = declaration && declaration.type;
3530
+ const element = node && ts11.isArrayTypeNode(node) ? node.elementType : node && ts11.isTypeReferenceNode(node) ? node.typeArguments?.[0] : undefined;
3531
+ return element ? this.layouts.iecName({ type: element }) : undefined;
3526
3532
  }
3527
- elementIec(array) {
3533
+ arrayElementIec(array) {
3528
3534
  const owner = array.owner;
3529
3535
  const last = owner?.steps.at(-1);
3530
3536
  if (!owner || last?.kind !== "field")
3531
3537
  return;
3532
3538
  const holder = this.at(owner.root, owner.steps.slice(0, -1));
3533
- const declaration = holder && (holder.captured.kind === "instance" ? this.model.member(this.model.classOf(holder), last.name) : this.fieldSymbol(holder, last.name)?.valueDeclaration);
3534
- const node = declaration && declaration.type;
3535
- const element = node && ts11.isArrayTypeNode(node) ? node.elementType : node && ts11.isTypeReferenceNode(node) ? node.typeArguments?.[0] : undefined;
3536
- return element ? this.layouts.iecName({ type: element }) : undefined;
3539
+ return holder && this.elementIec(this.fieldDeclaration(holder, last.name));
3537
3540
  }
3538
3541
  storedField(holder, step) {
3539
3542
  const declared = step.kind === "index" ? holder.type && this.model.elementType(holder.type) : holder.captured.kind === "instance" ? (() => {
@@ -3546,7 +3549,10 @@ class Specializer {
3546
3549
  text: `${this.pathText(holder)}${step.kind === "index" ? `[${step.index}]` : `.${step.name}`}`,
3547
3550
  declared,
3548
3551
  place: true,
3549
- iec: step.kind === "field" ? this.fieldIec(holder, step.name) : this.elementIec(holder),
3552
+ ...step.kind === "field" ? {
3553
+ iec: this.fieldIec(holder, step.name),
3554
+ elementIec: this.elementIec(this.fieldDeclaration(holder, step.name))
3555
+ } : { iec: this.arrayElementIec(holder) },
3550
3556
  ...global && { setter: `${this.pathText(holder)}.${setterName(step.name)}` }
3551
3557
  };
3552
3558
  }
@@ -3676,7 +3682,8 @@ class Specializer {
3676
3682
  kind: "code",
3677
3683
  text: `${object.text}[${this.code(index, undefined, frame)}]`,
3678
3684
  declared,
3679
- place: object.place
3685
+ place: object.place,
3686
+ iec: object.elementIec
3680
3687
  };
3681
3688
  }
3682
3689
  if (object.kind === "virtual" && object.items) {
@@ -6855,5 +6862,5 @@ export {
6855
6862
  typeCheckOnly
6856
6863
  };
6857
6864
 
6858
- //# debugId=73256814D883503164756E2164756E21
6865
+ //# debugId=43B8CCF724F116A364756E2164756E21
6859
6866
  //# sourceMappingURL=index.js.map