Skip to content
Draft

bugfix #1773

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/acos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function acos(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.acos(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/asin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function asin(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.asin(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/atan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function atan(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.atan(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/cosh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function cosh(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.cosh(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/exp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function exp(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.exp(num_in);
}
11 changes: 10 additions & 1 deletion packages/runtime/src/builtin/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {Character} from "../types";

export * from "./abs";
export * from "./acos";
export * from "./asin";
export * from "./atan";
export * from "./boolc";
export * from "./ceil";
export * from "./concat_lines_of";
export * from "./condense";
export * from "./contains";
export * from "./cos";
export * from "./cosh";
export * from "./count_any_of";
export * from "./count";
export * from "./escape";
export * from "./exp";
export * from "./find";
export * from "./floor";
export * from "./frac";
Expand All @@ -19,6 +24,8 @@ export * from "./ipow";
export * from "./line_exists";
export * from "./line_index";
export * from "./lines";
export * from "./log";
export * from "./log10";
export * from "./match";
export * from "./matches";
export * from "./nmax";
Expand All @@ -33,13 +40,15 @@ export * from "./shift_left";
export * from "./shift_right";
export * from "./sign";
export * from "./sin";
export * from "./sinh";
export * from "./sqrt";
export * from "./strlen";
export * from "./substring_after";
export * from "./substring_before";
export * from "./substring";
export * from "./sy";
export * from "./tan";
export * from "./tanh";
export * from "./to_lower";
export * from "./to_mixed";
export * from "./to_upper";
Expand All @@ -61,4 +70,4 @@ export const $_vertical_tab = new Character(1).set("\v").setConstant();
/*
export const $_maxchar = new Character(1).set(Buffer.from("FDFF", "hex").toString()).setConstant();
export const $_minchar = new Character(1).set(Buffer.from("0000", "hex").toString()).setConstant();
*/
*/
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function log(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.log(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/log10.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function log10(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.log10(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/sinh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function sinh(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.sinh(num_in);
}
17 changes: 17 additions & 0 deletions packages/runtime/src/builtin/tanh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Float} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function tanh(input: {val: number | string | ICharacter | INumeric}) {
let num_in: number | undefined = undefined;
if (typeof input.val === "number") {
num_in = input.val;
} else if (typeof input.val === "string") {
num_in = parseFloat(input.val);
} else if (input.val instanceof Float) {
num_in = input.val.getRaw();
} else {
num_in = parseFloat(input.val.get().toString());
}
return Math.tanh(num_in);
}
19 changes: 15 additions & 4 deletions packages/runtime/src/compare/eq.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
import {ABAPObject, Character, Date, FieldSymbol, Float, HashedTable, String, Hex, Integer, Numc, Structure, Table, DataReference, toInteger, XString, Integer8, Packed, HexUInt8, Time} from "../types";
import {ABAPObject, Character, Date, DecFloat34, FieldSymbol, Float, HashedTable, String, Hex, Integer, Numc, Structure, Table, DataReference, toInteger, XString, Integer8, Packed, HexUInt8, Time} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";
import {parse} from "../operators/_parse";
Expand Down Expand Up @@ -50,6 +50,7 @@ const DateC = Date;
const TimeC = Time;
const PackedC = Packed;
const FloatC = Float;
const DecFloat34C = DecFloat34;
const TableC = Table;
const HashedTableC = HashedTable;
const StructureC = Structure;
Expand All @@ -61,8 +62,8 @@ const ABAPObjectC = ABAPObject;
const DataReferenceC = DataReference;

export function eq(
left: number | string | ICharacter | Integer8 | INumeric | Float | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol,
right: number | string | ICharacter | Integer8 | INumeric | Float | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol): boolean {
left: number | string | ICharacter | Integer8 | INumeric | Float | DecFloat34 | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol,
right: number | string | ICharacter | Integer8 | INumeric | Float | DecFloat34 | String | ABAPObject | Structure | Hex | HashedTable | Table | FieldSymbol): boolean {
/*
console.dir(left);
console.dir(right);
Expand Down Expand Up @@ -92,6 +93,8 @@ export function eq(
return (left as Packed).get() === (right as Packed).get();
} else if (leftConstructor === FloatC) {
return (left as Float).getRaw() === (right as Float).getRaw();
} else if (leftConstructor === DecFloat34C) {
return (left as DecFloat34).getRaw() === (right as DecFloat34).getRaw();
} else if (leftConstructor === TableC || leftConstructor === HashedTableC) {
return compareTables(left as Table, right as Table);
} else if (leftConstructor === StructureC) {
Expand Down Expand Up @@ -225,6 +228,8 @@ export function eq(
return right.get() === left.get();
} else if (left instanceof Integer) {
return right.get() === left.get();
} else if (left instanceof DecFloat34) {
return right.get() === left.getRaw();
}
} else if (right instanceof Integer8) {
if (left instanceof Integer
Expand All @@ -241,6 +246,12 @@ export function eq(
|| left instanceof Integer8) {
return right.getRaw() === left.get();
}
} else if (right instanceof DecFloat34) {
if (left instanceof Float || left instanceof DecFloat34) {
return right.getRaw() === left.getRaw();
} else if (left instanceof Integer || left instanceof Packed) {
return right.getRaw() === left.get();
}
}

if (left instanceof Structure || right instanceof Structure) {
Expand Down Expand Up @@ -325,4 +336,4 @@ export function eq(
console.dir(r);
*/
return l === r;
}
}
Loading
Loading