@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.
- package/README.md +33 -8
- package/dist/cli.js +794 -621
- package/dist/cli.js.map +19 -16
- package/dist/clock.js +5 -2
- package/dist/clock.js.map +5 -4
- package/dist/codesys.js +4162 -4157
- package/dist/codesys.js.map +43 -29
- package/dist/index.js +7852 -6549
- package/dist/index.js.map +53 -50
- package/dist/ir.js +2482 -2277
- package/dist/ir.js.map +28 -25
- package/dist/retain.js +3 -1
- package/dist/retain.js.map +3 -3
- package/dist/signals.js +115 -0
- package/dist/signals.js.map +10 -0
- package/dist/telemetry.js +25 -20
- package/dist/telemetry.js.map +6 -6
- package/package.json +19 -39
- package/src/codesys/config.ts +3 -3
- package/src/codesys/debug.ts +92 -108
- package/src/codesys/emit.ts +100 -88
- package/src/codesys/endpoints.ts +111 -0
- package/src/codesys/engineering.ts +30 -54
- package/src/codesys/explain/expressions.ts +445 -0
- package/src/codesys/explain/flags.ts +134 -0
- package/src/codesys/explain/parameters.ts +53 -0
- package/src/codesys/explain/rows.ts +182 -0
- package/src/codesys/explain/tables.ts +79 -0
- package/src/codesys/explain/tasks.ts +68 -0
- package/src/codesys/explain/writes.ts +497 -0
- package/src/codesys/explain.ts +85 -1401
- package/src/codesys/expressions.ts +41 -33
- package/src/codesys/global-lists.ts +114 -94
- package/src/codesys/global-names.ts +12 -14
- package/src/codesys/http.ts +428 -388
- package/src/codesys/instrumentation.ts +142 -148
- package/src/codesys/io-paths.ts +31 -23
- package/src/codesys/loops.ts +101 -0
- package/src/codesys/manifest.ts +269 -269
- package/src/codesys/names.ts +10 -33
- package/src/codesys/numeric.ts +89 -42
- package/src/codesys/plan.ts +202 -190
- package/src/codesys/programs.ts +23 -16
- package/src/codesys/publication.ts +13 -86
- package/src/codesys/required.ts +8 -0
- package/src/codesys/routines.ts +103 -489
- package/src/codesys/scheduling.ts +96 -0
- package/src/codesys/service-channels.ts +23 -0
- package/src/codesys/sources.ts +34 -28
- package/src/codesys/st-files.ts +112 -105
- package/src/codesys/statements.ts +409 -0
- package/src/codesys/storage.ts +41 -23
- package/src/codesys/symbols.ts +130 -119
- package/src/codesys/task-access.ts +65 -221
- package/src/codesys/telemetry-settings.ts +19 -0
- package/src/codesys/telemetry.ts +185 -148
- package/src/codesys/types.ts +69 -109
- package/src/codesys/vendor.ts +13 -50
- package/src/frontend/analyzer.ts +66 -111
- package/src/frontend/async.ts +316 -128
- package/src/frontend/blocks.ts +178 -154
- package/src/frontend/configuration.ts +49 -153
- package/src/frontend/const-functions.ts +50 -40
- package/src/frontend/control-flow.ts +164 -129
- package/src/frontend/cooperative.ts +17 -9
- package/src/frontend/coroutines.ts +539 -441
- package/src/frontend/dialect-names.ts +104 -0
- package/src/frontend/elaborate/array-searches.ts +77 -69
- package/src/frontend/elaborate/assignments.ts +68 -77
- package/src/frontend/elaborate/calls.ts +878 -512
- package/src/frontend/elaborate/capture-protocol.ts +118 -21
- package/src/frontend/elaborate/capture.ts +196 -109
- package/src/frontend/elaborate/declarations.ts +124 -0
- package/src/frontend/elaborate/dialect.ts +119 -46
- package/src/frontend/elaborate/expressions.ts +763 -442
- package/src/frontend/elaborate/filtered-arrays.ts +127 -91
- package/src/frontend/elaborate/frame.ts +50 -2
- package/src/frontend/elaborate/generics.ts +20 -34
- package/src/frontend/elaborate/graph.ts +13 -87
- package/src/frontend/elaborate/imports.ts +0 -5
- package/src/frontend/elaborate/index.ts +416 -169
- package/src/frontend/elaborate/initializers.ts +64 -42
- package/src/frontend/elaborate/iterators.ts +228 -364
- package/src/frontend/elaborate/layouts.ts +477 -116
- package/src/frontend/elaborate/model.ts +113 -55
- package/src/frontend/elaborate/references.ts +116 -138
- package/src/frontend/elaborate/retention.ts +137 -59
- package/src/frontend/elaborate/specialize.ts +617 -308
- package/src/frontend/elaborate/statements.ts +436 -247
- package/src/frontend/elaborate/storage.ts +280 -213
- package/src/frontend/elaborate/time-constructors.ts +34 -0
- package/src/frontend/elaborate/values.ts +77 -7
- package/src/frontend/elaborate/writes.ts +98 -84
- package/src/frontend/expressions.ts +149 -151
- package/src/frontend/generated-names.ts +3 -3
- package/src/frontend/intrinsics.ts +31 -17
- package/src/frontend/lowering-key.ts +23 -0
- package/src/frontend/module-graph.ts +105 -43
- package/src/frontend/positions.ts +43 -35
- package/src/frontend/promise-chains.ts +226 -266
- package/src/frontend/promises.ts +88 -67
- package/src/frontend/routines.ts +122 -65
- package/src/frontend/sdk.ts +104 -5
- package/src/frontend/services.ts +149 -102
- package/src/frontend/statements.ts +60 -64
- package/src/frontend/tasks.ts +151 -96
- package/src/frontend/telemetry.ts +1 -1
- package/src/frontend/types.ts +366 -181
- package/src/frontend/typescript.ts +239 -112
- package/src/index.ts +2 -1
- package/src/ir/aggregates.ts +90 -75
- package/src/ir/allocation.ts +29 -18
- package/src/ir/conditions.ts +38 -78
- package/src/ir/core-model.ts +128 -11
- package/src/ir/declarations.ts +18 -32
- package/src/ir/diagnostics.ts +25 -18
- package/src/ir/domains.ts +26 -23
- package/src/ir/fold.ts +55 -50
- package/src/ir/identity.ts +10 -0
- package/src/ir/index.ts +31 -7
- package/src/ir/job-errors.ts +30 -8
- package/src/ir/layouts.ts +63 -34
- package/src/ir/link.ts +11 -46
- package/src/ir/model.ts +25 -6
- package/src/ir/normalize.ts +3 -28
- package/src/ir/numeric.ts +45 -18
- package/src/ir/operands.ts +102 -0
- package/src/ir/ranges.ts +242 -67
- package/src/ir/routine.ts +126 -183
- package/src/ir/scalars.ts +29 -25
- package/src/ir/share.ts +323 -343
- package/src/ir/short-circuit.ts +140 -0
- package/src/ir/tables.ts +111 -0
- package/src/ir/temporaries.ts +15 -113
- package/src/ir/types.ts +32 -8
- package/src/project/artifacts.ts +143 -71
- package/src/project/cli.ts +104 -87
- package/src/project/debugger.ts +48 -34
- package/src/project/deployments.ts +12 -68
- package/src/project/flags.ts +14 -0
- package/src/project/plant.ts +293 -225
- package/src/project/project-commands.ts +254 -192
- package/src/project/project.ts +184 -141
- package/src/project/release.ts +22 -28
- package/src/project/server.ts +22 -26
- package/src/project/terminal.ts +13 -2
- package/src/runtime/async.ts +17 -13
- package/src/runtime/launch.ts +5 -2
- package/src/runtime/main.ts +8 -3
- package/src/runtime/missing-file.ts +3 -0
- package/src/runtime/process.ts +24 -19
- package/src/runtime/program.ts +20 -53
- package/src/runtime/retain.ts +18 -10
- package/src/runtime/runtime.ts +47 -60
- package/src/runtime/settings.ts +27 -0
- package/src/runtime/storage.ts +49 -74
- package/src/runtime/symbols.ts +19 -75
- package/src/runtime/telemetry.ts +37 -14
- package/src/runtime/transport.ts +26 -30
- package/stdlib/clock.ts +4 -2
- package/stdlib/plc-time.ts +2 -0
- package/stdlib/retain.ts +2 -0
- package/stdlib/signals.ts +142 -0
- package/stdlib/telemetry.ts +5 -12
- package/types/dialect.d.ts +49 -0
- package/types/globals.d.ts +2 -42
- package/types/index.d.ts +3 -1
- package/types/retain.d.ts +8 -2
- package/types/telemetry.d.ts +3 -0
- package/dist/bun-runtime.js +0 -1472
- package/dist/bun-runtime.js.map +0 -26
- package/dist/elaborate-capture.js +0 -304
- package/dist/elaborate-capture.js.map +0 -11
- package/dist/math.js +0 -24
- package/dist/math.js.map +0 -10
- package/dist/project.js +0 -626
- package/dist/project.js.map +0 -12
- package/dist/server-check.js +0 -59
- package/dist/server-check.js.map +0 -11
- package/src/frontend/exposure.ts +0 -181
- package/src/project/index.ts +0 -6
- package/src/runtime/.runtime-65O4JH/server/router.ts +0 -17
- package/src/runtime/.runtime-65O4JH/src/cell.ts +0 -45
- package/src/runtime/.runtime-65O4JH/src/controller.ts +0 -58
- package/src/runtime/.runtime-65O4JH/src/lane.ts +0 -6
- package/src/runtime/.runtime-65O4JH/src/main.ts +0 -11
- package/src/runtime/.runtime-65O4JH/src/services.ts +0 -8
- package/src/runtime/.runtime-65O4JH/tsconfig.json +0 -13
- package/src/runtime/.runtime-65O4JH/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-Brw2kO/server/router.ts +0 -17
- package/src/runtime/.runtime-Brw2kO/src/cell.ts +0 -45
- package/src/runtime/.runtime-Brw2kO/src/controller.ts +0 -58
- package/src/runtime/.runtime-Brw2kO/src/lane.ts +0 -6
- package/src/runtime/.runtime-Brw2kO/src/main.ts +0 -11
- package/src/runtime/.runtime-Brw2kO/src/services.ts +0 -8
- package/src/runtime/.runtime-Brw2kO/tsconfig.json +0 -13
- package/src/runtime/.runtime-Brw2kO/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-NHfu1D/server/router.ts +0 -17
- package/src/runtime/.runtime-NHfu1D/src/cell.ts +0 -45
- package/src/runtime/.runtime-NHfu1D/src/controller.ts +0 -58
- package/src/runtime/.runtime-NHfu1D/src/lane.ts +0 -6
- package/src/runtime/.runtime-NHfu1D/src/main.ts +0 -11
- package/src/runtime/.runtime-NHfu1D/src/services.ts +0 -8
- package/src/runtime/.runtime-NHfu1D/tsconfig.json +0 -13
- package/src/runtime/.runtime-NHfu1D/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-VaUSOu/server/router.ts +0 -17
- package/src/runtime/.runtime-VaUSOu/src/cell.ts +0 -45
- package/src/runtime/.runtime-VaUSOu/src/controller.ts +0 -58
- package/src/runtime/.runtime-VaUSOu/src/lane.ts +0 -6
- package/src/runtime/.runtime-VaUSOu/src/main.ts +0 -11
- package/src/runtime/.runtime-VaUSOu/src/services.ts +0 -8
- package/src/runtime/.runtime-VaUSOu/tsconfig.json +0 -13
- package/src/runtime/.runtime-VaUSOu/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-WbtNvR/server/router.ts +0 -17
- package/src/runtime/.runtime-WbtNvR/src/cell.ts +0 -45
- package/src/runtime/.runtime-WbtNvR/src/controller.ts +0 -58
- package/src/runtime/.runtime-WbtNvR/src/lane.ts +0 -6
- package/src/runtime/.runtime-WbtNvR/src/main.ts +0 -11
- package/src/runtime/.runtime-WbtNvR/src/services.ts +0 -8
- package/src/runtime/.runtime-WbtNvR/tsconfig.json +0 -13
- package/src/runtime/.runtime-WbtNvR/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-GMPUt8/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-GMPUt8/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-GMPUt8/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-GMPUt8/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-GMPUt8/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-GMPUt8/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-GMPUt8/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-GMPUt8/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-UwafxO/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-UwafxO/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-UwafxO/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-UwafxO/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-UwafxO/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-UwafxO/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-UwafxO/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-UwafxO/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-ecaSee/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-ecaSee/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-ecaSee/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-ecaSee/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-ecaSee/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-ecaSee/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-ecaSee/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-ecaSee/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-y91UCm/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-y91UCm/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-y91UCm/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-y91UCm/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-y91UCm/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-y91UCm/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-y91UCm/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-y91UCm/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-ybIxYh/server/router.ts +0 -17
- package/src/runtime/.runtime-ybIxYh/src/cell.ts +0 -45
- package/src/runtime/.runtime-ybIxYh/src/controller.ts +0 -58
- package/src/runtime/.runtime-ybIxYh/src/lane.ts +0 -6
- package/src/runtime/.runtime-ybIxYh/src/main.ts +0 -11
- package/src/runtime/.runtime-ybIxYh/src/services.ts +0 -8
- package/src/runtime/.runtime-ybIxYh/tsconfig.json +0 -13
- package/src/runtime/.runtime-ybIxYh/tsplc.config.ts +0 -31
- package/stdlib/math.ts +0 -23
- package/types/plc.d.ts +0 -4
package/src/codesys/manifest.ts
CHANGED
|
@@ -1,48 +1,54 @@
|
|
|
1
|
-
// biome-ignore-all lint/style/noNonNullAssertion: Retain existing non-null assertions during the tooling migration; changing their contracts requires a separate review.
|
|
2
|
-
import type {
|
|
3
|
-
Constant,
|
|
4
|
-
CoreExpression,
|
|
5
|
-
CoreFunction,
|
|
6
|
-
CoreFunctionBlock,
|
|
7
|
-
CoreStatement,
|
|
8
|
-
PlcModule,
|
|
9
|
-
PlcType,
|
|
10
|
-
Variable,
|
|
11
|
-
} from "@tsplc/compiler/ir";
|
|
12
1
|
import {
|
|
2
|
+
type Constant,
|
|
3
|
+
type CoreExpression,
|
|
4
|
+
type CoreFunction,
|
|
5
|
+
type CoreFunctionBlock,
|
|
6
|
+
type CoreStatement,
|
|
7
|
+
coreTables,
|
|
13
8
|
instancedBlock,
|
|
9
|
+
instanceFields,
|
|
10
|
+
isBlockRoutine,
|
|
14
11
|
jobErrors,
|
|
15
|
-
nanosecondsPerMillisecond,
|
|
16
12
|
nestedBodies,
|
|
13
|
+
type PlcModule,
|
|
14
|
+
type PlcType,
|
|
17
15
|
standardBlocks,
|
|
18
16
|
statementExpressions,
|
|
19
17
|
subexpressions,
|
|
18
|
+
type Variable,
|
|
20
19
|
} from "@tsplc/compiler/ir";
|
|
21
20
|
import type { ResolvedTsplcConfig } from "@tsplc/config";
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
import { encodeConstant } from "@tsplc/debug/constant";
|
|
22
|
+
import {
|
|
23
|
+
type DebugConstant,
|
|
24
|
+
type DebugDevice,
|
|
25
|
+
type DebugEventSite,
|
|
26
|
+
type DebugFunction,
|
|
27
|
+
type DebugIo,
|
|
28
|
+
type DebugJob,
|
|
29
|
+
type DebugManifest,
|
|
30
|
+
type DebugType,
|
|
31
|
+
instrumentationFields,
|
|
32
|
+
type SourceRange,
|
|
32
33
|
} from "@tsplc/debug/manifest";
|
|
33
|
-
import {
|
|
34
|
-
import
|
|
34
|
+
import { nanosecondsPerMillisecond } from "@tsplc/iec";
|
|
35
|
+
import {
|
|
36
|
+
deviceChannel,
|
|
37
|
+
type HardwareCatalog,
|
|
38
|
+
isOutputAddress,
|
|
39
|
+
isPayloadByte,
|
|
40
|
+
modbusServerName,
|
|
41
|
+
} from "@tsplc/typegen/hardware";
|
|
35
42
|
import { version } from "../../package.json";
|
|
36
|
-
import { type InstancePath,
|
|
43
|
+
import { type InstancePath, typescriptPath } from "./debug";
|
|
44
|
+
import { ioTarget } from "./global-lists";
|
|
45
|
+
import { serviceName } from "./http";
|
|
46
|
+
import type { Instrumentation } from "./instrumentation";
|
|
47
|
+
import { required } from "./required";
|
|
37
48
|
import type { Sources } from "./sources";
|
|
38
|
-
import {
|
|
39
|
-
type CodesysSymbols,
|
|
40
|
-
type EmissionContext,
|
|
41
|
-
instrumentationFieldTypes,
|
|
42
|
-
required,
|
|
43
|
-
} from "./symbols";
|
|
49
|
+
import type { CodesysSymbols, EmissionContext } from "./symbols";
|
|
44
50
|
import { generated } from "./telemetry";
|
|
45
|
-
import {
|
|
51
|
+
import { sourceTypeName, stringTypeName } from "./types";
|
|
46
52
|
|
|
47
53
|
/** The configured hardware a manifest describes; `tree` when this build generates the device tree. */
|
|
48
54
|
export interface ProjectHardware {
|
|
@@ -51,131 +57,110 @@ export interface ProjectHardware {
|
|
|
51
57
|
tree: boolean;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* A value type as the debugger reads it, with TypeScript names; `field` gives a record field's name
|
|
62
|
+
* in the target.
|
|
63
|
+
*/
|
|
64
|
+
export function dataDebugType(
|
|
65
|
+
type: Exclude<PlcType, { kind: "block" }>,
|
|
66
|
+
field: (record: string, name: string) => string,
|
|
67
|
+
): DebugType {
|
|
68
|
+
switch (type.kind) {
|
|
69
|
+
case "bool":
|
|
70
|
+
case "integer":
|
|
71
|
+
case "bits":
|
|
72
|
+
case "float":
|
|
73
|
+
case "duration":
|
|
74
|
+
case "calendar":
|
|
75
|
+
return { kind: "scalar", iec: type.id };
|
|
76
|
+
case "string":
|
|
77
|
+
return {
|
|
78
|
+
kind: "scalar",
|
|
79
|
+
iec: stringTypeName(type),
|
|
80
|
+
capacity: type.capacity,
|
|
81
|
+
};
|
|
82
|
+
case "enum": {
|
|
83
|
+
const texts = type.members.flatMap((member) =>
|
|
84
|
+
member.text === undefined ? [] : [[member.name, member.text]],
|
|
85
|
+
);
|
|
86
|
+
return {
|
|
87
|
+
kind: "enum",
|
|
88
|
+
name: sourceTypeName(type.id),
|
|
89
|
+
members: Object.fromEntries(
|
|
90
|
+
type.members.map((member) => [member.name, Number(member.value)]),
|
|
91
|
+
),
|
|
92
|
+
...(texts.length && { texts: Object.fromEntries(texts) }),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
case "array":
|
|
96
|
+
return {
|
|
97
|
+
kind: "array",
|
|
98
|
+
element: type.element,
|
|
99
|
+
length: type.length,
|
|
100
|
+
lower: type.lowerBound,
|
|
101
|
+
...(type.index && { index: type.index }),
|
|
102
|
+
};
|
|
103
|
+
case "record":
|
|
104
|
+
return {
|
|
105
|
+
kind: "record",
|
|
106
|
+
name: sourceTypeName(type.id),
|
|
107
|
+
fields: type.fields.map((item) => ({
|
|
108
|
+
name: item.name,
|
|
109
|
+
target: field(type.id, item.name),
|
|
110
|
+
type: item.type,
|
|
111
|
+
})),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
62
115
|
|
|
63
|
-
/**
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
blocks: ReadonlyMap<string, CoreFunctionBlock>,
|
|
68
|
-
fields: (block: string, variable: string) => string,
|
|
69
|
-
extras: (
|
|
70
|
-
block: string,
|
|
71
|
-
) => readonly { name: string; target: string; type: string }[],
|
|
116
|
+
/** A block instance's type: its ports and state, then the fields the compiler adds for the debugger. */
|
|
117
|
+
function blockDebugType(
|
|
118
|
+
{ symbols, instrumentation }: EmissionContext,
|
|
119
|
+
block: CoreFunctionBlock,
|
|
72
120
|
sources: Sources,
|
|
73
|
-
):
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
case "string":
|
|
81
|
-
return [
|
|
82
|
-
type.id,
|
|
83
|
-
{
|
|
84
|
-
kind: "scalar",
|
|
85
|
-
iec: stringTypeName(type),
|
|
86
|
-
capacity: type.capacity,
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
case "enum": {
|
|
90
|
-
const texts = type.members.flatMap((member) =>
|
|
91
|
-
member.text === undefined ? [] : [[member.name, member.text]],
|
|
92
|
-
);
|
|
93
|
-
return [
|
|
94
|
-
type.id,
|
|
95
|
-
{
|
|
96
|
-
kind: "enum",
|
|
97
|
-
name: sourceTypeName(type.id),
|
|
98
|
-
members: Object.fromEntries(
|
|
99
|
-
type.members.map((member) => [
|
|
100
|
-
member.name,
|
|
101
|
-
Number(member.value),
|
|
102
|
-
]),
|
|
103
|
-
),
|
|
104
|
-
...(texts.length && { texts: Object.fromEntries(texts) }),
|
|
105
|
-
},
|
|
106
|
-
];
|
|
107
|
-
}
|
|
108
|
-
case "array":
|
|
109
|
-
return [
|
|
110
|
-
type.id,
|
|
111
|
-
{
|
|
112
|
-
kind: "array",
|
|
113
|
-
element: type.element,
|
|
114
|
-
length: type.length,
|
|
115
|
-
lower: type.lowerBound,
|
|
116
|
-
...(type.index && { index: type.index }),
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
case "record":
|
|
120
|
-
return [
|
|
121
|
-
type.id,
|
|
122
|
-
{
|
|
123
|
-
kind: "record",
|
|
124
|
-
name: sourceTypeName(type.id),
|
|
125
|
-
fields: type.fields.map((field) => ({
|
|
126
|
-
name: field.name,
|
|
127
|
-
target: target.field(type.id, field.name),
|
|
128
|
-
type: field.type,
|
|
129
|
-
})),
|
|
130
|
-
},
|
|
131
|
-
];
|
|
132
|
-
case "block": {
|
|
133
|
-
const block = blocks.get(type.block)!;
|
|
134
|
-
const native = block.standard && standardBlocks[block.standard];
|
|
135
|
-
const generated = Boolean(block.job || block.runtime);
|
|
136
|
-
const declaration = sources.range(block.span);
|
|
137
|
-
return [
|
|
138
|
-
type.id,
|
|
139
|
-
{
|
|
140
|
-
kind: "record",
|
|
141
|
-
name: block.job?.name ?? block.name,
|
|
142
|
-
...(declaration && { declaration }),
|
|
143
|
-
fields: [
|
|
144
|
-
...[...block.inputs, ...block.outputs, ...block.state].map(
|
|
145
|
-
(variable) => {
|
|
146
|
-
const declaration = !native && sources.range(variable.span);
|
|
147
|
-
return {
|
|
148
|
-
name: variable.name,
|
|
149
|
-
target: fields(block.id, variable.id),
|
|
150
|
-
type: variable.type,
|
|
151
|
-
...(declaration && { declaration }),
|
|
152
|
-
...(generated && { generated: true as const }),
|
|
153
|
-
};
|
|
154
|
-
},
|
|
155
|
-
),
|
|
156
|
-
...extras(block.id).map((field) => ({
|
|
157
|
-
...field,
|
|
158
|
-
generated: true as const,
|
|
159
|
-
})),
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
throw new Error(`Unsupported verified type ${type.id}`);
|
|
166
|
-
}),
|
|
121
|
+
): DebugType {
|
|
122
|
+
const native = block.standard && standardBlocks[block.standard];
|
|
123
|
+
const generated = Boolean(block.job || block.runtime);
|
|
124
|
+
const declaration = sources.range(block.span);
|
|
125
|
+
const fields = required(symbols.blockFields.get(block.id));
|
|
126
|
+
const added = new Map(
|
|
127
|
+
Object.entries(instrumentation.fields.get(block.id) ?? {}),
|
|
167
128
|
);
|
|
129
|
+
return {
|
|
130
|
+
kind: "record",
|
|
131
|
+
name: block.job?.name ?? block.name,
|
|
132
|
+
...(declaration && { declaration }),
|
|
133
|
+
fields: [
|
|
134
|
+
...instanceFields(block).map((variable) => {
|
|
135
|
+
const declaration = !native && sources.range(variable.span);
|
|
136
|
+
return {
|
|
137
|
+
name: variable.name,
|
|
138
|
+
target: required(fields.get(variable.id)),
|
|
139
|
+
type: variable.type,
|
|
140
|
+
...(declaration && { declaration }),
|
|
141
|
+
...(generated && { generated: true as const }),
|
|
142
|
+
};
|
|
143
|
+
}),
|
|
144
|
+
...Object.entries(instrumentationFields).flatMap(([key, type]) => {
|
|
145
|
+
const name = added.get(key);
|
|
146
|
+
return name
|
|
147
|
+
? [{ name, target: name, type, generated: true as const }]
|
|
148
|
+
: [];
|
|
149
|
+
}),
|
|
150
|
+
],
|
|
151
|
+
};
|
|
168
152
|
}
|
|
169
153
|
|
|
170
|
-
/** A folded constant's JSON value
|
|
154
|
+
/** A folded constant's JSON value. */
|
|
171
155
|
export const constantValue = (value: Constant): unknown => {
|
|
172
156
|
switch (value.kind) {
|
|
173
157
|
case "integer":
|
|
174
|
-
return
|
|
175
|
-
? Number(value.value)
|
|
176
|
-
: value.value;
|
|
158
|
+
return encodeConstant({ kind: "integer", value: BigInt(value.value) });
|
|
177
159
|
case "duration":
|
|
178
|
-
return
|
|
160
|
+
return encodeConstant({
|
|
161
|
+
kind: "duration",
|
|
162
|
+
nanoseconds: BigInt(value.nanoseconds),
|
|
163
|
+
});
|
|
179
164
|
case "array":
|
|
180
165
|
return value.items.map(constantValue);
|
|
181
166
|
case "record":
|
|
@@ -223,9 +208,7 @@ export const ioAddress = (
|
|
|
223
208
|
) =>
|
|
224
209
|
"address" in binding
|
|
225
210
|
? binding.address
|
|
226
|
-
: catalog
|
|
227
|
-
.find((device) => device.id === binding.device)
|
|
228
|
-
?.channels.find((item) => item.id === binding.channel)?.address;
|
|
211
|
+
: deviceChannel(catalog, binding)?.address;
|
|
229
212
|
|
|
230
213
|
/**
|
|
231
214
|
* Each configured `io` binding joined with its device channel and the target that holds its
|
|
@@ -234,15 +217,14 @@ export const ioAddress = (
|
|
|
234
217
|
* registers, so the debugger reads their state there.
|
|
235
218
|
*/
|
|
236
219
|
function debugHardware(
|
|
220
|
+
context: EmissionContext,
|
|
237
221
|
hardware: ProjectHardware,
|
|
238
|
-
io: (key: string) => { target: string; type: string } | undefined,
|
|
239
|
-
/** The byte array over each of a device's assemblies. */
|
|
240
|
-
raw: (id: string) => Partial<Record<"input" | "output", string>>,
|
|
241
222
|
): { io: DebugIo[]; devices: DebugDevice[] } {
|
|
223
|
+
const { instrumentation } = context;
|
|
242
224
|
const { catalog, config } = hardware;
|
|
243
225
|
const rows = Object.entries(config.io).flatMap(
|
|
244
226
|
([key, binding]): DebugIo[] => {
|
|
245
|
-
const held =
|
|
227
|
+
const held = ioTarget(context, key);
|
|
246
228
|
if (!held) {
|
|
247
229
|
return [];
|
|
248
230
|
}
|
|
@@ -251,7 +233,10 @@ function debugHardware(
|
|
|
251
233
|
{
|
|
252
234
|
path: key,
|
|
253
235
|
...held,
|
|
254
|
-
direction:
|
|
236
|
+
direction:
|
|
237
|
+
address !== undefined && isOutputAddress(address)
|
|
238
|
+
? "output"
|
|
239
|
+
: "input",
|
|
255
240
|
...("device" in binding && {
|
|
256
241
|
device: binding.device,
|
|
257
242
|
channel: binding.channel,
|
|
@@ -270,13 +255,13 @@ function debugHardware(
|
|
|
270
255
|
(item) => item.file === device.descriptor,
|
|
271
256
|
);
|
|
272
257
|
const network = config.devices[device.id]?.network;
|
|
273
|
-
const
|
|
258
|
+
const raw = instrumentation.devices.get(device.id);
|
|
274
259
|
const status = {
|
|
275
260
|
...device.statusSymbols,
|
|
276
261
|
...(hardware.tree &&
|
|
277
262
|
device.modbus && {
|
|
278
|
-
"Modbus error": `${device.id}
|
|
279
|
-
"Modbus error code": `${device.id}
|
|
263
|
+
"Modbus error": `${modbusServerName(device.id)}.xError`,
|
|
264
|
+
"Modbus error code": `${modbusServerName(device.id)}.byModbusError`,
|
|
280
265
|
}),
|
|
281
266
|
};
|
|
282
267
|
return {
|
|
@@ -290,17 +275,22 @@ function debugHardware(
|
|
|
290
275
|
network: {
|
|
291
276
|
address: network.address,
|
|
292
277
|
...(network.rpi && {
|
|
293
|
-
rpiMs:
|
|
278
|
+
rpiMs:
|
|
279
|
+
Number(network.rpi.nanoseconds) /
|
|
280
|
+
Number(nanosecondsPerMillisecond),
|
|
294
281
|
}),
|
|
295
282
|
},
|
|
296
283
|
}),
|
|
297
284
|
...(device.connection && { connection: device.connection.name }),
|
|
298
|
-
assemblies: device.assemblies.map((assembly) =>
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
285
|
+
assemblies: device.assemblies.map((assembly) => {
|
|
286
|
+
const field = raw?.[assembly.direction]?.field;
|
|
287
|
+
return {
|
|
288
|
+
direction: assembly.direction,
|
|
289
|
+
bytes: assembly.size,
|
|
290
|
+
address: assembly.address,
|
|
291
|
+
...(field && { raw: `${instrumentation.global}.${field}` }),
|
|
292
|
+
};
|
|
293
|
+
}),
|
|
304
294
|
...(hardware.tree && {
|
|
305
295
|
health: {
|
|
306
296
|
state: `${device.id}.eState`,
|
|
@@ -311,11 +301,7 @@ function debugHardware(
|
|
|
311
301
|
...(Object.keys(status).length && { status }),
|
|
312
302
|
// Byte and bit expansions of an assembly are covered by its raw bytes.
|
|
313
303
|
channels: device.channels
|
|
314
|
-
.filter(
|
|
315
|
-
(channel) =>
|
|
316
|
-
!channel.parent &&
|
|
317
|
-
!/^(inputs|outputs)\.Byte\d+$/.test(channel.id),
|
|
318
|
-
)
|
|
304
|
+
.filter((channel) => !channel.parent && !isPayloadByte(channel))
|
|
319
305
|
.map((channel) => ({
|
|
320
306
|
id: channel.id,
|
|
321
307
|
name: channel.name,
|
|
@@ -334,26 +320,49 @@ function debugHardware(
|
|
|
334
320
|
|
|
335
321
|
/** The IEC path of a block instance. */
|
|
336
322
|
function instancePath(symbols: CodesysSymbols, path: InstancePath): string {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
323
|
+
return path
|
|
324
|
+
.map(({ variable, index }, position) => {
|
|
325
|
+
const holder = path[position - 1];
|
|
326
|
+
const name = holder
|
|
327
|
+
? `.${required(
|
|
328
|
+
required(
|
|
329
|
+
symbols.blockFields.get(
|
|
330
|
+
required(instancedBlock(holder.variable.type, symbols.typeMap))
|
|
331
|
+
.block,
|
|
332
|
+
),
|
|
333
|
+
).get(variable.id),
|
|
334
|
+
)}`
|
|
335
|
+
: required(symbols.references.get(variable.id));
|
|
336
|
+
return index === undefined ? name : `${name}[${index}]`;
|
|
337
|
+
})
|
|
338
|
+
.join("");
|
|
349
339
|
}
|
|
350
340
|
|
|
351
|
-
/**
|
|
341
|
+
/**
|
|
342
|
+
* The job a service call is made for in debug.json: the id the PLC sends with the call's request,
|
|
343
|
+
* which only a job declared once passes down, so such a job nested in another replaces its caller's.
|
|
344
|
+
*/
|
|
345
|
+
const requestingJob = (
|
|
346
|
+
{ jobIds }: Pick<Instrumentation, "jobIds">,
|
|
347
|
+
declaration: string,
|
|
348
|
+
caller: number | undefined,
|
|
349
|
+
): number | undefined => jobIds.get(declaration) ?? caller;
|
|
350
|
+
|
|
351
|
+
/** The job a service call is made for in explain.json: the innermost job instance whose path holds the call's. */
|
|
352
|
+
export const enclosingJob = (
|
|
353
|
+
{ jobs }: Pick<Instrumentation, "jobs">,
|
|
354
|
+
instance: string,
|
|
355
|
+
): number | undefined =>
|
|
356
|
+
jobs
|
|
357
|
+
.filter((job) => instance.startsWith(`${job.instance}.`))
|
|
358
|
+
.sort((a, b) => b.instance.length - a.instance.length)[0]?.id;
|
|
359
|
+
|
|
360
|
+
/** Service calls a job instance makes, and those of the jobs it starts. */
|
|
352
361
|
function requests(
|
|
353
362
|
context: EmissionContext,
|
|
354
363
|
id: string,
|
|
355
364
|
prefix: string,
|
|
356
|
-
job
|
|
365
|
+
job: number | undefined,
|
|
357
366
|
): DebugJob["requests"] {
|
|
358
367
|
const { plan, symbols, instrumentation } = context;
|
|
359
368
|
const block = required(symbols.blocks.get(id));
|
|
@@ -362,8 +371,7 @@ function requests(
|
|
|
362
371
|
if (!instance) {
|
|
363
372
|
return [];
|
|
364
373
|
}
|
|
365
|
-
|
|
366
|
-
const caller = instrumentation.jobIds.get(child.id) ?? job;
|
|
374
|
+
const caller = requestingJob(instrumentation, child.id, job);
|
|
367
375
|
const type = required(symbols.typeMap.get(child.type));
|
|
368
376
|
const field = `${prefix}.${required(required(symbols.blockFields.get(id)).get(child.id))}`;
|
|
369
377
|
const targets =
|
|
@@ -379,7 +387,7 @@ function requests(
|
|
|
379
387
|
sequence && path
|
|
380
388
|
? [
|
|
381
389
|
{
|
|
382
|
-
service:
|
|
390
|
+
service: serviceName(path),
|
|
383
391
|
target,
|
|
384
392
|
sequence: `${target}.${sequence}`,
|
|
385
393
|
...(caller !== undefined && { job: caller }),
|
|
@@ -406,7 +414,10 @@ function reads(
|
|
|
406
414
|
if (value.kind !== "load") {
|
|
407
415
|
return;
|
|
408
416
|
}
|
|
409
|
-
const read =
|
|
417
|
+
const read = typescriptPath(
|
|
418
|
+
required(variables.get(value.root)),
|
|
419
|
+
value.path,
|
|
420
|
+
);
|
|
410
421
|
const range = read && sources.range(value.span);
|
|
411
422
|
if (range) {
|
|
412
423
|
reads.set(`${JSON.stringify(range)}${read}`, { range, path: read });
|
|
@@ -422,12 +433,21 @@ function reads(
|
|
|
422
433
|
return [...reads.values()];
|
|
423
434
|
}
|
|
424
435
|
|
|
436
|
+
/** How the debugger names a routine, and where it shows its declaration: a job's own, else the authored function's. */
|
|
437
|
+
export const routineLabel = (routine: CoreFunction | CoreFunctionBlock) =>
|
|
438
|
+
isBlockRoutine(routine)
|
|
439
|
+
? {
|
|
440
|
+
name: routine.job?.name ?? routine.name,
|
|
441
|
+
span: routine.job?.span ?? routine.span,
|
|
442
|
+
}
|
|
443
|
+
: { name: routine.origin?.name ?? routine.name, span: routine.span };
|
|
444
|
+
|
|
425
445
|
/** The IEC name of a routine: its function block, a method under its block, or its function or PROGRAM. */
|
|
426
446
|
const routineTarget = (
|
|
427
447
|
symbols: CodesysSymbols,
|
|
428
448
|
routine: CoreFunction | CoreFunctionBlock,
|
|
429
449
|
): string => {
|
|
430
|
-
if (
|
|
450
|
+
if (isBlockRoutine(routine)) {
|
|
431
451
|
return required(symbols.blockNames.get(routine.id));
|
|
432
452
|
}
|
|
433
453
|
const name = required(symbols.functionNames.get(routine.id));
|
|
@@ -436,14 +456,14 @@ const routineTarget = (
|
|
|
436
456
|
: name;
|
|
437
457
|
};
|
|
438
458
|
|
|
439
|
-
/**
|
|
459
|
+
/**
|
|
460
|
+
* The debugger's view of an emitted program, and the id of each function it lists by routine. Its
|
|
461
|
+
* build id is filled in once the id is known.
|
|
462
|
+
*/
|
|
440
463
|
export function debugManifest(
|
|
441
464
|
context: EmissionContext,
|
|
442
|
-
ioTarget: (key: string) => { target: string; type: string } | undefined,
|
|
443
465
|
sources: Sources,
|
|
444
|
-
|
|
445
|
-
functionIds: Map<string, number>,
|
|
446
|
-
): DebugManifest {
|
|
466
|
+
): { manifest: DebugManifest; functionIds: ReadonlyMap<string, number> } {
|
|
447
467
|
const { plan, symbols, instrumentation } = context;
|
|
448
468
|
const { core, project, deployment, options } = plan;
|
|
449
469
|
const settings = project.debug;
|
|
@@ -453,49 +473,35 @@ export function debugManifest(
|
|
|
453
473
|
string,
|
|
454
474
|
{ id: number; range: SourceRange }
|
|
455
475
|
>();
|
|
456
|
-
const routines =
|
|
457
|
-
const
|
|
458
|
-
// A merged instance's own locals are not in the program's variables any more.
|
|
459
|
-
const variables = new Map([
|
|
460
|
-
...instrumentation.analysis.variables,
|
|
461
|
-
...plan.specialized.functions.flatMap((fn) =>
|
|
462
|
-
[...fn.parameters, ...fn.locals].map(
|
|
463
|
-
(variable) => [variable.id, variable] as const,
|
|
464
|
-
),
|
|
465
|
-
),
|
|
466
|
-
...plan.specialized.blocks.flatMap((block) =>
|
|
467
|
-
block.locals.map((variable) => [variable.id, variable] as const),
|
|
468
|
-
),
|
|
469
|
-
]);
|
|
476
|
+
const { functions: routines } = coreTables(core);
|
|
477
|
+
const { variables } = coreTables(plan.specialized);
|
|
470
478
|
const functions = [
|
|
471
479
|
...plan.specialized.functions,
|
|
472
480
|
...plan.specialized.blocks.filter(
|
|
473
481
|
(block) => !block.standard && !block.runtime,
|
|
474
482
|
),
|
|
475
483
|
].flatMap((routine): DebugFunction[] => {
|
|
476
|
-
const
|
|
477
|
-
const
|
|
478
|
-
const declaration = sources.range(block?.job?.span ?? routine.span);
|
|
484
|
+
const label = routineLabel(routine);
|
|
485
|
+
const declaration = sources.range(label.span);
|
|
479
486
|
if (!declaration) {
|
|
480
487
|
return [];
|
|
481
488
|
}
|
|
482
489
|
// An instance whose routine was merged runs as the routine shared with the others. A
|
|
483
490
|
// routine that only returned a constant was replaced by it, and has nothing to describe.
|
|
484
|
-
const runs =
|
|
485
|
-
?
|
|
486
|
-
:
|
|
491
|
+
const runs = isBlockRoutine(routine)
|
|
492
|
+
? symbols.blocks.get(routine.id)
|
|
493
|
+
: routines.get(plan.sharedRoutines.get(routine.id) ?? routine.id);
|
|
487
494
|
if (!runs) {
|
|
488
495
|
return [];
|
|
489
496
|
}
|
|
490
497
|
const id = declaredFunctions.size;
|
|
491
498
|
declaredFunctions.set(routine.id, { id, range: declaration });
|
|
492
|
-
functionIds.set(routine.id, id);
|
|
493
499
|
const task = instrumentation.analysis.tasks.get(runs.id);
|
|
494
|
-
const origin =
|
|
500
|
+
const origin = isBlockRoutine(routine) ? undefined : routine.origin;
|
|
495
501
|
return [
|
|
496
502
|
{
|
|
497
503
|
id,
|
|
498
|
-
name:
|
|
504
|
+
name: label.name,
|
|
499
505
|
declaration,
|
|
500
506
|
...(origin?.instance && { instance: origin.instance }),
|
|
501
507
|
...(task && { task }),
|
|
@@ -520,10 +526,9 @@ export function debugManifest(
|
|
|
520
526
|
id: site.id,
|
|
521
527
|
kind: site.kind,
|
|
522
528
|
...(job && {
|
|
523
|
-
job:
|
|
524
|
-
instrumentation.jobs.
|
|
525
|
-
|
|
526
|
-
) + 1,
|
|
529
|
+
job: required(
|
|
530
|
+
instrumentation.jobs.find(({ block }) => block.id === job.block),
|
|
531
|
+
).id,
|
|
527
532
|
phase: job.phase,
|
|
528
533
|
}),
|
|
529
534
|
path: site.path,
|
|
@@ -545,7 +550,7 @@ export function debugManifest(
|
|
|
545
550
|
);
|
|
546
551
|
|
|
547
552
|
const jobs = instrumentation.jobs.flatMap(
|
|
548
|
-
({ block, path }
|
|
553
|
+
({ block, path, id }): DebugJob[] => {
|
|
549
554
|
const job = required(block.job);
|
|
550
555
|
const declaration = sources.range(job.span);
|
|
551
556
|
if (!declaration) {
|
|
@@ -555,7 +560,7 @@ export function debugManifest(
|
|
|
555
560
|
const startedAt = instrumentation.fields.get(block.id)?.startedAt;
|
|
556
561
|
return [
|
|
557
562
|
{
|
|
558
|
-
id
|
|
563
|
+
id,
|
|
559
564
|
name: job.name,
|
|
560
565
|
declaration,
|
|
561
566
|
...(job.instance && { instance: job.instance }),
|
|
@@ -567,8 +572,7 @@ export function debugManifest(
|
|
|
567
572
|
text: step.text,
|
|
568
573
|
})),
|
|
569
574
|
...(startedAt && { startedAt: `${target}.${startedAt}` }),
|
|
570
|
-
requests: requests(context, block.id, target),
|
|
571
|
-
// Compiler-made functions, such as each service call's own job, carry its prefix.
|
|
575
|
+
requests: requests(context, block.id, target, undefined),
|
|
572
576
|
...(generated(job.name) && { generated: true as const }),
|
|
573
577
|
},
|
|
574
578
|
];
|
|
@@ -596,65 +600,54 @@ export function debugManifest(
|
|
|
596
600
|
}))
|
|
597
601
|
: [];
|
|
598
602
|
|
|
599
|
-
const roots = core.variables
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
603
|
+
const roots = core.variables.flatMap((variable) => {
|
|
604
|
+
const path = typescriptPath(variable);
|
|
605
|
+
if (path === undefined) {
|
|
606
|
+
return [];
|
|
607
|
+
}
|
|
608
|
+
const declaration = sources.range(variable.span);
|
|
609
|
+
return [
|
|
610
|
+
{
|
|
611
|
+
path,
|
|
607
612
|
target: required(symbols.references.get(variable.id)),
|
|
608
613
|
type: variable.type,
|
|
609
614
|
...(declaration && { declaration }),
|
|
610
615
|
readable: true,
|
|
611
|
-
...(variable.name
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
});
|
|
616
|
+
...(generated(variable.name) && { generated: true as const }),
|
|
617
|
+
},
|
|
618
|
+
];
|
|
619
|
+
});
|
|
616
620
|
|
|
617
|
-
const types =
|
|
618
|
-
core.types,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
? [{ name, target: name, type: instrumentationFieldTypes[key] }]
|
|
631
|
-
: [];
|
|
632
|
-
});
|
|
633
|
-
},
|
|
634
|
-
sources,
|
|
621
|
+
const types = Object.fromEntries(
|
|
622
|
+
core.types.map((type): [string, DebugType] => [
|
|
623
|
+
type.id,
|
|
624
|
+
type.kind === "block"
|
|
625
|
+
? blockDebugType(
|
|
626
|
+
context,
|
|
627
|
+
required(symbols.blocks.get(type.block)),
|
|
628
|
+
sources,
|
|
629
|
+
)
|
|
630
|
+
: dataDebugType(type, (record, field) =>
|
|
631
|
+
symbols.targetTypes.field(record, field),
|
|
632
|
+
),
|
|
633
|
+
]),
|
|
635
634
|
);
|
|
636
635
|
const hardware = debugHardware(
|
|
636
|
+
context,
|
|
637
637
|
project.hardware ?? {
|
|
638
638
|
catalog: { descriptors: [], devices: [] },
|
|
639
639
|
config: { devices: {}, io: options.io },
|
|
640
640
|
tree: false,
|
|
641
641
|
},
|
|
642
|
-
(key) => ioTarget(key),
|
|
643
|
-
(id) =>
|
|
644
|
-
Object.fromEntries(
|
|
645
|
-
Object.entries(instrumentation.devices.get(id) ?? {}).map(
|
|
646
|
-
([direction, raw]) => [direction, global(raw.field)],
|
|
647
|
-
),
|
|
648
|
-
),
|
|
649
642
|
);
|
|
650
643
|
const constants = debugConstants(core.folded ?? [], sources);
|
|
651
644
|
|
|
652
|
-
|
|
645
|
+
const manifest: DebugManifest = {
|
|
653
646
|
kind: "tsplc-debug",
|
|
654
647
|
version: 1,
|
|
655
648
|
build: {
|
|
656
649
|
id: "",
|
|
657
|
-
target: global(
|
|
650
|
+
target: global(instrumentation.slots.buildId),
|
|
658
651
|
compiler: `@tsplc/compiler ${version}`,
|
|
659
652
|
},
|
|
660
653
|
sources: sources.files,
|
|
@@ -670,15 +663,22 @@ export function debugManifest(
|
|
|
670
663
|
// The task's ring sender reads the clock at the start of its first program.
|
|
671
664
|
const ring = instrumentation.rings.get(task.name);
|
|
672
665
|
const clock = ring
|
|
673
|
-
?
|
|
666
|
+
? `${ring}.now`
|
|
674
667
|
: instrumentation.scanClocks.get(task.name);
|
|
675
668
|
return {
|
|
676
669
|
name: task.name,
|
|
677
|
-
intervalMs:
|
|
670
|
+
intervalMs:
|
|
671
|
+
Number(task.intervalNanoseconds) / Number(nanosecondsPerMillisecond),
|
|
678
672
|
priority: task.priority,
|
|
679
|
-
...(clock && { clock }),
|
|
673
|
+
...(clock && { clock: global(clock) }),
|
|
680
674
|
};
|
|
681
675
|
}),
|
|
682
676
|
errors: jobErrors,
|
|
683
677
|
};
|
|
678
|
+
return {
|
|
679
|
+
manifest,
|
|
680
|
+
functionIds: new Map(
|
|
681
|
+
[...declaredFunctions].map(([routine, { id }]) => [routine, id]),
|
|
682
|
+
),
|
|
683
|
+
};
|
|
684
684
|
}
|