@abaplint/transpiler 2.13.93 → 2.13.95

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.
@@ -46,11 +46,14 @@ class DoTranspiler {
46
46
  transpile(node, traversal) {
47
47
  const found = node.findFirstExpression(abaplint.Expressions.Source);
48
48
  if (found) {
49
- const source = new expressions_1.SourceTranspiler(true).transpile(found, traversal).getCode();
49
+ // the count is converted to i, like any numeric expression position: an
50
+ // f count read with get( ) gives its text 3,0000000000000000E+00, which
51
+ // no loop counter compares with, and a p count of 2.4 means 2 passes
52
+ const source = new expressions_1.SourceTranspiler(false).transpile(found, traversal).getCode();
50
53
  const idSource = unique_identifier_1.UniqueIdentifier.get();
51
54
  const id = unique_identifier_1.UniqueIdentifier.get();
52
55
  return new chunk_1.Chunk(`const ${this.syIndexBackup} = abap.builtin.sy.get().index.get();
53
- const ${idSource} = ${source};
56
+ const ${idSource} = new abap.types.Integer().set(${source}).get();
54
57
  for (let ${id} = 0; ${id} < ${idSource}; ${id}++) {
55
58
  abap.builtin.sy.get().index.set(${id} + 1);`);
56
59
  }
@@ -148,7 +148,10 @@ class LoopTranspiler {
148
148
  extra.push(`atLast: (last) => { ${this.atLast} = last; }`);
149
149
  }
150
150
  const topEquals = {};
151
- for (const compare of whereNode?.findDirectExpressions(abaplint.Expressions.ComponentCompare) || []) {
151
+ // only a pure conjunction makes each top-level `=` a condition every row
152
+ // has to meet: `a = 1 OR b = 2` narrows by neither
153
+ const onlyAnd = whereNode?.getChildren().every(c => !(c instanceof abaplint.Nodes.TokenNode) || c.concatTokens().toUpperCase() !== "OR") ?? true;
154
+ for (const compare of onlyAnd ? whereNode?.findDirectExpressions(abaplint.Expressions.ComponentCompare) || [] : []) {
152
155
  const op = compare.findDirectExpression(abaplint.Expressions.CompareOperator)?.concatTokens().toUpperCase();
153
156
  if (op !== "=" && op !== "EQ") {
154
157
  continue;
@@ -58,8 +58,12 @@ class UpdateDatabaseTranspiler {
58
58
  }
59
59
  options.push(`"set": [${s.join(",")}]`);
60
60
  }
61
+ const fromTable = node.findExpressionAfterToken("TABLE");
62
+ if (fromTable && fromTable.get() instanceof abaplint.Expressions.SQLSource) {
63
+ options.push(`"table": ` + traversal.traverse(fromTable).getCode());
64
+ }
61
65
  const sourceExpression = node.findDirectExpression(abaplint.Expressions.SQLSource)?.findDirectExpression(abaplint.Expressions.SimpleSource3);
62
- if (sourceExpression) {
66
+ if (sourceExpression && fromTable === undefined) {
63
67
  const sqlSource = new expressions_1.SourceTranspiler(true).transpile(sourceExpression, traversal).getCode();
64
68
  const tableName = node.findDirectExpression(abaplint.Expressions.DatabaseTable)?.concatTokens();
65
69
  const tabl = traversal.findTable(tableName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.93",
3
+ "version": "2.13.95",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,14 +29,14 @@
29
29
  "author": "abaplint",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@abaplint/core": "^2.120.59",
32
+ "@abaplint/core": "^2.120.63",
33
33
  "source-map": "^0.8.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/chai": "^5.2.3",
37
37
  "@types/mocha": "^10.0.10",
38
38
  "chai": "^6.2.2",
39
- "mocha": "^12.0.2",
39
+ "mocha": "^12.0.3",
40
40
  "source-map-support": "^0.5.21",
41
41
  "typescript": "^6.0.3"
42
42
  }