@abaplint/transpiler 1.7.14 → 1.7.18

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.
@@ -10,8 +10,9 @@ class ConstantTranspiler {
10
10
  transpile(node, traversal) {
11
11
  const int = node.findFirstExpression(core_1.Expressions.Integer);
12
12
  if (int) {
13
- const val = parseInt(int.concatTokens(), 10);
14
- let ret = "constant_" + (val < 0 ? "minus_" : "") + Math.abs(val);
13
+ const concat = int.concatTokens().trim();
14
+ const post = concat.startsWith("-") ? "minus_" : "";
15
+ let ret = "constant_" + post + int.getLastToken().getStr();
15
16
  if (this.addGet === true) {
16
17
  ret += ".get()";
17
18
  }
@@ -0,0 +1,14 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { IOutputFile, ITranspilerOptions } from "./types";
3
+ import { Chunk } from "./chunk";
4
+ export declare class HandleABAP {
5
+ private readonly options;
6
+ constructor(options?: ITranspilerOptions);
7
+ runObject(obj: abaplint.ABAPObject, reg: abaplint.IRegistry): IOutputFile[];
8
+ /** merges the locals def and imp into one mjs file */
9
+ private rearrangeClassLocals;
10
+ protected addImportsAndExports(output: IOutputFile): Chunk;
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
+ }
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HandleABAP = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ const traversal_1 = require("./traversal");
6
+ const requires_1 = require("./requires");
7
+ const rearranger_1 = require("./rearranger");
8
+ const chunk_1 = require("./chunk");
9
+ class HandleABAP {
10
+ constructor(options) {
11
+ this.options = options;
12
+ }
13
+ runObject(obj, reg) {
14
+ var _a, _b, _c;
15
+ const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti;
16
+ let ret = [];
17
+ for (const file of obj.getSequencedFiles()) {
18
+ const chunk = new chunk_1.Chunk();
19
+ if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.addFilenames) === true) {
20
+ chunk.appendString("// " + file.getFilename() + "\n");
21
+ }
22
+ chunk.appendString(this.handleConstants(obj, file, reg));
23
+ const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
24
+ 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
+ chunk.appendChunk(contents);
26
+ chunk.stripLastNewline();
27
+ chunk.runIndentationLogic();
28
+ const exports = this.findExports(file.getStructure());
29
+ const filename = file.getFilename().replace(".abap", ".mjs").toLowerCase();
30
+ const output = {
31
+ object: {
32
+ name: obj.getName(),
33
+ type: obj.getType(),
34
+ },
35
+ filename: filename,
36
+ chunk: chunk,
37
+ requires: new requires_1.Requires(reg).find(obj, spaghetti.getTop(), file.getFilename()),
38
+ exports: exports,
39
+ };
40
+ ret.push(output);
41
+ }
42
+ ret = this.rearrangeClassLocals(obj, ret);
43
+ if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.addCommonJS) === true) {
44
+ ret.map(output => output.chunk = this.addImportsAndExports(output));
45
+ }
46
+ return ret;
47
+ }
48
+ /** merges the locals def and imp into one mjs file */
49
+ rearrangeClassLocals(obj, output) {
50
+ const ret = [];
51
+ if (obj.getType() !== "CLAS") {
52
+ return output;
53
+ }
54
+ let imp = undefined;
55
+ let def = undefined;
56
+ for (const o of output) {
57
+ if (o.filename.endsWith(".clas.locals_imp.mjs")) {
58
+ imp = o;
59
+ }
60
+ else if (o.filename.endsWith(".clas.locals_def.mjs")) {
61
+ def = o;
62
+ }
63
+ else {
64
+ ret.push(o);
65
+ }
66
+ }
67
+ if (def) {
68
+ def.filename = def.filename.replace(".locals_def.mjs", ".locals.mjs");
69
+ }
70
+ if (imp) {
71
+ imp.filename = imp.filename.replace(".locals_imp.mjs", ".locals.mjs");
72
+ }
73
+ if (imp && def) {
74
+ // remove duplicates
75
+ const requires = [...def.requires];
76
+ for (const r of imp.requires) {
77
+ if (requires.find(a => a.filename === r.filename && a.name === r.name) === undefined) {
78
+ requires.push(r);
79
+ }
80
+ }
81
+ const chunk = new chunk_1.Chunk().appendChunk(def.chunk).appendChunk(imp.chunk);
82
+ ret.push({
83
+ object: imp.object,
84
+ filename: imp.filename,
85
+ chunk: chunk,
86
+ requires: requires,
87
+ exports: def.exports.concat(imp.exports),
88
+ });
89
+ }
90
+ else if (imp) {
91
+ ret.push(imp);
92
+ }
93
+ else if (def) {
94
+ ret.push(def);
95
+ }
96
+ return ret;
97
+ }
98
+ addImportsAndExports(output) {
99
+ var _a;
100
+ const contents = new chunk_1.Chunk();
101
+ for (const r of output.requires) {
102
+ const name = (_a = r.name) === null || _a === void 0 ? void 0 : _a.toLowerCase();
103
+ const filename = r.filename.replace(".abap", ".mjs");
104
+ if (filename === output.filename) {
105
+ continue;
106
+ }
107
+ if (name) {
108
+ contents.appendString("const {" + name + "} = await import(\"./" + filename + "\");\n");
109
+ }
110
+ else {
111
+ contents.appendString("await import(\"./" + filename + "\");\n");
112
+ }
113
+ }
114
+ contents.appendChunk(output.chunk);
115
+ if (output.exports.length > 0) {
116
+ contents.appendString("\nexport {" + output.exports.join(", ") + "};");
117
+ }
118
+ return contents;
119
+ }
120
+ findExports(node) {
121
+ var _a, _b;
122
+ if (node === undefined) {
123
+ return [];
124
+ }
125
+ const res = [];
126
+ for (const c of node.findAllStatements(abaplint.Statements.ClassDefinition)) {
127
+ const e = (_a = c.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
128
+ if (e) {
129
+ res.push(e.toLowerCase());
130
+ }
131
+ }
132
+ for (const c of node.findAllStatements(abaplint.Statements.Interface)) {
133
+ const e = (_b = c.findFirstExpression(abaplint.Expressions.InterfaceName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
134
+ if (e) {
135
+ res.push(e.toLowerCase());
136
+ }
137
+ }
138
+ return res;
139
+ }
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
+ }
172
+ exports.HandleABAP = HandleABAP;
173
+ //# sourceMappingURL=handle_abap.js.map
@@ -0,0 +1,5 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { IOutputFile } from "./types";
3
+ export declare class HandleTable {
4
+ runObject(obj: abaplint.Objects.Table, reg: abaplint.IRegistry): IOutputFile[];
5
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HandleTable = void 0;
4
+ const chunk_1 = require("./chunk");
5
+ const transpile_types_1 = require("./transpile_types");
6
+ // tables or structures
7
+ class HandleTable {
8
+ runObject(obj, reg) {
9
+ var _a;
10
+ const filename = (_a = obj.getXMLFile()) === null || _a === void 0 ? void 0 : _a.getFilename().replace(".xml", ".mjs").toLowerCase();
11
+ if (filename === undefined) {
12
+ return [];
13
+ }
14
+ const type = obj.parseType(reg);
15
+ const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
16
+ "type": ${new transpile_types_1.TranspileTypes().toType(type)},
17
+ };`);
18
+ const output = {
19
+ object: {
20
+ name: obj.getName(),
21
+ type: obj.getType(),
22
+ },
23
+ filename: filename,
24
+ chunk: chunk,
25
+ requires: [],
26
+ exports: [],
27
+ };
28
+ return [output];
29
+ }
30
+ }
31
+ exports.HandleTable = HandleTable;
32
+ //# sourceMappingURL=handle_table.js.map
@@ -1,65 +1,11 @@
1
1
  import * as abaplint from "@abaplint/core";
2
2
  import { config } from "./validation";
3
- import { TestMethodList } from "./unit_test";
4
- import { Chunk } from "./chunk";
5
- export { config };
6
- export interface IFile {
7
- filename: string;
8
- relative?: string;
9
- contents: string;
10
- }
11
- export interface IObjectIdentifier {
12
- name: string;
13
- type: string;
14
- }
15
- export interface IOutput {
16
- objects: IOutputFile[];
17
- reg: abaplint.IRegistry;
18
- unitTestScript: string;
19
- initializationScript: string;
20
- databaseSetup: string;
21
- }
22
- export interface IRequire {
23
- name: string | undefined;
24
- filename: string;
25
- }
26
- export interface IProgress {
27
- set(total: number, text: string): void;
28
- tick(text: string): Promise<void>;
29
- }
30
- /** one javascript output file for each object */
31
- export interface IOutputFile {
32
- object: IObjectIdentifier;
33
- filename: string;
34
- chunk: Chunk;
35
- requires: readonly IRequire[];
36
- exports: readonly string[];
37
- }
38
- export interface ITranspilerOptions {
39
- /** ignore syntax check, used for internal testing */
40
- ignoreSyntaxCheck?: boolean;
41
- /** adds common js modules */
42
- addCommonJS?: boolean;
43
- /** adds filenames as comments in the output js */
44
- addFilenames?: boolean;
45
- /** skip outputing constants, used for internal testing */
46
- skipConstants?: boolean;
47
- /** sets behavior for unknown types, either fail at compile- or run-time */
48
- unknownTypes?: "compileError" | "runtimeError";
49
- skip?: TestMethodList;
50
- only?: TestMethodList;
51
- }
3
+ import { IFile, IOutput, IProgress, ITranspilerOptions, IOutputFile } from "./types";
4
+ export { config, ITranspilerOptions, IFile, IProgress, IOutputFile };
52
5
  export declare class Transpiler {
53
6
  private readonly options;
54
7
  constructor(options?: ITranspilerOptions);
55
8
  runRaw(files: IFile[]): Promise<IOutput>;
56
9
  run(reg: abaplint.IRegistry, progress?: IProgress): Promise<IOutput>;
57
- protected handleConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): string;
58
- protected findConstants(obj: abaplint.ABAPObject, file: abaplint.ABAPFile, reg: abaplint.IRegistry): Set<number>;
59
- protected runObject(obj: abaplint.ABAPObject, reg: abaplint.IRegistry): IOutputFile[];
60
- /** merges the locals def and imp into one mjs file */
61
- private rearrangeClassLocals;
62
- protected addImportsAndExports(output: IOutputFile): Chunk;
63
- protected findExports(node: abaplint.Nodes.StructureNode | undefined): string[];
64
10
  protected validate(reg: abaplint.IRegistry): void;
65
11
  }
@@ -4,13 +4,11 @@ exports.Transpiler = exports.config = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  const validation_1 = require("./validation");
6
6
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return validation_1.config; } });
7
- const traversal_1 = require("./traversal");
8
- const requires_1 = require("./requires");
9
7
  const unit_test_1 = require("./unit_test");
10
8
  const keywords_1 = require("./keywords");
11
9
  const database_setup_1 = require("./database_setup");
12
- const rearranger_1 = require("./rearranger");
13
- const chunk_1 = require("./chunk");
10
+ const handle_table_1 = require("./handle_table");
11
+ const handle_abap_1 = require("./handle_abap");
14
12
  class Transpiler {
15
13
  constructor(options) {
16
14
  this.options = options;
@@ -44,6 +42,7 @@ class Transpiler {
44
42
  for (const obj of reg.getObjects()) {
45
43
  await (progress === null || progress === void 0 ? void 0 : progress.tick("Building, Syntax Logic, " + obj.getName()));
46
44
  if (obj instanceof abaplint.ABAPObject) {
45
+ // todo, this is already done inside reg.parse()?
47
46
  new abaplint.SyntaxLogic(reg, obj).run();
48
47
  }
49
48
  }
@@ -51,171 +50,15 @@ class Transpiler {
51
50
  for (const obj of reg.getObjects()) {
52
51
  await (progress === null || progress === void 0 ? void 0 : progress.tick("Building, " + obj.getName()));
53
52
  if (obj instanceof abaplint.ABAPObject && !(obj instanceof abaplint.Objects.TypePool)) {
54
- output.objects = output.objects.concat(this.runObject(obj, reg));
53
+ output.objects.push(...new handle_abap_1.HandleABAP(this.options).runObject(obj, reg));
54
+ }
55
+ else if (obj instanceof abaplint.Objects.Table) {
56
+ output.objects.push(...new handle_table_1.HandleTable().runObject(obj, reg));
55
57
  }
56
58
  }
57
59
  return output;
58
60
  }
59
61
  // ///////////////////////////////
60
- handleConstants(obj, file, reg) {
61
- var _a, _b;
62
- let result = "";
63
- const constants = this.findConstants(obj, file, reg);
64
- 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) {
65
- for (const c of Array.from(constants).sort()) {
66
- const post = c < 0 ? "minus_" : "";
67
- result += `const constant_${post}${Math.abs(c)} = new abap.types.Integer().set(${c});\n`;
68
- }
69
- }
70
- return result;
71
- }
72
- findConstants(obj, file, reg) {
73
- var _a, _b;
74
- let constants = new Set();
75
- for (const i of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(abaplint.Expressions.Integer)) || []) {
76
- const j = parseInt(i.concatTokens(), 10);
77
- constants.add(j);
78
- }
79
- // extra constants from interfaces, used for default values
80
- if (obj.getType() === "CLAS") {
81
- const clas = obj;
82
- for (const i of ((_b = clas.getClassDefinition()) === null || _b === void 0 ? void 0 : _b.interfaces) || []) {
83
- const intf = reg.getObject("INTF", i.name);
84
- const main = intf === null || intf === void 0 ? void 0 : intf.getMainABAPFile();
85
- if (intf && main) {
86
- constants = new Set([...constants, ...this.findConstants(intf, main, reg).values()]);
87
- }
88
- }
89
- }
90
- return constants;
91
- }
92
- runObject(obj, reg) {
93
- var _a, _b, _c;
94
- const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti;
95
- let ret = [];
96
- for (const file of obj.getSequencedFiles()) {
97
- const chunk = new chunk_1.Chunk();
98
- if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.addFilenames) === true) {
99
- chunk.appendString("// " + file.getFilename() + "\n");
100
- }
101
- chunk.appendString(this.handleConstants(obj, file, reg));
102
- const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure());
103
- const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, ((_b = this.options) === null || _b === void 0 ? void 0 : _b.unknownTypes) === "runtimeError").traverse(rearranged);
104
- chunk.appendChunk(contents);
105
- chunk.stripLastNewline();
106
- chunk.runIndentationLogic();
107
- const exports = this.findExports(file.getStructure());
108
- const filename = file.getFilename().replace(".abap", ".mjs").toLowerCase();
109
- const output = {
110
- object: {
111
- name: obj.getName(),
112
- type: obj.getType(),
113
- },
114
- filename: filename,
115
- chunk: chunk,
116
- requires: new requires_1.Requires(reg).find(obj, spaghetti.getTop(), file.getFilename()),
117
- exports: exports,
118
- };
119
- ret.push(output);
120
- }
121
- ret = this.rearrangeClassLocals(obj, ret);
122
- if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.addCommonJS) === true) {
123
- ret.map(output => output.chunk = this.addImportsAndExports(output));
124
- }
125
- return ret;
126
- }
127
- /** merges the locals def and imp into one mjs file */
128
- rearrangeClassLocals(obj, output) {
129
- const ret = [];
130
- if (obj.getType() !== "CLAS") {
131
- return output;
132
- }
133
- let imp = undefined;
134
- let def = undefined;
135
- for (const o of output) {
136
- if (o.filename.endsWith(".clas.locals_imp.mjs")) {
137
- imp = o;
138
- }
139
- else if (o.filename.endsWith(".clas.locals_def.mjs")) {
140
- def = o;
141
- }
142
- else {
143
- ret.push(o);
144
- }
145
- }
146
- if (def) {
147
- def.filename = def.filename.replace(".locals_def.mjs", ".locals.mjs");
148
- }
149
- if (imp) {
150
- imp.filename = imp.filename.replace(".locals_imp.mjs", ".locals.mjs");
151
- }
152
- if (imp && def) {
153
- // remove duplicates
154
- const requires = [...def.requires];
155
- for (const r of imp.requires) {
156
- if (requires.find(a => a.filename === r.filename && a.name === r.name) === undefined) {
157
- requires.push(r);
158
- }
159
- }
160
- const chunk = new chunk_1.Chunk().appendChunk(def.chunk).appendChunk(imp.chunk);
161
- ret.push({
162
- object: imp.object,
163
- filename: imp.filename,
164
- chunk: chunk,
165
- requires: requires,
166
- exports: def.exports.concat(imp.exports),
167
- });
168
- }
169
- else if (imp) {
170
- ret.push(imp);
171
- }
172
- else if (def) {
173
- ret.push(def);
174
- }
175
- return ret;
176
- }
177
- addImportsAndExports(output) {
178
- var _a;
179
- const contents = new chunk_1.Chunk();
180
- for (const r of output.requires) {
181
- const name = (_a = r.name) === null || _a === void 0 ? void 0 : _a.toLowerCase();
182
- const filename = r.filename.replace(".abap", ".mjs");
183
- if (filename === output.filename) {
184
- continue;
185
- }
186
- if (name) {
187
- contents.appendString("const {" + name + "} = await import(\"./" + filename + "\");\n");
188
- }
189
- else {
190
- contents.appendString("await import(\"./" + filename + "\");\n");
191
- }
192
- }
193
- contents.appendChunk(output.chunk);
194
- if (output.exports.length > 0) {
195
- contents.appendString("\nexport {" + output.exports.join(", ") + "};");
196
- }
197
- return contents;
198
- }
199
- findExports(node) {
200
- var _a, _b;
201
- if (node === undefined) {
202
- return [];
203
- }
204
- const res = [];
205
- for (const c of node.findAllStatements(abaplint.Statements.ClassDefinition)) {
206
- const e = (_a = c.findFirstExpression(abaplint.Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
207
- if (e) {
208
- res.push(e.toLowerCase());
209
- }
210
- }
211
- for (const c of node.findAllStatements(abaplint.Statements.Interface)) {
212
- const e = (_b = c.findFirstExpression(abaplint.Expressions.InterfaceName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
213
- if (e) {
214
- res.push(e.toLowerCase());
215
- }
216
- }
217
- return res;
218
- }
219
62
  validate(reg) {
220
63
  const issues = new validation_1.Validation(this.options).run(reg);
221
64
  if (issues.length > 0) {
@@ -1,5 +1,5 @@
1
1
  import * as abaplint from "@abaplint/core";
2
- import { IRequire } from ".";
2
+ import { IRequire } from "./types";
3
3
  export declare class Requires {
4
4
  private readonly reg;
5
5
  constructor(reg: abaplint.IRegistry);
@@ -3,11 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateDataTranspiler = 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 CreateDataTranspiler {
7
8
  transpile(node, traversal) {
9
+ var _a, _b;
8
10
  const targetNode = node.findDirectExpression(abaplint.Expressions.Target);
9
11
  const target = traversal.traverse(targetNode);
10
- return new chunk_1.Chunk("abap.statements.createData(" + target.getCode() + ");");
12
+ const options = [];
13
+ let dynamic = (_a = node.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(abaplint.Expressions.ConstantString);
14
+ if (dynamic) {
15
+ options.push(`"name": ` + dynamic.getFirstToken().getStr());
16
+ }
17
+ else {
18
+ dynamic = (_b = node.findDirectExpression(abaplint.Expressions.Dynamic)) === null || _b === void 0 ? void 0 : _b.findFirstExpression(abaplint.Expressions.FieldChain);
19
+ if (dynamic) {
20
+ options.push(`"name": ` + new expressions_1.FieldChainTranspiler(true).transpile(dynamic, traversal).getCode());
21
+ }
22
+ }
23
+ if (node.findDirectTokenByText("TABLE")) {
24
+ options.push(`"table": true`);
25
+ }
26
+ let add = "";
27
+ if (options.length > 0) {
28
+ add = ",{" + options.join(",") + "}";
29
+ }
30
+ return new chunk_1.Chunk("abap.statements.createData(" + target.getCode() + add + ");");
11
31
  }
12
32
  }
13
33
  exports.CreateDataTranspiler = CreateDataTranspiler;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
- const types_1 = require("../types");
5
+ const transpile_types_1 = require("../transpile_types");
6
6
  const constant_1 = require("../expressions/constant");
7
7
  const expressions_1 = require("../expressions");
8
8
  const chunk_1 = require("../chunk");
@@ -40,7 +40,7 @@ class DataTranspiler {
40
40
  const ret = new chunk_1.Chunk()
41
41
  .appendString("let ")
42
42
  .append(found.getName().toLowerCase(), token, traversal)
43
- .appendString(" = " + new types_1.TranspileTypes().toType(found.getType()))
43
+ .appendString(" = " + new transpile_types_1.TranspileTypes().toType(found.getType()))
44
44
  .append(";", node.getLastToken(), traversal)
45
45
  .append(value, node.getLastToken(), traversal);
46
46
  return ret;
@@ -12,14 +12,14 @@ class DoTranspiler {
12
12
  const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();
13
13
  const idSource = unique_identifier_1.UniqueIdentifier.get();
14
14
  const id = unique_identifier_1.UniqueIdentifier.get();
15
- return new chunk_1.Chunk(`const ${idSource} = ${source};
16
- for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
15
+ return new chunk_1.Chunk(`const ${idSource} = ${source};
16
+ for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
17
17
  abap.builtin.sy.get().index.set(${id} + 1);`);
18
18
  }
19
19
  else {
20
20
  const unique = unique_identifier_1.UniqueIdentifier.get();
21
- return new chunk_1.Chunk(`let ${unique} = 1;
22
- while (true) {
21
+ return new chunk_1.Chunk(`let ${unique} = 1;
22
+ while (true) {
23
23
  abap.builtin.sy.get().index.set(${unique}++);`);
24
24
  }
25
25
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MethodImplementationTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
- const types_1 = require("../types");
5
+ const transpile_types_1 = require("../transpile_types");
6
6
  const expressions_1 = require("../expressions");
7
7
  const chunk_1 = require("../chunk");
8
8
  class MethodImplementationTranspiler {
@@ -37,7 +37,7 @@ class MethodImplementationTranspiler {
37
37
  if (unique === "") {
38
38
  unique = "INPUT";
39
39
  }
40
- after = after + new types_1.TranspileTypes().declare(identifier) + "\n";
40
+ after = after + new transpile_types_1.TranspileTypes().declare(identifier) + "\n";
41
41
  if (identifier.getMeta().includes("importing" /* MethodImporting */) && identifier.getType().isGeneric() === false) {
42
42
  after += "if (" + unique + " && " + unique + "." + varName + ") {" + varName + ".set(" + unique + "." + varName + ");}\n";
43
43
  }
@@ -72,7 +72,7 @@ class MethodImplementationTranspiler {
72
72
  }
73
73
  }
74
74
  else if (identifier.getMeta().includes("returning" /* MethodReturning */)) {
75
- after = after + new types_1.TranspileTypes().declare(identifier) + "\n";
75
+ after = after + new transpile_types_1.TranspileTypes().declare(identifier) + "\n";
76
76
  }
77
77
  }
78
78
  if (after.length > 0) { // argh
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SelectTranspiler = 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 SelectTranspiler {
7
8
  transpile(node, traversal) {
8
9
  var _a, _b;
@@ -10,6 +11,14 @@ class SelectTranspiler {
10
11
  let select = "SELECT ";
11
12
  select += ((_a = node.findFirstExpression(abaplint.Expressions.SQLFieldList)) === null || _a === void 0 ? void 0 : _a.concatTokens()) + " ";
12
13
  select += ((_b = node.findFirstExpression(abaplint.Expressions.SQLFrom)) === null || _b === void 0 ? void 0 : _b.concatTokens()) + " ";
14
+ for (const d of node.findAllExpressionsRecursive(abaplint.Expressions.Dynamic)) {
15
+ const chain = d.findFirstExpression(abaplint.Expressions.FieldChain);
16
+ if (chain) {
17
+ const code = new expressions_1.FieldChainTranspiler(true).transpile(chain, traversal).getCode();
18
+ const search = d.concatTokens();
19
+ select = select.replace(search, `" + ${code} + "`);
20
+ }
21
+ }
13
22
  if (node.concatTokens().toUpperCase().startsWith("SELECT SINGLE ")) {
14
23
  select += "LIMIT 1";
15
24
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassImplementationTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
- const types_1 = require("../types");
5
+ const transpile_types_1 = require("../transpile_types");
6
6
  const expressions_1 = require("../expressions");
7
7
  const chunk_1 = require("../chunk");
8
8
  class ClassImplementationTranspiler {
@@ -70,7 +70,7 @@ class ClassImplementationTranspiler {
70
70
  const staticAttributes = this.findStaticAttributes(cdef, scope);
71
71
  for (const attr of staticAttributes) {
72
72
  const name = clasName + "." + attr.prefix + attr.identifier.getName().toLowerCase();
73
- ret += name + " = " + new types_1.TranspileTypes().toType(attr.identifier.getType()) + ";\n";
73
+ ret += name + " = " + new transpile_types_1.TranspileTypes().toType(attr.identifier.getType()) + ";\n";
74
74
  const val = attr.identifier.getValue();
75
75
  if (typeof val === "string") {
76
76
  const e = new expressions_1.ConstantTranspiler().escape(val);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InterfaceTranspiler = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
- const types_1 = require("../types");
5
+ const transpile_types_1 = require("../transpile_types");
6
6
  const expressions_1 = require("../expressions");
7
7
  const chunk_1 = require("../chunk");
8
8
  class InterfaceTranspiler {
@@ -42,7 +42,7 @@ class InterfaceTranspiler {
42
42
  }
43
43
  const interfaceName = node.getFirstToken().getStr().toLowerCase();
44
44
  const name = interfaceName + "." + interfaceName + "$" + n.toLowerCase();
45
- ret += name + " = " + new types_1.TranspileTypes().toType(identifier.getType()) + ";\n";
45
+ ret += name + " = " + new transpile_types_1.TranspileTypes().toType(identifier.getType()) + ";\n";
46
46
  const constantStatement = traversal.findStatementInFile(identifier.getStart());
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) {
@@ -0,0 +1,5 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ export declare class TranspileTypes {
3
+ declare(t: abaplint.TypedIdentifier): string;
4
+ toType(type: abaplint.AbstractType): string;
5
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TranspileTypes = void 0;
4
+ const abaplint = require("@abaplint/core");
5
+ class TranspileTypes {
6
+ declare(t) {
7
+ const type = t.getType();
8
+ return "let " + t.getName().toLowerCase() + " = " + this.toType(type) + ";";
9
+ }
10
+ toType(type) {
11
+ let resolved = "";
12
+ let extra = "";
13
+ if (type instanceof abaplint.BasicTypes.ObjectReferenceType
14
+ || type instanceof abaplint.BasicTypes.GenericObjectReferenceType) {
15
+ resolved = "ABAPObject";
16
+ }
17
+ else if (type instanceof abaplint.BasicTypes.TableType) {
18
+ resolved = "Table";
19
+ extra = this.toType(type.getRowType());
20
+ extra += ", " + JSON.stringify(type.getOptions());
21
+ }
22
+ else if (type instanceof abaplint.BasicTypes.IntegerType) {
23
+ resolved = "Integer";
24
+ }
25
+ else if (type instanceof abaplint.BasicTypes.StringType) {
26
+ resolved = "String";
27
+ }
28
+ else if (type instanceof abaplint.BasicTypes.DateType) {
29
+ resolved = "Date";
30
+ }
31
+ else if (type instanceof abaplint.BasicTypes.TimeType) {
32
+ resolved = "Time";
33
+ }
34
+ else if (type instanceof abaplint.BasicTypes.DataReference) {
35
+ resolved = "DataReference";
36
+ extra = this.toType(type.getType());
37
+ }
38
+ else if (type instanceof abaplint.BasicTypes.StructureType) {
39
+ resolved = "Structure";
40
+ const list = [];
41
+ for (const c of type.getComponents()) {
42
+ list.push(c.name.toLowerCase() + ": " + this.toType(c.type));
43
+ }
44
+ extra = "{" + list.join(", ") + "}";
45
+ }
46
+ else if (type instanceof abaplint.BasicTypes.CLikeType
47
+ || type instanceof abaplint.BasicTypes.CSequenceType) {
48
+ // if not supplied its a Character(1)
49
+ resolved = "Character";
50
+ }
51
+ else if (type instanceof abaplint.BasicTypes.AnyType) {
52
+ // if not supplied its a Character(4)
53
+ resolved = "Character";
54
+ extra = "{length: 4}";
55
+ }
56
+ else if (type instanceof abaplint.BasicTypes.SimpleType) {
57
+ // if not supplied its a Character(1)
58
+ resolved = "Character";
59
+ }
60
+ else if (type instanceof abaplint.BasicTypes.CharacterType) {
61
+ resolved = "Character";
62
+ if (type.getLength() !== 1) {
63
+ extra = "{length: " + type.getLength() + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
64
+ }
65
+ else if (type.getQualifiedName() !== undefined) {
66
+ extra = "{qualifiedName: \"" + type.getQualifiedName() + "\"}";
67
+ }
68
+ }
69
+ else if (type instanceof abaplint.BasicTypes.NumericType) {
70
+ resolved = "Numc";
71
+ if (type.getLength() !== 1) {
72
+ extra = "{length: " + type.getLength() + "}";
73
+ }
74
+ }
75
+ else if (type instanceof abaplint.BasicTypes.PackedType) {
76
+ resolved = "Packed";
77
+ extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + "}";
78
+ }
79
+ else if (type instanceof abaplint.BasicTypes.NumericGenericType) {
80
+ resolved = "Packed";
81
+ extra = "{length: 8, decimals: 0}";
82
+ }
83
+ else if (type instanceof abaplint.BasicTypes.XStringType) {
84
+ resolved = "XString";
85
+ }
86
+ else if (type instanceof abaplint.BasicTypes.XSequenceType) {
87
+ // if not supplied itsa a Hex(1)
88
+ resolved = "Hex";
89
+ }
90
+ else if (type instanceof abaplint.BasicTypes.HexType) {
91
+ resolved = "Hex";
92
+ if (type.getLength() !== 1) {
93
+ extra = "{length: " + type.getLength() + "}";
94
+ }
95
+ }
96
+ else if (type instanceof abaplint.BasicTypes.FloatType) {
97
+ resolved = "Float";
98
+ }
99
+ else if (type instanceof abaplint.BasicTypes.DecFloat34Type) {
100
+ resolved = "DecFloat34";
101
+ }
102
+ else if (type instanceof abaplint.BasicTypes.UnknownType) {
103
+ return `(() => { throw "Unknown type: ${type.getError()}" })()`;
104
+ }
105
+ else if (type instanceof abaplint.BasicTypes.VoidType) {
106
+ return `(() => { throw "Void type: ${type.getVoided()}" })()`;
107
+ }
108
+ else {
109
+ resolved = "typeTodo" + type.constructor.name;
110
+ }
111
+ return "new abap.types." + resolved + "(" + extra + ")";
112
+ }
113
+ }
114
+ exports.TranspileTypes = TranspileTypes;
115
+ //# sourceMappingURL=transpile_types.js.map
@@ -5,7 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const StatementTranspilers = require("./statements");
6
6
  const ExpressionTranspilers = require("./expressions");
7
7
  const StructureTranspilers = require("./structures");
8
- const types_1 = require("./types");
8
+ const transpile_types_1 = require("./transpile_types");
9
9
  const chunk_1 = require("./chunk");
10
10
  class Traversal {
11
11
  constructor(spaghetti, file, obj, reg, runtimeTypeError = false) {
@@ -265,7 +265,7 @@ class Traversal {
265
265
  continue;
266
266
  }
267
267
  const name = a.getName().toLowerCase();
268
- ret += "this." + name + " = " + new types_1.TranspileTypes().toType(a.getType()) + ";\n";
268
+ ret += "this." + name + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
269
269
  }
270
270
  // attributes from directly implemented interfaces(not interfaces implemented in super classes)
271
271
  for (const i of def.getImplementing()) {
@@ -305,7 +305,7 @@ class Traversal {
305
305
  continue;
306
306
  }
307
307
  const n = name.toLowerCase() + "$" + a.getName().toLowerCase();
308
- ret += "this." + n + " = " + new types_1.TranspileTypes().toType(a.getType()) + ";\n";
308
+ ret += "this." + n + " = " + new transpile_types_1.TranspileTypes().toType(a.getType()) + ";\n";
309
309
  }
310
310
  for (const i of (intf === null || intf === void 0 ? void 0 : intf.getImplementing()) || []) {
311
311
  ret += this.dataFromInterfaces(i.name, scope);
@@ -1,5 +1,49 @@
1
+ import { Chunk } from "./chunk";
1
2
  import * as abaplint from "@abaplint/core";
2
- export declare class TranspileTypes {
3
- declare(t: abaplint.TypedIdentifier): string;
4
- toType(type: abaplint.AbstractType): string;
3
+ import { TestMethodList } from "./unit_test";
4
+ export interface IFile {
5
+ filename: string;
6
+ relative?: string;
7
+ contents: string;
8
+ }
9
+ export interface IObjectIdentifier {
10
+ name: string;
11
+ type: string;
12
+ }
13
+ export interface IOutput {
14
+ objects: IOutputFile[];
15
+ reg: abaplint.IRegistry;
16
+ unitTestScript: string;
17
+ initializationScript: string;
18
+ databaseSetup: string;
19
+ }
20
+ export interface IRequire {
21
+ name: string | undefined;
22
+ filename: string;
23
+ }
24
+ export interface IProgress {
25
+ set(total: number, text: string): void;
26
+ tick(text: string): Promise<void>;
27
+ }
28
+ /** one javascript output file for each object */
29
+ export interface IOutputFile {
30
+ object: IObjectIdentifier;
31
+ filename: string;
32
+ chunk: Chunk;
33
+ requires: readonly IRequire[];
34
+ exports: readonly string[];
35
+ }
36
+ export interface ITranspilerOptions {
37
+ /** ignore syntax check, used for internal testing */
38
+ ignoreSyntaxCheck?: boolean;
39
+ /** adds common js modules */
40
+ addCommonJS?: boolean;
41
+ /** adds filenames as comments in the output js */
42
+ addFilenames?: boolean;
43
+ /** skip outputing constants, used for internal testing */
44
+ skipConstants?: boolean;
45
+ /** sets behavior for unknown types, either fail at compile- or run-time */
46
+ unknownTypes?: "compileError" | "runtimeError";
47
+ skip?: TestMethodList;
48
+ only?: TestMethodList;
5
49
  }
@@ -1,112 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TranspileTypes = void 0;
4
- const abaplint = require("@abaplint/core");
5
- class TranspileTypes {
6
- declare(t) {
7
- const type = t.getType();
8
- return "let " + t.getName().toLowerCase() + " = " + this.toType(type) + ";";
9
- }
10
- toType(type) {
11
- let resolved = "";
12
- let extra = "";
13
- if (type instanceof abaplint.BasicTypes.ObjectReferenceType
14
- || type instanceof abaplint.BasicTypes.GenericObjectReferenceType) {
15
- resolved = "ABAPObject";
16
- }
17
- else if (type instanceof abaplint.BasicTypes.TableType) {
18
- resolved = "Table";
19
- extra = this.toType(type.getRowType());
20
- extra += ", " + JSON.stringify(type.getOptions());
21
- }
22
- else if (type instanceof abaplint.BasicTypes.IntegerType) {
23
- resolved = "Integer";
24
- }
25
- else if (type instanceof abaplint.BasicTypes.StringType) {
26
- resolved = "String";
27
- }
28
- else if (type instanceof abaplint.BasicTypes.DateType) {
29
- resolved = "Date";
30
- }
31
- else if (type instanceof abaplint.BasicTypes.TimeType) {
32
- resolved = "Time";
33
- }
34
- else if (type instanceof abaplint.BasicTypes.DataReference) {
35
- resolved = "DataReference";
36
- extra = this.toType(type.getType());
37
- }
38
- else if (type instanceof abaplint.BasicTypes.StructureType) {
39
- resolved = "Structure";
40
- const list = [];
41
- for (const c of type.getComponents()) {
42
- list.push(c.name.toLowerCase() + ": " + this.toType(c.type));
43
- }
44
- extra = "{" + list.join(", ") + "}";
45
- }
46
- else if (type instanceof abaplint.BasicTypes.CLikeType
47
- || type instanceof abaplint.BasicTypes.CSequenceType) {
48
- // if not supplied its a Character(1)
49
- resolved = "Character";
50
- }
51
- else if (type instanceof abaplint.BasicTypes.AnyType) {
52
- // if not supplied its a Character(4)
53
- resolved = "Character";
54
- extra = "{length: 4}";
55
- }
56
- else if (type instanceof abaplint.BasicTypes.SimpleType) {
57
- // if not supplied its a Character(1)
58
- resolved = "Character";
59
- }
60
- else if (type instanceof abaplint.BasicTypes.CharacterType) {
61
- resolved = "Character";
62
- if (type.getLength() !== 1) {
63
- extra = "{length: " + type.getLength() + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
64
- }
65
- else if (type.getQualifiedName() !== undefined) {
66
- extra = "{qualifiedName: \"" + type.getQualifiedName() + "\"}";
67
- }
68
- }
69
- else if (type instanceof abaplint.BasicTypes.NumericType) {
70
- resolved = "Numc";
71
- if (type.getLength() !== 1) {
72
- extra = "{length: " + type.getLength() + "}";
73
- }
74
- }
75
- else if (type instanceof abaplint.BasicTypes.PackedType) {
76
- resolved = "Packed";
77
- extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + "}";
78
- }
79
- else if (type instanceof abaplint.BasicTypes.NumericGenericType) {
80
- resolved = "Packed";
81
- extra = "{length: 8, decimals: 0}";
82
- }
83
- else if (type instanceof abaplint.BasicTypes.XStringType) {
84
- resolved = "XString";
85
- }
86
- else if (type instanceof abaplint.BasicTypes.XSequenceType) {
87
- // if not supplied itsa a Hex(1)
88
- resolved = "Hex";
89
- }
90
- else if (type instanceof abaplint.BasicTypes.HexType) {
91
- resolved = "Hex";
92
- if (type.getLength() !== 1) {
93
- extra = "{length: " + type.getLength() + "}";
94
- }
95
- }
96
- else if (type instanceof abaplint.BasicTypes.FloatType) {
97
- resolved = "Float";
98
- }
99
- else if (type instanceof abaplint.BasicTypes.UnknownType) {
100
- return `(() => { throw "Unknown type: ${type.getError()}" })()`;
101
- }
102
- else if (type instanceof abaplint.BasicTypes.VoidType) {
103
- return `(() => { throw "Void type: ${type.getVoided()}" })()`;
104
- }
105
- else {
106
- resolved = "typeTodo" + type.constructor.name;
107
- }
108
- return "new abap.types." + resolved + "(" + extra + ")";
109
- }
110
- }
111
- exports.TranspileTypes = TranspileTypes;
112
3
  //# sourceMappingURL=types.js.map
@@ -5,9 +5,9 @@ const abaplint = require("@abaplint/core");
5
5
  class UnitTest {
6
6
  // todo, move this somewhere else, its much more than just unit test relevant
7
7
  initializationScript(reg, dbSetup) {
8
- let ret = `import runtime from "@abaplint/runtime";
9
- global.abap = new runtime.ABAP();
10
- ${this.buildImports(reg)}
8
+ let ret = `import runtime from "@abaplint/runtime";
9
+ global.abap = new runtime.ABAP();
10
+ ${this.buildImports(reg)}
11
11
  export async function initializeABAP(settings) {\n`;
12
12
  if (dbSetup === "") {
13
13
  ret += `// no database artifacts, skip DB initialization\n`;
@@ -19,20 +19,20 @@ export async function initializeABAP(settings) {\n`;
19
19
  return ret;
20
20
  }
21
21
  unitTestScript(reg, skip, _only) {
22
- let ret = `import fs from "fs";
23
- import path from "path";
24
- import {dirname} from 'path';
25
- import {fileURLToPath} from 'url';
26
- const __dirname = dirname(fileURLToPath(import.meta.url));
27
- import {initializeABAP} from "./init.mjs";
28
- import runtime from "@abaplint/runtime";
29
-
30
- async function run() {
31
- await initializeABAP();
32
- const unit = new runtime.UnitTestResult();
33
- let clas;
34
- let locl;
35
- let meth;
22
+ let ret = `import fs from "fs";
23
+ import path from "path";
24
+ import {dirname} from 'path';
25
+ import {fileURLToPath} from 'url';
26
+ const __dirname = dirname(fileURLToPath(import.meta.url));
27
+ import {initializeABAP} from "./init.mjs";
28
+ import runtime from "@abaplint/runtime";
29
+
30
+ async function run() {
31
+ await initializeABAP();
32
+ const unit = new runtime.UnitTestResult();
33
+ let clas;
34
+ let locl;
35
+ let meth;
36
36
  try {\n`;
37
37
  for (const obj of reg.getObjects()) {
38
38
  if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
@@ -47,8 +47,8 @@ try {\n`;
47
47
  || def.methods.length === 0) {
48
48
  continue;
49
49
  }
50
- ret += `{
51
- const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
50
+ ret += `{
51
+ const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
52
52
  locl = clas.addTestClass("${def.name}");\n`;
53
53
  ret += `if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
54
54
  for (const m of def.methods) {
@@ -76,24 +76,24 @@ locl = clas.addTestClass("${def.name}");\n`;
76
76
  }
77
77
  }
78
78
  }
79
- ret += `// -------------------END-------------------
80
- console.log(abap.console.get());
81
- fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
82
- } catch (e) {
83
- if (meth) {
84
- meth.fail();
85
- }
86
- console.log(abap.console.get());
87
- fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
88
- throw e;
89
- }
90
- }
91
-
92
- run().then(() => {
93
- process.exit(0);
94
- }).catch((err) => {
95
- console.log(err);
96
- process.exit(1);
79
+ ret += `// -------------------END-------------------
80
+ console.log(abap.console.get());
81
+ fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
82
+ } catch (e) {
83
+ if (meth) {
84
+ meth.fail();
85
+ }
86
+ console.log(abap.console.get());
87
+ fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
88
+ throw e;
89
+ }
90
+ }
91
+
92
+ run().then(() => {
93
+ process.exit(0);
94
+ }).catch((err) => {
95
+ console.log(err);
96
+ process.exit(1);
97
97
  });`;
98
98
  return ret;
99
99
  }
@@ -102,6 +102,11 @@ run().then(() => {
102
102
  // todo, some sorting might be required? eg. a class constructor using constant from interface?
103
103
  // temporary sorting: by filename
104
104
  const list = [];
105
+ for (const obj of reg.getObjects()) {
106
+ if (obj instanceof abaplint.Objects.Table) {
107
+ list.push(`await import("./${obj.getName().toLowerCase()}.tabl.mjs");`);
108
+ }
109
+ }
105
110
  for (const obj of reg.getObjects()) {
106
111
  if (obj instanceof abaplint.Objects.FunctionGroup) {
107
112
  for (const m of obj.getModules()) {
@@ -1,5 +1,5 @@
1
1
  import { Issue, IRegistry, IConfig } from "@abaplint/core";
2
- import { ITranspilerOptions } from ".";
2
+ import { ITranspilerOptions } from "./types";
3
3
  export declare const config: IConfig;
4
4
  export declare class Validation {
5
5
  private readonly options;
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "@abaplint/transpiler",
3
- "version": "1.7.14",
4
- "description": "Transpiler",
5
- "main": "build/src/index.js",
6
- "typings": "build/src/index.d.ts",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/abaplint/transpiler.git"
10
- },
11
- "scripts": {
12
- "compile": "tsc",
13
- "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
14
- "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
15
- "test": "npm run compile && mocha"
16
- },
17
- "mocha": {
18
- "recursive": true,
19
- "reporter": "progress",
20
- "spec": "build/test/**/*.js",
21
- "require": "source-map-support/register"
22
- },
23
- "keywords": [
24
- "ABAP",
25
- "abaplint"
26
- ],
27
- "author": "abaplint",
28
- "license": "MIT",
29
- "dependencies": {
30
- "@abaplint/core": "^2.83.23",
31
- "source-map": "^0.7.3"
32
- },
33
- "devDependencies": {
34
- "@types/chai": "^4.3.0",
35
- "@types/mocha": "^9.0.0",
36
- "chai": "^4.3.4",
37
- "mocha": "^9.1.3",
38
- "source-map-support": "^0.5.21",
39
- "typescript": "^4.5.4"
40
- }
41
- }
1
+ {
2
+ "name": "@abaplint/transpiler",
3
+ "version": "1.7.18",
4
+ "description": "Transpiler",
5
+ "main": "build/src/index.js",
6
+ "typings": "build/src/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/abaplint/transpiler.git"
10
+ },
11
+ "scripts": {
12
+ "compile": "tsc",
13
+ "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
14
+ "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
15
+ "test": "npm run compile && mocha"
16
+ },
17
+ "mocha": {
18
+ "recursive": true,
19
+ "reporter": "progress",
20
+ "spec": "build/test/**/*.js",
21
+ "require": "source-map-support/register"
22
+ },
23
+ "keywords": [
24
+ "ABAP",
25
+ "abaplint"
26
+ ],
27
+ "author": "abaplint",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "@abaplint/core": "^2.83.23",
31
+ "source-map": "^0.7.3"
32
+ },
33
+ "devDependencies": {
34
+ "@types/chai": "^4.3.0",
35
+ "@types/mocha": "^9.0.0",
36
+ "chai": "^4.3.4",
37
+ "mocha": "^9.1.4",
38
+ "source-map-support": "^0.5.21",
39
+ "typescript": "^4.5.4"
40
+ }
41
+ }