@abaplint/transpiler 2.5.5 → 2.5.7
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/handlers/handle_abap.js +3 -3
- package/build/src/statements/create_object.js +2 -1
- package/build/src/statements/read_report.d.ts +1 -1
- package/build/src/statements/read_report.js +17 -2
- package/build/src/structures/function_module.js +6 -3
- package/build/src/traversal.d.ts +3 -2
- package/build/src/traversal.js +2 -2
- package/package.json +2 -2
|
@@ -11,7 +11,7 @@ class HandleABAP {
|
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
13
|
runObject(obj, reg) {
|
|
14
|
-
var _a, _b
|
|
14
|
+
var _a, _b;
|
|
15
15
|
let ret = [];
|
|
16
16
|
if (obj instanceof abaplint.Objects.Program && obj.isInclude() === true) {
|
|
17
17
|
// includes are only compiled along with the programs where its used?
|
|
@@ -24,7 +24,7 @@ class HandleABAP {
|
|
|
24
24
|
chunk.appendString("// " + file.getFilename() + "\n");
|
|
25
25
|
}
|
|
26
26
|
const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
|
|
27
|
-
const contents = new traversal_1.Traversal(spaghetti, file, obj, reg,
|
|
27
|
+
const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, this.options).traverse(rearranged);
|
|
28
28
|
chunk.appendChunk(contents);
|
|
29
29
|
chunk.stripLastNewline();
|
|
30
30
|
chunk.runIndentationLogic();
|
|
@@ -43,7 +43,7 @@ class HandleABAP {
|
|
|
43
43
|
ret.push(output);
|
|
44
44
|
}
|
|
45
45
|
ret = this.rearrangeClassLocals(obj, ret);
|
|
46
|
-
if (((
|
|
46
|
+
if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.addCommonJS) === true) {
|
|
47
47
|
ret.map(output => output.chunk = this.addImportsAndExports(output));
|
|
48
48
|
}
|
|
49
49
|
return ret;
|
|
@@ -40,6 +40,7 @@ class CreateObjectTranspiler {
|
|
|
40
40
|
return new chunk_1.Chunk(ret);
|
|
41
41
|
}
|
|
42
42
|
findClassName(node, traversal) {
|
|
43
|
+
var _a;
|
|
43
44
|
const c = node.findDirectExpression(abaplint.Expressions.ClassName);
|
|
44
45
|
if (c) {
|
|
45
46
|
return c.concatTokens();
|
|
@@ -60,7 +61,7 @@ class CreateObjectTranspiler {
|
|
|
60
61
|
return "object";
|
|
61
62
|
}
|
|
62
63
|
else if (!(type instanceof abaplint.BasicTypes.ObjectReferenceType)) {
|
|
63
|
-
if (traversal.
|
|
64
|
+
if (((_a = traversal.options) === null || _a === void 0 ? void 0 : _a.unknownTypes) !== "runtimeError") {
|
|
64
65
|
throw new Error(`CreateObjectTranspiler, target variable "${target === null || target === void 0 ? void 0 : target.concatTokens()}" not a object reference`);
|
|
65
66
|
}
|
|
66
67
|
else {
|
|
@@ -3,5 +3,5 @@ import { IStatementTranspiler } from "./_statement_transpiler";
|
|
|
3
3
|
import { Traversal } from "../traversal";
|
|
4
4
|
import { Chunk } from "../chunk";
|
|
5
5
|
export declare class ReadReportTranspiler implements IStatementTranspiler {
|
|
6
|
-
transpile(
|
|
6
|
+
transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
|
|
7
7
|
}
|
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReadReportTranspiler = void 0;
|
|
4
4
|
const chunk_1 = require("../chunk");
|
|
5
|
+
const expressions_1 = require("../expressions");
|
|
5
6
|
class ReadReportTranspiler {
|
|
6
|
-
transpile(
|
|
7
|
-
|
|
7
|
+
transpile(node, traversal) {
|
|
8
|
+
const reportNode = node.findExpressionAfterToken("REPORT");
|
|
9
|
+
const reportChunk = new expressions_1.SourceTranspiler().transpile(reportNode, traversal);
|
|
10
|
+
const options = [];
|
|
11
|
+
const intoNode = node.findExpressionAfterToken("INTO");
|
|
12
|
+
if (intoNode) {
|
|
13
|
+
options.push("into: " + new expressions_1.TargetTranspiler().transpile(intoNode, traversal).getCode());
|
|
14
|
+
}
|
|
15
|
+
const stateNode = node.findExpressionAfterToken("STATE");
|
|
16
|
+
if (stateNode) {
|
|
17
|
+
options.push("state: " + new expressions_1.SourceTranspiler().transpile(stateNode, traversal).getCode());
|
|
18
|
+
}
|
|
19
|
+
return new chunk_1.Chunk().appendString(`abap.statements.readReport(`)
|
|
20
|
+
.appendChunk(reportChunk)
|
|
21
|
+
.appendString(", {" + options.join(",") + "}")
|
|
22
|
+
.appendString(");");
|
|
8
23
|
}
|
|
9
24
|
}
|
|
10
25
|
exports.ReadReportTranspiler = ReadReportTranspiler;
|
|
@@ -33,7 +33,7 @@ class FunctionModuleTranspiler {
|
|
|
33
33
|
}
|
|
34
34
|
//////////////////////
|
|
35
35
|
findSignature(traversal, name, node) {
|
|
36
|
-
var _a;
|
|
36
|
+
var _a, _b, _c;
|
|
37
37
|
const group = traversal.getCurrentObject();
|
|
38
38
|
if (group === undefined) {
|
|
39
39
|
throw "FunctionModuleTranspilerGroupNotFound";
|
|
@@ -54,10 +54,13 @@ class FunctionModuleTranspiler {
|
|
|
54
54
|
direction = "importing";
|
|
55
55
|
}
|
|
56
56
|
// note: all directions are optional
|
|
57
|
-
|
|
57
|
+
let name = p.name.toLowerCase();
|
|
58
|
+
if ((_b = (_a = traversal.options) === null || _a === void 0 ? void 0 : _a.keywords) === null || _b === void 0 ? void 0 : _b.some(a => a === name)) {
|
|
59
|
+
name += "_";
|
|
60
|
+
}
|
|
58
61
|
ret += `let ${name} = INPUT.${direction}?.${name};\n`;
|
|
59
62
|
if (direction === "exporting" || direction === "importing" || direction === "changing") {
|
|
60
|
-
const type = (
|
|
63
|
+
const type = (_c = scope === null || scope === void 0 ? void 0 : scope.findVariable(name)) === null || _c === void 0 ? void 0 : _c.getType();
|
|
61
64
|
if (type !== undefined) {
|
|
62
65
|
// todo, set DEFAULT value
|
|
63
66
|
// todo, check for OPTIONALness and raise exceptions and stuff
|
package/build/src/traversal.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as abaplint from "@abaplint/core";
|
|
2
2
|
import { ISpaghettiScopeNode } from "@abaplint/core";
|
|
3
3
|
import { Chunk } from "./chunk";
|
|
4
|
+
import { ITranspilerOptions } from "./types";
|
|
4
5
|
export declare class Traversal {
|
|
5
6
|
private readonly spaghetti;
|
|
6
7
|
private readonly file;
|
|
7
8
|
private readonly obj;
|
|
8
9
|
readonly reg: abaplint.IRegistry;
|
|
9
|
-
readonly
|
|
10
|
-
constructor(spaghetti: abaplint.ISpaghettiScope, file: abaplint.ABAPFile, obj: abaplint.ABAPObject, reg: abaplint.IRegistry,
|
|
10
|
+
readonly options: ITranspilerOptions | undefined;
|
|
11
|
+
constructor(spaghetti: abaplint.ISpaghettiScope, file: abaplint.ABAPFile, obj: abaplint.ABAPObject, reg: abaplint.IRegistry, options?: ITranspilerOptions);
|
|
11
12
|
static escapeNamespace(name: string | undefined): string | undefined;
|
|
12
13
|
getCurrentObject(): abaplint.ABAPObject;
|
|
13
14
|
traverse(node: abaplint.INode | undefined): Chunk;
|
package/build/src/traversal.js
CHANGED
|
@@ -9,13 +9,13 @@ const transpile_types_1 = require("./transpile_types");
|
|
|
9
9
|
const chunk_1 = require("./chunk");
|
|
10
10
|
const expressions_1 = require("./expressions");
|
|
11
11
|
class Traversal {
|
|
12
|
-
constructor(spaghetti, file, obj, reg,
|
|
12
|
+
constructor(spaghetti, file, obj, reg, options) {
|
|
13
13
|
this.scopeCache = undefined;
|
|
14
14
|
this.spaghetti = spaghetti;
|
|
15
15
|
this.file = file;
|
|
16
16
|
this.obj = obj;
|
|
17
17
|
this.reg = reg;
|
|
18
|
-
this.
|
|
18
|
+
this.options = options;
|
|
19
19
|
}
|
|
20
20
|
static escapeNamespace(name) {
|
|
21
21
|
return name === null || name === void 0 ? void 0 : name.replace(/\//g, "$");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.7",
|
|
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.25",
|
|
32
32
|
"source-map": "^0.7.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|