@tsplc/compiler 0.5.6 → 0.5.8
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 +139 -30
- package/dist/bun-runtime.js.map +8 -7
- package/dist/cli.js +24 -9
- package/dist/cli.js.map +6 -6
- package/dist/codesys.js +3237 -1957
- package/dist/codesys.js.map +19 -18
- package/dist/index.js +54 -6
- package/dist/index.js.map +8 -8
- package/dist/ir.js +1645 -1326
- package/dist/ir.js.map +13 -12
- package/dist/project.js +12 -6
- package/dist/project.js.map +4 -4
- package/package.json +9 -9
- package/src/codesys/debug.ts +17 -2
- package/src/codesys/emit.ts +40 -12
- package/src/codesys/explain.ts +1465 -0
- package/src/codesys/global-lists.ts +21 -9
- package/src/codesys/http.ts +125 -71
- package/src/codesys/instrumentation.ts +161 -9
- package/src/codesys/manifest.ts +29 -12
- package/src/codesys/numeric.ts +5 -3
- package/src/codesys/plan.ts +22 -6
- package/src/codesys/programs.ts +2 -0
- package/src/codesys/routines.ts +39 -9
- package/src/codesys/st-files.ts +73 -6
- package/src/codesys/telemetry.ts +70 -35
- package/src/frontend/elaborate/index.ts +16 -1
- package/src/frontend/elaborate/storage.ts +56 -1
- package/src/frontend/expressions.ts +2 -2
- package/src/frontend/intrinsics.ts +1 -2
- package/src/frontend/statements.ts +3 -2
- package/src/frontend/typescript.ts +3 -0
- package/src/ir/conditions.ts +895 -0
- package/src/ir/core-model.ts +2 -2
- package/src/ir/fold.ts +15 -107
- package/src/ir/index.ts +10 -11
- package/src/ir/link.ts +1 -0
- package/src/ir/model.ts +16 -79
- package/src/ir/numeric.ts +5 -41
- package/src/ir/ranges.ts +8 -14
- package/src/ir/scalars.ts +6 -4
- package/src/project/debugger.ts +9 -0
- package/src/project/project.ts +6 -0
- package/src/project/release.ts +7 -4
- package/src/runtime/async.ts +15 -12
- package/src/runtime/launch.ts +11 -4
- package/src/runtime/runtime.ts +26 -23
- package/src/runtime/telemetry.ts +14 -6
- package/src/runtime/transport.ts +172 -0
package/dist/index.js
CHANGED
|
@@ -902,9 +902,9 @@ import {
|
|
|
902
902
|
narrowRanges,
|
|
903
903
|
parseInteger as parseInteger3,
|
|
904
904
|
placeType,
|
|
905
|
-
roundFloat,
|
|
906
905
|
valueRange
|
|
907
906
|
} from "@tsplc/compiler/ir";
|
|
907
|
+
import { roundFloat } from "@tsplc/iec/arithmetic";
|
|
908
908
|
import ts5 from "typescript";
|
|
909
909
|
|
|
910
910
|
// packages/compiler/src/frontend/intrinsics.ts
|
|
@@ -912,9 +912,9 @@ import {
|
|
|
912
912
|
calendarLiteral,
|
|
913
913
|
defaultValue as defaultValue2,
|
|
914
914
|
durationLiteral,
|
|
915
|
-
elementaryFunctions,
|
|
916
915
|
parseInteger as parseInteger2
|
|
917
916
|
} from "@tsplc/compiler/ir";
|
|
917
|
+
import { elementaryFunctions } from "@tsplc/iec/arithmetic";
|
|
918
918
|
import ts4 from "typescript";
|
|
919
919
|
var durationScales = new Map([
|
|
920
920
|
["ms", 1000000n],
|
|
@@ -2145,9 +2145,9 @@ import {
|
|
|
2145
2145
|
aggregate as aggregate4,
|
|
2146
2146
|
integerRange as integerRange2,
|
|
2147
2147
|
loopBounds,
|
|
2148
|
-
loopIterations,
|
|
2149
2148
|
maxLoopIterations
|
|
2150
2149
|
} from "@tsplc/compiler/ir";
|
|
2150
|
+
import { loopIterations } from "@tsplc/iec/arithmetic";
|
|
2151
2151
|
import ts9 from "typescript";
|
|
2152
2152
|
|
|
2153
2153
|
// packages/compiler/src/frontend/telemetry.ts
|
|
@@ -2543,7 +2543,7 @@ class StatementLowering {
|
|
|
2543
2543
|
const direction = ascending ? 1n : -1n;
|
|
2544
2544
|
const finish = BigInt(bound.value) - (exclusive ? direction : 0n);
|
|
2545
2545
|
const first = BigInt(start.value);
|
|
2546
|
-
const count = loopIterations(first,
|
|
2546
|
+
const count = loopIterations(first, BigInt(bound.value), exclusive, step);
|
|
2547
2547
|
this.checkIterations(node, count);
|
|
2548
2548
|
if (existing) {
|
|
2549
2549
|
this.checkFinalIncrement(node, plcType, first + count * step);
|
|
@@ -11376,8 +11376,41 @@ class Storage {
|
|
|
11376
11376
|
const type = holder.captured.kind === "instance" ? this.model.capturedFieldType(holder, name) : undefined;
|
|
11377
11377
|
const found = type !== undefined && referenceType(type) && this.written(holder, name);
|
|
11378
11378
|
this.referenceFields.set(key, found);
|
|
11379
|
+
if (found) {
|
|
11380
|
+
this.references.push({ holder, name });
|
|
11381
|
+
}
|
|
11379
11382
|
return found;
|
|
11380
11383
|
}
|
|
11384
|
+
references = [];
|
|
11385
|
+
referenceTable() {
|
|
11386
|
+
if (!this.references.length) {
|
|
11387
|
+
return { references: [], referenceFields: [] };
|
|
11388
|
+
}
|
|
11389
|
+
return {
|
|
11390
|
+
references: this.model.nodes.flatMap((node) => {
|
|
11391
|
+
const path = referable(node) ? this.storagePlace(node) : undefined;
|
|
11392
|
+
return path === undefined ? [] : [{ id: node.id, path }];
|
|
11393
|
+
}),
|
|
11394
|
+
referenceFields: this.references.flatMap(({ holder, name }) => {
|
|
11395
|
+
const path = this.storagePlace(holder);
|
|
11396
|
+
return path === undefined ? [] : [`${path}.${name}`];
|
|
11397
|
+
})
|
|
11398
|
+
};
|
|
11399
|
+
}
|
|
11400
|
+
storagePlace(node) {
|
|
11401
|
+
const owner = node.owner;
|
|
11402
|
+
if (!owner) {
|
|
11403
|
+
return;
|
|
11404
|
+
}
|
|
11405
|
+
const root = this.flattened(owner.root) ? owner.root.name : `${owner.root.name}.${owner.root.name}`;
|
|
11406
|
+
return root + owner.steps.map((step, index) => {
|
|
11407
|
+
const holder = this.model.at(owner.root, owner.steps.slice(0, index));
|
|
11408
|
+
if (step.kind === "index") {
|
|
11409
|
+
return holder && this.mixedStates(holder) ? `.${mixedItem(step.index)}` : `[${step.index}]`;
|
|
11410
|
+
}
|
|
11411
|
+
return /^\d+$/.test(step.name) ? `[${step.name}]` : `.${step.name}`;
|
|
11412
|
+
}).join("");
|
|
11413
|
+
}
|
|
11381
11414
|
referenceFields = new Map;
|
|
11382
11415
|
storedArray(array) {
|
|
11383
11416
|
const owner = array.owner;
|
|
@@ -12238,7 +12271,16 @@ var lowerElaboration = (program, sdk, entries, root, positions, debug) => {
|
|
|
12238
12271
|
const origins = new Map;
|
|
12239
12272
|
const folded = [];
|
|
12240
12273
|
const literals = new Map;
|
|
12241
|
-
const
|
|
12274
|
+
const references = [];
|
|
12275
|
+
const referenceFields = [];
|
|
12276
|
+
const result = {
|
|
12277
|
+
sources,
|
|
12278
|
+
diagnostics,
|
|
12279
|
+
origins,
|
|
12280
|
+
folded,
|
|
12281
|
+
literals,
|
|
12282
|
+
references: { objects: references, fields: referenceFields }
|
|
12283
|
+
};
|
|
12242
12284
|
const runtime = runtimeSources(program).filter((source) => !source.isDeclarationFile && !inSdk(sdk, source.fileName));
|
|
12243
12285
|
const checker = program.getTypeChecker();
|
|
12244
12286
|
const kept = new Set(runtime.filter((source) => keptModule(source, checker, sdk)).map((source) => source.fileName));
|
|
@@ -12333,6 +12375,9 @@ var lowerElaboration = (program, sdk, entries, root, positions, debug) => {
|
|
|
12333
12375
|
for (const { name, members } of specializer.layouts.literalEnums) {
|
|
12334
12376
|
literals.set(`${typesFile}:${name}`, members);
|
|
12335
12377
|
}
|
|
12378
|
+
const table = specializer.storage.referenceTable();
|
|
12379
|
+
references.push(...table.references);
|
|
12380
|
+
referenceFields.push(...table.referenceFields);
|
|
12336
12381
|
for (const item of specializer.storage.folded()) {
|
|
12337
12382
|
const known = constant2(item.value, item.iec);
|
|
12338
12383
|
if (known) {
|
|
@@ -13824,6 +13869,9 @@ function attachLowerings(module, root, {
|
|
|
13824
13869
|
if (elaboration.folded.length) {
|
|
13825
13870
|
module.folded = elaboration.folded;
|
|
13826
13871
|
}
|
|
13872
|
+
if (elaboration.references?.fields.length) {
|
|
13873
|
+
module.references = elaboration.references;
|
|
13874
|
+
}
|
|
13827
13875
|
for (const entry of module.programs) {
|
|
13828
13876
|
const background = lowering.schedules.get(entry.name);
|
|
13829
13877
|
if (background) {
|
|
@@ -13855,5 +13903,5 @@ export {
|
|
|
13855
13903
|
typeCheckOnly
|
|
13856
13904
|
};
|
|
13857
13905
|
|
|
13858
|
-
//# debugId=
|
|
13906
|
+
//# debugId=3A082B094D1DC57864756E2164756E21
|
|
13859
13907
|
//# sourceMappingURL=index.js.map
|