@abaplint/transpiler 2.3.12 → 2.3.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.
@@ -11,12 +11,11 @@ class ConstantTranspiler {
11
11
  const int = node.findFirstExpression(core_1.Expressions.Integer);
12
12
  if (int) {
13
13
  const concat = int.concatTokens().trim();
14
- const post = concat.startsWith("-") ? "minus_" : "";
15
- let ret = "constant_" + post + int.getLastToken().getStr();
14
+ let code = `new abap.types.Integer().set(${concat})`;
16
15
  if (this.addGet === true) {
17
- ret += ".get()";
16
+ code += ".get()";
18
17
  }
19
- return new chunk_1.Chunk().append(ret, node, traversal);
18
+ return new chunk_1.Chunk().append(code, node, traversal);
20
19
  }
21
20
  let str = node.findDirectExpression(core_1.Expressions.ConstantString);
22
21
  if (str === undefined) {
@@ -9,7 +9,10 @@ class TargetTranspiler {
9
9
  transpile(node, traversal) {
10
10
  const offset = [];
11
11
  const ret = new chunk_1.Chunk();
12
- for (const c of node.getChildren()) {
12
+ const children = node.getChildren();
13
+ for (let i = 0; i < children.length; i++) {
14
+ const c = children[i];
15
+ const next = children[i + 1];
13
16
  if (c.get() instanceof core_1.Expressions.TargetField) {
14
17
  const prefix = traversal.prefixAndName(c.getFirstToken()).replace("~", "$");
15
18
  ret.append(prefix, c, traversal);
@@ -43,15 +46,13 @@ class TargetTranspiler {
43
46
  }
44
47
  else if (c instanceof core_1.Nodes.ExpressionNode && c.get() instanceof core_1.Expressions.Dereference) {
45
48
  ret.append(".getPointer()", c, traversal);
46
- break;
47
49
  }
48
50
  else if (c.getFirstToken().getStr() === "=>") {
49
51
  ret.append(".", c, traversal);
50
52
  }
51
53
  else if (c.getFirstToken().getStr() === "->") {
52
- if (node.concatTokens().endsWith("->*")) {
54
+ if (next.concatTokens() === "*") {
53
55
  ret.append(".getPointer()", c, traversal);
54
- break;
55
56
  }
56
57
  else {
57
58
  ret.append(".get().", c, traversal);
@@ -9,6 +9,4 @@ export declare class HandleABAP {
9
9
  private rearrangeClassLocals;
10
10
  protected addImportsAndExports(output: IOutputFile): Chunk;
11
11
  protected findExports(node: abaplint.Nodes.StructureNode | undefined): string[];
12
- protected handleConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): string;
13
- protected findConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): Set<string>;
14
12
  }
@@ -19,7 +19,6 @@ class HandleABAP {
19
19
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.addFilenames) === true) {
20
20
  chunk.appendString("// " + file.getFilename() + "\n");
21
21
  }
22
- chunk.appendString(this.handleConstants(obj, file, reg));
23
22
  const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
24
23
  const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, ((_b = this.options) === null || _b === void 0 ? void 0 : _b.unknownTypes) === "runtimeError").traverse(rearranged);
25
24
  chunk.appendChunk(contents);
@@ -137,37 +136,6 @@ class HandleABAP {
137
136
  }
138
137
  return res;
139
138
  }
140
- handleConstants(obj, file, reg) {
141
- var _a, _b;
142
- let result = "";
143
- const constants = this.findConstants(obj, file, reg);
144
- if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.skipConstants) === false || ((_b = this.options) === null || _b === void 0 ? void 0 : _b.skipConstants) === undefined) {
145
- for (const concat of Array.from(constants).sort()) {
146
- const post = concat.startsWith("-") ? "minus_" : "";
147
- result += `const constant_${post}${concat.replace("-", "")} = new abap.types.Integer().set(${concat});\n`;
148
- }
149
- }
150
- return result;
151
- }
152
- findConstants(obj, file, reg) {
153
- var _a, _b;
154
- let constants = new Set();
155
- for (const i of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(abaplint.Expressions.Integer)) || []) {
156
- constants.add(i.concatTokens().replace(" ", ""));
157
- }
158
- // extra constants from interfaces, used for default values
159
- if (obj.getType() === "CLAS") {
160
- const clas = obj;
161
- for (const i of ((_b = clas.getClassDefinition()) === null || _b === void 0 ? void 0 : _b.interfaces) || []) {
162
- const intf = reg.getObject("INTF", i.name);
163
- const main = intf === null || intf === void 0 ? void 0 : intf.getMainABAPFile();
164
- if (intf && main) {
165
- constants = new Set([...constants, ...this.findConstants(intf, main, reg).values()]);
166
- }
167
- }
168
- }
169
- return constants;
170
- }
171
139
  }
172
140
  exports.HandleABAP = HandleABAP;
173
141
  //# sourceMappingURL=handle_abap.js.map
@@ -6,8 +6,12 @@ const chunk_1 = require("../chunk");
6
6
  class AppendTranspiler {
7
7
  transpile(node, traversal) {
8
8
  const concat = node.concatTokens().toUpperCase();
9
- const target = traversal.traverse(node.findDirectExpression(abaplint.Expressions.Target));
10
- if (concat.includes("INITIAL LINE")) {
9
+ const t = node.findDirectExpression(abaplint.Expressions.Target);
10
+ let target = undefined;
11
+ if (t) {
12
+ target = traversal.traverse(t);
13
+ }
14
+ if (concat.includes("INITIAL LINE") && target) {
11
15
  const assigning = node.findExpressionAfterToken("ASSIGNING");
12
16
  const into = node.findExpressionAfterToken("INTO");
13
17
  if (assigning) {
@@ -52,7 +56,9 @@ class AppendTranspiler {
52
56
  if (concat.startsWith("APPEND LINES OF ")) {
53
57
  options.push(new chunk_1.Chunk().appendString("lines: true"));
54
58
  }
55
- options.push(new chunk_1.Chunk().appendString("target: ").appendChunk(target));
59
+ if (target) {
60
+ options.push(new chunk_1.Chunk().appendString("target: ").appendChunk(target));
61
+ }
56
62
  const ret = new chunk_1.Chunk();
57
63
  ret.append("abap.statements.append({", node, traversal);
58
64
  ret.join(options);
@@ -59,7 +59,7 @@ exports.config = {
59
59
  "^throw$", "^throws$", "^transient$", "^true$",
60
60
  "^try$", "^typeof$", "^var$", "^void$",
61
61
  "^volatile$", "^while$", "^yield$",
62
- "^unique\\d+$", "^constant_\\d+$"
62
+ "^unique\\d+$"
63
63
  ],
64
64
  },
65
65
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.3.12",
3
+ "version": "2.3.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.47",
31
+ "@abaplint/core": "^2.93.49",
32
32
  "source-map": "^0.7.4"
33
33
  },
34
34
  "devDependencies": {