@abaplint/transpiler 1.7.2 → 1.7.6
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/compare_operator.js +2 -0
- package/build/src/statements/end_method.d.ts +1 -0
- package/build/src/statements/end_method.js +29 -16
- package/build/src/statements/raise.js +2 -1
- package/build/src/statements/read_table.js +5 -0
- package/build/src/structures/interface.js +4 -2
- package/build/src/traversal.d.ts +2 -0
- package/build/src/traversal.js +14 -2
- package/package.json +2 -2
|
@@ -36,6 +36,8 @@ class CompareOperatorTranspiler {
|
|
|
36
36
|
return new chunk_1.Chunk().append("ns", node, traversal);
|
|
37
37
|
case "CN":
|
|
38
38
|
return new chunk_1.Chunk().append("cn", node, traversal);
|
|
39
|
+
case "NA":
|
|
40
|
+
return new chunk_1.Chunk().append("na", node, traversal);
|
|
39
41
|
default:
|
|
40
42
|
return new chunk_1.Chunk().append("compareoperatortodo" + op, node, traversal);
|
|
41
43
|
}
|
|
@@ -5,28 +5,13 @@ const abaplint = require("@abaplint/core");
|
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
6
|
class EndMethodTranspiler {
|
|
7
7
|
transpile(node, traversal) {
|
|
8
|
-
var _a, _b;
|
|
9
8
|
const token = node.getFirstToken();
|
|
10
9
|
const scope = traversal.findCurrentScopeByToken(token);
|
|
11
10
|
if (scope === undefined) {
|
|
12
11
|
throw new Error("EndMethodTranspiler, scope not found");
|
|
13
12
|
}
|
|
14
13
|
let returning = "";
|
|
15
|
-
|
|
16
|
-
if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Method) {
|
|
17
|
-
methodName = scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname;
|
|
18
|
-
}
|
|
19
|
-
let className = undefined;
|
|
20
|
-
if (((_a = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _a === void 0 ? void 0 : _a.getIdentifier().stype) === abaplint.ScopeType.ClassImplementation) {
|
|
21
|
-
className = (_b = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _b === void 0 ? void 0 : _b.getIdentifier().sname;
|
|
22
|
-
}
|
|
23
|
-
if (methodName && className) {
|
|
24
|
-
const classDef = scope.findClassDefinition(className);
|
|
25
|
-
const methodDef = classDef === null || classDef === void 0 ? void 0 : classDef.getMethodDefinitions().getByName(methodName);
|
|
26
|
-
if (methodDef && methodDef.getExceptions().length > 0) {
|
|
27
|
-
returning += "abap.builtin.sy.get().subrc.set(0);\n";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
14
|
+
returning += this.setSubrc(scope, traversal);
|
|
30
15
|
const vars = scope.getData().vars;
|
|
31
16
|
for (const n in vars) {
|
|
32
17
|
const identifier = vars[n];
|
|
@@ -40,6 +25,34 @@ class EndMethodTranspiler {
|
|
|
40
25
|
}
|
|
41
26
|
return new chunk_1.Chunk().append(returning + "}", node, traversal);
|
|
42
27
|
}
|
|
28
|
+
setSubrc(scope, traversal) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
let methodName = undefined;
|
|
31
|
+
if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Method) {
|
|
32
|
+
methodName = scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname;
|
|
33
|
+
}
|
|
34
|
+
let className = undefined;
|
|
35
|
+
if (((_a = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _a === void 0 ? void 0 : _a.getIdentifier().stype) === abaplint.ScopeType.ClassImplementation) {
|
|
36
|
+
className = (_b = scope === null || scope === void 0 ? void 0 : scope.getParent()) === null || _b === void 0 ? void 0 : _b.getIdentifier().sname;
|
|
37
|
+
}
|
|
38
|
+
if (methodName === undefined || className === undefined) {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
let methodDef = undefined;
|
|
42
|
+
if (methodName.includes("~")) {
|
|
43
|
+
const split = methodName.split("~");
|
|
44
|
+
const classDef = traversal.findInterfaceDefinition(split[0], scope);
|
|
45
|
+
methodDef = classDef === null || classDef === void 0 ? void 0 : classDef.getMethodDefinitions().getByName(split[1]);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const classDef = traversal.findClassDefinition(className, scope);
|
|
49
|
+
methodDef = classDef === null || classDef === void 0 ? void 0 : classDef.getMethodDefinitions().getByName(methodName);
|
|
50
|
+
}
|
|
51
|
+
if (methodDef && methodDef.getExceptions().length > 0) {
|
|
52
|
+
return "abap.builtin.sy.get().subrc.set(0);\n";
|
|
53
|
+
}
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
43
56
|
}
|
|
44
57
|
exports.EndMethodTranspiler = EndMethodTranspiler;
|
|
45
58
|
//# sourceMappingURL=end_method.js.map
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RaiseTranspiler = void 0;
|
|
4
4
|
const abaplint = require("@abaplint/core");
|
|
5
5
|
const chunk_1 = require("../chunk");
|
|
6
|
+
const expressions_1 = require("../expressions");
|
|
6
7
|
class RaiseTranspiler {
|
|
7
8
|
transpile(node, traversal) {
|
|
8
9
|
var _a;
|
|
@@ -13,7 +14,7 @@ class RaiseTranspiler {
|
|
|
13
14
|
if (s === undefined) {
|
|
14
15
|
throw "Raise: Non-class based exceptions not supported";
|
|
15
16
|
}
|
|
16
|
-
const sCode =
|
|
17
|
+
const sCode = new expressions_1.SourceTranspiler(true).transpile(s, traversal).getCode();
|
|
17
18
|
return new chunk_1.Chunk().append(`throw ${sCode};`, node, traversal);
|
|
18
19
|
}
|
|
19
20
|
let p = "";
|
|
@@ -16,6 +16,11 @@ class ReadTableTranspiler {
|
|
|
16
16
|
const s = new expressions_1.SourceTranspiler().transpile(index, traversal).getCode();
|
|
17
17
|
extra.push("index: " + s);
|
|
18
18
|
}
|
|
19
|
+
const from = node.findExpressionAfterToken("FROM");
|
|
20
|
+
if (from) {
|
|
21
|
+
const s = new expressions_1.SourceTranspiler().transpile(from, traversal).getCode();
|
|
22
|
+
extra.push("from: " + s);
|
|
23
|
+
}
|
|
19
24
|
const rt = node.findDirectExpression(abaplint.Expressions.ReadTableTarget);
|
|
20
25
|
const target = rt === null || rt === void 0 ? void 0 : rt.findDirectExpression(abaplint.Expressions.Target);
|
|
21
26
|
const fs = rt === null || rt === void 0 ? void 0 : rt.findDirectExpression(abaplint.Expressions.FSTarget);
|
|
@@ -47,12 +47,14 @@ class InterfaceTranspiler {
|
|
|
47
47
|
const valExpression = constantStatement === null || constantStatement === void 0 ? void 0 : constantStatement.findFirstExpression(abaplint.Expressions.Value);
|
|
48
48
|
if ((valExpression === null || valExpression === void 0 ? void 0 : valExpression.getChildren()[1].get()) instanceof abaplint.Expressions.SimpleFieldChain) {
|
|
49
49
|
const s = new expressions_1.FieldChainTranspiler().transpile(valExpression.getChildren()[1], traversal, false).getCode();
|
|
50
|
-
|
|
50
|
+
const e = new expressions_1.ConstantTranspiler().escape(s);
|
|
51
|
+
ret += name + ".set(" + e + ");\n";
|
|
51
52
|
continue;
|
|
52
53
|
}
|
|
53
54
|
const val = identifier.getValue();
|
|
54
55
|
if (typeof val === "string") {
|
|
55
|
-
|
|
56
|
+
const e = new expressions_1.ConstantTranspiler().escape(val);
|
|
57
|
+
ret += name + ".set(" + e + ");\n";
|
|
56
58
|
}
|
|
57
59
|
else if (typeof val === "object") {
|
|
58
60
|
const a = val;
|
package/build/src/traversal.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare class Traversal {
|
|
|
31
31
|
isInterfaceAttribute(token: abaplint.Token): string | undefined;
|
|
32
32
|
private findReadOrWriteReference;
|
|
33
33
|
buildConstructorContents(scope: abaplint.ISpaghettiScopeNode | undefined, def: abaplint.IClassDefinition, inputName: string): string;
|
|
34
|
+
findInterfaceDefinition(name: string, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.IInterfaceDefinition | undefined;
|
|
35
|
+
findClassDefinition(name: string, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.IClassDefinition | undefined;
|
|
34
36
|
private dataFromInterfaces;
|
|
35
37
|
determineType(node: abaplint.Nodes.ExpressionNode | abaplint.Nodes.StatementNode, scope: abaplint.ISpaghettiScopeNode | undefined): abaplint.AbstractType | undefined;
|
|
36
38
|
registerClassOrInterface(def: abaplint.IClassDefinition | abaplint.IInterfaceDefinition | undefined): string;
|
package/build/src/traversal.js
CHANGED
|
@@ -281,13 +281,25 @@ class Traversal {
|
|
|
281
281
|
}
|
|
282
282
|
return ret;
|
|
283
283
|
}
|
|
284
|
-
|
|
285
|
-
let ret = "";
|
|
284
|
+
findInterfaceDefinition(name, scope) {
|
|
286
285
|
let intf = scope === null || scope === void 0 ? void 0 : scope.findInterfaceDefinition(name);
|
|
287
286
|
if (intf === undefined) {
|
|
288
287
|
const iglobal = this.reg.getObject("INTF", name);
|
|
289
288
|
intf = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
|
|
290
289
|
}
|
|
290
|
+
return intf;
|
|
291
|
+
}
|
|
292
|
+
findClassDefinition(name, scope) {
|
|
293
|
+
let clas = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(name);
|
|
294
|
+
if (clas === undefined) {
|
|
295
|
+
const iglobal = this.reg.getObject("CLAS", name);
|
|
296
|
+
clas = iglobal === null || iglobal === void 0 ? void 0 : iglobal.getDefinition();
|
|
297
|
+
}
|
|
298
|
+
return clas;
|
|
299
|
+
}
|
|
300
|
+
dataFromInterfaces(name, scope) {
|
|
301
|
+
let ret = "";
|
|
302
|
+
const intf = this.findInterfaceDefinition(name, scope);
|
|
291
303
|
for (const a of (intf === null || intf === void 0 ? void 0 : intf.getAttributes().getAll()) || []) {
|
|
292
304
|
if (a.getMeta().includes("static" /* Static */) === true) {
|
|
293
305
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.6",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"author": "abaplint",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abaplint/core": "^2.83.
|
|
30
|
+
"@abaplint/core": "^2.83.21",
|
|
31
31
|
"source-map": "^0.7.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|