MCPcopy Create free account
hub / github.com/abaplint/transpiler / set

Method set

packages/runtime/src/types/integer.ts:60–99  ·  view source on GitHub ↗
(value: INumeric | ICharacter | Hex | string | number | Integer | Float)

Source from the content-addressed store, hash-verified

58 return this;
59 }
60
61 public isIntegerCalculationType(): boolean {
62 return this.integerCalculationType;
63 }
64
65 public getQualifiedName() {
66 return this.qualifiedName;
67 }
68
69 public clone(): Integer {
70 const n = new Integer({qualifiedName: this.qualifiedName});
71 // set without trigger checks and padding
72 n.value = this.value;
73 return n;
74 }
75
76 public setConstant() {
77 this.constant = true;
78 return this;
79 }
80
81 public set(value: INumeric | ICharacter | Hex | string | number | Integer | Float | DecFloat34) {
82 if (this.constant === true) {
83 throw new Error("Changing constant");
84 }
85
86 if (typeof value === "number") {
87 this.value = roundHalfAwayFromZero(value);
88 } else if (value instanceof Integer) {
89 this.set(value.get());
90 } else if (value instanceof Character) {
91 this.value = toInteger(value.get());
92 } else if (value instanceof String) {
93 this.value = toInteger(value.get());
94 } else if (value instanceof Integer8) {
95 this.set(Number(value.get()));
96 } else if (value instanceof Float || value instanceof DecFloat34) {
97 this.set(roundHalfAwayFromZero(value.getRaw()));
98 } else if (value instanceof Hex || value instanceof XString || value instanceof HexUInt8) {
99// the last four bytes, 00 on the left, as a signed integer; an empty xstring is 0
100 const hex = value.get().slice(-8);
101 let num = hex === "" ? 0 : parseInt(hex, 16);
102 if (hex.length === 8 && num > 0x7FFFFFFF) {

Callers

nothing calls this directly

Calls 5

toIntegerFunction · 0.85
roundMethod · 0.80
getMethod · 0.65
getRawMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected