@abaplint/transpiler 2.13.58 → 2.13.60

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.
@@ -145,8 +145,13 @@ class SQLCondTranspiler {
145
145
  sqlSource(source, traversal, filename, table) {
146
146
  let ret = "";
147
147
  const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
148
+ const hostExpression = source.findDirectExpression(abaplint.Expressions.Source);
148
149
  const alias = source.findDirectExpression(abaplint.Expressions.SQLAliasField);
149
- if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
150
+ if (source.getFirstToken().getStr() === "@" && hostExpression) {
151
+ const code = new source_1.SourceTranspiler(true).transpile(hostExpression, traversal).getCode();
152
+ ret += "'\" + " + code + " + \"'";
153
+ }
154
+ else if (simple && simple.findDirectExpression(abaplint.Expressions.Constant) === undefined) {
150
155
  ret += "'\" + " + new simple_source3_1.SimpleSource3Transpiler(true).transpile(simple, traversal).getCode() + " + \"'";
151
156
  }
152
157
  else if (alias) {
@@ -6,7 +6,35 @@ class AuthorityCheckTranspiler {
6
6
  transpile(node, traversal) {
7
7
  const lookup = traversal.lookupClassOrInterface("KERNEL_AUTHORITY_CHECK", node.getFirstToken());
8
8
  const options = [];
9
- // todo
9
+ const object = node.findExpressionAfterToken("OBJECT");
10
+ if (object) {
11
+ options.push("object: " + traversal.traverse(object).getCode());
12
+ }
13
+ const user = node.findExpressionAfterToken("USER");
14
+ if (user) {
15
+ options.push("user: " + traversal.traverse(user).getCode());
16
+ }
17
+ const fields = [];
18
+ const children = node.getChildren();
19
+ for (let i = 0; i < children.length; i++) {
20
+ if (children[i].concatTokens().toUpperCase() !== "ID") {
21
+ continue;
22
+ }
23
+ const id = children[i + 1];
24
+ const addition = children[i + 2]?.concatTokens().toUpperCase();
25
+ if (id === undefined) {
26
+ continue;
27
+ }
28
+ const field = ["id: " + traversal.traverse(id).getCode()];
29
+ if (addition === "FIELD" && children[i + 3] !== undefined) {
30
+ field.push("field: " + traversal.traverse(children[i + 3]).getCode());
31
+ }
32
+ else if (addition === "DUMMY") {
33
+ field.push("dummy: true");
34
+ }
35
+ fields.push("{" + field.join(", ") + "}");
36
+ }
37
+ options.push("fields: [" + fields.join(", ") + "]");
10
38
  const call = `await ${lookup}.call({${options.join(",")}});`;
11
39
  return new chunk_1.Chunk().append(`if (${lookup} === undefined) throw new Error("AuthorityCheck, kernel class missing");\n${call}`, node, traversal);
12
40
  }
@@ -69,8 +69,13 @@ class CreateObjectTranspiler {
69
69
  const cx = traversal.lookupClassOrInterface("CX_SY_CREATE_OBJECT_ERROR", node.getFirstToken());
70
70
  if (dynamic) {
71
71
  const id = unique_identifier_1.UniqueIdentifier.get();
72
+ const internalName = unique_identifier_1.UniqueIdentifier.get();
72
73
  ret += `let ${id} = abap.Classes["${traversal.buildPrefix()}"+${name}.trimEnd()];\n`;
73
74
  ret += `if (${id} === undefined) { ${id} = abap.Classes[${name}.trimEnd()]; }\n`;
75
+ ret += `if (${id} === undefined && abap.Classes['KERNEL_INTERNAL_NAME'] !== undefined) {\n`;
76
+ ret += ` const ${internalName} = await abap.Classes['KERNEL_INTERNAL_NAME'].rtti_to_internal({iv_rtti: ${name}});\n`;
77
+ ret += ` ${id} = abap.Classes[${internalName}.get().trimEnd()];\n`;
78
+ ret += `}\n`;
74
79
  ret += `if (${id} === undefined) { throw new ${cx}; }\n`;
75
80
  clas = id;
76
81
  }
@@ -135,6 +135,7 @@ export * from "./generate_subroutine";
135
135
  export * from "./set_screen";
136
136
  export * from "./set_titlebar";
137
137
  export * from "./shift";
138
+ export * from "./skip";
138
139
  export * from "./sort_dataset";
139
140
  export * from "./sort";
140
141
  export * from "./split";
@@ -151,6 +151,7 @@ __exportStar(require("./generate_subroutine"), exports);
151
151
  __exportStar(require("./set_screen"), exports);
152
152
  __exportStar(require("./set_titlebar"), exports);
153
153
  __exportStar(require("./shift"), exports);
154
+ __exportStar(require("./skip"), exports);
154
155
  __exportStar(require("./sort_dataset"), exports);
155
156
  __exportStar(require("./sort"), exports);
156
157
  __exportStar(require("./split"), exports);
@@ -69,7 +69,10 @@ class SelectTranspiler {
69
69
  else if (node.findFirstExpression(abaplint.Expressions.SQLIntoStructure)) {
70
70
  target = traversal.traverse(node.findFirstExpression(abaplint.Expressions.SQLIntoStructure)).getCode();
71
71
  }
72
- let select = "SELECT ";
72
+ const tokens = node.getTokens();
73
+ const isDistinct = tokens[0]?.getStr().toUpperCase() === "SELECT"
74
+ && tokens[1]?.getStr().toUpperCase() === "DISTINCT";
75
+ let select = isDistinct ? "SELECT DISTINCT " : "SELECT ";
73
76
  const fieldList = node.findFirstExpression(abaplint.Expressions.SQLFieldList)
74
77
  || node.findFirstExpression(abaplint.Expressions.SQLFieldListLoop);
75
78
  if (fieldList === undefined) {
@@ -0,0 +1,7 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { Chunk } from "../chunk";
3
+ import { Traversal } from "../traversal";
4
+ import { IStatementTranspiler } from "./_statement_transpiler";
5
+ export declare class SkipTranspiler implements IStatementTranspiler {
6
+ transpile(node: abaplint.Nodes.StatementNode, traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SkipTranspiler = void 0;
37
+ const abaplint = __importStar(require("@abaplint/core"));
38
+ const chunk_1 = require("../chunk");
39
+ class SkipTranspiler {
40
+ transpile(node, traversal) {
41
+ const source = node.findDirectExpression(abaplint.Expressions.Source);
42
+ if (source === undefined) {
43
+ return new chunk_1.Chunk().append("abap.statements.skip();", node, traversal);
44
+ }
45
+ const option = node.concatTokens().toUpperCase().includes("TO LINE") ? "toLine" : "lines";
46
+ return new chunk_1.Chunk().append("abap.statements.skip({" + option + ": ", node, traversal)
47
+ .appendChunk(traversal.traverse(source))
48
+ .append("});", node.getLastToken(), traversal);
49
+ }
50
+ }
51
+ exports.SkipTranspiler = SkipTranspiler;
52
+ //# sourceMappingURL=skip.js.map
@@ -39,6 +39,7 @@ const traversal_1 = require("../traversal");
39
39
  const chunk_1 = require("../chunk");
40
40
  const transpile_types_1 = require("../transpile_types");
41
41
  const unique_identifier_1 = require("../unique_identifier");
42
+ const inline_1 = require("../inline");
42
43
  class FunctionModuleTranspiler {
43
44
  transpile(node, traversal) {
44
45
  const chunk = new chunk_1.Chunk();
@@ -51,6 +52,7 @@ class FunctionModuleTranspiler {
51
52
  }
52
53
  chunk.append(`async function ${traversal_1.Traversal.escapeNamespace(name)}(INPUT) {\n`, c, traversal);
53
54
  chunk.appendString(this.findSignature(traversal, name, c));
55
+ chunk.appendString(inline_1.InlineDeclarations.buildDeclarations(node, traversal));
54
56
  }
55
57
  else if (c.get() instanceof abaplint.Statements.EndFunction) {
56
58
  chunk.append("}\n", c, traversal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.58",
3
+ "version": "2.13.60",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "author": "abaplint",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@abaplint/core": "^2.120.22",
32
+ "@abaplint/core": "^2.120.28",
33
33
  "source-map": "^0.7.6"
34
34
  },
35
35
  "devDependencies": {