@abaplint/transpiler 2.12.34 → 2.13.0

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.
@@ -19,7 +19,7 @@ class HandleDataElement {
19
19
  }
20
20
  const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
21
21
  "objectType": "DTEL",
22
- "type": ${transpile_types_1.TranspileTypes.toType(type)},
22
+ "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type)},
23
23
  "domain": ${JSON.stringify(obj.getDomainName())},
24
24
  "fixedValues": ${JSON.stringify(fixedValues)},
25
25
  "description": ${JSON.stringify(obj.getDescription())},
@@ -13,7 +13,7 @@ class HandleTable {
13
13
  const type = obj.parseType(reg);
14
14
  const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
15
15
  "objectType": "TABL",
16
- "type": ${transpile_types_1.TranspileTypes.toType(type)},
16
+ "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type)},
17
17
  "keyFields": ${JSON.stringify(obj.listKeys(reg))},
18
18
  "description": ${JSON.stringify(obj.getDescription())},
19
19
  };`);
@@ -12,7 +12,7 @@ class HandleTableType {
12
12
  const type = obj.parseType(reg);
13
13
  const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
14
14
  "objectType": "TTYP",
15
- "type": ${transpile_types_1.TranspileTypes.toType(type)},
15
+ "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type)},
16
16
  "description": ${JSON.stringify(obj.getDescription())},
17
17
  };`);
18
18
  const output = {
@@ -13,7 +13,7 @@ class HandleView {
13
13
  const type = obj.parseType(reg);
14
14
  const chunk = new chunk_1.Chunk().appendString(`abap.DDIC["${obj.getName().toUpperCase()}"] = {
15
15
  "objectType": "VIEW",
16
- "type": ${transpile_types_1.TranspileTypes.toType(type)},
16
+ "type": ${transpile_types_1.TranspileTypes.toTypeFunction(type)},
17
17
  };`);
18
18
  // todo, "keyFields": ${JSON.stringify(obj.listKeys())},
19
19
  const output = {
@@ -135,6 +135,8 @@ export * from "./sort_dataset";
135
135
  export * from "./sort";
136
136
  export * from "./split";
137
137
  export * from "./start_of_selection";
138
+ export * from "./load_of_program";
139
+ export * from "./stop";
138
140
  export * from "./submit";
139
141
  export * from "./subtract";
140
142
  export * from "./at_line_selection";
@@ -151,6 +151,8 @@ __exportStar(require("./sort_dataset"), exports);
151
151
  __exportStar(require("./sort"), exports);
152
152
  __exportStar(require("./split"), exports);
153
153
  __exportStar(require("./start_of_selection"), exports);
154
+ __exportStar(require("./load_of_program"), exports);
155
+ __exportStar(require("./stop"), exports);
154
156
  __exportStar(require("./submit"), exports);
155
157
  __exportStar(require("./subtract"), exports);
156
158
  __exportStar(require("./at_line_selection"), exports);
@@ -0,0 +1,6 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { Chunk } from "../chunk";
3
+ import { IStatementTranspiler } from "./_statement_transpiler";
4
+ export declare class LoadOfProgramTranspiler implements IStatementTranspiler {
5
+ transpile(_node: abaplint.Nodes.StatementNode): Chunk;
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoadOfProgramTranspiler = void 0;
4
+ const chunk_1 = require("../chunk");
5
+ class LoadOfProgramTranspiler {
6
+ transpile(_node) {
7
+ return new chunk_1.Chunk(`throw new Error("LOAD-OF-PROGRAM not supported, transpiler");`);
8
+ }
9
+ }
10
+ exports.LoadOfProgramTranspiler = LoadOfProgramTranspiler;
11
+ //# sourceMappingURL=load_of_program.js.map
@@ -0,0 +1,7 @@
1
+ import * as abaplint from "@abaplint/core";
2
+ import { IStatementTranspiler } from "./_statement_transpiler";
3
+ import { Traversal } from "../traversal";
4
+ import { Chunk } from "../chunk";
5
+ export declare class StopTranspiler implements IStatementTranspiler {
6
+ transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StopTranspiler = void 0;
4
+ const chunk_1 = require("../chunk");
5
+ class StopTranspiler {
6
+ transpile(_node, _traversal) {
7
+ return new chunk_1.Chunk(`throw new Error("Stop, not supported, transpiler");`);
8
+ }
9
+ }
10
+ exports.StopTranspiler = StopTranspiler;
11
+ //# sourceMappingURL=stop.js.map
@@ -26,7 +26,7 @@ class SelectTranspiler {
26
26
  // note: this implementation SELECTs everything into memory, which might be bad, and sometimes not correct
27
27
  const targetName = unique_identifier_1.UniqueIdentifier.get();
28
28
  const loopName = unique_identifier_1.UniqueIdentifier.get();
29
- ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${from}"].type);\n`);
29
+ ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${from}"].type());\n`);
30
30
  ret.appendChunk(new select_1.SelectTranspiler().transpile(selectStatement, traversal, targetName));
31
31
  // todo: optimize, it should do real streaming?
32
32
  const packageSize = node.findFirstExpression(abaplint.Expressions.SelectLoop)?.findExpressionAfterToken("SIZE");
@@ -2,5 +2,7 @@ import * as abaplint from "@abaplint/core";
2
2
  export declare class TranspileTypes {
3
3
  static declare(t: abaplint.TypedIdentifier): string;
4
4
  static declareStaticSkipVoid(pre: string, t: abaplint.TypedIdentifier): string;
5
+ /** this returns a function, so it doesnt throw when loading the code, only when running */
6
+ static toTypeFunction(type: abaplint.AbstractType): string;
5
7
  static toType(type: abaplint.AbstractType): string;
6
8
  }
@@ -18,6 +18,17 @@ class TranspileTypes {
18
18
  }
19
19
  return pre + t.getName().toLowerCase() + " = " + code + ";\n";
20
20
  }
21
+ /** this returns a function, so it doesnt throw when loading the code, only when running */
22
+ static toTypeFunction(type) {
23
+ if (type instanceof abaplint.BasicTypes.UnknownType) {
24
+ return `() => { throw new Error("Unknown type: ${type.getError()}") }`;
25
+ }
26
+ else if (type instanceof abaplint.BasicTypes.VoidType) {
27
+ return `() => { throw new Error("Void type: ${type.getVoided()}") }`;
28
+ }
29
+ // return singleton,
30
+ return "(() => { let _t; return () => (_t ??= " + this.toType(type) + "); })()";
31
+ }
21
32
  static toType(type) {
22
33
  let resolved = "";
23
34
  let extra = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.12.34",
3
+ "version": "2.13.0",
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.117.1",
32
+ "@abaplint/core": "^2.118.1",
33
33
  "source-map": "^0.7.6"
34
34
  },
35
35
  "devDependencies": {