@abaplint/transpiler 2.2.12 → 2.2.14
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/expressions/component_compare.js +7 -7
- package/build/src/expressions/component_cond.js +2 -2
- package/build/src/expressions/component_cond_sub.js +2 -2
- package/build/src/expressions/method_call_body.d.ts +3 -0
- package/build/src/expressions/method_call_body.js +8 -0
- package/build/src/keywords.js +6 -2
- package/build/src/statements/call.js +5 -3
- package/build/src/statements/class_definition_load.d.ts +7 -0
- package/build/src/statements/class_definition_load.js +12 -0
- package/build/src/statements/index.d.ts +1 -0
- package/build/src/statements/index.js +1 -0
- package/build/src/statements/method_implementation.js +3 -0
- package/package.json +2 -2
|
@@ -11,28 +11,28 @@ class ComponentCompareTranspiler {
|
|
|
11
11
|
if (node.findDirectExpression(core_1.Expressions.CompareOperator)) {
|
|
12
12
|
const compare = traversal.traverse(node.findDirectExpression(core_1.Expressions.CompareOperator)).getCode();
|
|
13
13
|
const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source)).getCode();
|
|
14
|
-
return new chunk_1.Chunk(`(
|
|
14
|
+
return new chunk_1.Chunk(`(I) => {return ${pre}abap.compare.${compare}(I.${component}, ${source});}`);
|
|
15
15
|
}
|
|
16
16
|
if ((concat.startsWith("NOT") && concat.endsWith("IS INITIAL"))
|
|
17
17
|
|| concat.endsWith("IS NOT INITIAL")) {
|
|
18
|
-
return new chunk_1.Chunk(`(
|
|
18
|
+
return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component}) === false;}`);
|
|
19
19
|
}
|
|
20
20
|
else if (concat.endsWith("IS INITIAL")) {
|
|
21
|
-
return new chunk_1.Chunk(`(
|
|
21
|
+
return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component});}`);
|
|
22
22
|
}
|
|
23
23
|
if ((concat.startsWith("NOT") && concat.endsWith("IS BOUND"))
|
|
24
24
|
|| concat.endsWith("IS NOT BOUND")) {
|
|
25
|
-
return new chunk_1.Chunk(`(
|
|
25
|
+
return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component});}`);
|
|
26
26
|
}
|
|
27
27
|
else if (concat.endsWith("IS BOUND")) {
|
|
28
|
-
return new chunk_1.Chunk(`(
|
|
28
|
+
return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component}) === false;}`);
|
|
29
29
|
}
|
|
30
30
|
if ((concat.startsWith("NOT") && concat.endsWith("IS ASSIGNED"))
|
|
31
31
|
|| concat.endsWith("IS NOT ASSIGNED")) {
|
|
32
|
-
return new chunk_1.Chunk(`(
|
|
32
|
+
return new chunk_1.Chunk(`(I) => {return abap.compare.assigned(I.${component}) === false;}`);
|
|
33
33
|
}
|
|
34
34
|
else if (concat.endsWith("IS ASSIGNED")) {
|
|
35
|
-
return new chunk_1.Chunk(`(
|
|
35
|
+
return new chunk_1.Chunk(`(I) => {return abap.compare.assigned(I.${component});}`);
|
|
36
36
|
}
|
|
37
37
|
return new chunk_1.Chunk("ComponentCompareTodo");
|
|
38
38
|
}
|
|
@@ -9,7 +9,7 @@ class ComponentCondTranspiler {
|
|
|
9
9
|
for (const c of node.getChildren()) {
|
|
10
10
|
if (c instanceof abaplint.Nodes.ExpressionNode) {
|
|
11
11
|
let cond = traversal.traverse(c).getCode();
|
|
12
|
-
cond = cond.replace(/^\(
|
|
12
|
+
cond = cond.replace(/^\(I\) => \{return /, "");
|
|
13
13
|
cond = cond.replace(/;\}$/, "");
|
|
14
14
|
ret += cond;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ class ComponentCondTranspiler {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
ret = `(
|
|
29
|
+
ret = `(I) => {return ${ret};}`;
|
|
30
30
|
return new chunk_1.Chunk(ret);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -9,7 +9,7 @@ class ComponentCondSubTranspiler {
|
|
|
9
9
|
for (const c of node.getChildren()) {
|
|
10
10
|
if (c instanceof abaplint.Nodes.ExpressionNode) {
|
|
11
11
|
let cond = traversal.traverse(c).getCode();
|
|
12
|
-
cond = cond.replace(/^\(
|
|
12
|
+
cond = cond.replace(/^\(I\) => \{return /, "");
|
|
13
13
|
cond = cond.replace(/;\}$/, "");
|
|
14
14
|
ret += cond;
|
|
15
15
|
}
|
|
@@ -29,7 +29,7 @@ class ComponentCondSubTranspiler {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
ret = `(
|
|
32
|
+
ret = `(I) => {return ${ret};}`;
|
|
33
33
|
return new chunk_1.Chunk(ret);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
1
2
|
import { Nodes } from "@abaplint/core";
|
|
2
3
|
import { IExpressionTranspiler } from "./_expression_transpiler";
|
|
3
4
|
import { Traversal } from "../traversal";
|
|
4
5
|
import { Chunk } from "../chunk";
|
|
5
6
|
export declare class MethodCallBodyTranspiler implements IExpressionTranspiler {
|
|
7
|
+
private readonly m;
|
|
8
|
+
constructor(m?: abaplint.Types.MethodDefinition);
|
|
6
9
|
transpile(node: Nodes.ExpressionNode, traversal: Traversal): Chunk;
|
|
7
10
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MethodCallBodyTranspiler = void 0;
|
|
4
|
+
const abaplint = require("@abaplint/core");
|
|
4
5
|
const core_1 = require("@abaplint/core");
|
|
5
6
|
const chunk_1 = require("../chunk");
|
|
7
|
+
const method_call_param_1 = require("./method_call_param");
|
|
6
8
|
class MethodCallBodyTranspiler {
|
|
9
|
+
constructor(m) {
|
|
10
|
+
this.m = m;
|
|
11
|
+
}
|
|
7
12
|
transpile(node, traversal) {
|
|
8
13
|
const ret = new chunk_1.Chunk();
|
|
9
14
|
for (const c of node.getChildren()) {
|
|
@@ -11,6 +16,9 @@ class MethodCallBodyTranspiler {
|
|
|
11
16
|
// PARAMETER-TABLE
|
|
12
17
|
continue;
|
|
13
18
|
}
|
|
19
|
+
else if (c.get() instanceof abaplint.Expressions.MethodCallParam) {
|
|
20
|
+
ret.appendChunk(new method_call_param_1.MethodCallParamTranspiler(this.m).transpile(c, traversal));
|
|
21
|
+
}
|
|
14
22
|
else {
|
|
15
23
|
ret.appendChunk(traversal.traverse(c));
|
|
16
24
|
}
|
package/build/src/keywords.js
CHANGED
|
@@ -55,8 +55,12 @@ class Keywords {
|
|
|
55
55
|
let ret = [];
|
|
56
56
|
for (const c of node.getChildren()) {
|
|
57
57
|
if (c instanceof abaplint.Nodes.TokenNodeRegex) {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const token = c.getFirstToken();
|
|
59
|
+
if (keywords.some(k => k === token.getStr().toLowerCase())) {
|
|
60
|
+
const start = token.getStart();
|
|
61
|
+
if (!(start instanceof abaplint.VirtualPosition)) {
|
|
62
|
+
ret.push(token);
|
|
63
|
+
}
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
else if (c instanceof abaplint.Nodes.TokenNode) {
|
|
@@ -6,7 +6,7 @@ const chunk_1 = require("../chunk");
|
|
|
6
6
|
const expressions_1 = require("../expressions");
|
|
7
7
|
class CallTranspiler {
|
|
8
8
|
transpile(node, traversal) {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
10
|
const chain = node.findDirectExpression(abaplint.Expressions.MethodCallChain);
|
|
11
11
|
if (chain) {
|
|
12
12
|
let pre = "";
|
|
@@ -59,13 +59,15 @@ if (e.classic) {
|
|
|
59
59
|
const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);
|
|
60
60
|
if (methodSource) {
|
|
61
61
|
let body = "";
|
|
62
|
+
const nameToken = (_d = methodSource.getLastChild()) === null || _d === void 0 ? void 0 : _d.getFirstToken();
|
|
63
|
+
const m = nameToken ? traversal.findMethodReference(nameToken, traversal.findCurrentScopeByToken(nameToken)) : undefined;
|
|
62
64
|
const methodCallBody = node.findDirectExpression(abaplint.Expressions.MethodCallBody);
|
|
63
65
|
if (methodCallBody) {
|
|
64
|
-
body =
|
|
66
|
+
body = new expressions_1.MethodCallBodyTranspiler(m === null || m === void 0 ? void 0 : m.def).transpile(methodCallBody, traversal).getCode();
|
|
65
67
|
}
|
|
66
68
|
let pre = "";
|
|
67
69
|
let post = "";
|
|
68
|
-
const receiving = (
|
|
70
|
+
const receiving = (_e = node.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _e === void 0 ? void 0 : _e.findExpressionAfterToken("RECEIVING");
|
|
69
71
|
if (receiving) {
|
|
70
72
|
const target = traversal.traverse(receiving.findDirectExpression(abaplint.Expressions.Target));
|
|
71
73
|
pre = target.getCode() + ".set(";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStatementTranspiler } from "./_statement_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class ClassDefinitionLoadTranspiler implements IStatementTranspiler {
|
|
6
|
+
transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassDefinitionLoadTranspiler = void 0;
|
|
4
|
+
const chunk_1 = require("../chunk");
|
|
5
|
+
class ClassDefinitionLoadTranspiler {
|
|
6
|
+
transpile(_node, _traversal) {
|
|
7
|
+
// for now, do nothing
|
|
8
|
+
return new chunk_1.Chunk(``);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ClassDefinitionLoadTranspiler = ClassDefinitionLoadTranspiler;
|
|
12
|
+
//# sourceMappingURL=class_definition_load.js.map
|
|
@@ -12,6 +12,7 @@ export * from "./call";
|
|
|
12
12
|
export * from "./case";
|
|
13
13
|
export * from "./check";
|
|
14
14
|
export * from "./class_deferred";
|
|
15
|
+
export * from "./class_definition_load";
|
|
15
16
|
export * from "./class_implementation";
|
|
16
17
|
export * from "./class_local_friends";
|
|
17
18
|
export * from "./clear";
|
|
@@ -28,6 +28,7 @@ __exportStar(require("./call"), exports);
|
|
|
28
28
|
__exportStar(require("./case"), exports);
|
|
29
29
|
__exportStar(require("./check"), exports);
|
|
30
30
|
__exportStar(require("./class_deferred"), exports);
|
|
31
|
+
__exportStar(require("./class_definition_load"), exports);
|
|
31
32
|
__exportStar(require("./class_implementation"), exports);
|
|
32
33
|
__exportStar(require("./class_local_friends"), exports);
|
|
33
34
|
__exportStar(require("./clear"), exports);
|
|
@@ -62,6 +62,9 @@ class MethodImplementationTranspiler {
|
|
|
62
62
|
else if (parameterDefault.getFirstToken().getStr().toLowerCase() === "abap_false") {
|
|
63
63
|
val = "abap.builtin.abap_false";
|
|
64
64
|
}
|
|
65
|
+
else if (parameterDefault.getFirstToken().getStr().toLowerCase() === "space") {
|
|
66
|
+
val = "abap.builtin.space";
|
|
67
|
+
}
|
|
65
68
|
else {
|
|
66
69
|
// note: this can be difficult, the "def" might be from an interface, ie. a different scope than the method
|
|
67
70
|
val = new expressions_1.FieldChainTranspiler().transpile(parameterDefault, traversal, true, methodDef === null || methodDef === void 0 ? void 0 : methodDef.getFilename()).getCode();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.14",
|
|
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.38",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|