@tsplc/compiler 0.5.3 → 0.5.5
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 +2 -2
- package/dist/codesys.js.map +23 -23
- package/dist/elaborate-capture.js +3 -2
- package/dist/elaborate-capture.js.map +3 -3
- package/dist/index.js +26 -19
- package/dist/index.js.map +38 -38
- 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 +3 -3
- 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/st-files.ts +4 -4
- package/src/codesys/symbols.ts +6 -6
- package/src/codesys/telemetry.ts +6 -6
- 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 +29 -18
- package/src/frontend/elaborate/capture.ts +3 -2
- package/src/frontend/elaborate/dialect.ts +9 -9
- 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/imports.ts +14 -15
- 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/sdk.ts +7 -1
- 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
|
@@ -26,10 +26,10 @@ import {
|
|
|
26
26
|
valueRange,
|
|
27
27
|
} from "@tsplc/compiler/ir";
|
|
28
28
|
import ts from "typescript";
|
|
29
|
-
import type { BlockResolver, BlockSource } from "./blocks
|
|
30
|
-
import { intrinsicExpression } from "./intrinsics
|
|
31
|
-
import type { Positions } from "./positions
|
|
32
|
-
import type { RoutineTable } from "./routines
|
|
29
|
+
import type { BlockResolver, BlockSource } from "./blocks";
|
|
30
|
+
import { intrinsicExpression } from "./intrinsics";
|
|
31
|
+
import type { Positions } from "./positions";
|
|
32
|
+
import type { RoutineTable } from "./routines";
|
|
33
33
|
import {
|
|
34
34
|
calleeName,
|
|
35
35
|
type Fail,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
type TypeEnvironment,
|
|
42
42
|
type TypeResolver,
|
|
43
43
|
unparenthesized,
|
|
44
|
-
} from "./types
|
|
44
|
+
} from "./types";
|
|
45
45
|
|
|
46
46
|
type UnaryOperator = Extract<Expression, { kind: "unary" }>["operator"];
|
|
47
47
|
type ArrayLayout = Extract<PlcType, { kind: "array" }>;
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
parseInteger,
|
|
8
8
|
} from "@tsplc/compiler/ir";
|
|
9
9
|
import ts from "typescript";
|
|
10
|
-
import type { ExpressionLowering } from "./expressions
|
|
11
|
-
import { numericLiteral } from "./types
|
|
10
|
+
import type { ExpressionLowering } from "./expressions";
|
|
11
|
+
import { numericLiteral } from "./types";
|
|
12
12
|
|
|
13
13
|
type Conversion = Extract<Expression, { kind: "convert" }>["policy"];
|
|
14
14
|
type Arithmetic = Pick<
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, relative } from "node:path";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { symbolAt } from "./sdk
|
|
3
|
+
import { symbolAt } from "./sdk";
|
|
4
4
|
|
|
5
5
|
/** The quoted specifier an import generated into `importer` uses to reach `target`. */
|
|
6
6
|
export const importSpecifier = (importer: string, target: string): string => {
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { PromiseContext, Routine } from "./promises
|
|
4
|
-
import { hasModifier } from "./types
|
|
3
|
+
import type { PromiseContext, Routine } from "./promises";
|
|
4
|
+
import { hasModifier } from "./types";
|
|
5
5
|
|
|
6
6
|
type Handler = ts.ArrowFunction | ts.FunctionExpression | Routine;
|
|
7
7
|
type Owner = ts.FunctionDeclaration | ts.MethodDeclaration;
|
package/src/frontend/promises.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 { type Diagnostic, error } from "@tsplc/compiler/ir";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
-
import { importSpecifier, runtimeSources } from "./module-graph
|
|
4
|
+
import { importSpecifier, runtimeSources } from "./module-graph";
|
|
5
5
|
import {
|
|
6
6
|
type Edit,
|
|
7
7
|
edited,
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
type Mapped,
|
|
11
11
|
mapped,
|
|
12
12
|
type Positions,
|
|
13
|
-
} from "./positions
|
|
14
|
-
import { chainOf, lowerChain } from "./promise-chains
|
|
15
|
-
import { namesSdk, symbolAt } from "./sdk
|
|
16
|
-
import { hasModifier, SemanticError } from "./types
|
|
13
|
+
} from "./positions";
|
|
14
|
+
import { chainOf, lowerChain } from "./promise-chains";
|
|
15
|
+
import { namesSdk, symbolAt } from "./sdk";
|
|
16
|
+
import { hasModifier, SemanticError } from "./types";
|
|
17
17
|
|
|
18
18
|
export type Routine = ts.FunctionDeclaration | ts.MethodDeclaration;
|
|
19
19
|
|
package/src/frontend/routines.ts
CHANGED
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
type PlcFunction,
|
|
6
6
|
} from "@tsplc/compiler/ir";
|
|
7
7
|
import ts from "typescript";
|
|
8
|
-
import type { Positions } from "./positions
|
|
8
|
+
import type { Positions } from "./positions";
|
|
9
9
|
import {
|
|
10
10
|
type Fail,
|
|
11
11
|
hasModifier,
|
|
12
12
|
type TypeEnvironment,
|
|
13
13
|
type TypeResolver,
|
|
14
|
-
} from "./types
|
|
14
|
+
} from "./types";
|
|
15
15
|
|
|
16
16
|
/** A routine whose signature is admitted and whose body is still to be lowered. */
|
|
17
17
|
interface PendingRoutine {
|
package/src/frontend/sdk.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { dirname } from "node:path";
|
|
3
|
+
import { basename, dirname } from "node:path";
|
|
4
4
|
import ts from "typescript";
|
|
5
5
|
|
|
6
6
|
/** The `@tsplc/compiler/globals` declaration file a project compiles against. */
|
|
@@ -44,6 +44,12 @@ export const sdkFor = (
|
|
|
44
44
|
export const inSdk = (sdk: string, fileName: string): boolean =>
|
|
45
45
|
fileName.startsWith(`${dirname(sdk)}/`);
|
|
46
46
|
|
|
47
|
+
/** The path a program imports an SDK declaration file by: `index.d.ts` is `@tsplc/compiler/types`, any other its own name. */
|
|
48
|
+
export const sdkModule = (fileName: string): string => {
|
|
49
|
+
const name = basename(fileName, ".d.ts");
|
|
50
|
+
return `@tsplc/compiler/${name === "index" ? "types" : name}`;
|
|
51
|
+
};
|
|
52
|
+
|
|
47
53
|
/** A symbol followed through import and export aliases to what it names. */
|
|
48
54
|
export const unaliased = (
|
|
49
55
|
checker: ts.TypeChecker,
|
package/src/frontend/services.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
wireRecord,
|
|
13
13
|
} from "@tsplc/server";
|
|
14
14
|
import ts from "typescript";
|
|
15
|
-
import { runtimeSources } from "./module-graph
|
|
15
|
+
import { runtimeSources } from "./module-graph";
|
|
16
16
|
import {
|
|
17
17
|
type Edit,
|
|
18
18
|
edited,
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
type Mapped,
|
|
21
21
|
mapped,
|
|
22
22
|
type Positions,
|
|
23
|
-
} from "./positions
|
|
24
|
-
import { namesSdk, symbolAt } from "./sdk
|
|
23
|
+
} from "./positions";
|
|
24
|
+
import { namesSdk, symbolAt } from "./sdk";
|
|
25
25
|
|
|
26
26
|
/** The server section's transport; each client's type argument names its router. */
|
|
27
27
|
export interface ServiceOptions {
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
type Variable,
|
|
15
15
|
} from "@tsplc/compiler/ir";
|
|
16
16
|
import ts from "typescript";
|
|
17
|
-
import type { AnalysisContext, ExpressionLowering } from "./expressions
|
|
18
|
-
import type { Positions } from "./positions
|
|
19
|
-
import { telemetryStatement } from "./telemetry
|
|
20
|
-
import { type Fail, numericLiteral, type TypeResolver } from "./types
|
|
17
|
+
import type { AnalysisContext, ExpressionLowering } from "./expressions";
|
|
18
|
+
import type { Positions } from "./positions";
|
|
19
|
+
import { telemetryStatement } from "./telemetry";
|
|
20
|
+
import { type Fail, numericLiteral, type TypeResolver } from "./types";
|
|
21
21
|
|
|
22
22
|
type IterationForm = "elements" | "entries" | "recordValues" | "recordEntries";
|
|
23
23
|
|
package/src/frontend/tasks.ts
CHANGED
|
@@ -6,16 +6,11 @@ import {
|
|
|
6
6
|
nanosecondsPerMillisecond,
|
|
7
7
|
} from "@tsplc/compiler/ir";
|
|
8
8
|
import ts from "typescript";
|
|
9
|
-
import type { AsyncContext, Routine, SourceRewrite } from "./async
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
taskSite,
|
|
15
|
-
} from "./cooperative.ts";
|
|
16
|
-
import { aliasPrefix } from "./coroutines.ts";
|
|
17
|
-
import { importSpecifier } from "./module-graph.ts";
|
|
18
|
-
import { from } from "./positions.ts";
|
|
9
|
+
import type { AsyncContext, Routine, SourceRewrite } from "./async";
|
|
10
|
+
import { cooperativeSite, copyValue, type Site, taskSite } from "./cooperative";
|
|
11
|
+
import { aliasPrefix } from "./coroutines";
|
|
12
|
+
import { importSpecifier } from "./module-graph";
|
|
13
|
+
import { from } from "./positions";
|
|
19
14
|
|
|
20
15
|
/** A `<tasks>.define(...)` initializer, the declaration holding it, and that declaration's block. */
|
|
21
16
|
interface TaskDefinition {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Statement } from "@tsplc/compiler/ir";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import type { ExpressionLowering } from "./expressions
|
|
4
|
-
import { namedProperty, type TelemetryMethod } from "./types
|
|
3
|
+
import type { ExpressionLowering } from "./expressions";
|
|
4
|
+
import { namedProperty, type TelemetryMethod } from "./types";
|
|
5
5
|
|
|
6
6
|
type Telemetry = Extract<Statement, { kind: "telemetry" }>;
|
|
7
7
|
|
package/src/frontend/types.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "@tsplc/compiler/ir";
|
|
14
14
|
import { elementaryType, integerRange } from "@tsplc/iec";
|
|
15
15
|
import ts from "typescript";
|
|
16
|
-
import { declaredBySdk, unaliased } from "./sdk
|
|
16
|
+
import { declaredBySdk, unaliased } from "./sdk";
|
|
17
17
|
|
|
18
18
|
export interface ResolvedType {
|
|
19
19
|
type: string;
|
|
@@ -3,21 +3,17 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { type Diagnostic, hasErrors, type PlcModule } from "@tsplc/compiler/ir";
|
|
5
5
|
import ts from "typescript";
|
|
6
|
-
import { Analyzer, suppressionDiagnostics } from "./analyzer
|
|
7
|
-
import { type AsyncLowering, lowerAsync } from "./async
|
|
8
|
-
import { lowerEnvironment } from "./configuration
|
|
9
|
-
import { lowerConstFunctions } from "./const-functions
|
|
10
|
-
import { lowerElaboration } from "./elaborate/index
|
|
11
|
-
import { lowerExposure } from "./exposure
|
|
12
|
-
import { runtimeSources } from "./module-graph
|
|
13
|
-
import { type Mapped, Positions, sourceSpan } from "./positions
|
|
14
|
-
import { lowerPromises } from "./promises
|
|
15
|
-
import { inSdk, sdkFor } from "./sdk
|
|
16
|
-
import {
|
|
17
|
-
lowerServices,
|
|
18
|
-
type ServiceOptions,
|
|
19
|
-
serviceRecords,
|
|
20
|
-
} from "./services.ts";
|
|
6
|
+
import { Analyzer, suppressionDiagnostics } from "./analyzer";
|
|
7
|
+
import { type AsyncLowering, lowerAsync } from "./async";
|
|
8
|
+
import { lowerEnvironment } from "./configuration";
|
|
9
|
+
import { lowerConstFunctions } from "./const-functions";
|
|
10
|
+
import { lowerElaboration } from "./elaborate/index";
|
|
11
|
+
import { lowerExposure } from "./exposure";
|
|
12
|
+
import { runtimeSources } from "./module-graph";
|
|
13
|
+
import { type Mapped, Positions, sourceSpan } from "./positions";
|
|
14
|
+
import { lowerPromises } from "./promises";
|
|
15
|
+
import { inSdk, sdkFor } from "./sdk";
|
|
16
|
+
import { lowerServices, type ServiceOptions, serviceRecords } from "./services";
|
|
21
17
|
|
|
22
18
|
/** The host environment a compilation reads, as `env()` values and endpoint settings. */
|
|
23
19
|
export type CompileEnvironment = Readonly<Record<string, string | undefined>>;
|
package/src/index.ts
CHANGED
package/src/ir/aggregates.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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
|
-
import { calendarZero, domainConstantFits, domainIssue } from "./domains
|
|
2
|
+
import { calendarZero, domainConstantFits, domainIssue } from "./domains";
|
|
3
3
|
import {
|
|
4
4
|
type Constant,
|
|
5
5
|
comparisonOperators,
|
|
6
6
|
type Expression,
|
|
7
7
|
type Place,
|
|
8
8
|
type Variable,
|
|
9
|
-
} from "./model
|
|
10
|
-
import { constantFits, type IntegerInterval } from "./numeric
|
|
11
|
-
import { interval } from "./ranges
|
|
12
|
-
import { scalarIssue } from "./scalars
|
|
13
|
-
import type { PlcType } from "./types
|
|
9
|
+
} from "./model";
|
|
10
|
+
import { constantFits, type IntegerInterval } from "./numeric";
|
|
11
|
+
import { interval } from "./ranges";
|
|
12
|
+
import { scalarIssue } from "./scalars";
|
|
13
|
+
import type { PlcType } from "./types";
|
|
14
14
|
|
|
15
15
|
export function aggregate(type: PlcType | undefined): boolean {
|
|
16
16
|
return type?.kind === "record" || type?.kind === "array";
|
package/src/ir/allocation.ts
CHANGED
|
@@ -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
|
-
import type { ModuleDeclarations } from "./declarations
|
|
3
|
-
import { maxNestingDepth, maxScalarElements } from "./layouts
|
|
4
|
-
import type { PlcModule } from "./model
|
|
5
|
-
import { reject } from "./normalization-error
|
|
6
|
-
import { instancedBlock } from "./types
|
|
2
|
+
import type { ModuleDeclarations } from "./declarations";
|
|
3
|
+
import { maxNestingDepth, maxScalarElements } from "./layouts";
|
|
4
|
+
import type { PlcModule } from "./model";
|
|
5
|
+
import { reject } from "./normalization-error";
|
|
6
|
+
import { instancedBlock } from "./types";
|
|
7
7
|
|
|
8
8
|
export function checkStaticAllocation(
|
|
9
9
|
module: PlcModule,
|
package/src/ir/core-model.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SourceSpan } from "./diagnostics
|
|
1
|
+
import type { SourceSpan } from "./diagnostics";
|
|
2
2
|
import type {
|
|
3
3
|
BinaryOperator,
|
|
4
4
|
Constant,
|
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
PlcProgram,
|
|
10
10
|
TelemetryCall,
|
|
11
11
|
Variable,
|
|
12
|
-
} from "./model
|
|
13
|
-
import type { PlcType } from "./types
|
|
12
|
+
} from "./model";
|
|
13
|
+
import type { PlcType } from "./types";
|
|
14
14
|
|
|
15
15
|
// Core expressions contain no source-level calls. Their effects have already
|
|
16
16
|
// become ordered statements, and every place has passed storage/bounds checks.
|
package/src/ir/declarations.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { valueFits } from "./aggregates
|
|
2
|
-
import type { SourceSpan } from "./diagnostics
|
|
3
|
-
import { admitLayouts } from "./layouts
|
|
1
|
+
import { valueFits } from "./aggregates";
|
|
2
|
+
import type { SourceSpan } from "./diagnostics";
|
|
3
|
+
import { admitLayouts } from "./layouts";
|
|
4
4
|
import {
|
|
5
5
|
type FunctionBlock,
|
|
6
6
|
type PlcFunction,
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
type StandardBlock,
|
|
9
9
|
standardBlocks,
|
|
10
10
|
type Variable,
|
|
11
|
-
} from "./model
|
|
12
|
-
import { reject } from "./normalization-error
|
|
13
|
-
import { instancedBlock, type PlcType } from "./types
|
|
11
|
+
} from "./model";
|
|
12
|
+
import { reject } from "./normalization-error";
|
|
13
|
+
import { instancedBlock, type PlcType } from "./types";
|
|
14
14
|
|
|
15
15
|
const matchesPorts = (
|
|
16
16
|
variables: readonly Variable[],
|
package/src/ir/domains.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { elementaryType, integerRange } from "@tsplc/iec";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type Expression,
|
|
6
|
-
} from "./model.ts";
|
|
7
|
-
import { canonicalInteger, exactDecimal } from "./numeric.ts";
|
|
8
|
-
import type { PlcType } from "./types.ts";
|
|
2
|
+
import { type Constant, comparisonOperators, type Expression } from "./model";
|
|
3
|
+
import { canonicalInteger, exactDecimal } from "./numeric";
|
|
4
|
+
import type { PlcType } from "./types";
|
|
9
5
|
|
|
10
6
|
export const nanosecondsPerMillisecond = 1_000_000n;
|
|
11
7
|
|
package/src/ir/fold.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { nanosecondsPerMillisecond } from "./domains
|
|
2
|
-
import type {
|
|
3
|
-
BinaryOperator,
|
|
4
|
-
Constant,
|
|
5
|
-
Expression,
|
|
6
|
-
Variable,
|
|
7
|
-
} from "./model.ts";
|
|
1
|
+
import { nanosecondsPerMillisecond } from "./domains";
|
|
2
|
+
import type { BinaryOperator, Constant, Expression, Variable } from "./model";
|
|
8
3
|
import {
|
|
9
4
|
applyIntegerPolicy,
|
|
10
5
|
integerType,
|
|
11
6
|
roundFloat,
|
|
12
7
|
saturateFloat,
|
|
13
|
-
} from "./numeric
|
|
14
|
-
import type { PlcType } from "./types
|
|
8
|
+
} from "./numeric";
|
|
9
|
+
import type { PlcType } from "./types";
|
|
15
10
|
|
|
16
11
|
type Types = ReadonlyMap<string, PlcType> | undefined;
|
|
17
12
|
|
package/src/ir/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export {
|
|
|
5
5
|
expressionIssue,
|
|
6
6
|
placeType,
|
|
7
7
|
valueFits,
|
|
8
|
-
} from "./aggregates
|
|
8
|
+
} from "./aggregates";
|
|
9
9
|
export {
|
|
10
10
|
type CheckedPlace,
|
|
11
11
|
type CoreExpression,
|
|
@@ -16,24 +16,24 @@ export {
|
|
|
16
16
|
directWrites,
|
|
17
17
|
nestedBodies,
|
|
18
18
|
type VerifiedCoreModule,
|
|
19
|
-
} from "./core-model
|
|
19
|
+
} from "./core-model";
|
|
20
20
|
export {
|
|
21
21
|
type Diagnostic,
|
|
22
22
|
error,
|
|
23
23
|
formatDiagnostic,
|
|
24
24
|
hasErrors,
|
|
25
25
|
type SourceSpan,
|
|
26
|
-
} from "./diagnostics
|
|
26
|
+
} from "./diagnostics";
|
|
27
27
|
export {
|
|
28
28
|
calendarLiteral,
|
|
29
29
|
domainConstantFits,
|
|
30
30
|
domainIssue,
|
|
31
31
|
durationLiteral,
|
|
32
32
|
nanosecondsPerMillisecond,
|
|
33
|
-
} from "./domains
|
|
34
|
-
export { fold } from "./fold
|
|
35
|
-
export { errorName, httpErrors, jobError, jobErrors } from "./job-errors
|
|
36
|
-
export { layoutIssue, maxNestingDepth, maxScalarElements } from "./layouts
|
|
33
|
+
} from "./domains";
|
|
34
|
+
export { fold } from "./fold";
|
|
35
|
+
export { errorName, httpErrors, jobError, jobErrors } from "./job-errors";
|
|
36
|
+
export { layoutIssue, maxNestingDepth, maxScalarElements } from "./layouts";
|
|
37
37
|
export {
|
|
38
38
|
type Artifact,
|
|
39
39
|
type BinaryOperator,
|
|
@@ -57,8 +57,8 @@ export {
|
|
|
57
57
|
type TelemetryCall,
|
|
58
58
|
telemetryOperands,
|
|
59
59
|
type Variable,
|
|
60
|
-
} from "./model
|
|
61
|
-
export { isVerifiedCore, normalizeModule } from "./normalize
|
|
60
|
+
} from "./model";
|
|
61
|
+
export { isVerifiedCore, normalizeModule } from "./normalize";
|
|
62
62
|
export {
|
|
63
63
|
applyIntegerPolicy,
|
|
64
64
|
canAssign,
|
|
@@ -70,12 +70,12 @@ export {
|
|
|
70
70
|
roundFloat,
|
|
71
71
|
saturateFloat,
|
|
72
72
|
wrapsNatively,
|
|
73
|
-
} from "./numeric
|
|
73
|
+
} from "./numeric";
|
|
74
74
|
export {
|
|
75
75
|
pathIndexes,
|
|
76
76
|
statementExpressions,
|
|
77
77
|
subexpressions,
|
|
78
|
-
} from "./operands
|
|
78
|
+
} from "./operands";
|
|
79
79
|
export {
|
|
80
80
|
interval,
|
|
81
81
|
loopBounds,
|
|
@@ -83,15 +83,15 @@ export {
|
|
|
83
83
|
maxLoopIterations,
|
|
84
84
|
narrowRanges,
|
|
85
85
|
valueRange,
|
|
86
|
-
} from "./ranges
|
|
87
|
-
export { scalarIssue } from "./scalars
|
|
86
|
+
} from "./ranges";
|
|
87
|
+
export { scalarIssue } from "./scalars";
|
|
88
88
|
export {
|
|
89
89
|
foldConstantRoutines,
|
|
90
90
|
joinPrograms,
|
|
91
91
|
type SharedRoutines,
|
|
92
92
|
shareRoutines,
|
|
93
|
-
} from "./share
|
|
94
|
-
export { forwardTemporaries } from "./temporaries
|
|
93
|
+
} from "./share";
|
|
94
|
+
export { forwardTemporaries } from "./temporaries";
|
|
95
95
|
export {
|
|
96
96
|
type Field,
|
|
97
97
|
instancedBlock,
|
|
@@ -100,4 +100,4 @@ export {
|
|
|
100
100
|
primitiveTypes,
|
|
101
101
|
type SymbolId,
|
|
102
102
|
type TypeId,
|
|
103
|
-
} from "./types
|
|
103
|
+
} from "./types";
|
package/src/ir/layouts.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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 { elementaryType, integerRange } from "@tsplc/iec";
|
|
3
|
-
import { InvalidCore, reject } from "./normalization-error
|
|
4
|
-
import { constantFits } from "./numeric
|
|
5
|
-
import { type PlcType, primitiveTypes } from "./types
|
|
3
|
+
import { InvalidCore, reject } from "./normalization-error";
|
|
4
|
+
import { constantFits } from "./numeric";
|
|
5
|
+
import { type PlcType, primitiveTypes } from "./types";
|
|
6
6
|
|
|
7
7
|
/** The finite storage budget: scalar elements in one layout or allocation, and nesting depth. */
|
|
8
8
|
export const maxScalarElements = 1_000_000;
|
package/src/ir/link.ts
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
type CoreStatement,
|
|
6
6
|
directWrites,
|
|
7
7
|
nestedBodies,
|
|
8
|
-
} from "./core-model
|
|
9
|
-
import type { ModuleDeclarations } from "./declarations
|
|
10
|
-
import { type PlcModule, telemetryOperands } from "./model
|
|
11
|
-
import { reject } from "./normalization-error
|
|
12
|
-
import { instancedBlock, type PlcType } from "./types
|
|
8
|
+
} from "./core-model";
|
|
9
|
+
import type { ModuleDeclarations } from "./declarations";
|
|
10
|
+
import { type PlcModule, telemetryOperands } from "./model";
|
|
11
|
+
import { reject } from "./normalization-error";
|
|
12
|
+
import { instancedBlock, type PlcType } from "./types";
|
|
13
13
|
|
|
14
14
|
type Edges = ReadonlyMap<string, ReadonlySet<string>>;
|
|
15
15
|
type Routine = CoreFunction | CoreFunctionBlock;
|
package/src/ir/model.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Diagnostic, SourceSpan } from "./diagnostics
|
|
2
|
-
import type { PlcType, SymbolId, TypeId } from "./types
|
|
1
|
+
import type { Diagnostic, SourceSpan } from "./diagnostics";
|
|
2
|
+
import type { PlcType, SymbolId, TypeId } from "./types";
|
|
3
3
|
|
|
4
4
|
export type Constant =
|
|
5
5
|
| { kind: "bool"; value: boolean }
|
package/src/ir/normalize.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { checkStaticAllocation } from "./allocation
|
|
1
|
+
import { checkStaticAllocation } from "./allocation";
|
|
2
2
|
import {
|
|
3
3
|
type CoreFunction,
|
|
4
4
|
type CoreFunctionBlock,
|
|
5
5
|
type VerifiedCoreModule,
|
|
6
6
|
verified,
|
|
7
|
-
} from "./core-model
|
|
8
|
-
import { ModuleDeclarations } from "./declarations
|
|
9
|
-
import type { Diagnostic } from "./diagnostics
|
|
10
|
-
import { linkModule } from "./link
|
|
11
|
-
import type { PlcModule } from "./model
|
|
12
|
-
import { InvalidCore } from "./normalization-error
|
|
13
|
-
import { RoutineNormalizer } from "./routine
|
|
7
|
+
} from "./core-model";
|
|
8
|
+
import { ModuleDeclarations } from "./declarations";
|
|
9
|
+
import type { Diagnostic } from "./diagnostics";
|
|
10
|
+
import { linkModule } from "./link";
|
|
11
|
+
import type { PlcModule } from "./model";
|
|
12
|
+
import { InvalidCore } from "./normalization-error";
|
|
13
|
+
import { RoutineNormalizer } from "./routine";
|
|
14
14
|
|
|
15
15
|
const verifiedModules = new WeakSet<object>();
|
|
16
16
|
export function isVerifiedCore(value: unknown): value is VerifiedCoreModule {
|
package/src/ir/numeric.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
import type { Constant } from "./model
|
|
3
|
-
import { integerRange, type PlcType } from "./types
|
|
2
|
+
import type { Constant } from "./model";
|
|
3
|
+
import { integerRange, type PlcType } from "./types";
|
|
4
4
|
|
|
5
5
|
type IntegerType = Extract<PlcType, { kind: "integer" | "bits" }>;
|
|
6
6
|
type FloatType = Extract<PlcType, { kind: "float" }>;
|
package/src/ir/operands.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CoreExpression, CorePath, CoreStatement } from "./core-model
|
|
2
|
-
import { telemetryOperands } from "./model
|
|
1
|
+
import type { CoreExpression, CorePath, CoreStatement } from "./core-model";
|
|
2
|
+
import { telemetryOperands } from "./model";
|
|
3
3
|
|
|
4
4
|
/** The index expressions along a place's path. */
|
|
5
5
|
export const pathIndexes = (path: CorePath = []): CoreExpression[] =>
|
package/src/ir/ranges.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { fold } from "./fold
|
|
2
|
-
import type {
|
|
3
|
-
BinaryOperator,
|
|
4
|
-
Expression,
|
|
5
|
-
MathHelper,
|
|
6
|
-
Variable,
|
|
7
|
-
} from "./model.ts";
|
|
1
|
+
import { fold } from "./fold";
|
|
2
|
+
import type { BinaryOperator, Expression, MathHelper, Variable } from "./model";
|
|
8
3
|
import {
|
|
9
4
|
admits,
|
|
10
5
|
highest,
|
|
@@ -12,8 +7,8 @@ import {
|
|
|
12
7
|
integerType,
|
|
13
8
|
lowest,
|
|
14
9
|
within,
|
|
15
|
-
} from "./numeric
|
|
16
|
-
import { integerRange, type PlcType } from "./types
|
|
10
|
+
} from "./numeric";
|
|
11
|
+
import { integerRange, type PlcType } from "./types";
|
|
17
12
|
|
|
18
13
|
export const interval = (
|
|
19
14
|
expression: Expression,
|
package/src/ir/routine.ts
CHANGED
|
@@ -1,20 +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
|
-
import {
|
|
3
|
-
aggregate,
|
|
4
|
-
expressionIssue,
|
|
5
|
-
placeType,
|
|
6
|
-
valueFits,
|
|
7
|
-
} from "./aggregates.ts";
|
|
2
|
+
import { aggregate, expressionIssue, placeType, valueFits } from "./aggregates";
|
|
8
3
|
import type {
|
|
9
4
|
CoreExpression,
|
|
10
5
|
CoreFunction,
|
|
11
6
|
CoreFunctionBlock,
|
|
12
7
|
CorePath,
|
|
13
8
|
CoreStatement,
|
|
14
|
-
} from "./core-model
|
|
15
|
-
import type { ModuleDeclarations } from "./declarations
|
|
16
|
-
import type { SourceSpan } from "./diagnostics
|
|
17
|
-
import { fold } from "./fold
|
|
9
|
+
} from "./core-model";
|
|
10
|
+
import type { ModuleDeclarations } from "./declarations";
|
|
11
|
+
import type { SourceSpan } from "./diagnostics";
|
|
12
|
+
import { fold } from "./fold";
|
|
18
13
|
import type {
|
|
19
14
|
Expression,
|
|
20
15
|
FunctionBlock,
|
|
@@ -22,17 +17,17 @@ import type {
|
|
|
22
17
|
PlcFunction,
|
|
23
18
|
Statement,
|
|
24
19
|
Variable,
|
|
25
|
-
} from "./model
|
|
26
|
-
import { reject } from "./normalization-error
|
|
27
|
-
import { admits, canonicalInteger, type IntegerInterval } from "./numeric
|
|
20
|
+
} from "./model";
|
|
21
|
+
import { reject } from "./normalization-error";
|
|
22
|
+
import { admits, canonicalInteger, type IntegerInterval } from "./numeric";
|
|
28
23
|
import {
|
|
29
24
|
interval,
|
|
30
25
|
loopBounds,
|
|
31
26
|
maxLoopIterations,
|
|
32
27
|
narrowRanges,
|
|
33
28
|
valueRange,
|
|
34
|
-
} from "./ranges
|
|
35
|
-
import { instancedBlock, integerRange } from "./types
|
|
29
|
+
} from "./ranges";
|
|
30
|
+
import { instancedBlock, integerRange } from "./types";
|
|
36
31
|
|
|
37
32
|
type Flow = "fallthrough" | "return" | "loop" | "mixed";
|
|
38
33
|
interface FlowState {
|
package/src/ir/scalars.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { fold } from "./fold
|
|
1
|
+
import { fold } from "./fold";
|
|
2
2
|
import {
|
|
3
3
|
type Constant,
|
|
4
4
|
comparisonOperators,
|
|
5
5
|
type Expression,
|
|
6
6
|
type Variable,
|
|
7
|
-
} from "./model
|
|
7
|
+
} from "./model";
|
|
8
8
|
import {
|
|
9
9
|
admits,
|
|
10
10
|
canAssign,
|
|
@@ -16,9 +16,9 @@ import {
|
|
|
16
16
|
roundFloat,
|
|
17
17
|
within,
|
|
18
18
|
wrapsNatively,
|
|
19
|
-
} from "./numeric
|
|
20
|
-
import { interval } from "./ranges
|
|
21
|
-
import { integerRange, type PlcType } from "./types
|
|
19
|
+
} from "./numeric";
|
|
20
|
+
import { interval } from "./ranges";
|
|
21
|
+
import { integerRange, type PlcType } from "./types";
|
|
22
22
|
|
|
23
23
|
/** An operand's constant value and proved integer range, over the storage in scope. */
|
|
24
24
|
interface Proof {
|