@tsplc/compiler 0.4.3 → 0.5.0
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/codesys.js +24 -8
- package/dist/codesys.js.map +4 -4
- package/dist/index.js +13 -7
- package/dist/index.js.map +3 -3
- package/package.json +9 -9
- package/src/codesys/http.ts +27 -7
- package/src/codesys/telemetry.ts +2 -1
- package/src/frontend/statements.ts +23 -6
package/dist/index.js
CHANGED
|
@@ -2219,6 +2219,11 @@ function textProperty(lowering, node) {
|
|
|
2219
2219
|
}
|
|
2220
2220
|
|
|
2221
2221
|
// packages/compiler/src/frontend/statements.ts
|
|
2222
|
+
var unbraced = (statements) => {
|
|
2223
|
+
const [only] = statements;
|
|
2224
|
+
return statements.length === 1 && only && ts9.isBlock(only) ? unbraced(only.statements) : statements;
|
|
2225
|
+
};
|
|
2226
|
+
|
|
2222
2227
|
class StatementLowering {
|
|
2223
2228
|
expressions;
|
|
2224
2229
|
routine;
|
|
@@ -2368,10 +2373,11 @@ class StatementLowering {
|
|
|
2368
2373
|
} else {
|
|
2369
2374
|
labels.push(this.caseValue(clause, value.type));
|
|
2370
2375
|
}
|
|
2371
|
-
|
|
2376
|
+
const statements = unbraced(clause.statements);
|
|
2377
|
+
if (!statements.length) {
|
|
2372
2378
|
continue;
|
|
2373
2379
|
}
|
|
2374
|
-
const body = this.caseBody(clause);
|
|
2380
|
+
const body = this.caseBody(clause, statements);
|
|
2375
2381
|
if (labels.length) {
|
|
2376
2382
|
cases.push({ values: labels.splice(0), body });
|
|
2377
2383
|
}
|
|
@@ -2395,15 +2401,15 @@ class StatementLowering {
|
|
|
2395
2401
|
}
|
|
2396
2402
|
return constant;
|
|
2397
2403
|
}
|
|
2398
|
-
caseBody(clause) {
|
|
2399
|
-
const last =
|
|
2404
|
+
caseBody(clause, statements) {
|
|
2405
|
+
const last = statements.at(-1);
|
|
2400
2406
|
if (last && ts9.isBreakStatement(last) && !last.label) {
|
|
2401
|
-
return this.statements(
|
|
2407
|
+
return this.statements(statements.slice(0, -1));
|
|
2402
2408
|
}
|
|
2403
2409
|
if (!(last && ts9.isReturnStatement(last))) {
|
|
2404
2410
|
this.fail(clause, "PLC1001", "Switch cases must end with break or return; fallthrough is prohibited.");
|
|
2405
2411
|
}
|
|
2406
|
-
return this.statements(
|
|
2412
|
+
return this.statements(statements);
|
|
2407
2413
|
}
|
|
2408
2414
|
localDeclarations(node) {
|
|
2409
2415
|
const origin = { span: this.positions.node(node) };
|
|
@@ -9578,5 +9584,5 @@ export {
|
|
|
9578
9584
|
typeCheckOnly
|
|
9579
9585
|
};
|
|
9580
9586
|
|
|
9581
|
-
//# debugId=
|
|
9587
|
+
//# debugId=16279797F1A1FD1264756E2164756E21
|
|
9582
9588
|
//# sourceMappingURL=index.js.map
|