@abaplint/transpiler-cli 2.7.81 → 2.7.83

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.
Files changed (2) hide show
  1. package/build/bundle.js +127 -31
  2. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -7573,7 +7573,8 @@ class TypeTableKey extends combi_1.Expression {
7573
7573
  const defaultKey = "DEFAULT KEY";
7574
7574
  const emptyKey = (0, combi_1.ver)(version_1.Version.v740sp02, "EMPTY KEY");
7575
7575
  const components = (0, combi_1.plus)((0, combi_1.alt)((0, combi_1.seq)("WITH", (0, combi_1.failStar)()), _1.FieldSub));
7576
- const key = (0, combi_1.seq)("WITH", (0, combi_1.opt)(uniqueness), (0, combi_1.altPrio)(defaultKey, emptyKey, (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("SORTED", "HASHED")), "KEY", (0, combi_1.alt)((0, combi_1.seq)(_1.Field, "COMPONENTS", components), components))), (0, combi_1.optPrio)("READ-ONLY"));
7576
+ const further = (0, combi_1.seq)((0, combi_1.alt)("WITHOUT", "WITH"), "FURTHER SECONDARY KEYS");
7577
+ const key = (0, combi_1.seq)("WITH", (0, combi_1.opt)(uniqueness), (0, combi_1.altPrio)(defaultKey, emptyKey, (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("SORTED", "HASHED")), "KEY", (0, combi_1.alt)((0, combi_1.seq)(_1.Field, "COMPONENTS", components), components))), (0, combi_1.optPrio)(further), (0, combi_1.optPrio)("READ-ONLY"));
7577
7578
  return key;
7578
7579
  }
7579
7580
  }
@@ -15700,7 +15701,7 @@ class TypeMesh {
15700
15701
  const on = (0, combi_1.seq)("ON", expressions_1.NamespaceSimpleName, "=", expressions_1.NamespaceSimpleName, (0, combi_1.star)((0, combi_1.seq)("AND", expressions_1.NamespaceSimpleName, "=", expressions_1.NamespaceSimpleName)));
15701
15702
  const using = (0, combi_1.seq)("USING KEY", expressions_1.NamespaceSimpleName);
15702
15703
  const association = (0, combi_1.seq)("ASSOCIATION", expressions_1.NamespaceSimpleName, "TO", expressions_1.NamespaceSimpleName, (0, combi_1.plus)(on));
15703
- const ret = (0, combi_1.ver)(version_1.Version.v751, (0, combi_1.seq)("TYPES", expressions_1.NamespaceSimpleName, "TYPE", expressions_1.TypeName, (0, combi_1.plus)(association), (0, combi_1.opt)(using)));
15704
+ const ret = (0, combi_1.ver)(version_1.Version.v751, (0, combi_1.seq)("TYPES", expressions_1.NamespaceSimpleName, "TYPE", (0, combi_1.opt)("REF TO"), expressions_1.TypeName, (0, combi_1.plus)(association), (0, combi_1.opt)(using)));
15704
15705
  return ret;
15705
15706
  }
15706
15707
  }
