@abaplint/transpiler-cli 2.6.16 → 2.6.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.
Files changed (2) hide show
  1. package/build/bundle.js +73 -25
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -20454,16 +20454,24 @@ class TypeUtils {
20454
20454
  return false;
20455
20455
  }
20456
20456
  isAssignableStrict(source, target) {
20457
- var _a;
20457
+ var _a, _b;
20458
20458
  /*
20459
20459
  console.dir(source);
20460
20460
  console.dir(target);
20461
20461
  */
20462
- if (source instanceof basic_1.CharacterType && target instanceof basic_1.CharacterType) {
20463
- if (((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
20464
- return source.getLength() <= target.getLength();
20462
+ if (source instanceof basic_1.CharacterType) {
20463
+ if (target instanceof basic_1.CharacterType) {
20464
+ if (((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
20465
+ return source.getLength() <= target.getLength();
20466
+ }
20467
+ return source.getLength() === target.getLength();
20468
+ }
20469
+ else if (target instanceof basic_1.IntegerType) {
20470
+ if (((_b = source.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true) {
20471
+ return true;
20472
+ }
20473
+ return false;
20465
20474
  }
20466
- return source.getLength() === target.getLength();
20467
20475
  }
20468
20476
  else if (source instanceof basic_1.StringType && target instanceof basic_1.StructureType) {
20469
20477
  if (this.structureContainsString(target)) {
@@ -20471,6 +20479,19 @@ class TypeUtils {
20471
20479
  }
20472
20480
  return true;
20473
20481
  }
20482
+ else if (source instanceof basic_1.StructureType && target instanceof basic_1.StructureType) {
20483
+ const sourceComponents = source.getComponents();
20484
+ const targetComponents = target.getComponents();
20485
+ if (sourceComponents.length !== targetComponents.length) {
20486
+ return false;
20487
+ }
20488
+ for (let i = 0; i < sourceComponents.length; i++) {
20489
+ if (this.isAssignableStrict(sourceComponents[i].type, targetComponents[i].type) === false) {
20490
+ return false;
20491
+ }
20492
+ }
20493
+ return true;
20494
+ }
20474
20495
  return this.isAssignable(source, target);
20475
20496
  }
20476
20497
  isAssignable(source, target) {
@@ -20488,7 +20509,31 @@ class TypeUtils {
20488
20509
  return true;
20489
20510
  }
20490
20511
  else if (source instanceof basic_1.TableType) {
20491
- return this.isAssignableStrict(source.getRowType(), target.getRowType());
20512
+ const targetRowType = target.getRowType();
20513
+ const sourceRowType = source.getRowType();
20514
+ if (targetRowType instanceof basic_1.VoidType || targetRowType instanceof basic_1.AnyType || targetRowType instanceof basic_1.UnknownType) {
20515
+ return true;
20516
+ }
20517
+ else if (sourceRowType instanceof basic_1.VoidType || sourceRowType instanceof basic_1.AnyType || sourceRowType instanceof basic_1.UnknownType) {
20518
+ return true;
20519
+ }
20520
+ if (targetRowType instanceof basic_1.StructureType && this.structureContainsString(targetRowType)) {
20521
+ if (!(sourceRowType instanceof basic_1.StructureType)) {
20522
+ return false;
20523
+ }
20524
+ else if (!(this.structureContainsString(sourceRowType))) {
20525
+ return false;
20526
+ }
20527
+ }
20528
+ if (sourceRowType instanceof basic_1.StructureType && this.structureContainsString(sourceRowType)) {
20529
+ if (!(targetRowType instanceof basic_1.StructureType)) {
20530
+ return false;
20531
+ }
20532
+ else if (!(this.structureContainsString(targetRowType))) {
20533
+ return false;
20534
+ }
20535
+ }
20536
+ return true;
20492
20537
  }
20493
20538
  return false;
20494
20539
  }
@@ -46313,7 +46358,7 @@ class Registry {
46313
46358
  }
46314
46359
  static abaplintVersion() {
46315
46360
  // magic, see build script "version.sh"
46316
- return "2.97.10";
46361
+ return "2.97.12";
46317
46362
  }
46318
46363
  getDDICReferences() {
46319
46364
  return this.references;
@@ -67121,7 +67166,7 @@ class Chunk {
67121
67166
  const lines = this.raw.split("\n");
67122
67167
  const lineCount = lines.length;
67123
67168
  const lastLine = lines[lines.length - 1];
67124
- append.mappings.forEach(m => {
67169
+ for (const m of append.mappings) {
67125
67170
  // original stays the same, but adjust the generated positions
67126
67171
  const add = m;
67127
67172
  if (add.generated.line === 1 && this.raw.endsWith("\n") === false) {
@@ -67131,7 +67176,7 @@ class Chunk {
67131
67176
  add.generated.line += lineCount - 1;
67132
67177
  }
67133
67178
  this.mappings.push(add);
67134
- });
67179
+ }
67135
67180
  this.raw += append.getCode();
67136
67181
  return this;
67137
67182
  }
@@ -67183,10 +67228,13 @@ class Chunk {
67183
67228
  toString() {
67184
67229
  throw "error, dont toString a Chunk";
67185
67230
  }
67186
- runIndentationLogic() {
67231
+ runIndentationLogic(ignoreSourceMap = false) {
67187
67232
  let i = 0;
67188
67233
  let line = 1;
67189
67234
  const output = [];
67235
+ if (ignoreSourceMap === true) {
67236
+ this.mappings = [];
67237
+ }
67190
67238
  for (const l of this.raw.split("\n")) {
67191
67239
  if (l.startsWith("}")) {
67192
67240
  i = i - 1;
@@ -70079,7 +70127,7 @@ class HandleABAP {
70079
70127
  this.options = options;
70080
70128
  }
70081
70129
  runObject(obj, reg) {
70082
- var _a, _b;
70130
+ var _a, _b, _c;
70083
70131
  let ret = [];
70084
70132
  if (obj instanceof abaplint.Objects.Program && obj.isInclude() === true) {
70085
70133
  // includes are only compiled along with the programs where its used?
@@ -70095,7 +70143,7 @@ class HandleABAP {
70095
70143
  const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, this.options).traverse(rearranged);
70096
70144
  chunk.appendChunk(contents);
70097
70145
  chunk.stripLastNewline();
70098
- chunk.runIndentationLogic();
70146
+ chunk.runIndentationLogic((_b = this.options) === null || _b === void 0 ? void 0 : _b.ignoreSourceMap);
70099
70147
  const exports = this.findExports(file.getStructure());
70100
70148
  const filename = file.getFilename().replace(".abap", ".mjs").toLowerCase();
70101
70149
  const output = {
@@ -70111,7 +70159,7 @@ class HandleABAP {
70111
70159
  ret.push(output);
70112
70160
  }
70113
70161
  ret = this.rearrangeClassLocals(obj, ret);
70114
- if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.addCommonJS) === true) {
70162
+ if (((_c = this.options) === null || _c === void 0 ? void 0 : _c.addCommonJS) === true) {
70115
70163
  ret.map(output => output.chunk = this.addImportsAndExports(output));
70116
70164
  }
70117
70165
  return ret;
@@ -71197,7 +71245,7 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/
71197
71245
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
71198
71246
  class AssignTranspiler {
71199
71247
  transpile(node, traversal) {
71200
- var _a;
71248
+ var _a, _b;
71201
71249
  const assignSource = node.findDirectExpression(abaplint.Expressions.AssignSource);
71202
71250
  const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressions(abaplint.Expressions.Source).map(e => new expressions_1.SourceTranspiler(false).transpile(e, traversal).getCode())) || [];
71203
71251
  const fs = new expressions_1.FieldSymbolTranspiler().transpile(node.findDirectExpression(abaplint.Expressions.FSTarget), traversal).getCode();
@@ -71249,8 +71297,13 @@ class AssignTranspiler {
71249
71297
  if ((first === null || first === void 0 ? void 0 : first.get()) instanceof abaplint.Expressions.Dynamic && first instanceof abaplint.Nodes.ExpressionNode) {
71250
71298
  const firstFirst = first.getChildren()[1];
71251
71299
  if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.Constant) {
71252
- const s = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/);
71253
- options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
71300
+ const s = (_b = firstFirst.getFirstToken().getStr().toLowerCase().match(/\w+/)) === null || _b === void 0 ? void 0 : _b.toString();
71301
+ if (s === "me") {
71302
+ options.push(`dynamicSource: this.me`);
71303
+ }
71304
+ else {
71305
+ options.push(`dynamicSource: (() => {try { return ${s}; } catch {}})()`);
71306
+ }
71254
71307
  }
71255
71308
  else if ((firstFirst === null || firstFirst === void 0 ? void 0 : firstFirst.get()) instanceof abaplint.Expressions.FieldChain && firstFirst instanceof abaplint.Nodes.ExpressionNode) {
71256
71309
  const code = new expressions_1.FieldChainTranspiler(true).transpile(firstFirst, traversal).getCode();
@@ -77947,7 +78000,7 @@ class Traversal {
77947
78000
  }
77948
78001
  const name = def.getName();
77949
78002
  if (def.isGlobal() === false) {
77950
- const prefix = this.buildPrefix(def);
78003
+ const prefix = this.buildPrefix();
77951
78004
  return `abap.Classes['${prefix}-${name.toUpperCase()}'] = ${Traversal.escapeNamespace(name.toLowerCase())};`;
77952
78005
  }
77953
78006
  else {
@@ -77993,7 +78046,7 @@ class Traversal {
77993
78046
  }
77994
78047
  if (def) {
77995
78048
  if (def.isGlobal() === false) {
77996
- const prefix = this.buildPrefix(def);
78049
+ const prefix = this.buildPrefix();
77997
78050
  return `abap.Classes['${prefix}-${(_a = def === null || def === void 0 ? void 0 : def.getName()) === null || _a === void 0 ? void 0 : _a.toUpperCase()}']`;
77998
78051
  }
77999
78052
  else {
@@ -78005,13 +78058,8 @@ class Traversal {
78005
78058
  return "abap.Classes['" + name.toUpperCase() + "']";
78006
78059
  }
78007
78060
  }
78008
- buildPrefix(def) {
78009
- const file = this.reg.getFileByName(def.getFilename());
78010
- if (file === undefined) {
78011
- return "NOT_FOUND";
78012
- }
78013
- const obj = this.reg.findObjectForFile(file);
78014
- return (obj === null || obj === void 0 ? void 0 : obj.getType()) + "-" + (obj === null || obj === void 0 ? void 0 : obj.getName());
78061
+ buildPrefix() {
78062
+ return this.obj.getType() + "-" + this.obj.getName();
78015
78063
  }
78016
78064
  ////////////////////////////
78017
78065
  traverseStructure(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.6.16",
3
+ "version": "2.6.18",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,12 +25,12 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.6.16",
28
+ "@abaplint/transpiler": "^2.6.18",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",
32
32
  "@types/node": "^18.15.11",
33
- "@abaplint/core": "^2.97.10",
33
+ "@abaplint/core": "^2.97.12",
34
34
  "progress": "^2.0.3",
35
35
  "webpack": "^5.79.0",
36
36
  "webpack-cli": "^5.0.1",