@abaplint/transpiler 2.13.81 → 2.13.82

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.
@@ -92,12 +92,19 @@ class DataTranspiler {
92
92
  value = "\n" + traversal_1.Traversal.prefixVariable(found.getName().toLowerCase()) + ".set(\"" + enumDefault + "\");";
93
93
  }
94
94
  }
95
+ let packedDecimals;
96
+ if (found.getType() instanceof abaplint.BasicTypes.PackedType) {
97
+ const decimals = node.findFirstExpression(abaplint.Expressions.Decimals)?.findFirstExpression(abaplint.Expressions.Integer);
98
+ if (decimals) {
99
+ packedDecimals = parseInt(decimals.concatTokens(), 10);
100
+ }
101
+ }
95
102
  this.variableName = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase()));
96
103
  this.loopScoped = traversal.isInsideLoop(node);
97
104
  const ret = new chunk_1.Chunk()
98
105
  .appendString(this.loopScoped === true ? "var " : "let ")
99
106
  .appendString(this.variableName)
100
- .appendString(" = " + transpile_types_1.TranspileTypes.toType(found.getType()))
107
+ .appendString(" = " + transpile_types_1.TranspileTypes.toType(found.getType(), { packedDecimals }))
101
108
  .appendString(";")
102
109
  .appendString(value);
103
110
  if (this.loopScoped === true && this.skipLoopScoping === false) {
@@ -4,5 +4,7 @@ export declare class TranspileTypes {
4
4
  static declareStaticSkipVoid(pre: string, t: abaplint.TypedIdentifier): string;
5
5
  /** this returns a function, so it doesnt throw when loading the code, only when running */
6
6
  static toTypeFunction(type: abaplint.AbstractType): string;
7
- static toType(type: abaplint.AbstractType): string;
7
+ static toType(type: abaplint.AbstractType, options?: {
8
+ packedDecimals?: number;
9
+ }): string;
8
10
  }
@@ -62,7 +62,7 @@ class TranspileTypes {
62
62
  // return singleton,
63
63
  return "(() => { let _t; return () => (_t ??= " + this.toType(type) + "); })()";
64
64
  }
65
- static toType(type) {
65
+ static toType(type, options) {
66
66
  let resolved = "";
67
67
  let extra = "";
68
68
  if (type instanceof abaplint.BasicTypes.ObjectReferenceType
@@ -185,11 +185,12 @@ class TranspileTypes {
185
185
  }
186
186
  else if (type instanceof abaplint.BasicTypes.PackedType) {
187
187
  resolved = "Packed";
188
+ const decimals = options?.packedDecimals ?? type.getDecimals();
188
189
  if (type.getQualifiedName()) {
189
- extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
190
+ extra = "{length: " + type.getLength() + ", decimals: " + decimals + ", qualifiedName: \"" + type.getQualifiedName() + "\"}";
190
191
  }
191
192
  else {
192
- extra = "{length: " + type.getLength() + ", decimals: " + type.getDecimals() + "}";
193
+ extra = "{length: " + type.getLength() + ", decimals: " + decimals + "}";
193
194
  }
194
195
  }
195
196
  else if (type instanceof abaplint.BasicTypes.NumericGenericType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.13.81",
3
+ "version": "2.13.82",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",