@abaplint/transpiler 2.3.28 → 2.3.29
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/statements/end_do.js +1 -1
- package/build/src/statements/end_while.js +1 -1
- package/build/src/statements/form.js +2 -0
- package/build/src/statements/method_implementation.js +3 -0
- package/build/src/statements/return.js +6 -1
- package/build/src/structures/do.js +1 -1
- package/build/src/structures/function_module.js +2 -0
- package/build/src/structures/while.js +1 -1
- package/build/src/traversal.d.ts +1 -0
- package/build/src/traversal.js +18 -0
- package/build/src/unique_identifier.d.ts +5 -1
- package/build/src/unique_identifier.js +11 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ class EndDoTranspiler {
|
|
|
8
8
|
}
|
|
9
9
|
transpile(node, traversal) {
|
|
10
10
|
return new chunk_1.Chunk().append(`}
|
|
11
|
-
abap.builtin.sy.get().index.set(${this.syIndexBackup})
|
|
11
|
+
abap.builtin.sy.get().index.set(${this.syIndexBackup});\n`, node, traversal);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.EndDoTranspiler = EndDoTranspiler;
|
|
@@ -8,7 +8,7 @@ class EndWhileTranspiler {
|
|
|
8
8
|
}
|
|
9
9
|
transpile(node, traversal) {
|
|
10
10
|
return new chunk_1.Chunk().append(`}
|
|
11
|
-
abap.builtin.sy.get().index.set(${this.syIndexBackup})
|
|
11
|
+
abap.builtin.sy.get().index.set(${this.syIndexBackup});\n`, node, traversal);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.EndWhileTranspiler = EndWhileTranspiler;
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FormTranspiler = void 0;
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
6
7
|
class FormTranspiler {
|
|
7
8
|
transpile(node) {
|
|
9
|
+
unique_identifier_1.UniqueIdentifier.resetIndexBackup();
|
|
8
10
|
const name = node.findFirstExpression(abaplint.Expressions.FormName).getFirstToken().getStr();
|
|
9
11
|
return new chunk_1.Chunk("async function " + name + "() {");
|
|
10
12
|
}
|
|
@@ -6,6 +6,7 @@ const transpile_types_1 = require("../transpile_types");
|
|
|
6
6
|
const traversal_1 = require("../traversal");
|
|
7
7
|
const expressions_1 = require("../expressions");
|
|
8
8
|
const chunk_1 = require("../chunk");
|
|
9
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
9
10
|
class MethodImplementationTranspiler {
|
|
10
11
|
transpile(node, traversal) {
|
|
11
12
|
var _a, _b;
|
|
@@ -100,9 +101,11 @@ class MethodImplementationTranspiler {
|
|
|
100
101
|
"return " + traversal_1.Traversal.escapeClassName(className) + "." + traversal_1.Traversal.escapeClassName(methodName) + "(" + unique + ");\n" +
|
|
101
102
|
"}\n" + "static ";
|
|
102
103
|
}
|
|
104
|
+
unique_identifier_1.UniqueIdentifier.resetIndexBackup();
|
|
103
105
|
const str = staticMethod + "async " + traversal_1.Traversal.escapeClassName(methodName) + "(" + unique + ") {" + after;
|
|
104
106
|
return new chunk_1.Chunk().append(str, node, traversal);
|
|
105
107
|
}
|
|
108
|
+
/////////////////////////////
|
|
106
109
|
findMethod(name, cdef, traversal) {
|
|
107
110
|
var _a, _b;
|
|
108
111
|
if (cdef === undefined) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReturnTranspiler = void 0;
|
|
4
4
|
const chunk_1 = require("../chunk");
|
|
5
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
5
6
|
class ReturnTranspiler {
|
|
6
7
|
transpile(node, traversal) {
|
|
7
8
|
let extra = "";
|
|
@@ -13,7 +14,11 @@ class ReturnTranspiler {
|
|
|
13
14
|
extra = " " + n.toLowerCase();
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
let pre = "";
|
|
18
|
+
if (traversal.isInsideDoOrWhile(node)) {
|
|
19
|
+
pre = `abap.builtin.sy.get().index.set(${unique_identifier_1.UniqueIdentifier.getIndexBackup1()});\n`;
|
|
20
|
+
}
|
|
21
|
+
return new chunk_1.Chunk().append(pre + "return" + extra + ";", node, traversal);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
exports.ReturnTranspiler = ReturnTranspiler;
|
|
@@ -8,7 +8,7 @@ const unique_identifier_1 = require("../unique_identifier");
|
|
|
8
8
|
class DoTranspiler {
|
|
9
9
|
transpile(node, traversal) {
|
|
10
10
|
const ret = new chunk_1.Chunk();
|
|
11
|
-
const syIndexBackup = unique_identifier_1.UniqueIdentifier.
|
|
11
|
+
const syIndexBackup = unique_identifier_1.UniqueIdentifier.getIndexBackup();
|
|
12
12
|
for (const c of node.getChildren()) {
|
|
13
13
|
if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.Do) {
|
|
14
14
|
ret.appendChunk(new statements_1.DoTranspiler(syIndexBackup).transpile(c, traversal));
|
|
@@ -5,6 +5,7 @@ const abaplint = require("@abaplint/core");
|
|
|
5
5
|
const traversal_1 = require("../traversal");
|
|
6
6
|
const chunk_1 = require("../chunk");
|
|
7
7
|
const transpile_types_1 = require("../transpile_types");
|
|
8
|
+
const unique_identifier_1 = require("../unique_identifier");
|
|
8
9
|
class FunctionModuleTranspiler {
|
|
9
10
|
transpile(node, traversal) {
|
|
10
11
|
var _a;
|
|
@@ -27,6 +28,7 @@ class FunctionModuleTranspiler {
|
|
|
27
28
|
r += traversal.traverse(c).getCode();
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
unique_identifier_1.UniqueIdentifier.resetIndexBackup();
|
|
30
32
|
return new chunk_1.Chunk(r);
|
|
31
33
|
}
|
|
32
34
|
//////////////////////
|
|
@@ -8,7 +8,7 @@ const unique_identifier_1 = require("../unique_identifier");
|
|
|
8
8
|
class WhileTranspiler {
|
|
9
9
|
transpile(node, traversal) {
|
|
10
10
|
const ret = new chunk_1.Chunk();
|
|
11
|
-
const syIndexBackup = unique_identifier_1.UniqueIdentifier.
|
|
11
|
+
const syIndexBackup = unique_identifier_1.UniqueIdentifier.getIndexBackup();
|
|
12
12
|
for (const c of node.getChildren()) {
|
|
13
13
|
if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.While) {
|
|
14
14
|
ret.appendChunk(new statements_1.WhileTranspiler(syIndexBackup).transpile(c, traversal));
|
package/build/src/traversal.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare class Traversal {
|
|
|
38
38
|
private dataFromInterfaces;
|
|
39
39
|
determineType(node: abaplint.Nodes.ExpressionNode | abaplint.Nodes.StatementNode, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.AbstractType | undefined;
|
|
40
40
|
isInsideLoop(node: abaplint.Nodes.StatementNode): boolean;
|
|
41
|
+
isInsideDoOrWhile(node: abaplint.Nodes.StatementNode): boolean;
|
|
41
42
|
registerClassOrInterface(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
|
|
42
43
|
lookupClassOrInterface(name: string | undefined, token: abaplint.Token | undefined, directGlobal?: boolean): string;
|
|
43
44
|
private buildPrefix;
|
package/build/src/traversal.js
CHANGED
|
@@ -373,6 +373,24 @@ class Traversal {
|
|
|
373
373
|
}
|
|
374
374
|
return stack.length > 0;
|
|
375
375
|
}
|
|
376
|
+
isInsideDoOrWhile(node) {
|
|
377
|
+
const stack = [];
|
|
378
|
+
for (const statement of this.getFile().getStatements()) {
|
|
379
|
+
const get = statement.get();
|
|
380
|
+
if (get instanceof abaplint.Statements.While
|
|
381
|
+
|| get instanceof abaplint.Statements.Do) {
|
|
382
|
+
stack.push(statement);
|
|
383
|
+
}
|
|
384
|
+
else if (get instanceof abaplint.Statements.EndWhile
|
|
385
|
+
|| get instanceof abaplint.Statements.EndDo) {
|
|
386
|
+
stack.pop();
|
|
387
|
+
}
|
|
388
|
+
if (statement === node) {
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return stack.length > 0;
|
|
393
|
+
}
|
|
376
394
|
registerClassOrInterface(def) {
|
|
377
395
|
if (def === undefined) {
|
|
378
396
|
return "";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export declare class UniqueIdentifier {
|
|
2
|
-
static counter
|
|
2
|
+
private static counter;
|
|
3
|
+
private static indexBackup;
|
|
3
4
|
static reset(): void;
|
|
4
5
|
static get(): string;
|
|
6
|
+
static resetIndexBackup(): void;
|
|
7
|
+
static getIndexBackup(): string;
|
|
8
|
+
static getIndexBackup1(): string;
|
|
5
9
|
}
|
|
@@ -11,7 +11,18 @@ class UniqueIdentifier {
|
|
|
11
11
|
this.counter++;
|
|
12
12
|
return "unique" + this.counter;
|
|
13
13
|
}
|
|
14
|
+
static resetIndexBackup() {
|
|
15
|
+
this.indexBackup = 0;
|
|
16
|
+
}
|
|
17
|
+
static getIndexBackup() {
|
|
18
|
+
this.indexBackup++;
|
|
19
|
+
return "indexBackup" + this.indexBackup;
|
|
20
|
+
}
|
|
21
|
+
static getIndexBackup1() {
|
|
22
|
+
return "indexBackup1";
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
25
|
exports.UniqueIdentifier = UniqueIdentifier;
|
|
16
26
|
UniqueIdentifier.counter = 0;
|
|
27
|
+
UniqueIdentifier.indexBackup = 0;
|
|
17
28
|
//# sourceMappingURL=unique_identifier.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.29",
|
|
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.93.
|
|
31
|
+
"@abaplint/core": "^2.93.58",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|