@abaplint/transpiler 2.5.11 → 2.5.13
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/build/src/structures/at_first.d.ts +7 -0
- package/build/src/structures/at_first.js +17 -0
- package/build/src/structures/at_last.d.ts +7 -0
- package/build/src/structures/at_last.js +17 -0
- package/build/src/structures/index.d.ts +4 -1
- package/build/src/structures/index.js +4 -1
- package/build/src/structures/loop.d.ts +7 -0
- package/build/src/structures/loop.js +55 -0
- package/build/src/traversal.js +6 -6
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStructureTranspiler } from "./_structure_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class AtFirstTranspiler implements IStructureTranspiler {
|
|
6
|
+
transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AtFirstTranspiler = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
5
|
+
const chunk_1 = require("../chunk");
|
|
6
|
+
class AtFirstTranspiler {
|
|
7
|
+
transpile(node, traversal) {
|
|
8
|
+
const ret = new chunk_1.Chunk();
|
|
9
|
+
const body = node.findDirectStructure(abaplint.Structures.Body);
|
|
10
|
+
if (body) {
|
|
11
|
+
ret.appendChunk(traversal.traverse(body));
|
|
12
|
+
}
|
|
13
|
+
return ret;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.AtFirstTranspiler = AtFirstTranspiler;
|
|
17
|
+
//# sourceMappingURL=at_first.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStructureTranspiler } from "./_structure_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class AtLastTranspiler implements IStructureTranspiler {
|
|
6
|
+
transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AtLastTranspiler = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
5
|
+
const chunk_1 = require("../chunk");
|
|
6
|
+
class AtLastTranspiler {
|
|
7
|
+
transpile(node, traversal) {
|
|
8
|
+
const ret = new chunk_1.Chunk();
|
|
9
|
+
const body = node.findDirectStructure(abaplint.Structures.Body);
|
|
10
|
+
if (body) {
|
|
11
|
+
ret.appendChunk(traversal.traverse(body));
|
|
12
|
+
}
|
|
13
|
+
return ret;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.AtLastTranspiler = AtLastTranspiler;
|
|
17
|
+
//# sourceMappingURL=at_last.js.map
|
|
@@ -5,10 +5,13 @@ export * from "./constants";
|
|
|
5
5
|
export * from "./data";
|
|
6
6
|
export * from "./define";
|
|
7
7
|
export * from "./do";
|
|
8
|
+
export * from "./at_first";
|
|
9
|
+
export * from "./at_last";
|
|
8
10
|
export * from "./function_module";
|
|
9
11
|
export * from "./interface";
|
|
10
|
-
export * from "./
|
|
12
|
+
export * from "./loop";
|
|
11
13
|
export * from "./select";
|
|
12
14
|
export * from "./try";
|
|
13
15
|
export * from "./types";
|
|
14
16
|
export * from "./when";
|
|
17
|
+
export * from "./while";
|
|
@@ -21,11 +21,14 @@ __exportStar(require("./constants"), exports);
|
|
|
21
21
|
__exportStar(require("./data"), exports);
|
|
22
22
|
__exportStar(require("./define"), exports);
|
|
23
23
|
__exportStar(require("./do"), exports);
|
|
24
|
+
__exportStar(require("./at_first"), exports);
|
|
25
|
+
__exportStar(require("./at_last"), exports);
|
|
24
26
|
__exportStar(require("./function_module"), exports);
|
|
25
27
|
__exportStar(require("./interface"), exports);
|
|
26
|
-
__exportStar(require("./
|
|
28
|
+
__exportStar(require("./loop"), exports);
|
|
27
29
|
__exportStar(require("./select"), exports);
|
|
28
30
|
__exportStar(require("./try"), exports);
|
|
29
31
|
__exportStar(require("./types"), exports);
|
|
30
32
|
__exportStar(require("./when"), exports);
|
|
33
|
+
__exportStar(require("./while"), exports);
|
|
31
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStructureTranspiler } from "./_structure_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class LoopTranspiler implements IStructureTranspiler {
|
|
6
|
+
transpile(node: abaplint.Nodes.StructureNode, traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoopTranspiler = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
5
|
+
const chunk_1 = require("../chunk");
|
|
6
|
+
const at_first_1 = require("./at_first");
|
|
7
|
+
const at_last_1 = require("./at_last");
|
|
8
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
9
|
+
class LoopTranspiler {
|
|
10
|
+
transpile(node, traversal) {
|
|
11
|
+
const ret = new chunk_1.Chunk();
|
|
12
|
+
let pre = "";
|
|
13
|
+
let atFirst = undefined;
|
|
14
|
+
let atLast = undefined;
|
|
15
|
+
for (const c of node.getChildren()) {
|
|
16
|
+
if (c instanceof abaplint.Nodes.StructureNode && c.get() instanceof abaplint.Structures.Body) {
|
|
17
|
+
for (const b of c.getChildren()) {
|
|
18
|
+
for (const n of b.getChildren()) {
|
|
19
|
+
if (n instanceof abaplint.Nodes.StructureNode && n.get() instanceof abaplint.Structures.AtFirst) {
|
|
20
|
+
atFirst = new at_first_1.AtFirstTranspiler().transpile(n, traversal);
|
|
21
|
+
const u = unique_identifier_1.UniqueIdentifier.get();
|
|
22
|
+
pre = "let " + u + " = false;\n";
|
|
23
|
+
ret.appendString("if (" + u + " === false) {\n");
|
|
24
|
+
ret.appendChunk(atFirst);
|
|
25
|
+
ret.appendString(u + " = true;\n");
|
|
26
|
+
ret.appendString("}\n");
|
|
27
|
+
}
|
|
28
|
+
else if (n instanceof abaplint.Nodes.StructureNode && n.get() instanceof abaplint.Structures.AtLast) {
|
|
29
|
+
atLast = new at_last_1.AtLastTranspiler().transpile(n, traversal);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
ret.appendChunk(traversal.traverse(n));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
ret.appendChunk(traversal.traverse(c));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const atted = new chunk_1.Chunk();
|
|
42
|
+
if (pre) {
|
|
43
|
+
atted.appendString(pre);
|
|
44
|
+
}
|
|
45
|
+
atted.appendChunk(ret);
|
|
46
|
+
if (atLast) {
|
|
47
|
+
atted.appendString("if (abap.builtin.sy.get().subrc.get() === 0) {\n");
|
|
48
|
+
atted.appendChunk(atLast);
|
|
49
|
+
atted.appendString("}\n");
|
|
50
|
+
}
|
|
51
|
+
return atted;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.LoopTranspiler = LoopTranspiler;
|
|
55
|
+
//# sourceMappingURL=loop.js.map
|
package/build/src/traversal.js
CHANGED
|
@@ -506,14 +506,14 @@ class Traversal {
|
|
|
506
506
|
traverseStructure(node) {
|
|
507
507
|
const list = StructureTranspilers;
|
|
508
508
|
const ret = new chunk_1.Chunk();
|
|
509
|
+
const search = node.get().constructor.name + "Transpiler";
|
|
510
|
+
if (list[search]) {
|
|
511
|
+
const transpiler = new list[search]();
|
|
512
|
+
ret.appendChunk(transpiler.transpile(node, this));
|
|
513
|
+
return ret;
|
|
514
|
+
}
|
|
509
515
|
for (const c of node.getChildren()) {
|
|
510
516
|
if (c instanceof abaplint.Nodes.StructureNode) {
|
|
511
|
-
const search = c.get().constructor.name + "Transpiler";
|
|
512
|
-
if (list[search]) {
|
|
513
|
-
const transpiler = new list[search]();
|
|
514
|
-
ret.appendChunk(transpiler.transpile(c, this));
|
|
515
|
-
continue;
|
|
516
|
-
}
|
|
517
517
|
ret.appendChunk(this.traverseStructure(c));
|
|
518
518
|
}
|
|
519
519
|
else if (c instanceof abaplint.Nodes.StatementNode) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.13",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"author": "abaplint",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@abaplint/core": "^2.95.
|
|
31
|
+
"@abaplint/core": "^2.95.28",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|