@abaplint/runtime 2.0.13 → 2.0.16
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.
- package/README.md +2 -2
- package/build/src/abap_regex.d.ts +3 -0
- package/build/src/abap_regex.js +13 -0
- package/build/src/builtin/boolc.d.ts +4 -2
- package/build/src/builtin/boolc.js +4 -1
- package/build/src/builtin/index.d.ts +3 -0
- package/build/src/builtin/index.js +3 -0
- package/build/src/builtin/match.d.ts +5 -0
- package/build/src/builtin/match.js +23 -0
- package/build/src/builtin/matches.d.ts +5 -0
- package/build/src/builtin/matches.js +24 -0
- package/build/src/builtin/replace.js +11 -4
- package/build/src/builtin/sy.js +2 -1
- package/build/src/builtin/to_mixed.d.ts +9 -0
- package/build/src/builtin/to_mixed.js +48 -0
- package/build/src/compare/eq.js +5 -1
- package/build/src/statements/message.js +7 -0
- package/build/src/template_formatting.d.ts +1 -0
- package/build/src/template_formatting.js +3 -0
- package/build/src/types/index.d.ts +1 -0
- package/build/src/types/index.js +1 -0
- package/build/src/types/utc_long.d.ts +14 -0
- package/build/src/types/utc_long.js +23 -0
- package/package.json +39 -39
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @abaplint/runtime
|
|
2
|
-
|
|
1
|
+
# @abaplint/runtime
|
|
2
|
+
|
|
3
3
|
Runtime
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ABAPRegExp = void 0;
|
|
4
|
+
class ABAPRegExp {
|
|
5
|
+
// converts from ABAP specific regex to javascript regex
|
|
6
|
+
static convert(input) {
|
|
7
|
+
let ret = input;
|
|
8
|
+
ret = input.replace(/\[\[:punct:\]\]/g, "[\\.\\,]");
|
|
9
|
+
return ret;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.ABAPRegExp = ABAPRegExp;
|
|
13
|
+
//# sourceMappingURL=abap_regex.js.map
|
|
@@ -7,7 +7,10 @@ function boolc(input) {
|
|
|
7
7
|
return new types_1.String().set("X");
|
|
8
8
|
}
|
|
9
9
|
else if (input === false || input === undefined) {
|
|
10
|
-
return new types_1.String().set("");
|
|
10
|
+
return new types_1.String().set(" ");
|
|
11
|
+
}
|
|
12
|
+
else if (input.val instanceof types_1.Character && input.val.get().trim() === "") {
|
|
13
|
+
return new types_1.String().set(" ");
|
|
11
14
|
}
|
|
12
15
|
else {
|
|
13
16
|
return new types_1.String().set("X");
|
|
@@ -12,6 +12,8 @@ export * from "./floor";
|
|
|
12
12
|
export * from "./frac";
|
|
13
13
|
export * from "./insert";
|
|
14
14
|
export * from "./lines";
|
|
15
|
+
export * from "./match";
|
|
16
|
+
export * from "./matches";
|
|
15
17
|
export * from "./nmax";
|
|
16
18
|
export * from "./nmin";
|
|
17
19
|
export * from "./repeat";
|
|
@@ -29,6 +31,7 @@ export * from "./substring";
|
|
|
29
31
|
export * from "./sy";
|
|
30
32
|
export * from "./tan";
|
|
31
33
|
export * from "./to_lower";
|
|
34
|
+
export * from "./to_mixed";
|
|
32
35
|
export * from "./to_upper";
|
|
33
36
|
export * from "./trunc";
|
|
34
37
|
export * from "./xstrlen";
|
|
@@ -29,6 +29,8 @@ __exportStar(require("./floor"), exports);
|
|
|
29
29
|
__exportStar(require("./frac"), exports);
|
|
30
30
|
__exportStar(require("./insert"), exports);
|
|
31
31
|
__exportStar(require("./lines"), exports);
|
|
32
|
+
__exportStar(require("./match"), exports);
|
|
33
|
+
__exportStar(require("./matches"), exports);
|
|
32
34
|
__exportStar(require("./nmax"), exports);
|
|
33
35
|
__exportStar(require("./nmin"), exports);
|
|
34
36
|
__exportStar(require("./repeat"), exports);
|
|
@@ -46,6 +48,7 @@ __exportStar(require("./substring"), exports);
|
|
|
46
48
|
__exportStar(require("./sy"), exports);
|
|
47
49
|
__exportStar(require("./tan"), exports);
|
|
48
50
|
__exportStar(require("./to_lower"), exports);
|
|
51
|
+
__exportStar(require("./to_mixed"), exports);
|
|
49
52
|
__exportStar(require("./to_upper"), exports);
|
|
50
53
|
__exportStar(require("./trunc"), exports);
|
|
51
54
|
__exportStar(require("./xstrlen"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.match = void 0;
|
|
4
|
+
const string_1 = require("../types/string");
|
|
5
|
+
function match(input) {
|
|
6
|
+
const val = typeof input.val === "string" ? input.val : input.val.get();
|
|
7
|
+
let reg = "";
|
|
8
|
+
if (typeof input.regex === "string") {
|
|
9
|
+
reg = input.regex;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
reg = input.regex.get();
|
|
13
|
+
}
|
|
14
|
+
const r = new RegExp(reg);
|
|
15
|
+
const res = val.match(r);
|
|
16
|
+
let ret = "";
|
|
17
|
+
if (res && res[0]) {
|
|
18
|
+
ret = res[0];
|
|
19
|
+
}
|
|
20
|
+
return new string_1.String().set(ret);
|
|
21
|
+
}
|
|
22
|
+
exports.match = match;
|
|
23
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matches = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
function matches(input) {
|
|
6
|
+
const val = typeof input.val === "string" ? input.val : input.val.get();
|
|
7
|
+
let reg = "";
|
|
8
|
+
if (typeof input.regex === "string") {
|
|
9
|
+
reg = input.regex;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
reg = input.regex.get();
|
|
13
|
+
}
|
|
14
|
+
const r = new RegExp("^" + reg + "$");
|
|
15
|
+
const res = val.match(r);
|
|
16
|
+
if (res !== null) {
|
|
17
|
+
return new types_1.Character().set("X");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return new types_1.Character().set(" ");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.matches = matches;
|
|
24
|
+
//# sourceMappingURL=matches.js.map
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replace = void 0;
|
|
4
4
|
const string_1 = require("../types/string");
|
|
5
|
+
const abap_regex_1 = require("../abap_regex");
|
|
6
|
+
const types_1 = require("../types");
|
|
5
7
|
function replace(input) {
|
|
6
8
|
let val = undefined;
|
|
7
9
|
if (typeof input.val === "string") {
|
|
@@ -14,6 +16,9 @@ function replace(input) {
|
|
|
14
16
|
if (typeof input.with === "string") {
|
|
15
17
|
wi = input.with;
|
|
16
18
|
}
|
|
19
|
+
else if (input.with instanceof types_1.Character) {
|
|
20
|
+
wi = input.with.get().trimEnd();
|
|
21
|
+
}
|
|
17
22
|
else if (input.with) {
|
|
18
23
|
wi = input.with.get();
|
|
19
24
|
}
|
|
@@ -29,10 +34,10 @@ function replace(input) {
|
|
|
29
34
|
sub = sub.replace(/\[/g, "\\[");
|
|
30
35
|
}
|
|
31
36
|
if (typeof input.regex === "string") {
|
|
32
|
-
sub = input.regex;
|
|
37
|
+
sub = new RegExp(abap_regex_1.ABAPRegExp.convert(input.regex), "g");
|
|
33
38
|
}
|
|
34
39
|
else if (input.regex) {
|
|
35
|
-
sub = input.regex.get();
|
|
40
|
+
sub = new RegExp(abap_regex_1.ABAPRegExp.convert(input.regex.get()), "g");
|
|
36
41
|
}
|
|
37
42
|
if (input.off && input.len && typeof input.val === "string") {
|
|
38
43
|
const offset = input.off.get();
|
|
@@ -50,8 +55,10 @@ function replace(input) {
|
|
|
50
55
|
val = val.replace(sub, wi);
|
|
51
56
|
}
|
|
52
57
|
else if (input.occ && input.occ.get() === 0 && sub && wi !== undefined) {
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
if (typeof sub === "string") {
|
|
59
|
+
sub = new RegExp(sub, "g");
|
|
60
|
+
}
|
|
61
|
+
val = val.replace(sub, wi);
|
|
55
62
|
}
|
|
56
63
|
return new string_1.String().set(val);
|
|
57
64
|
}
|
package/build/src/builtin/sy.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.sy = new types_1.Structure({
|
|
|
13
13
|
mandt: new types_1.Character({ length: 3 }).set("123"),
|
|
14
14
|
msgid: new types_1.Character({ length: 20 }),
|
|
15
15
|
msgno: new types_1.Numc({ length: 3 }),
|
|
16
|
+
msgty: new types_1.Character({ length: 1 }),
|
|
16
17
|
msgv1: new types_1.Character({ length: 50 }),
|
|
17
18
|
msgv2: new types_1.Character({ length: 50 }),
|
|
18
19
|
msgv3: new types_1.Character({ length: 50 }),
|
|
@@ -20,8 +21,8 @@ exports.sy = new types_1.Structure({
|
|
|
20
21
|
subrc: new types_1.Integer(),
|
|
21
22
|
sysid: new types_1.Character({ length: 3 }).set("ABC"),
|
|
22
23
|
tabix: new types_1.Integer(),
|
|
23
|
-
tzone: new types_1.Integer(),
|
|
24
24
|
timlo: new types_1.Time(),
|
|
25
|
+
tzone: new types_1.Integer(),
|
|
25
26
|
uname: new types_1.Character({ length: 12 }).set("USERNAME"),
|
|
26
27
|
uzeit: new types_1.Time(),
|
|
27
28
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { String } from "../types";
|
|
2
|
+
import { ICharacter } from "../types/_character";
|
|
3
|
+
import { INumeric } from "../types/_numeric";
|
|
4
|
+
export declare function to_mixed(input: {
|
|
5
|
+
val: ICharacter | string;
|
|
6
|
+
sep?: ICharacter | string;
|
|
7
|
+
case?: ICharacter | string;
|
|
8
|
+
min?: INumeric | number;
|
|
9
|
+
}): String;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.to_mixed = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
function to_mixed(input) {
|
|
7
|
+
let sep = input.sep;
|
|
8
|
+
if (sep === undefined) {
|
|
9
|
+
sep = "_";
|
|
10
|
+
}
|
|
11
|
+
if (typeof sep !== "string") {
|
|
12
|
+
sep = sep.get();
|
|
13
|
+
}
|
|
14
|
+
if (sep.length === 0) {
|
|
15
|
+
throw "CX_SY_STRG_PAR_VAL";
|
|
16
|
+
}
|
|
17
|
+
const min = 1;
|
|
18
|
+
if (min < 0) {
|
|
19
|
+
throw "CX_SY_STRG_PAR_VAL";
|
|
20
|
+
}
|
|
21
|
+
let val = input.val;
|
|
22
|
+
if (typeof val !== "string") {
|
|
23
|
+
val = val.get();
|
|
24
|
+
}
|
|
25
|
+
val = val.substring(0, min) + val.substring(min).toLowerCase();
|
|
26
|
+
if (input.case) {
|
|
27
|
+
if (typeof input.case === "string") {
|
|
28
|
+
if (input.case === input.case.toLowerCase()) {
|
|
29
|
+
val = val.substring(0, 1).toLowerCase() + val.substring(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (input.case.get() === input.case.get().toLowerCase()) {
|
|
34
|
+
val = val.substring(0, 1).toLowerCase() + val.substring(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const length = sep.length;
|
|
39
|
+
const regex = new RegExp(sep + "\\w");
|
|
40
|
+
while (val.match(regex)) {
|
|
41
|
+
val = val.replace(regex, (x) => {
|
|
42
|
+
return x.substring(length).toUpperCase();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return new types_1.String().set(val);
|
|
46
|
+
}
|
|
47
|
+
exports.to_mixed = to_mixed;
|
|
48
|
+
//# sourceMappingURL=to_mixed.js.map
|
package/build/src/compare/eq.js
CHANGED
|
@@ -80,7 +80,11 @@ function eq(left, right) {
|
|
|
80
80
|
else if (left instanceof types_1.Hex && typeof r === "number") {
|
|
81
81
|
l = parseInt(left.get(), 16);
|
|
82
82
|
}
|
|
83
|
-
if (right instanceof types_1.Float &&
|
|
83
|
+
if (right instanceof types_1.Float && left instanceof types_1.Float) {
|
|
84
|
+
r = right.getRaw();
|
|
85
|
+
l = left.getRaw();
|
|
86
|
+
}
|
|
87
|
+
else if (right instanceof types_1.Float && typeof l === "number") {
|
|
84
88
|
r = right.getRaw();
|
|
85
89
|
}
|
|
86
90
|
else if (left instanceof types_1.Float) {
|
|
@@ -54,6 +54,11 @@ class MessageStatement {
|
|
|
54
54
|
arbgb = arbgb.get();
|
|
55
55
|
}
|
|
56
56
|
arbgb = arbgb === null || arbgb === void 0 ? void 0 : arbgb.toUpperCase();
|
|
57
|
+
let msgty = options.type;
|
|
58
|
+
if (msgty !== undefined && typeof msgty !== "string") {
|
|
59
|
+
msgty = msgty.get();
|
|
60
|
+
}
|
|
61
|
+
msgty = msgty === null || msgty === void 0 ? void 0 : msgty.toUpperCase();
|
|
57
62
|
// @ts-ignore
|
|
58
63
|
abap.builtin.sy.get().msgid.set(arbgb);
|
|
59
64
|
let msgnr = options.number;
|
|
@@ -62,6 +67,8 @@ class MessageStatement {
|
|
|
62
67
|
}
|
|
63
68
|
// @ts-ignore
|
|
64
69
|
abap.builtin.sy.get().msgno.set(msgnr);
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
abap.builtin.sy.get().msgty.set(msgty);
|
|
65
72
|
const text = await findText(this.context, arbgb, msgnr);
|
|
66
73
|
const replaced = replace(text, options.with);
|
|
67
74
|
if (options.into) {
|
|
@@ -4,6 +4,9 @@ exports.templateFormatting = void 0;
|
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
function templateFormatting(source, options) {
|
|
6
6
|
let text = source.get() + "";
|
|
7
|
+
if (options.currency !== undefined) {
|
|
8
|
+
throw "template formatting with currency not supported";
|
|
9
|
+
}
|
|
7
10
|
if (options.timestamp === "iso") {
|
|
8
11
|
text = text.substr(0, 4) + "-" + text.substr(4, 2) + "-" + text.substr(6, 2) + "T" + text.substr(8, 2) + ":" + text.substr(10, 2) + ":" + text.substr(12, 2);
|
|
9
12
|
}
|
package/build/src/types/index.js
CHANGED
|
@@ -29,5 +29,6 @@ __exportStar(require("./string"), exports);
|
|
|
29
29
|
__exportStar(require("./structure"), exports);
|
|
30
30
|
__exportStar(require("./table"), exports);
|
|
31
31
|
__exportStar(require("./time"), exports);
|
|
32
|
+
__exportStar(require("./utc_long"), exports);
|
|
32
33
|
__exportStar(require("./xstring"), exports);
|
|
33
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Hex } from "./hex";
|
|
2
|
+
import { ICharacter } from "./_character";
|
|
3
|
+
import { INumeric } from "./_numeric";
|
|
4
|
+
export declare class UTCLong implements ICharacter {
|
|
5
|
+
private value;
|
|
6
|
+
constructor();
|
|
7
|
+
getOffset(_input: {
|
|
8
|
+
offset?: number | undefined;
|
|
9
|
+
length?: number | undefined;
|
|
10
|
+
}): ICharacter;
|
|
11
|
+
set(_value: INumeric | ICharacter | Hex | string | number): this;
|
|
12
|
+
clear(): void;
|
|
13
|
+
get(): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UTCLong = void 0;
|
|
4
|
+
class UTCLong {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.clear();
|
|
7
|
+
}
|
|
8
|
+
getOffset(_input) {
|
|
9
|
+
throw new Error("Method not implemented.");
|
|
10
|
+
}
|
|
11
|
+
set(_value) {
|
|
12
|
+
// todo
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
clear() {
|
|
16
|
+
this.value = "";
|
|
17
|
+
}
|
|
18
|
+
get() {
|
|
19
|
+
return this.value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UTCLong = UTCLong;
|
|
23
|
+
//# sourceMappingURL=utc_long.js.map
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "Transpiler - Runtime",
|
|
5
|
-
"main": "build/src/index.js",
|
|
6
|
-
"typings": "build/src/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"compile": "tsc",
|
|
13
|
-
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
-
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
|
-
"test": "npm run compile && mocha"
|
|
17
|
-
},
|
|
18
|
-
"mocha": {
|
|
19
|
-
"recursive": true,
|
|
20
|
-
"reporter": "progress",
|
|
21
|
-
"spec": "build/test/**/*.js",
|
|
22
|
-
"require": "source-map-support/register"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"ABAP",
|
|
26
|
-
"abaplint"
|
|
27
|
-
],
|
|
28
|
-
"author": "abaplint",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@types/chai": "^4.3.1",
|
|
32
|
-
"@types/mocha": "^9.1.1",
|
|
33
|
-
"@types/sql.js": "^1.4.3",
|
|
34
|
-
"chai": "^4.3.6",
|
|
35
|
-
"mocha": "^9.2.2",
|
|
36
|
-
"source-map-support": "^0.5.21",
|
|
37
|
-
"typescript": "^4.6.
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/runtime",
|
|
3
|
+
"version": "2.0.16",
|
|
4
|
+
"description": "Transpiler - Runtime",
|
|
5
|
+
"main": "build/src/index.js",
|
|
6
|
+
"typings": "build/src/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"compile": "tsc",
|
|
13
|
+
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
|
+
"test": "npm run compile && mocha"
|
|
17
|
+
},
|
|
18
|
+
"mocha": {
|
|
19
|
+
"recursive": true,
|
|
20
|
+
"reporter": "progress",
|
|
21
|
+
"spec": "build/test/**/*.js",
|
|
22
|
+
"require": "source-map-support/register"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"ABAP",
|
|
26
|
+
"abaplint"
|
|
27
|
+
],
|
|
28
|
+
"author": "abaplint",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/chai": "^4.3.1",
|
|
32
|
+
"@types/mocha": "^9.1.1",
|
|
33
|
+
"@types/sql.js": "^1.4.3",
|
|
34
|
+
"chai": "^4.3.6",
|
|
35
|
+
"mocha": "^9.2.2",
|
|
36
|
+
"source-map-support": "^0.5.21",
|
|
37
|
+
"typescript": "^4.6.4"
|
|
38
|
+
}
|
|
39
|
+
}
|