@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
|
@@ -1,27 +1,27 @@
|
|
|
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 { DialectText } from "./dialect
|
|
3
|
+
import { from, joined, type Mapped, mapped } from "../positions";
|
|
4
|
+
import { DialectText } from "./dialect";
|
|
5
5
|
import {
|
|
6
6
|
ExpressionSpecializer,
|
|
7
7
|
type RoutineCall,
|
|
8
8
|
type RoutineTable,
|
|
9
9
|
type SpecializeContext,
|
|
10
|
-
} from "./expressions
|
|
11
|
-
import { Emitter, type Frame } from "./frame
|
|
12
|
-
import { EntryImports } from "./imports
|
|
13
|
-
import { Initializers } from "./initializers
|
|
14
|
-
import { Layouts, unusedName } from "./layouts
|
|
15
|
-
import { type Model, type ModelNode, type Root, tsPath } from "./model
|
|
16
|
-
import { StatementSpecializer } from "./statements
|
|
17
|
-
import { Storage } from "./storage
|
|
10
|
+
} from "./expressions";
|
|
11
|
+
import { Emitter, type Frame } from "./frame";
|
|
12
|
+
import { EntryImports } from "./imports";
|
|
13
|
+
import { Initializers } from "./initializers";
|
|
14
|
+
import { Layouts, unusedName } from "./layouts";
|
|
15
|
+
import { type Model, type ModelNode, type Root, tsPath } from "./model";
|
|
16
|
+
import { StatementSpecializer } from "./statements";
|
|
17
|
+
import { Storage } from "./storage";
|
|
18
18
|
import {
|
|
19
19
|
constant,
|
|
20
20
|
type Env,
|
|
21
21
|
type FunctionLike,
|
|
22
22
|
SpecializeError,
|
|
23
23
|
type Value,
|
|
24
|
-
} from "./values
|
|
24
|
+
} from "./values";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Evaluates the program's scan code against the setup graph. Everything setup decided (which
|
|
@@ -1,16 +1,13 @@
|
|
|
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 { copied, type Mapped, mapped, type Part } from "../positions
|
|
4
|
-
import type { DialectText } from "./dialect
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./
|
|
9
|
-
import type
|
|
10
|
-
import
|
|
11
|
-
import type { Layouts } from "./layouts.ts";
|
|
12
|
-
import { SpecializeError, type Value } from "./values.ts";
|
|
13
|
-
import { isAssignment, isUpdate } from "./writes.ts";
|
|
3
|
+
import { copied, type Mapped, mapped, type Part } from "../positions";
|
|
4
|
+
import type { DialectText } from "./dialect";
|
|
5
|
+
import type { ExpressionSpecializer, SpecializeContext } from "./expressions";
|
|
6
|
+
import type { Frame } from "./frame";
|
|
7
|
+
import type { Initializers } from "./initializers";
|
|
8
|
+
import type { Layouts } from "./layouts";
|
|
9
|
+
import { SpecializeError, type Value } from "./values";
|
|
10
|
+
import { isAssignment, isUpdate } from "./writes";
|
|
14
11
|
|
|
15
12
|
/** Specializes one routine's statements; expressions in them go through its ExpressionSpecializer. */
|
|
16
13
|
export class StatementSpecializer {
|
|
@@ -1,13 +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 ts from "typescript";
|
|
3
|
-
import type { CapturedPrimitive, CapturedValue } from "./capture-protocol
|
|
4
|
-
import type { EntryImports } from "./imports
|
|
5
|
-
import {
|
|
6
|
-
type Layouts,
|
|
7
|
-
pascalCase,
|
|
8
|
-
recordTypes,
|
|
9
|
-
unusedName,
|
|
10
|
-
} from "./layouts.ts";
|
|
3
|
+
import type { CapturedPrimitive, CapturedValue } from "./capture-protocol";
|
|
4
|
+
import type { EntryImports } from "./imports";
|
|
5
|
+
import { type Layouts, pascalCase, recordTypes, unusedName } from "./layouts";
|
|
11
6
|
import {
|
|
12
7
|
children,
|
|
13
8
|
type Model,
|
|
@@ -16,9 +11,9 @@ import {
|
|
|
16
11
|
type Root,
|
|
17
12
|
type Step,
|
|
18
13
|
tsPath,
|
|
19
|
-
} from "./model
|
|
20
|
-
import { constant, type Value } from "./values
|
|
21
|
-
import { ScanWrites } from "./writes
|
|
14
|
+
} from "./model";
|
|
15
|
+
import { constant, type Value } from "./values";
|
|
16
|
+
import { ScanWrites } from "./writes";
|
|
22
17
|
|
|
23
18
|
/** A primitive scan code read from setup and folded, at its TypeScript path. */
|
|
24
19
|
interface FoldedField {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ts from "typescript";
|
|
2
|
-
import type { Mapped } from "../positions
|
|
3
|
-
import type { ModelNode } from "./model
|
|
2
|
+
import type { Mapped } from "../positions";
|
|
3
|
+
import type { ModelNode } from "./model";
|
|
4
4
|
|
|
5
5
|
export type FunctionLike =
|
|
6
6
|
| ts.FunctionDeclaration
|
package/src/frontend/exposure.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { type Diagnostic, error } from "@tsplc/compiler/ir";
|
|
3
3
|
import { elementaryType, isIntegerValued } from "@tsplc/iec";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
-
import { runtimeSources } from "./module-graph
|
|
5
|
+
import { runtimeSources } from "./module-graph";
|
|
6
6
|
import {
|
|
7
7
|
copied,
|
|
8
8
|
type Edit,
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
type Mapped,
|
|
13
13
|
mapped,
|
|
14
14
|
type Positions,
|
|
15
|
-
} from "./positions
|
|
16
|
-
import { namesSdk, symbolAt } from "./sdk
|
|
15
|
+
} from "./positions";
|
|
16
|
+
import { namesSdk, symbolAt } from "./sdk";
|
|
17
17
|
|
|
18
18
|
/** Telemetry carries a BOOL, an integer or bit string of up to 32 bits, or a bounded STRING. */
|
|
19
19
|
const telemetryType = (annotation: string): boolean => {
|
|
@@ -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/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" }>;
|