@tsplc/compiler 0.5.13 → 0.5.15

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.
Files changed (263) hide show
  1. package/README.md +33 -8
  2. package/dist/cli.js +794 -621
  3. package/dist/cli.js.map +19 -16
  4. package/dist/clock.js +5 -2
  5. package/dist/clock.js.map +5 -4
  6. package/dist/codesys.js +4162 -4157
  7. package/dist/codesys.js.map +43 -29
  8. package/dist/index.js +7852 -6549
  9. package/dist/index.js.map +53 -50
  10. package/dist/ir.js +2482 -2277
  11. package/dist/ir.js.map +28 -25
  12. package/dist/retain.js +3 -1
  13. package/dist/retain.js.map +3 -3
  14. package/dist/signals.js +115 -0
  15. package/dist/signals.js.map +10 -0
  16. package/dist/telemetry.js +25 -20
  17. package/dist/telemetry.js.map +6 -6
  18. package/package.json +19 -39
  19. package/src/codesys/config.ts +3 -3
  20. package/src/codesys/debug.ts +92 -108
  21. package/src/codesys/emit.ts +100 -88
  22. package/src/codesys/endpoints.ts +111 -0
  23. package/src/codesys/engineering.ts +30 -54
  24. package/src/codesys/explain/expressions.ts +445 -0
  25. package/src/codesys/explain/flags.ts +134 -0
  26. package/src/codesys/explain/parameters.ts +53 -0
  27. package/src/codesys/explain/rows.ts +182 -0
  28. package/src/codesys/explain/tables.ts +79 -0
  29. package/src/codesys/explain/tasks.ts +68 -0
  30. package/src/codesys/explain/writes.ts +497 -0
  31. package/src/codesys/explain.ts +85 -1401
  32. package/src/codesys/expressions.ts +41 -33
  33. package/src/codesys/global-lists.ts +114 -94
  34. package/src/codesys/global-names.ts +12 -14
  35. package/src/codesys/http.ts +428 -388
  36. package/src/codesys/instrumentation.ts +142 -148
  37. package/src/codesys/io-paths.ts +31 -23
  38. package/src/codesys/loops.ts +101 -0
  39. package/src/codesys/manifest.ts +269 -269
  40. package/src/codesys/names.ts +10 -33
  41. package/src/codesys/numeric.ts +89 -42
  42. package/src/codesys/plan.ts +202 -190
  43. package/src/codesys/programs.ts +23 -16
  44. package/src/codesys/publication.ts +13 -86
  45. package/src/codesys/required.ts +8 -0
  46. package/src/codesys/routines.ts +103 -489
  47. package/src/codesys/scheduling.ts +96 -0
  48. package/src/codesys/service-channels.ts +23 -0
  49. package/src/codesys/sources.ts +34 -28
  50. package/src/codesys/st-files.ts +112 -105
  51. package/src/codesys/statements.ts +409 -0
  52. package/src/codesys/storage.ts +41 -23
  53. package/src/codesys/symbols.ts +130 -119
  54. package/src/codesys/task-access.ts +65 -221
  55. package/src/codesys/telemetry-settings.ts +19 -0
  56. package/src/codesys/telemetry.ts +185 -148
  57. package/src/codesys/types.ts +69 -109
  58. package/src/codesys/vendor.ts +13 -50
  59. package/src/frontend/analyzer.ts +66 -111
  60. package/src/frontend/async.ts +316 -128
  61. package/src/frontend/blocks.ts +178 -154
  62. package/src/frontend/configuration.ts +49 -153
  63. package/src/frontend/const-functions.ts +50 -40
  64. package/src/frontend/control-flow.ts +164 -129
  65. package/src/frontend/cooperative.ts +17 -9
  66. package/src/frontend/coroutines.ts +539 -441
  67. package/src/frontend/dialect-names.ts +104 -0
  68. package/src/frontend/elaborate/array-searches.ts +77 -69
  69. package/src/frontend/elaborate/assignments.ts +68 -77
  70. package/src/frontend/elaborate/calls.ts +878 -512
  71. package/src/frontend/elaborate/capture-protocol.ts +118 -21
  72. package/src/frontend/elaborate/capture.ts +196 -109
  73. package/src/frontend/elaborate/declarations.ts +124 -0
  74. package/src/frontend/elaborate/dialect.ts +119 -46
  75. package/src/frontend/elaborate/expressions.ts +763 -442
  76. package/src/frontend/elaborate/filtered-arrays.ts +127 -91
  77. package/src/frontend/elaborate/frame.ts +50 -2
  78. package/src/frontend/elaborate/generics.ts +20 -34
  79. package/src/frontend/elaborate/graph.ts +13 -87
  80. package/src/frontend/elaborate/imports.ts +0 -5
  81. package/src/frontend/elaborate/index.ts +416 -169
  82. package/src/frontend/elaborate/initializers.ts +64 -42
  83. package/src/frontend/elaborate/iterators.ts +228 -364
  84. package/src/frontend/elaborate/layouts.ts +477 -116
  85. package/src/frontend/elaborate/model.ts +113 -55
  86. package/src/frontend/elaborate/references.ts +116 -138
  87. package/src/frontend/elaborate/retention.ts +137 -59
  88. package/src/frontend/elaborate/specialize.ts +617 -308
  89. package/src/frontend/elaborate/statements.ts +436 -247
  90. package/src/frontend/elaborate/storage.ts +280 -213
  91. package/src/frontend/elaborate/time-constructors.ts +34 -0
  92. package/src/frontend/elaborate/values.ts +77 -7
  93. package/src/frontend/elaborate/writes.ts +98 -84
  94. package/src/frontend/expressions.ts +149 -151
  95. package/src/frontend/generated-names.ts +3 -3
  96. package/src/frontend/intrinsics.ts +31 -17
  97. package/src/frontend/lowering-key.ts +23 -0
  98. package/src/frontend/module-graph.ts +105 -43
  99. package/src/frontend/positions.ts +43 -35
  100. package/src/frontend/promise-chains.ts +226 -266
  101. package/src/frontend/promises.ts +88 -67
  102. package/src/frontend/routines.ts +122 -65
  103. package/src/frontend/sdk.ts +104 -5
  104. package/src/frontend/services.ts +149 -102
  105. package/src/frontend/statements.ts +60 -64
  106. package/src/frontend/tasks.ts +151 -96
  107. package/src/frontend/telemetry.ts +1 -1
  108. package/src/frontend/types.ts +366 -181
  109. package/src/frontend/typescript.ts +239 -112
  110. package/src/index.ts +2 -1
  111. package/src/ir/aggregates.ts +90 -75
  112. package/src/ir/allocation.ts +29 -18
  113. package/src/ir/conditions.ts +38 -78
  114. package/src/ir/core-model.ts +128 -11
  115. package/src/ir/declarations.ts +18 -32
  116. package/src/ir/diagnostics.ts +25 -18
  117. package/src/ir/domains.ts +26 -23
  118. package/src/ir/fold.ts +55 -50
  119. package/src/ir/identity.ts +10 -0
  120. package/src/ir/index.ts +31 -7
  121. package/src/ir/job-errors.ts +30 -8
  122. package/src/ir/layouts.ts +63 -34
  123. package/src/ir/link.ts +11 -46
  124. package/src/ir/model.ts +25 -6
  125. package/src/ir/normalize.ts +3 -28
  126. package/src/ir/numeric.ts +45 -18
  127. package/src/ir/operands.ts +102 -0
  128. package/src/ir/ranges.ts +242 -67
  129. package/src/ir/routine.ts +126 -183
  130. package/src/ir/scalars.ts +29 -25
  131. package/src/ir/share.ts +323 -343
  132. package/src/ir/short-circuit.ts +140 -0
  133. package/src/ir/tables.ts +111 -0
  134. package/src/ir/temporaries.ts +15 -113
  135. package/src/ir/types.ts +32 -8
  136. package/src/project/artifacts.ts +143 -71
  137. package/src/project/cli.ts +104 -87
  138. package/src/project/debugger.ts +48 -34
  139. package/src/project/deployments.ts +12 -68
  140. package/src/project/flags.ts +14 -0
  141. package/src/project/plant.ts +293 -225
  142. package/src/project/project-commands.ts +254 -192
  143. package/src/project/project.ts +184 -141
  144. package/src/project/release.ts +22 -28
  145. package/src/project/server.ts +22 -26
  146. package/src/project/terminal.ts +13 -2
  147. package/src/runtime/async.ts +17 -13
  148. package/src/runtime/launch.ts +5 -2
  149. package/src/runtime/main.ts +8 -3
  150. package/src/runtime/missing-file.ts +3 -0
  151. package/src/runtime/process.ts +24 -19
  152. package/src/runtime/program.ts +20 -53
  153. package/src/runtime/retain.ts +18 -10
  154. package/src/runtime/runtime.ts +47 -60
  155. package/src/runtime/settings.ts +27 -0
  156. package/src/runtime/storage.ts +49 -74
  157. package/src/runtime/symbols.ts +19 -75
  158. package/src/runtime/telemetry.ts +37 -14
  159. package/src/runtime/transport.ts +26 -30
  160. package/stdlib/clock.ts +4 -2
  161. package/stdlib/plc-time.ts +2 -0
  162. package/stdlib/retain.ts +2 -0
  163. package/stdlib/signals.ts +142 -0
  164. package/stdlib/telemetry.ts +5 -12
  165. package/types/dialect.d.ts +49 -0
  166. package/types/globals.d.ts +2 -42
  167. package/types/index.d.ts +3 -1
  168. package/types/retain.d.ts +8 -2
  169. package/types/telemetry.d.ts +3 -0
  170. package/dist/bun-runtime.js +0 -1472
  171. package/dist/bun-runtime.js.map +0 -26
  172. package/dist/elaborate-capture.js +0 -304
  173. package/dist/elaborate-capture.js.map +0 -11
  174. package/dist/math.js +0 -24
  175. package/dist/math.js.map +0 -10
  176. package/dist/project.js +0 -626
  177. package/dist/project.js.map +0 -12
  178. package/dist/server-check.js +0 -59
  179. package/dist/server-check.js.map +0 -11
  180. package/src/frontend/exposure.ts +0 -181
  181. package/src/project/index.ts +0 -6
  182. package/src/runtime/.runtime-65O4JH/server/router.ts +0 -17
  183. package/src/runtime/.runtime-65O4JH/src/cell.ts +0 -45
  184. package/src/runtime/.runtime-65O4JH/src/controller.ts +0 -58
  185. package/src/runtime/.runtime-65O4JH/src/lane.ts +0 -6
  186. package/src/runtime/.runtime-65O4JH/src/main.ts +0 -11
  187. package/src/runtime/.runtime-65O4JH/src/services.ts +0 -8
  188. package/src/runtime/.runtime-65O4JH/tsconfig.json +0 -13
  189. package/src/runtime/.runtime-65O4JH/tsplc.config.ts +0 -31
  190. package/src/runtime/.runtime-Brw2kO/server/router.ts +0 -17
  191. package/src/runtime/.runtime-Brw2kO/src/cell.ts +0 -45
  192. package/src/runtime/.runtime-Brw2kO/src/controller.ts +0 -58
  193. package/src/runtime/.runtime-Brw2kO/src/lane.ts +0 -6
  194. package/src/runtime/.runtime-Brw2kO/src/main.ts +0 -11
  195. package/src/runtime/.runtime-Brw2kO/src/services.ts +0 -8
  196. package/src/runtime/.runtime-Brw2kO/tsconfig.json +0 -13
  197. package/src/runtime/.runtime-Brw2kO/tsplc.config.ts +0 -31
  198. package/src/runtime/.runtime-NHfu1D/server/router.ts +0 -17
  199. package/src/runtime/.runtime-NHfu1D/src/cell.ts +0 -45
  200. package/src/runtime/.runtime-NHfu1D/src/controller.ts +0 -58
  201. package/src/runtime/.runtime-NHfu1D/src/lane.ts +0 -6
  202. package/src/runtime/.runtime-NHfu1D/src/main.ts +0 -11
  203. package/src/runtime/.runtime-NHfu1D/src/services.ts +0 -8
  204. package/src/runtime/.runtime-NHfu1D/tsconfig.json +0 -13
  205. package/src/runtime/.runtime-NHfu1D/tsplc.config.ts +0 -31
  206. package/src/runtime/.runtime-VaUSOu/server/router.ts +0 -17
  207. package/src/runtime/.runtime-VaUSOu/src/cell.ts +0 -45
  208. package/src/runtime/.runtime-VaUSOu/src/controller.ts +0 -58
  209. package/src/runtime/.runtime-VaUSOu/src/lane.ts +0 -6
  210. package/src/runtime/.runtime-VaUSOu/src/main.ts +0 -11
  211. package/src/runtime/.runtime-VaUSOu/src/services.ts +0 -8
  212. package/src/runtime/.runtime-VaUSOu/tsconfig.json +0 -13
  213. package/src/runtime/.runtime-VaUSOu/tsplc.config.ts +0 -31
  214. package/src/runtime/.runtime-WbtNvR/server/router.ts +0 -17
  215. package/src/runtime/.runtime-WbtNvR/src/cell.ts +0 -45
  216. package/src/runtime/.runtime-WbtNvR/src/controller.ts +0 -58
  217. package/src/runtime/.runtime-WbtNvR/src/lane.ts +0 -6
  218. package/src/runtime/.runtime-WbtNvR/src/main.ts +0 -11
  219. package/src/runtime/.runtime-WbtNvR/src/services.ts +0 -8
  220. package/src/runtime/.runtime-WbtNvR/tsconfig.json +0 -13
  221. package/src/runtime/.runtime-WbtNvR/tsplc.config.ts +0 -31
  222. package/src/runtime/.runtime-opcua-GMPUt8/server/router.ts +0 -17
  223. package/src/runtime/.runtime-opcua-GMPUt8/src/cell.ts +0 -45
  224. package/src/runtime/.runtime-opcua-GMPUt8/src/controller.ts +0 -58
  225. package/src/runtime/.runtime-opcua-GMPUt8/src/lane.ts +0 -6
  226. package/src/runtime/.runtime-opcua-GMPUt8/src/main.ts +0 -11
  227. package/src/runtime/.runtime-opcua-GMPUt8/src/services.ts +0 -8
  228. package/src/runtime/.runtime-opcua-GMPUt8/tsconfig.json +0 -13
  229. package/src/runtime/.runtime-opcua-GMPUt8/tsplc.config.ts +0 -31
  230. package/src/runtime/.runtime-opcua-UwafxO/server/router.ts +0 -17
  231. package/src/runtime/.runtime-opcua-UwafxO/src/cell.ts +0 -45
  232. package/src/runtime/.runtime-opcua-UwafxO/src/controller.ts +0 -58
  233. package/src/runtime/.runtime-opcua-UwafxO/src/lane.ts +0 -6
  234. package/src/runtime/.runtime-opcua-UwafxO/src/main.ts +0 -11
  235. package/src/runtime/.runtime-opcua-UwafxO/src/services.ts +0 -8
  236. package/src/runtime/.runtime-opcua-UwafxO/tsconfig.json +0 -13
  237. package/src/runtime/.runtime-opcua-UwafxO/tsplc.config.ts +0 -31
  238. package/src/runtime/.runtime-opcua-ecaSee/server/router.ts +0 -17
  239. package/src/runtime/.runtime-opcua-ecaSee/src/cell.ts +0 -45
  240. package/src/runtime/.runtime-opcua-ecaSee/src/controller.ts +0 -58
  241. package/src/runtime/.runtime-opcua-ecaSee/src/lane.ts +0 -6
  242. package/src/runtime/.runtime-opcua-ecaSee/src/main.ts +0 -11
  243. package/src/runtime/.runtime-opcua-ecaSee/src/services.ts +0 -8
  244. package/src/runtime/.runtime-opcua-ecaSee/tsconfig.json +0 -13
  245. package/src/runtime/.runtime-opcua-ecaSee/tsplc.config.ts +0 -31
  246. package/src/runtime/.runtime-opcua-y91UCm/server/router.ts +0 -17
  247. package/src/runtime/.runtime-opcua-y91UCm/src/cell.ts +0 -45
  248. package/src/runtime/.runtime-opcua-y91UCm/src/controller.ts +0 -58
  249. package/src/runtime/.runtime-opcua-y91UCm/src/lane.ts +0 -6
  250. package/src/runtime/.runtime-opcua-y91UCm/src/main.ts +0 -11
  251. package/src/runtime/.runtime-opcua-y91UCm/src/services.ts +0 -8
  252. package/src/runtime/.runtime-opcua-y91UCm/tsconfig.json +0 -13
  253. package/src/runtime/.runtime-opcua-y91UCm/tsplc.config.ts +0 -31
  254. package/src/runtime/.runtime-ybIxYh/server/router.ts +0 -17
  255. package/src/runtime/.runtime-ybIxYh/src/cell.ts +0 -45
  256. package/src/runtime/.runtime-ybIxYh/src/controller.ts +0 -58
  257. package/src/runtime/.runtime-ybIxYh/src/lane.ts +0 -6
  258. package/src/runtime/.runtime-ybIxYh/src/main.ts +0 -11
  259. package/src/runtime/.runtime-ybIxYh/src/services.ts +0 -8
  260. package/src/runtime/.runtime-ybIxYh/tsconfig.json +0 -13
  261. package/src/runtime/.runtime-ybIxYh/tsplc.config.ts +0 -31
  262. package/stdlib/math.ts +0 -23
  263. package/types/plc.d.ts +0 -4
