@abaplint/transpiler 2.7.71 → 2.7.73

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.
@@ -1,7 +1,7 @@
1
1
  import * as abaplint from "@abaplint/core";
2
2
  import { config } from "./validation";
3
- import { IFile, IOutput, IProgress, ITranspilerOptions, IOutputFile } from "./types";
4
- export { config, ITranspilerOptions, IFile, IProgress, IOutputFile, IOutput };
3
+ import { IFile, IOutput, IProgress, ITranspilerOptions, IOutputFile, UnknownTypesEnum } from "./types";
4
+ export { config, ITranspilerOptions, IFile, IProgress, IOutputFile, IOutput, UnknownTypesEnum };
5
5
  export declare class Transpiler {
6
6
  private readonly options;
7
7
  constructor(options?: ITranspilerOptions);
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transpiler = exports.config = void 0;
3
+ exports.Transpiler = exports.UnknownTypesEnum = 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
7
  const unit_test_1 = require("./unit_test");
8
8
  const keywords_1 = require("./keywords");
9
+ const types_1 = require("./types");
10
+ Object.defineProperty(exports, "UnknownTypesEnum", { enumerable: true, get: function () { return types_1.UnknownTypesEnum; } });
9
11
  const db_1 = require("./db");
10
12
  const handle_table_1 = require("./handlers/handle_table");
11
13
  const handle_abap_1 = require("./handlers/handle_abap");
@@ -24,7 +26,7 @@ class Transpiler {
24
26
  this.options = {};
25
27
  }
26
28
  if (this.options.unknownTypes === undefined) {
27
- this.options.unknownTypes = "compileError";
29
+ this.options.unknownTypes = types_1.UnknownTypesEnum.compileError;
28
30
  }
29
31
  }
30
32
  // workaround for web/webpack
@@ -5,6 +5,7 @@ const abaplint = require("@abaplint/core");
5
5
  const chunk_1 = require("../chunk");
6
6
  const expressions_1 = require("../expressions");
7
7
  const unique_identifier_1 = require("../unique_identifier");
8
+ const types_1 = require("../types");
8
9
  class CreateObjectTranspiler {
9
10
  transpile(node, traversal) {
10
11
  var _a, _b;
@@ -66,7 +67,7 @@ class CreateObjectTranspiler {
66
67
  return "object";
67
68
  }
68
69
  else if (!(type instanceof abaplint.BasicTypes.ObjectReferenceType)) {
69
- if (((_a = traversal.options) === null || _a === void 0 ? void 0 : _a.unknownTypes) !== "runtimeError") {
70
+ if (((_a = traversal.options) === null || _a === void 0 ? void 0 : _a.unknownTypes) !== types_1.UnknownTypesEnum.runtimeError) {
70
71
  throw new Error(`CreateObjectTranspiler, target variable "${target === null || target === void 0 ? void 0 : target.concatTokens()}" not a object reference`);
71
72
  }
72
73
  else {
@@ -48,7 +48,7 @@ class TryTranspiler {
48
48
  const catchNames = catchStatement.findDirectExpressions(abaplint.Expressions.ClassName).map(e => traversal.lookupClassOrInterface(e.concatTokens(), e.getFirstToken()));
49
49
  ret += first ? "" : " else ";
50
50
  first = false;
51
- ret += "if (" + (catchNames === null || catchNames === void 0 ? void 0 : catchNames.map(n => "e instanceof " + n).join(" || ")) + ") {\n";
51
+ ret += "if (" + (catchNames === null || catchNames === void 0 ? void 0 : catchNames.map(n => "(" + n + " && e instanceof " + n + ")").join(" || ")) + ") {\n";
52
52
  const intoNode = catchStatement.findExpressionAfterToken("INTO");
53
53
  if (intoNode) {
54
54
  ret += traversal.traverse(intoNode).getCode() + ".set(e);\n";
@@ -36,6 +36,10 @@ export interface IOutputFile {
36
36
  requires: readonly IRequire[];
37
37
  exports: readonly string[];
38
38
  }
39
+ export declare enum UnknownTypesEnum {
40
+ compileError = "compileError",
41
+ runtimeError = "runtimeError"
42
+ }
39
43
  export interface ITranspilerOptions {
40
44
  /** ignore syntax check, used for internal testing */
41
45
  ignoreSyntaxCheck?: boolean;
@@ -46,7 +50,7 @@ export interface ITranspilerOptions {
46
50
  /** skip outputing constants, used for internal testing */
47
51
  skipConstants?: boolean;
48
52
  /** sets behavior for unknown types, either fail at compile- or run-time */
49
- unknownTypes?: "compileError" | "runtimeError";
53
+ unknownTypes?: UnknownTypesEnum;
50
54
  /** list of unit tests to skip */
51
55
  skip?: TestMethodList;
52
56
  /** extra setup script to be executed during initialization */
@@ -1,3 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownTypesEnum = void 0;
4
+ var UnknownTypesEnum;
5
+ (function (UnknownTypesEnum) {
6
+ UnknownTypesEnum["compileError"] = "compileError";
7
+ UnknownTypesEnum["runtimeError"] = "runtimeError";
8
+ })(UnknownTypesEnum || (exports.UnknownTypesEnum = UnknownTypesEnum = {}));
3
9
  //# sourceMappingURL=types.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Validation = exports.config = void 0;
4
4
  const core_1 = require("@abaplint/core");
5
5
  const keywords_1 = require("./keywords");
6
+ const types_1 = require("./types");
6
7
  exports.config = {
7
8
  "global": {
8
9
  "files": "/**/*.*",
@@ -103,7 +104,7 @@ class Validation {
103
104
  exports.config.rules["forbidden_identifier"]["check"].push(add);
104
105
  }
105
106
  }
106
- if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.unknownTypes) === "runtimeError") {
107
+ if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.unknownTypes) === types_1.UnknownTypesEnum.runtimeError) {
107
108
  // this is not a constant, just a regex that happens to not match anything
108
109
  exports.config.syntax.errorNamespace = "VOID_EVERYTHING";
109
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.7.71",
3
+ "version": "2.7.73",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",