@abaplint/transpiler 1.7.5 → 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.
@@ -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
  }
@@ -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 = traversal.traverse(s).getCode();
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 = "";
@@ -4,28 +4,28 @@ exports.UnitTest = void 0;
4
4
  const abaplint = require("@abaplint/core");
5
5
  class UnitTest {
6
6
  initializationScript(reg, dbSetup) {
7
- return `import runtime from "@abaplint/runtime";
8
- global.abap = new runtime.ABAP();
9
- ${this.buildImports(reg)}
10
- export async function initDB() {
11
- return global.abap.initDB(\`${dbSetup}\`);
7
+ return `import runtime from "@abaplint/runtime";
8
+ global.abap = new runtime.ABAP();
9
+ ${this.buildImports(reg)}
10
+ export async function initDB() {
11
+ return global.abap.initDB(\`${dbSetup}\`);
12
12
  }`;
13
13
  }
14
14
  unitTestScript(reg, skip) {
15
- let ret = `import fs from "fs";
16
- import path from "path";
17
- import {dirname} from 'path';
18
- import {fileURLToPath} from 'url';
19
- const __dirname = dirname(fileURLToPath(import.meta.url));
20
- import {initDB} from "./init.mjs";
21
- import runtime from "@abaplint/runtime";
22
-
23
- async function run() {
24
- await initDB();
25
- const unit = new runtime.UnitTestResult();
26
- let clas;
27
- let locl;
28
- let meth;
15
+ let ret = `import fs from "fs";
16
+ import path from "path";
17
+ import {dirname} from 'path';
18
+ import {fileURLToPath} from 'url';
19
+ const __dirname = dirname(fileURLToPath(import.meta.url));
20
+ import {initDB} from "./init.mjs";
21
+ import runtime from "@abaplint/runtime";
22
+
23
+ async function run() {
24
+ await initDB();
25
+ const unit = new runtime.UnitTestResult();
26
+ let clas;
27
+ let locl;
28
+ let meth;
29
29
  try {\n`;
30
30
  for (const obj of reg.getObjects()) {
31
31
  if (reg.isDependency(obj) || !(obj instanceof abaplint.Objects.Class)) {
@@ -40,8 +40,8 @@ try {\n`;
40
40
  || def.methods.length === 0) {
41
41
  continue;
42
42
  }
43
- ret += `{
44
- const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
43
+ ret += `{
44
+ const {${def.name}} = await import("./${obj.getName().toLowerCase()}.${obj.getType().toLowerCase()}.testclasses.mjs");
45
45
  locl = clas.addTestClass("${def.name}");\n`;
46
46
  ret += `if (${def.name}.class_setup) await ${def.name}.class_setup();\n`;
47
47
  for (const m of def.methods) {
@@ -69,24 +69,24 @@ locl = clas.addTestClass("${def.name}");\n`;
69
69
  }
70
70
  }
71
71
  }
72
- ret += `// -------------------END-------------------
73
- console.log(abap.console.get());
74
- fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
75
- } catch (e) {
76
- if (meth) {
77
- meth.fail();
78
- }
79
- console.log(abap.console.get());
80
- fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
81
- throw e;
82
- }
83
- }
84
-
85
- run().then(() => {
86
- process.exit();
87
- }).catch((err) => {
88
- console.log(err);
89
- process.exit(1);
72
+ ret += `// -------------------END-------------------
73
+ console.log(abap.console.get());
74
+ fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
75
+ } catch (e) {
76
+ if (meth) {
77
+ meth.fail();
78
+ }
79
+ console.log(abap.console.get());
80
+ fs.writeFileSync(__dirname + path.sep + "output.xml", unit.xUnitXML());
81
+ throw e;
82
+ }
83
+ }
84
+
85
+ run().then(() => {
86
+ process.exit();
87
+ }).catch((err) => {
88
+ console.log(err);
89
+ process.exit(1);
90
90
  });`;
91
91
  return ret;
92
92
  }
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "@abaplint/transpiler",
3
- "version": "1.7.5",
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.21",
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.6",
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.21",
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
+ }