@tsplc/compiler 0.5.2 → 0.5.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.
- package/dist/bun-runtime.js.map +7 -7
- package/dist/cli.js.map +8 -8
- package/dist/codesys.js +91 -20
- package/dist/codesys.js.map +24 -24
- package/dist/elaborate-capture.js.map +1 -1
- package/dist/index.js.map +35 -35
- package/dist/ir.js.map +19 -19
- package/dist/project.js.map +1 -1
- package/dist/server-check.js.map +1 -1
- package/dist/telemetry.js.map +1 -1
- package/package.json +9 -9
- package/src/codesys/config.ts +2 -2
- package/src/codesys/debug.ts +2 -2
- package/src/codesys/emit.ts +10 -10
- package/src/codesys/engineering.ts +1 -1
- package/src/codesys/expressions.ts +1 -1
- package/src/codesys/global-lists.ts +6 -6
- package/src/codesys/global-names.ts +3 -3
- package/src/codesys/http.ts +77 -6
- package/src/codesys/index.ts +8 -8
- package/src/codesys/instrumentation.ts +9 -13
- package/src/codesys/io-paths.ts +1 -1
- package/src/codesys/manifest.ts +5 -5
- package/src/codesys/plan.ts +9 -9
- package/src/codesys/programs.ts +3 -3
- package/src/codesys/publication.ts +4 -4
- package/src/codesys/routines.ts +5 -5
- package/src/codesys/sources.ts +48 -8
- package/src/codesys/st-files.ts +14 -20
- package/src/codesys/symbols.ts +6 -6
- package/src/codesys/telemetry.ts +8 -8
- package/src/codesys/types.ts +2 -2
- package/src/codesys/vendor.ts +2 -2
- package/src/frontend/analyzer.ts +9 -9
- package/src/frontend/async.ts +6 -6
- package/src/frontend/blocks.ts +1 -1
- package/src/frontend/configuration.ts +4 -4
- package/src/frontend/const-functions.ts +2 -2
- package/src/frontend/cooperative.ts +1 -1
- package/src/frontend/coroutines.ts +6 -6
- package/src/frontend/elaborate/calls.ts +9 -12
- package/src/frontend/elaborate/capture.ts +1 -1
- package/src/frontend/elaborate/dialect.ts +7 -7
- package/src/frontend/elaborate/expressions.ts +12 -12
- package/src/frontend/elaborate/frame.ts +4 -4
- package/src/frontend/elaborate/graph.ts +1 -1
- package/src/frontend/elaborate/index.ts +12 -12
- package/src/frontend/elaborate/initializers.ts +4 -4
- package/src/frontend/elaborate/layouts.ts +3 -3
- package/src/frontend/elaborate/model.ts +1 -1
- package/src/frontend/elaborate/retention.ts +5 -5
- package/src/frontend/elaborate/specialize.ts +11 -11
- package/src/frontend/elaborate/statements.ts +8 -11
- package/src/frontend/elaborate/storage.ts +6 -11
- package/src/frontend/elaborate/values.ts +2 -2
- package/src/frontend/exposure.ts +3 -3
- package/src/frontend/expressions.ts +5 -5
- package/src/frontend/intrinsics.ts +2 -2
- package/src/frontend/module-graph.ts +1 -1
- package/src/frontend/promise-chains.ts +2 -2
- package/src/frontend/promises.ts +5 -5
- package/src/frontend/routines.ts +2 -2
- package/src/frontend/services.ts +3 -3
- package/src/frontend/statements.ts +4 -4
- package/src/frontend/tasks.ts +5 -10
- package/src/frontend/telemetry.ts +2 -2
- package/src/frontend/types.ts +1 -1
- package/src/frontend/typescript.ts +11 -15
- package/src/index.ts +1 -1
- package/src/ir/aggregates.ts +6 -6
- package/src/ir/allocation.ts +5 -5
- package/src/ir/core-model.ts +3 -3
- package/src/ir/declarations.ts +6 -6
- package/src/ir/domains.ts +3 -7
- package/src/ir/fold.ts +4 -9
- package/src/ir/index.ts +16 -16
- package/src/ir/layouts.ts +3 -3
- package/src/ir/link.ts +5 -5
- package/src/ir/model.ts +2 -2
- package/src/ir/normalization-error.ts +1 -1
- package/src/ir/normalize.ts +8 -8
- package/src/ir/numeric.ts +2 -2
- package/src/ir/operands.ts +2 -2
- package/src/ir/ranges.ts +4 -9
- package/src/ir/routine.ts +10 -15
- package/src/ir/scalars.ts +5 -5
- package/src/ir/share.ts +4 -4
- package/src/ir/temporaries.ts +4 -4
- package/src/project/cli.ts +3 -3
- package/src/project/debugger.ts +1 -1
- package/src/project/index.ts +1 -1
- package/src/project/plant.ts +2 -2
- package/src/project/project-commands.ts +3 -3
- package/src/project/project.ts +2 -2
- package/src/project/release.ts +2 -2
- package/src/project/server-check.ts +1 -1
- package/src/runtime/main.ts +2 -2
- package/src/runtime/process.ts +1 -1
- package/src/runtime/program.ts +2 -2
- package/src/runtime/retain.ts +1 -1
- package/src/runtime/runtime.ts +11 -16
- package/stdlib/telemetry.ts +2 -2
package/src/codesys/routines.ts
CHANGED
|
@@ -9,27 +9,27 @@ import {
|
|
|
9
9
|
type SourceSpan,
|
|
10
10
|
type Variable,
|
|
11
11
|
} from "@tsplc/compiler/ir";
|
|
12
|
-
import type { SourceMapping } from "./emit
|
|
12
|
+
import type { SourceMapping } from "./emit";
|
|
13
13
|
import {
|
|
14
14
|
expressionText,
|
|
15
15
|
placeText,
|
|
16
16
|
type StorageScope,
|
|
17
17
|
storageName,
|
|
18
|
-
} from "./expressions
|
|
18
|
+
} from "./expressions";
|
|
19
19
|
import {
|
|
20
20
|
jobField,
|
|
21
21
|
jobTracking,
|
|
22
22
|
type RoutineProbes,
|
|
23
23
|
ringTarget,
|
|
24
24
|
writeProbes,
|
|
25
|
-
} from "./instrumentation
|
|
25
|
+
} from "./instrumentation";
|
|
26
26
|
import {
|
|
27
27
|
type CodesysSymbols,
|
|
28
28
|
type EmissionContext,
|
|
29
29
|
instrumentationFieldTypes,
|
|
30
30
|
required,
|
|
31
|
-
} from "./symbols
|
|
32
|
-
import { callParameters } from "./telemetry
|
|
31
|
+
} from "./symbols";
|
|
32
|
+
import { callParameters } from "./telemetry";
|
|
33
33
|
|
|
34
34
|
function routineHeader(
|
|
35
35
|
symbols: CodesysSymbols,
|
package/src/codesys/sources.ts
CHANGED
|
@@ -1,10 +1,55 @@
|
|
|
1
1
|
// biome-ignore-all lint/style/noNonNullAssertion: Retain existing non-null assertions during the tooling migration; changing their contracts requires a separate review.
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { isAbsolute, relative } from "node:path";
|
|
3
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
import type { SourceSpan } from "@tsplc/compiler/ir";
|
|
5
5
|
import type { SourceRange } from "@tsplc/debug/manifest";
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Whether a compiled file is the project's own source: anything but an installed dependency. A
|
|
9
|
+
* monorepo's workspace packages count wherever they sit, as their files resolve to their real paths.
|
|
10
|
+
*/
|
|
11
|
+
export const projectSource = (root: string, file: string): boolean => {
|
|
12
|
+
const path = relative(root, file);
|
|
13
|
+
return !isAbsolute(path) && !path.split(/[\\/]/).includes("node_modules");
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** The nearest directory at or above `directory` that holds a `package.json`. */
|
|
17
|
+
const packageDirectory = (directory: string): string | undefined => {
|
|
18
|
+
if (existsSync(join(directory, "package.json"))) {
|
|
19
|
+
return directory;
|
|
20
|
+
}
|
|
21
|
+
const parent = dirname(directory);
|
|
22
|
+
return parent === directory ? undefined : packageDirectory(parent);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The folders a source module's objects go in, without a leading `src`: its path in the project,
|
|
27
|
+
* or a workspace package's own, so its objects keep the folders they would have in its own project.
|
|
28
|
+
* `undefined` for a module that is not the project's own source.
|
|
29
|
+
*/
|
|
30
|
+
export const sourceFolders = (
|
|
31
|
+
root: string,
|
|
32
|
+
module: string,
|
|
33
|
+
): string[] | undefined => {
|
|
34
|
+
if (!/^[\w./ -]+\.tsx?$/.test(module)) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const file = resolve(root, module);
|
|
38
|
+
if (!projectSource(root, file)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const base = relative(root, file).startsWith("..")
|
|
42
|
+
? (packageDirectory(dirname(file)) ?? dirname(file))
|
|
43
|
+
: root;
|
|
44
|
+
const segments = relative(base, file).replaceAll("\\", "/").split("/");
|
|
45
|
+
const folders = segments.slice(0, -1);
|
|
46
|
+
return folders[0] === "src" ? folders.slice(1) : folders;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Project files by index, as paths relative to the project root, so a workspace package's start with
|
|
51
|
+
* `../`. Spans outside the project's own sources, such as virtual modules and dependencies, have no range.
|
|
52
|
+
*/
|
|
8
53
|
export class Sources {
|
|
9
54
|
readonly files: string[] = [];
|
|
10
55
|
private readonly loaded = new Map<
|
|
@@ -18,13 +63,8 @@ export class Sources {
|
|
|
18
63
|
if (this.loaded.has(file)) {
|
|
19
64
|
return this.loaded.get(file);
|
|
20
65
|
}
|
|
21
|
-
const path = relative(this.root, file);
|
|
22
|
-
const inside =
|
|
23
|
-
!path.startsWith("..") &&
|
|
24
|
-
!isAbsolute(path) &&
|
|
25
|
-
!path.split(/[\\/]/).includes("node_modules");
|
|
26
66
|
let source: { text: string; lines: number[] } | undefined;
|
|
27
|
-
if (
|
|
67
|
+
if (projectSource(this.root, file) && existsSync(file)) {
|
|
28
68
|
const text = readFileSync(file, "utf8");
|
|
29
69
|
const lines = [0];
|
|
30
70
|
for (let index = 0; index < text.length; index++) {
|
package/src/codesys/st-files.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { EmitResult, GeneratedObject } from "@tsplc/compiler/ir";
|
|
2
|
-
import type { SourceMapping } from "./emit
|
|
3
|
-
import type { CodesysPlan } from "./plan
|
|
4
|
-
import {
|
|
2
|
+
import type { SourceMapping } from "./emit";
|
|
3
|
+
import type { CodesysPlan } from "./plan";
|
|
4
|
+
import { sourceFolders } from "./sources";
|
|
5
|
+
import { type CodesysSymbols, required } from "./symbols";
|
|
5
6
|
|
|
6
7
|
/** The file that holds an object's declaration, under its path: its only file, or `declaration.st` beside its implementation. */
|
|
7
8
|
export const declarationFile = (path: string, object: GeneratedObject) =>
|
|
@@ -128,24 +129,17 @@ function objectPaths(
|
|
|
128
129
|
);
|
|
129
130
|
return `${objectPath(owner)}/methods/${object.name}`;
|
|
130
131
|
}
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
!source.split(/[\\/]/).includes("..") &&
|
|
135
|
-
!source.startsWith("/")
|
|
136
|
-
) {
|
|
137
|
-
const segments = source.replaceAll("\\", "/").split("/").slice(0, -1);
|
|
138
|
-
if (segments[0] === "src") {
|
|
139
|
-
segments.shift();
|
|
140
|
-
}
|
|
141
|
-
// A DUT directory can also contain sibling input/output layouts. Keep
|
|
142
|
-
// that directory for every DUT, or its primary type would block the folder.
|
|
143
|
-
if (object.kind !== "dataType" && segments.at(-1) === object.name) {
|
|
144
|
-
segments.pop();
|
|
145
|
-
}
|
|
146
|
-
return [...segments, object.name].join("/");
|
|
132
|
+
const folders = sourceFolders(plan.project.root, sourceModule(object));
|
|
133
|
+
if (!folders) {
|
|
134
|
+
return `${generatedFolder(object)}/${object.name}`;
|
|
147
135
|
}
|
|
148
|
-
|
|
136
|
+
// A DUT directory can also contain sibling input/output layouts. Keep
|
|
137
|
+
// that directory for every DUT, or its primary type would block the folder.
|
|
138
|
+
const kept =
|
|
139
|
+
object.kind !== "dataType" && folders.at(-1) === object.name
|
|
140
|
+
? folders.slice(0, -1)
|
|
141
|
+
: folders;
|
|
142
|
+
return [...kept, object.name].join("/");
|
|
149
143
|
};
|
|
150
144
|
return objectPath;
|
|
151
145
|
}
|
package/src/codesys/symbols.ts
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
type GeneratedObject,
|
|
5
5
|
standardBlocks,
|
|
6
6
|
} from "@tsplc/compiler/ir";
|
|
7
|
-
import { planGlobalNames } from "./global-names
|
|
8
|
-
import type { Instrumentation } from "./instrumentation
|
|
9
|
-
import { Names } from "./names
|
|
10
|
-
import { NumericLowering } from "./numeric
|
|
11
|
-
import type { CodesysPlan } from "./plan
|
|
12
|
-
import { accessedStorage } from "./task-access
|
|
7
|
+
import { planGlobalNames } from "./global-names";
|
|
8
|
+
import type { Instrumentation } from "./instrumentation";
|
|
9
|
+
import { Names } from "./names";
|
|
10
|
+
import { NumericLowering } from "./numeric";
|
|
11
|
+
import type { CodesysPlan } from "./plan";
|
|
12
|
+
import { accessedStorage } from "./task-access";
|
|
13
13
|
|
|
14
14
|
// All symbol relationships were checked by normalization and planning. Failure
|
|
15
15
|
// here is an emitter invariant violation, rather than a recoverable source error.
|
package/src/codesys/telemetry.ts
CHANGED
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
} from "@tsplc/compiler/ir";
|
|
14
14
|
import { type ResolvedTelemetryConfig, telemetrySchema } from "@tsplc/config";
|
|
15
15
|
import { plcBufferBytes } from "@tsplc/server/wire";
|
|
16
|
-
import type { CodesysOptions } from "./config
|
|
17
|
-
import { blockInstances, type InstancePath } from "./debug
|
|
16
|
+
import type { CodesysOptions } from "./config";
|
|
17
|
+
import { blockInstances, type InstancePath } from "./debug";
|
|
18
18
|
import {
|
|
19
19
|
type HttpEndpoint,
|
|
20
20
|
httpCertificateVerifier,
|
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
jsonScalar,
|
|
23
23
|
nativeHttp,
|
|
24
24
|
resolveHttpEndpoint,
|
|
25
|
-
} from "./http
|
|
26
|
-
import { Sources } from "./sources
|
|
27
|
-
import { routineTasks } from "./task-access
|
|
28
|
-
import { type CodesysTypes, stStringLiteral } from "./types
|
|
25
|
+
} from "./http";
|
|
26
|
+
import { Sources } from "./sources";
|
|
27
|
+
import { routineTasks } from "./task-access";
|
|
28
|
+
import { type CodesysTypes, stStringLiteral } from "./types";
|
|
29
29
|
|
|
30
30
|
/** The sender's key in `CodesysPlan.http`, and its HTTP block's id. */
|
|
31
31
|
export const telemetryClient = "tsplc:telemetry";
|
|
@@ -623,7 +623,7 @@ export function telemetryObjects({
|
|
|
623
623
|
const helpers = httpMethods(writer).filter((item) =>
|
|
624
624
|
["ByteLength", "Append", "WriteString"].includes(item.name),
|
|
625
625
|
);
|
|
626
|
-
const [client,
|
|
626
|
+
const [client, ...clientLifecycle] = nativeHttp({
|
|
627
627
|
id: telemetryClient,
|
|
628
628
|
name: names.client,
|
|
629
629
|
ports: `VAR_INPUT\nstart : BOOL;\ncancel : BOOL;\nEND_VAR\nVAR_IN_OUT\nbody : STRING(${plcBufferBytes});\nEND_VAR\nVAR_OUTPUT\nbusy : BOOL;\ndone : BOOL;\nerror : UDINT;\nEND_VAR`,
|
|
@@ -773,7 +773,7 @@ WriteString(text);
|
|
|
773
773
|
...failures,
|
|
774
774
|
...trace,
|
|
775
775
|
client,
|
|
776
|
-
|
|
776
|
+
...clientLifecycle,
|
|
777
777
|
...httpMethods(telemetryClient),
|
|
778
778
|
...httpCertificateVerifier(telemetryClient, names.client, endpoint),
|
|
779
779
|
];
|
package/src/codesys/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Constant, GeneratedObject, PlcType } from "@tsplc/compiler/ir";
|
|
2
2
|
import { instancedBlock, nanosecondsPerMillisecond } from "@tsplc/compiler/ir";
|
|
3
3
|
import { escapeString } from "@tsplc/iec/st";
|
|
4
|
-
import { Names } from "./names
|
|
5
|
-
import { scalarLiteral } from "./numeric
|
|
4
|
+
import { Names } from "./names";
|
|
5
|
+
import { scalarLiteral } from "./numeric";
|
|
6
6
|
|
|
7
7
|
/** A type's name as its source declares it: the last segment of its id. */
|
|
8
8
|
export const sourceTypeName = (id: string) => id.slice(id.lastIndexOf(":") + 1);
|
package/src/codesys/vendor.ts
CHANGED
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
EmitResult,
|
|
5
5
|
GeneratedObject,
|
|
6
6
|
} from "@tsplc/compiler/ir";
|
|
7
|
-
import type { SourceMapping } from "./emit
|
|
8
|
-
import { declarationFile } from "./st-files
|
|
7
|
+
import type { SourceMapping } from "./emit";
|
|
8
|
+
import { declarationFile } from "./st-files";
|
|
9
9
|
|
|
10
10
|
type MappedBundle = Pick<EmitResult, "objects"> & {
|
|
11
11
|
mappings: readonly SourceMapping[];
|
package/src/frontend/analyzer.ts
CHANGED
|
@@ -10,17 +10,17 @@ import {
|
|
|
10
10
|
type Variable,
|
|
11
11
|
} from "@tsplc/compiler/ir";
|
|
12
12
|
import ts from "typescript";
|
|
13
|
-
import { BlockResolver, storageInitializer } from "./blocks
|
|
13
|
+
import { BlockResolver, storageInitializer } from "./blocks";
|
|
14
14
|
import {
|
|
15
15
|
type AnalysisContext,
|
|
16
16
|
ExpressionLowering,
|
|
17
17
|
type LoweringScope,
|
|
18
|
-
} from "./expressions
|
|
19
|
-
import { runtimeSources } from "./module-graph
|
|
20
|
-
import type { Positions } from "./positions
|
|
21
|
-
import { methodAccess, RoutineTable } from "./routines
|
|
22
|
-
import { inSdk, unaliased } from "./sdk
|
|
23
|
-
import { StatementLowering } from "./statements
|
|
18
|
+
} from "./expressions";
|
|
19
|
+
import { runtimeSources } from "./module-graph";
|
|
20
|
+
import type { Positions } from "./positions";
|
|
21
|
+
import { methodAccess, RoutineTable } from "./routines";
|
|
22
|
+
import { inSdk, unaliased } from "./sdk";
|
|
23
|
+
import { StatementLowering } from "./statements";
|
|
24
24
|
import {
|
|
25
25
|
type Fail,
|
|
26
26
|
hasModifier,
|
|
@@ -29,8 +29,8 @@ import {
|
|
|
29
29
|
type ResolvedType,
|
|
30
30
|
SemanticError,
|
|
31
31
|
TypeResolver,
|
|
32
|
-
} from "./types
|
|
33
|
-
import type { FrontendOptions } from "./typescript
|
|
32
|
+
} from "./types";
|
|
33
|
+
import type { FrontendOptions } from "./typescript";
|
|
34
34
|
|
|
35
35
|
/** What a module variable's initializer and keyword establish about its storage. */
|
|
36
36
|
interface StorageFacts {
|
package/src/frontend/async.ts
CHANGED
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
type PlcProgram,
|
|
8
8
|
} from "@tsplc/compiler/ir";
|
|
9
9
|
import ts from "typescript";
|
|
10
|
-
import { lowerCoroutine } from "./coroutines
|
|
11
|
-
import { runtimeSources } from "./module-graph
|
|
10
|
+
import { lowerCoroutine } from "./coroutines";
|
|
11
|
+
import { runtimeSources } from "./module-graph";
|
|
12
12
|
import {
|
|
13
13
|
type Edit,
|
|
14
14
|
edited,
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
mapped,
|
|
19
19
|
type Positions,
|
|
20
20
|
slice,
|
|
21
|
-
} from "./positions
|
|
22
|
-
import { namesSdk, symbolAt } from "./sdk
|
|
23
|
-
import { lowerTaskDefinitions } from "./tasks
|
|
24
|
-
import { hasModifier, SemanticError } from "./types
|
|
21
|
+
} from "./positions";
|
|
22
|
+
import { namesSdk, symbolAt } from "./sdk";
|
|
23
|
+
import { lowerTaskDefinitions } from "./tasks";
|
|
24
|
+
import { hasModifier, SemanticError } from "./types";
|
|
25
25
|
|
|
26
26
|
export type Job = NonNullable<FunctionBlock["job"]>;
|
|
27
27
|
/** A named async function or method. */
|
package/src/frontend/blocks.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Diagnostic, error } from "@tsplc/compiler/ir";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { runtimeSources } from "./module-graph
|
|
4
|
-
import { type Edit, edited, type Mapped, type Positions } from "./positions
|
|
5
|
-
import { namesSdk, symbolAt } from "./sdk
|
|
6
|
-
import type { CompileEnvironment } from "./typescript
|
|
3
|
+
import { runtimeSources } from "./module-graph";
|
|
4
|
+
import { type Edit, edited, type Mapped, type Positions } from "./positions";
|
|
5
|
+
import { namesSdk, symbolAt } from "./sdk";
|
|
6
|
+
import type { CompileEnvironment } from "./typescript";
|
|
7
7
|
|
|
8
8
|
export const lowerEnvironment = (
|
|
9
9
|
program: ts.Program,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Diagnostic, error } from "@tsplc/compiler/ir";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { runtimeSources } from "./module-graph
|
|
3
|
+
import { runtimeSources } from "./module-graph";
|
|
4
4
|
import {
|
|
5
5
|
copied,
|
|
6
6
|
type Edit,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
mapped,
|
|
12
12
|
type Part,
|
|
13
13
|
type Positions,
|
|
14
|
-
} from "./positions
|
|
14
|
+
} from "./positions";
|
|
15
15
|
|
|
16
16
|
/** An arrow body as a function body: a block as written, or its expression returned (or, for void, evaluated). */
|
|
17
17
|
const functionBody = (
|
|
@@ -7,10 +7,10 @@ import type {
|
|
|
7
7
|
MethodMembers,
|
|
8
8
|
Routine,
|
|
9
9
|
SourceRewrite,
|
|
10
|
-
} from "./async
|
|
11
|
-
import { staticString } from "./configuration
|
|
12
|
-
import { copyValue } from "./cooperative
|
|
13
|
-
import { importSpecifier } from "./module-graph
|
|
10
|
+
} from "./async";
|
|
11
|
+
import { staticString } from "./configuration";
|
|
12
|
+
import { copyValue } from "./cooperative";
|
|
13
|
+
import { importSpecifier } from "./module-graph";
|
|
14
14
|
import {
|
|
15
15
|
copied,
|
|
16
16
|
type Edit,
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
type Mapped,
|
|
21
21
|
mapped,
|
|
22
22
|
type Part,
|
|
23
|
-
} from "./positions
|
|
24
|
-
import { hasModifier } from "./types
|
|
23
|
+
} from "./positions";
|
|
24
|
+
import { hasModifier } from "./types";
|
|
25
25
|
|
|
26
26
|
type Step = Job["steps"][number];
|
|
27
27
|
/** What a step does when the operation it waits on fails; `cancellable` failures may be a cancel. */
|
|
@@ -7,24 +7,21 @@ import {
|
|
|
7
7
|
type Mapped,
|
|
8
8
|
mapped,
|
|
9
9
|
type Part,
|
|
10
|
-
} from "../positions
|
|
11
|
-
import { declaredBySdk, inSdk, symbolAt } from "../sdk
|
|
12
|
-
import type { DialectText } from "./dialect
|
|
13
|
-
import type {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "./
|
|
17
|
-
import type {
|
|
18
|
-
import type { EntryImports } from "./imports.ts";
|
|
19
|
-
import type { Model } from "./model.ts";
|
|
20
|
-
import type { Storage } from "./storage.ts";
|
|
10
|
+
} from "../positions";
|
|
11
|
+
import { declaredBySdk, inSdk, symbolAt } from "../sdk";
|
|
12
|
+
import type { DialectText } from "./dialect";
|
|
13
|
+
import type { ExpressionSpecializer, SpecializeContext } from "./expressions";
|
|
14
|
+
import type { Frame } from "./frame";
|
|
15
|
+
import type { EntryImports } from "./imports";
|
|
16
|
+
import type { Model } from "./model";
|
|
17
|
+
import type { Storage } from "./storage";
|
|
21
18
|
import {
|
|
22
19
|
constant,
|
|
23
20
|
type FunctionLike,
|
|
24
21
|
repeatable,
|
|
25
22
|
SpecializeError,
|
|
26
23
|
type Value,
|
|
27
|
-
} from "./values
|
|
24
|
+
} from "./values";
|
|
28
25
|
|
|
29
26
|
/** Specializes calls: to what the language and SDK provide, to the service client, and to functions. */
|
|
30
27
|
export class CallSpecializer {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
type CaptureRequest,
|
|
17
17
|
captureRequestSchema,
|
|
18
18
|
withBindingRegistry,
|
|
19
|
-
} from "./capture-protocol
|
|
19
|
+
} from "./capture-protocol";
|
|
20
20
|
|
|
21
21
|
const request: CaptureRequest = captureRequestSchema.parse(
|
|
22
22
|
JSON.parse(readFileSync(process.argv[2]!, "utf8")),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { canAssign, integerType, primitiveTypes } from "@tsplc/compiler/ir";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { joined, type Mapped, mapped } from "../positions
|
|
4
|
-
import type { EntryImports } from "./imports
|
|
5
|
-
import type { Initializers } from "./initializers
|
|
6
|
-
import type { Layouts } from "./layouts
|
|
7
|
-
import type { Model } from "./model
|
|
8
|
-
import type { Storage } from "./storage
|
|
9
|
-
import type { Value } from "./values
|
|
3
|
+
import { joined, type Mapped, mapped } from "../positions";
|
|
4
|
+
import type { EntryImports } from "./imports";
|
|
5
|
+
import type { Initializers } from "./initializers";
|
|
6
|
+
import type { Layouts } from "./layouts";
|
|
7
|
+
import type { Model } from "./model";
|
|
8
|
+
import type { Storage } from "./storage";
|
|
9
|
+
import type { Value } from "./values";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Specialized values as dialect text, in a place of a declared type: literals as enum members,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// biome-ignore-all lint/style/noNonNullAssertion: Retain existing non-null assertions during the tooling migration; changing their contracts requires a separate review.
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { from, joined, type Mapped, mapped } from "../positions
|
|
4
|
-
import { unaliased } from "../sdk
|
|
5
|
-
import { CallSpecializer } from "./calls
|
|
6
|
-
import type { DialectText } from "./dialect
|
|
7
|
-
import type { Frame } from "./frame
|
|
8
|
-
import type { EntryImports } from "./imports
|
|
9
|
-
import type { Initializers } from "./initializers
|
|
10
|
-
import { type Layouts, recordTypes } from "./layouts
|
|
11
|
-
import type { Model, ModelNode } from "./model
|
|
12
|
-
import type { Storage } from "./storage
|
|
3
|
+
import { from, joined, type Mapped, mapped } from "../positions";
|
|
4
|
+
import { unaliased } from "../sdk";
|
|
5
|
+
import { CallSpecializer } from "./calls";
|
|
6
|
+
import type { DialectText } from "./dialect";
|
|
7
|
+
import type { Frame } from "./frame";
|
|
8
|
+
import type { EntryImports } from "./imports";
|
|
9
|
+
import type { Initializers } from "./initializers";
|
|
10
|
+
import { type Layouts, recordTypes } from "./layouts";
|
|
11
|
+
import type { Model, ModelNode } from "./model";
|
|
12
|
+
import type { Storage } from "./storage";
|
|
13
13
|
import {
|
|
14
14
|
constant,
|
|
15
15
|
type Env,
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
repeatable,
|
|
18
18
|
SpecializeError,
|
|
19
19
|
type Value,
|
|
20
|
-
} from "./values
|
|
21
|
-
import { isAssignment } from "./writes
|
|
20
|
+
} from "./values";
|
|
21
|
+
import { isAssignment } from "./writes";
|
|
22
22
|
|
|
23
23
|
/** What every part of scan-code specialization shares. */
|
|
24
24
|
export interface SpecializeContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type ts from "typescript";
|
|
2
|
-
import { from, type Mapped, mapped, type Part } from "../positions
|
|
3
|
-
import { unusedName } from "./layouts
|
|
4
|
-
import type { ModelNode } from "./model
|
|
5
|
-
import type { Env } from "./values
|
|
2
|
+
import { from, type Mapped, mapped, type Part } from "../positions";
|
|
3
|
+
import { unusedName } from "./layouts";
|
|
4
|
+
import type { ModelNode } from "./model";
|
|
5
|
+
import type { Env } from "./values";
|
|
6
6
|
|
|
7
7
|
/** Indented lines of one generated routine, with the local names it has used. */
|
|
8
8
|
export class Emitter {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
type CapturedGraph,
|
|
16
16
|
type CaptureRequest,
|
|
17
17
|
capturedGraphSchema,
|
|
18
|
-
} from "./capture-protocol
|
|
18
|
+
} from "./capture-protocol";
|
|
19
19
|
|
|
20
20
|
/** The top-level bindings a module declares: values, classes and functions, arrow functions among them. */
|
|
21
21
|
export const bindingNames = (source: ts.SourceFile) => {
|
|
@@ -8,24 +8,24 @@ import {
|
|
|
8
8
|
} from "@tsplc/compiler/ir";
|
|
9
9
|
import { generatedDirectory } from "@tsplc/config/project-files";
|
|
10
10
|
import ts from "typescript";
|
|
11
|
-
import { runtimeSources } from "../module-graph
|
|
11
|
+
import { runtimeSources } from "../module-graph";
|
|
12
12
|
import {
|
|
13
13
|
copied,
|
|
14
14
|
from,
|
|
15
15
|
joined,
|
|
16
16
|
type Mapped,
|
|
17
17
|
type Positions,
|
|
18
|
-
} from "../positions
|
|
19
|
-
import { inSdk, namesSdk } from "../sdk
|
|
20
|
-
import type { CompileDebug } from "../typescript
|
|
21
|
-
import type { CapturedValue } from "./capture-protocol
|
|
22
|
-
import { captureGraph } from "./graph
|
|
23
|
-
import { importPath } from "./imports
|
|
24
|
-
import { Model, type Root } from "./model
|
|
25
|
-
import { Retention, retainedDeclarations } from "./retention
|
|
26
|
-
import { closingBrace, Specializer } from "./specialize
|
|
27
|
-
import { setterName } from "./storage
|
|
28
|
-
import { SpecializeError } from "./values
|
|
18
|
+
} from "../positions";
|
|
19
|
+
import { inSdk, namesSdk } from "../sdk";
|
|
20
|
+
import type { CompileDebug } from "../typescript";
|
|
21
|
+
import type { CapturedValue } from "./capture-protocol";
|
|
22
|
+
import { captureGraph } from "./graph";
|
|
23
|
+
import { importPath } from "./imports";
|
|
24
|
+
import { Model, type Root } from "./model";
|
|
25
|
+
import { Retention, retainedDeclarations } from "./retention";
|
|
26
|
+
import { closingBrace, Specializer } from "./specialize";
|
|
27
|
+
import { setterName } from "./storage";
|
|
28
|
+
import { SpecializeError } from "./values";
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* A module the compiled program keeps as written: only types, enums, constants and the service
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// biome-ignore-all lint/style/noNonNullAssertion: Retain existing non-null assertions during the tooling migration; changing their contracts requires a separate review.
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import type { CapturedValue } from "./capture-protocol
|
|
4
|
-
import { type Layouts, recordTypes } from "./layouts
|
|
5
|
-
import type { Model, ModelNode } from "./model
|
|
6
|
-
import type { Storage } from "./storage
|
|
3
|
+
import type { CapturedValue } from "./capture-protocol";
|
|
4
|
+
import { type Layouts, recordTypes } from "./layouts";
|
|
5
|
+
import type { Model, ModelNode } from "./model";
|
|
6
|
+
import type { Storage } from "./storage";
|
|
7
7
|
|
|
8
8
|
/** Values setup captured as dialect text: storage initializers, and fixed data scan code reads. */
|
|
9
9
|
export class Initializers {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { primitiveTypes } from "@tsplc/compiler/ir";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import type { CapturedValue } from "./capture-protocol
|
|
4
|
-
import { ModuleImports } from "./imports
|
|
5
|
-
import type { Model } from "./model
|
|
3
|
+
import type { CapturedValue } from "./capture-protocol";
|
|
4
|
+
import { ModuleImports } from "./imports";
|
|
5
|
+
import type { Model } from "./model";
|
|
6
6
|
|
|
7
7
|
/** IEC names a program can write as types; they keep their width rather than becoming DINT. */
|
|
8
8
|
const iecNames = new Set(primitiveTypes.map((type) => type.id));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import { namesSdk } from "../sdk
|
|
3
|
-
import type { CapturedValue } from "./capture-protocol
|
|
2
|
+
import { namesSdk } from "../sdk";
|
|
3
|
+
import type { CapturedValue } from "./capture-protocol";
|
|
4
4
|
import {
|
|
5
5
|
children,
|
|
6
6
|
type Model,
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
type Owner,
|
|
9
9
|
type Root,
|
|
10
10
|
tsPath,
|
|
11
|
-
} from "./model
|
|
12
|
-
import type { Storage } from "./storage
|
|
13
|
-
import { SpecializeError } from "./values
|
|
11
|
+
} from "./model";
|
|
12
|
+
import type { Storage } from "./storage";
|
|
13
|
+
import { SpecializeError } from "./values";
|
|
14
14
|
|
|
15
15
|
/** A declaration whose initializer retains a primitive: a module binding or a class field. */
|
|
16
16
|
type RetainedDeclaration = ts.VariableDeclaration | ts.PropertyDeclaration;
|