UNPKG

@abaplint/runtime

Version:
47 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mod = mod; const throw_error_1 = require("../throw_error"); const types_1 = require("../types"); const _parse_1 = require("./_parse"); function mod(left, right) { if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) { const l = left instanceof types_1.Integer8 ? left.get() : BigInt((0, _parse_1.parse)(left)); const r = right instanceof types_1.Integer8 ? right.get() : BigInt((0, _parse_1.parse)(right)); if (r === 0n) { if (l === 0n) { return new types_1.Integer8().set(0n); } else { (0, throw_error_1.throwError)("CX_SY_ZERODIVIDE"); } } let val = ((l % r) + r) % r; if (val < 0) { val = val * -1n; } return new types_1.Integer8().set(val); } const l = (0, _parse_1.parse)(left); const r = (0, _parse_1.parse)(right); if (r === 0) { if (l === 0) { return new types_1.Integer().set(0); } else { (0, throw_error_1.throwError)("CX_SY_ZERODIVIDE"); } } let val = ((l % r) + r) % r; if (val < 0) { val = val * -1; } // hmm, to handle field symbols? if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) { return new types_1.Integer8().set(val); } else { return new types_1.Integer().set(val); } } //# sourceMappingURL=mod.js.map