@@ -30031,6 +30032,7 @@ const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "./node_modu
30031
30032
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
30032
30033
  class Sort {
30033
30034
  runSyntax(node, scope, filename) {
30035
+ var _a, _b;
30034
30036
  for (const s of node.findDirectExpressions(Expressions.Dynamic)) {
30035
30037
  new dynamic_1.Dynamic().runSyntax(s, scope, filename);
30036
30038
  }
@@ -30038,6 +30040,9 @@ class Sort {
30038
30040
  if (tnode) {
30039
30041
  const ttype = new target_1.Target().runSyntax(tnode, scope, filename);
30040
30042
  if (ttype instanceof basic_1.TableType) {
30043
+ if (((_b = (_a = ttype.getOptions()) === null || _a === void 0 ? void 0 : _a.primaryKey) === null || _b === void 0 ? void 0 : _b.type) === basic_1.TableAccessType.sorted) {
30044
+ throw new Error(`Sorted table, already sorted`);
30045
+ }
30041
30046
  const rowType = ttype.getRowType();
30042
30047
  if (!(rowType instanceof basic_1.VoidType)
30043
30048
  && !(rowType instanceof basic_1.UnknownType)
@@ -47792,7 +47797,7 @@ class Registry {
47792
47797
  }
47793
47798
  static abaplintVersion() {
47794
47799
  // magic, see build script "version.sh"
47795
- return "2.102.28";
47800
+ return "2.102.29";
47796
47801
  }
47797
47802
  getDDICReferences() {
47798
47803
  return this.ddicReferences;
@@ -70342,9 +70347,16 @@ exports.ComponentChainSimpleTranspiler = void 0;
70342
70347
  const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
70343
70348
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
70344
70349
  const traversal_1 = __webpack_require__(/*! ../traversal */ "./node_modules/@abaplint/transpiler/build/src/traversal.js");
70350
+ const field_length_1 = __webpack_require__(/*! ./field_length */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_length.js");
70351
+ const field_offset_1 = __webpack_require__(/*! ./field_offset */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_offset.js");
70345
70352
  class ComponentChainSimpleTranspiler {
70353
+ constructor(prefix = "") {
70354
+ this.prefix = "";
70355
+ this.prefix = prefix;
70356
+ }
70346
70357
  transpile(node, traversal) {
70347
- const ret = new chunk_1.Chunk();
70358
+ const offset = [];
70359
+ let ret = new chunk_1.Chunk();
70348
70360
  for (const c of node.getChildren()) {
70349
70361
  const type = c.get();
70350
70362
  if (type instanceof core_1.Expressions.ComponentName) {
@@ -70354,11 +70366,26 @@ class ComponentChainSimpleTranspiler {
70354
70366
  field = interfaceName + "$" + field;
70355
70367
  }
70356
70368
  field = traversal_1.Traversal.escapeNamespace(field).replace("~", "$");
70357
- ret.append(field, c, traversal);
70369
+ ret.append(this.prefix + field, c, traversal);
70370
+ this.prefix = "";
70358
70371
  }
70359
70372
  else if (type instanceof core_1.Expressions.ArrowOrDash) {
70360
70373
  ret.append(".get().", c, traversal);
70361
70374
  }
70375
+ else if (c instanceof core_1.Nodes.ExpressionNode && c.get() instanceof core_1.Expressions.FieldOffset) {
70376
+ offset.push("offset: " + new field_offset_1.FieldOffsetTranspiler().transpile(c, traversal).getCode());
70377
+ }
70378
+ else if (c instanceof core_1.Nodes.ExpressionNode && c.get() instanceof core_1.Expressions.FieldLength) {
70379
+ const len = new field_length_1.FieldLengthTranspiler().transpile(c, traversal).getCode();
70380
+ if (len !== "*") {
70381
+ offset.push("length: " + len);
70382
+ }
70383
+ }
70384
+ }
70385
+ if (offset.length > 0) {
70386
+ const pre = "new abap.OffsetLength(";
70387
+ const post = ", {" + offset.join(", ") + "})";
70388
+ ret = new chunk_1.Chunk().appendString(pre).appendChunk(ret).appendString(post);
70362
70389
  }
70363
70390
  return ret;
70364
70391
  }
@@ -70380,45 +70407,49 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
70380
70407
  exports.ComponentCompareTranspiler = void 0;
70381
70408
  const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
70382
70409
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
70410
+ const component_chain_simple_1 = __webpack_require__(/*! ./component_chain_simple */ "./node_modules/@abaplint/transpiler/build/src/expressions/component_chain_simple.js");
70383
70411
  class ComponentCompareTranspiler {
70384
70412
  transpile(node, traversal) {
70385
70413
  const concat = node.concatTokens().toUpperCase();
70386
70414
  const pre = concat.startsWith("NOT") ? "!" : "";
70387
70415
  const componentExpression = node.findDirectExpression(core_1.Expressions.ComponentChainSimple);
70388
- const component = traversal.traverse(componentExpression).getCode();
70416
+ if (componentExpression === undefined) {
70417
+ throw new Error("unexpected, ComponentCompareTranspiler");
70418
+ }
70419
+ const component = new component_chain_simple_1.ComponentChainSimpleTranspiler("I.").transpile(componentExpression, traversal).getCode();
70389
70420
  if (node.findDirectExpression(core_1.Expressions.CompareOperator)) {
70390
70421
  const compare = traversal.traverse(node.findDirectExpression(core_1.Expressions.CompareOperator)).getCode();
70391
70422
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source)).getCode();
70392
- return new chunk_1.Chunk(`(I) => {return ${pre}abap.compare.${compare}(I.${component}, ${source});}`);
70423
+ return new chunk_1.Chunk(`(I) => {return ${pre}abap.compare.${compare}(${component}, ${source});}`);
70393
70424
  }
70394
70425
  if ((concat.startsWith("NOT") && concat.endsWith("IS INITIAL"))
70395
70426
  || concat.endsWith("IS NOT INITIAL")) {
70396
- return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component}) === false;}`);
70427
+ return new chunk_1.Chunk(`(I) => {return abap.compare.initial(${component}) === false;}`);
70397
70428
  }
70398
70429
  else if (concat.endsWith("IS INITIAL")) {
70399
- return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component});}`);
70430
+ return new chunk_1.Chunk(`(I) => {return abap.compare.initial(${component});}`);
70400
70431
  }
70401
70432
  if (concat.startsWith((componentExpression === null || componentExpression === void 0 ? void 0 : componentExpression.concatTokens().toUpperCase()) + " IN ")) {
70402
70433
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source)).getCode();
70403
- return new chunk_1.Chunk(`(I) => {return ${pre}abap.compare.in(I.${component}, ${source});}`);
70434
+ return new chunk_1.Chunk(`(I) => {return ${pre}abap.compare.in(${component}, ${source});}`);
70404
70435
  }
70405
70436
  else if (concat.startsWith((componentExpression === null || componentExpression === void 0 ? void 0 : componentExpression.concatTokens().toUpperCase()) + " NOT IN ")) {
70406
70437
  const source = traversal.traverse(node.findDirectExpression(core_1.Expressions.Source)).getCode();
70407
- return new chunk_1.Chunk(`(I) => {return !abap.compare.in(I.${component}, ${source});}`);
70438
+ return new chunk_1.Chunk(`(I) => {return !abap.compare.in(${component}, ${source});}`);
70408
70439
  }
70409
70440
  if ((concat.startsWith("NOT") && concat.endsWith("IS BOUND"))
70410
70441
  || concat.endsWith("IS NOT BOUND")) {
70411
- return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component});}`);
70442
+ return new chunk_1.Chunk(`(I) => {return abap.compare.initial(${component});}`);
70412
70443
  }
70413
70444
  else if (concat.endsWith("IS BOUND")) {
70414
- return new chunk_1.Chunk(`(I) => {return abap.compare.initial(I.${component}) === false;}`);
70445
+ return new chunk_1.Chunk(`(I) => {return abap.compare.initial(${component}) === false;}`);
70415
70446
  }
70416
70447
  if ((concat.startsWith("NOT") && concat.endsWith("IS ASSIGNED"))
70417
70448
  || concat.endsWith("IS NOT ASSIGNED")) {
70418
- return new chunk_1.Chunk(`(I) => {return abap.compare.assigned(I.${component}) === false;}`);
70449
+ return new chunk_1.Chunk(`(I) => {return abap.compare.assigned(${component}) === false;}`);
70419
70450
  }
70420
70451
  else if (concat.endsWith("IS ASSIGNED")) {
70421
- return new chunk_1.Chunk(`(I) => {return abap.compare.assigned(I.${component});}`);
70452
+ return new chunk_1.Chunk(`(I) => {return abap.compare.assigned(${component});}`);
70422
70453
  }
70423
70454
  return new chunk_1.Chunk("ComponentCompareTodo");
70424
70455
  }
@@ -72618,7 +72649,7 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
72618
72649
  class TargetTranspiler {
72619
72650
  transpile(node, traversal) {
72620
72651
  const offset = [];
72621
- const ret = new chunk_1.Chunk();
72652
+ let ret = new chunk_1.Chunk();
72622
72653
  const children = node.getChildren();
72623
72654
  for (let i = 0; i < children.length; i++) {
72624
72655
  const c = children[i];
@@ -72678,16 +72709,12 @@ class TargetTranspiler {
72678
72709
  }
72679
72710
  }
72680
72711
  }
72681
- let pre = "";
72682
- let post = "";
72683
72712
  if (offset.length > 0) {
72684
- pre = "new abap.OffsetLength(";
72685
- post = ", {" + offset.join(", ") + "})";
72713
+ const pre = "new abap.OffsetLength(";
72714
+ const post = ", {" + offset.join(", ") + "})";
72715
+ ret = new chunk_1.Chunk().appendString(pre).appendChunk(ret).appendString(post);
72686
72716
  }
72687
- return new chunk_1.Chunk()
72688
- .appendString(pre)
72689
- .appendChunk(ret)
72690
- .appendString(post);
72717
+ return ret;
72691
72718
  }
72692
72719
  }
72693
72720
  exports.TargetTranspiler = TargetTranspiler;
@@ -75966,10 +75993,26 @@ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abap
75966
75993
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
75967
75994
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
75968
75995
  class FormTranspiler {
75969
- transpile(node) {
75996
+ transpile(node, traversal) {
75970
75997
  unique_identifier_1.UniqueIdentifier.resetIndexBackup();
75971
75998
  const name = node.findFirstExpression(abaplint.Expressions.FormName).getFirstToken().getStr();
75972
- return new chunk_1.Chunk("async function " + name + "() {");
75999
+ const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
76000
+ const def = scope === null || scope === void 0 ? void 0 : scope.findFormDefinition(name);
76001
+ const ret = new chunk_1.Chunk("async function " + name + "(INPUT) {");
76002
+ const params = [];
76003
+ for (const p of (def === null || def === void 0 ? void 0 : def.getChangingParameters()) || []) {
76004
+ params.push(`let ${p.getName()} = INPUT.${p.getName()};`);
76005
+ }
76006
+ for (const p of (def === null || def === void 0 ? void 0 : def.getTablesParameters()) || []) {
76007
+ params.push(`let ${p.getName()} = INPUT.${p.getName()};`);
76008
+ }
76009
+ for (const p of (def === null || def === void 0 ? void 0 : def.getUsingParameters()) || []) {
76010
+ params.push(`let ${p.getName()} = INPUT.${p.getName()};`);
76011
+ }
76012
+ if (params.length > 0) {
76013
+ ret.appendString("\n" + params.join("\n"));
76014
+ }
76015
+ return ret;
75973
76016
  }
75974
76017
  }
75975
76018
  exports.FormTranspiler = FormTranspiler;
@@ -76787,7 +76830,11 @@ class LoopTranspiler {
76787
76830
  else if (compare.findDirectTokenByText("NOT")) {
76788
76831
  continue;
76789
76832
  }
76790
- const tchain = traversal.traverse(compare.findDirectExpression(abaplint.Expressions.ComponentChainSimple));
76833
+ const simple = compare.findDirectExpression(abaplint.Expressions.ComponentChainSimple);
76834
+ if ((simple === null || simple === void 0 ? void 0 : simple.getChildren().length) !== 1) {
76835
+ continue;
76836
+ }
76837
+ const tchain = traversal.traverse(simple);
76791
76838
  const tsource = traversal.traverse(compare.findDirectExpression(abaplint.Expressions.Source));
76792
76839
  topEquals[tchain.getCode()] = tsource.getCode();
76793
76840
  }
@@ -77410,19 +77457,61 @@ exports.ParameterTranspiler = ParameterTranspiler;
77410
77457
 
77411
77458
  Object.defineProperty(exports, "__esModule", ({ value: true }));
77412
77459
  exports.PerformTranspiler = void 0;
77460
+ /* eslint-disable max-len */
77413
77461
  const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
77414
77462
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
77415
77463
  class PerformTranspiler {
77416
- transpile(node, _traversal) {
77464
+ transpile(node, traversal) {
77465
+ var _a, _b, _c;
77417
77466
  const formName = node.findDirectExpression(abaplint.Expressions.FormName);
77418
77467
  if (formName === undefined) {
77419
77468
  return new chunk_1.Chunk(`throw new Error("PerformTranspiler FormName not found");`);
77420
77469
  }
77421
- // todo, parameters
77422
- if (node.concatTokens().toUpperCase().includes(" IN PROGRAM ")) {
77470
+ else if (node.concatTokens().toUpperCase().includes(" IN PROGRAM ")) {
77423
77471
  return new chunk_1.Chunk(`throw new Error("PerformTranspiler IN PROGRAM, transpiler todo");`);
77424
77472
  }
77425
- return new chunk_1.Chunk("await " + formName.concatTokens() + "();");
77473
+ let def = undefined;
77474
+ const scope = traversal.findCurrentScopeByToken(node.getFirstToken());
77475
+ for (const r of (scope === null || scope === void 0 ? void 0 : scope.getData().references) || []) {
77476
+ if (r.referenceType === abaplint.ReferenceType.FormReference
77477
+ && r.position.getStart().equals(formName.getFirstToken().getStart())
77478
+ && r.resolved instanceof abaplint.Types.FormDefinition) {
77479
+ def = r.resolved;
77480
+ }
77481
+ }
77482
+ // todo: pass by VALUE()
77483
+ const params = [];
77484
+ let index = 0;
77485
+ for (const t of ((_a = node.findDirectExpression(abaplint.Expressions.PerformTables)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(abaplint.Expressions.Source)) || []) {
77486
+ console.dir(t);
77487
+ const name = def === null || def === void 0 ? void 0 : def.getTablesParameters()[index].getName().toLowerCase();
77488
+ if (name === undefined) {
77489
+ continue;
77490
+ }
77491
+ params.push(`"${name}": ` + traversal.traverse(t).getCode());
77492
+ index++;
77493
+ }
77494
+ index = 0;
77495
+ for (const u of ((_b = node.findDirectExpression(abaplint.Expressions.PerformUsing)) === null || _b === void 0 ? void 0 : _b.findDirectExpressions(abaplint.Expressions.Source)) || []) {
77496
+ console.dir(u);
77497
+ const name = def === null || def === void 0 ? void 0 : def.getUsingParameters()[index].getName().toLowerCase();
77498
+ if (name === undefined) {
77499
+ continue;
77500
+ }
77501
+ params.push(`"${name}": ` + traversal.traverse(u).getCode());
77502
+ index++;
77503
+ }
77504
+ index = 0;
77505
+ for (const c of ((_c = node.findDirectExpression(abaplint.Expressions.PerformChanging)) === null || _c === void 0 ? void 0 : _c.findDirectExpressions(abaplint.Expressions.Source)) || []) {
77506
+ console.dir(c);
77507
+ const name = def === null || def === void 0 ? void 0 : def.getChangingParameters()[index].getName().toLowerCase();
77508
+ if (name === undefined) {
77509
+ continue;
77510
+ }
77511
+ params.push(`"${name}": ` + traversal.traverse(c).getCode());
77512
+ index++;
77513
+ }
77514
+ return new chunk_1.Chunk("await " + formName.concatTokens() + `({${params.join(",")}});`);
77426
77515
  }
77427
77516
  }
77428
77517
  exports.PerformTranspiler = PerformTranspiler;
@@ -80946,6 +81035,13 @@ class Traversal {
80946
81035
  }
80947
81036
  }
80948
81037
  }
81038
+ else if (c.get() instanceof abaplint.Expressions.AttributeName
81039
+ && context instanceof abaplint.BasicTypes.DataReference) {
81040
+ const type = context.getType();
81041
+ if (type instanceof abaplint.BasicTypes.StructureType) {
81042
+ context = type.getComponentByName(c.concatTokens());
81043
+ }
81044
+ }
80949
81045
  }
80950
81046
  return context;
80951
81047
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.7.81",
3
+ "version": "2.7.83",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -26,12 +26,12 @@
26
26
  "author": "abaplint",
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@abaplint/transpiler": "^2.7.81",
29
+ "@abaplint/transpiler": "^2.7.83",
30
30
  "@types/glob": "^7.2.0",
31
31
  "glob": "=7.2.0",
32
32
  "@types/progress": "^2.0.5",
33
- "@types/node": "^20.5.6",
34
- "@abaplint/core": "^2.102.28",
33
+ "@types/node": "^20.5.7",
34
+ "@abaplint/core": "^2.102.29",
35
35
  "progress": "^2.0.3",
36
36
  "webpack": "^5.88.2",
37
37
  "webpack-cli": "^5.1.4",