@@ -1,12 +1,21 @@
1
- // biome-ignore-all lint/style/noNonNullAssertion: Retain existing non-null assertions during the tooling migration; changing their contracts requires a separate review.
2
1
  import ts from "typescript";
3
2
  import type { CapturedValue } from "./capture-protocol";
4
- import { type Layouts, recordTypes } from "./layouts";
3
+ import {
4
+ definedOptional,
5
+ holdsInstances,
6
+ type Layouts,
7
+ recordTypes,
8
+ } from "./layouts";
5
9
  import type { Model, ModelNode } from "./model";
6
- import type { Storage } from "./storage";
10
+ import { noReference } from "./references";
11
+ import { mixedStateText, type Storage } from "./storage";
12
+ import { calendarConstructor } from "./time-constructors";
7
13
 
8
14
  /** Values setup captured as dialect text: storage initializers, and fixed data scan code reads. */
9
15
  export class Initializers {
16
+ /** SDK functions the text written since `takeSdkCalls` last ran calls, which its module imports. */
17
+ private readonly sdkCalls = new Set<string>();
18
+
10
19
  constructor(
11
20
  private readonly model: Model,
12
21
  private readonly checker: ts.TypeChecker,
@@ -30,27 +39,46 @@ export class Initializers {
30
39
  const name = layout ?? this.layouts.text(declared, value);
31
40
  return value.kind === "undefined"
32
41
  ? `defaultValue<${name}>()`
33
- : `{ has: true, value: ${this.valueText(value, inner)} }`;
42
+ : definedOptional(this.valueText(value, inner)).text;
34
43
  }
35
44
  if (this.layouts.enumDeclaration(declared) && value.kind === "number") {
36
- const enumName = this.layouts.text(declared);
37
- const member = this.layouts.enumMemberName(declared, value.value);
38
- return member ? `${enumName}.${member}` : String(value.value);
45
+ return (
46
+ this.layouts.enumMember(declared, value.value) ?? String(value.value)
47
+ );
48
+ }
49
+ // Setup's TIME is a number of milliseconds; the dialect spells a TIME constant as a duration.
50
+ if (
51
+ value.kind === "number" &&
52
+ (layout ?? declared.aliasSymbol?.name) === "TIME"
53
+ ) {
54
+ this.sdkCalls.add("ms");
55
+ return `ms(${value.value})`;
56
+ }
57
+ // Setup's calendar value is the text it was written in, which its constructor takes.
58
+ const calendar = calendarConstructor(
59
+ layout ?? declared.aliasSymbol?.name ?? "",
60
+ );
61
+ if (value.kind === "string" && calendar) {
62
+ this.sdkCalls.add(calendar);
63
+ return `${calendar}(${JSON.stringify(value.value)})`;
39
64
  }
40
65
  if (!node) {
41
66
  return this.literal(value);
42
67
  }
43
68
  if (node.captured.kind === "array") {
44
69
  const element = this.model.elementType(declared);
45
- const items = node.captured.items;
46
70
  // Instances of different classes are stored side by side, a field each.
47
- if (this.storage.mixedStates(node)) {
48
- return `{ ${items.map((item, index) => `item${index}: ${element ? this.valueText(item, element) : this.literal(item)}`).join(", ")} }`;
71
+ const mixed = this.storage.mixedStates(node);
72
+ const items = node.captured.items.map((item) =>
73
+ element ? this.valueText(item, element) : this.literal(item),
74
+ );
75
+ if (mixed) {
76
+ return mixedStateText(items);
49
77
  }
50
78
  if (!items.length) {
51
79
  return `defaultValue<${layout ?? this.layouts.text(declared, value)}>()`;
52
80
  }
53
- return `[${items.map((item) => (element ? this.valueText(item, element) : this.literal(item))).join(", ")}]`;
81
+ return `[${items.join(", ")}]`;
54
82
  }
55
83
  if (node.captured.kind === "object") {
56
84
  return this.recordInitializer(node, declared);
@@ -62,6 +90,13 @@ export class Initializers {
62
90
  throw new Error("A function has no stored value.");
63
91
  }
64
92
 
93
+ /** The SDK functions of `@tsplc/compiler/types` the text written since the last call calls. */
94
+ takeSdkCalls(): string[] {
95
+ const names = [...this.sdkCalls];
96
+ this.sdkCalls.clear();
97
+ return names;
98
+ }
99
+
65
100
  private instanceInitializer(node: ModelNode): string {
66
101
  return `{ ${this.storage
67
102
  .instanceFields(node)
@@ -82,43 +117,31 @@ export class Initializers {
82
117
  if (captured.kind !== "instance") {
83
118
  throw new Error("Not an instance.");
84
119
  }
85
- const value = captured.fields[name] ?? { kind: "undefined" as const };
120
+ const value = this.model.field(node, name);
86
121
  const inner = this.model.node(value);
87
- // A reference starts as the id of the object setup gave it, or -1 for none.
88
122
  if (this.storage.referenceField(node, name)) {
89
- return String(inner ? inner.id : -1);
123
+ return inner ? String(inner.reference) : noReference;
90
124
  }
91
125
  if (inner?.captured.kind === "instance") {
92
126
  return this.instanceInitializer(inner);
93
127
  }
94
- if (
95
- inner?.captured.kind === "array" &&
96
- inner.captured.items.some(
97
- (item) => this.model.node(item)?.captured.kind === "instance",
98
- )
99
- ) {
100
- const states = inner.captured.items.map((item) =>
101
- this.instanceInitializer(this.model.node(item)!),
102
- );
103
- // Instances of different classes are stored side by side, a field each.
128
+ if (inner?.captured.kind === "array" && holdsInstances(this.model, inner)) {
129
+ const states = inner.captured.items.map((item) => {
130
+ const instance = this.model.node(item);
131
+ if (!instance) {
132
+ throw new Error(`${name} holds a primitive among its instances.`);
133
+ }
134
+ return this.instanceInitializer(instance);
135
+ });
104
136
  return this.storage.mixedStates(inner)
105
- ? `{ ${states.map((state, index) => `item${index}: ${state}`).join(", ")} }`
137
+ ? mixedStateText(states)
106
138
  : `[${states.join(", ")}]`;
107
139
  }
108
- return this.fieldInitializer(node, name, value, layout);
109
- }
110
-
111
- private fieldInitializer(
112
- holder: ModelNode,
113
- name: string,
114
- value: CapturedValue,
115
- type: string,
116
- ): string {
117
- const declaredType = this.model.capturedFieldType(holder, name);
118
- if (!declaredType) {
140
+ const declared = this.model.capturedFieldType(node, name);
141
+ if (!declared) {
119
142
  throw new Error(`${name} has no declared type.`);
120
143
  }
121
- return this.valueText(value, declaredType, type);
144
+ return this.valueText(value, declared, layout);
122
145
  }
123
146
 
124
147
  private recordInitializer(node: ModelNode, declared: ts.Type): string {
@@ -139,9 +162,7 @@ export class Initializers {
139
162
  const fields = properties.map((name): [string, string] => {
140
163
  const field = captured.fields[name];
141
164
  if (tagged && name === tagged.tag) {
142
- const tag = this.layouts.literalEnum(
143
- this.layouts.tagType(declared, tagged),
144
- )!;
165
+ const tag = this.layouts.tagEnum(declared, tagged);
145
166
  return [
146
167
  name,
147
168
  this.layouts.member(
@@ -168,9 +189,11 @@ export class Initializers {
168
189
  }
169
190
  const literal = this.layouts.literalEnum(record.key);
170
191
  const entries = fields.map(([name, value]) => {
192
+ // A string member of a mixed enum has no number; its key stays as written for verification to reject.
171
193
  const key = literal
172
194
  ? this.layouts.member(literal, name)
173
- : `${this.layouts.text(record.key)}.${this.layouts.enumMemberName(record.key, Number(name))}`;
195
+ : (this.layouts.enumMember(record.key, Number(name)) ??
196
+ JSON.stringify(name));
174
197
  return `[${key}]: ${value}`;
175
198
  });
176
199
  // An enum that is also optional elsewhere has an Undefined member the table must cover.
@@ -185,7 +208,6 @@ export class Initializers {
185
208
  private literal(value: CapturedValue): string {
186
209
  switch (value.kind) {
187
210
  case "number":
188
- return String(value.value);
189
211
  case "boolean":
190
212
  return String(value.value);
191
213
  case "string":