@abaplint/transpiler-cli 2.14.31 → 2.14.33
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/build/bundle.js +300 -70
- package/package.json +2 -2
package/build/bundle.js
CHANGED
|
@@ -116978,43 +116978,92 @@ class Chunk {
|
|
|
116978
116978
|
if (search === "") {
|
|
116979
116979
|
throw new Error("Chunk.replaceAll, search string must not be empty");
|
|
116980
116980
|
}
|
|
116981
|
-
const
|
|
116981
|
+
const escaped = search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
116982
|
+
return this.replaceMatches(new RegExp(escaped, "g"), () => replacement);
|
|
116983
|
+
}
|
|
116984
|
+
/** Replace every match of a global pattern in one forward pass. The replacer
|
|
116985
|
+
* returns the new text, or undefined to keep the match. Source-map positions
|
|
116986
|
+
* are moved once at the end, so the cost is linear in the code size plus
|
|
116987
|
+
* mappings * log(replacements), however many matches there are. */
|
|
116988
|
+
replaceMatches(pattern, replacer) {
|
|
116989
|
+
if (!pattern.global) {
|
|
116990
|
+
throw new Error("Chunk.replaceMatches, pattern must be global");
|
|
116991
|
+
}
|
|
116992
|
+
const advance = (position, text) => {
|
|
116993
|
+
const lastNewline = text.lastIndexOf("\n");
|
|
116994
|
+
if (lastNewline < 0) {
|
|
116995
|
+
return { line: position.line, column: position.column + text.length };
|
|
116996
|
+
}
|
|
116997
|
+
let lines = 0;
|
|
116998
|
+
for (let index = text.indexOf("\n"); index >= 0; index = text.indexOf("\n", index + 1)) {
|
|
116999
|
+
lines++;
|
|
117000
|
+
}
|
|
117001
|
+
return { line: position.line + lines, column: text.length - lastNewline - 1 };
|
|
117002
|
+
};
|
|
117003
|
+
const edits = [];
|
|
117004
|
+
const output = [];
|
|
117005
|
+
let oldPosition = { line: 1, column: 0 };
|
|
117006
|
+
let newPosition = { line: 1, column: 0 };
|
|
116982
117007
|
let cursor = 0;
|
|
116983
|
-
|
|
116984
|
-
const
|
|
116985
|
-
if (
|
|
116986
|
-
|
|
117008
|
+
for (const match of this.raw.matchAll(pattern)) {
|
|
117009
|
+
const replacement = replacer(match);
|
|
117010
|
+
if (replacement === undefined || replacement === match[0]) {
|
|
117011
|
+
continue;
|
|
116987
117012
|
}
|
|
116988
|
-
|
|
116989
|
-
|
|
116990
|
-
|
|
116991
|
-
|
|
116992
|
-
|
|
116993
|
-
|
|
116994
|
-
|
|
116995
|
-
|
|
116996
|
-
|
|
116997
|
-
|
|
116998
|
-
|
|
116999
|
-
|
|
117000
|
-
|
|
117001
|
-
|
|
117002
|
-
|
|
117003
|
-
|
|
117004
|
-
|
|
117005
|
-
|
|
117006
|
-
|
|
117007
|
-
|
|
117008
|
-
|
|
117009
|
-
|
|
117010
|
-
|
|
117013
|
+
const between = this.raw.substring(cursor, match.index);
|
|
117014
|
+
output.push(between, replacement);
|
|
117015
|
+
const oldStart = advance(oldPosition, between);
|
|
117016
|
+
const newStart = advance(newPosition, between);
|
|
117017
|
+
oldPosition = advance(oldStart, match[0]);
|
|
117018
|
+
newPosition = advance(newStart, replacement);
|
|
117019
|
+
edits.push({ oldStart, oldEnd: oldPosition, newStart, newEnd: newPosition });
|
|
117020
|
+
cursor = match.index + match[0].length;
|
|
117021
|
+
}
|
|
117022
|
+
if (edits.length === 0) {
|
|
117023
|
+
return this;
|
|
117024
|
+
}
|
|
117025
|
+
output.push(this.raw.substring(cursor));
|
|
117026
|
+
const before = (a, b) => a.line < b.line || (a.line === b.line && a.column < b.column);
|
|
117027
|
+
for (const mapping of this.mappings) {
|
|
117028
|
+
const position = mapping.generated;
|
|
117029
|
+
// last edit starting at or before this mapping
|
|
117030
|
+
let low = 0;
|
|
117031
|
+
let high = edits.length - 1;
|
|
117032
|
+
let found = -1;
|
|
117033
|
+
while (low <= high) {
|
|
117034
|
+
const middle = Math.floor((low + high) / 2);
|
|
117035
|
+
if (before(position, edits[middle].oldStart)) {
|
|
117036
|
+
high = middle - 1;
|
|
117011
117037
|
}
|
|
117038
|
+
else {
|
|
117039
|
+
found = middle;
|
|
117040
|
+
low = middle + 1;
|
|
117041
|
+
}
|
|
117042
|
+
}
|
|
117043
|
+
if (found < 0) {
|
|
117044
|
+
continue;
|
|
117045
|
+
}
|
|
117046
|
+
const edit = edits[found];
|
|
117047
|
+
if (before(position, edit.oldEnd) && position.line === edit.oldStart.line) {
|
|
117048
|
+
// inside the replaced text, keep the offset from its start
|
|
117049
|
+
position.column = edit.newStart.column + position.column - edit.oldStart.column;
|
|
117050
|
+
position.line = edit.newStart.line;
|
|
117051
|
+
}
|
|
117052
|
+
else if (before(position, edit.oldEnd)) {
|
|
117053
|
+
position.line += edit.newStart.line - edit.oldStart.line;
|
|
117054
|
+
}
|
|
117055
|
+
else if (position.line === edit.oldEnd.line) {
|
|
117056
|
+
position.column = edit.newEnd.column + position.column - edit.oldEnd.column;
|
|
117057
|
+
position.line = edit.newEnd.line;
|
|
117058
|
+
}
|
|
117059
|
+
else {
|
|
117060
|
+
position.line += edit.newEnd.line - edit.oldEnd.line;
|
|
117012
117061
|
}
|
|
117013
|
-
this.raw = this.raw.substring(0, index) + replacement + this.raw.substring(index + search.length);
|
|
117014
117062
|
}
|
|
117015
|
-
|
|
117016
|
-
|
|
117017
|
-
this.
|
|
117063
|
+
this.raw = output.join("");
|
|
117064
|
+
const end = advance(newPosition, output[output.length - 1]);
|
|
117065
|
+
this.lineCount = end.line;
|
|
117066
|
+
this.lastLineLength = end.column;
|
|
117018
117067
|
return this;
|
|
117019
117068
|
}
|
|
117020
117069
|
stripLastNewline() {
|
|
@@ -125762,7 +125811,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
125762
125811
|
};
|
|
125763
125812
|
})();
|
|
125764
125813
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
125765
|
-
exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config = exports.importPath = exports.OutputLayout = void 0;
|
|
125814
|
+
exports.Transpiler = exports.Chunk = exports.UnknownTypesEnum = exports.config = exports.DDIC_MODULE = exports.importPath = exports.OutputLayout = void 0;
|
|
125766
125815
|
const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
|
|
125767
125816
|
const validation_1 = __webpack_require__(/*! ./validation */ "./node_modules/@abaplint/transpiler/build/src/validation.js");
|
|
125768
125817
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return validation_1.config; } });
|
|
@@ -125790,6 +125839,7 @@ const output_layout_1 = __webpack_require__(/*! ./output_layout */ "./node_modul
|
|
|
125790
125839
|
var output_layout_2 = __webpack_require__(/*! ./output_layout */ "./node_modules/@abaplint/transpiler/build/src/output_layout.js");
|
|
125791
125840
|
Object.defineProperty(exports, "OutputLayout", ({ enumerable: true, get: function () { return output_layout_2.OutputLayout; } }));
|
|
125792
125841
|
Object.defineProperty(exports, "importPath", ({ enumerable: true, get: function () { return output_layout_2.importPath; } }));
|
|
125842
|
+
Object.defineProperty(exports, "DDIC_MODULE", ({ enumerable: true, get: function () { return output_layout_2.DDIC_MODULE; } }));
|
|
125793
125843
|
class Transpiler {
|
|
125794
125844
|
options;
|
|
125795
125845
|
constructor(options) {
|
|
@@ -125877,8 +125927,46 @@ class Transpiler {
|
|
|
125877
125927
|
for (const file of output.objects) {
|
|
125878
125928
|
file.filename = layout.file(file.object, file.filename);
|
|
125879
125929
|
}
|
|
125930
|
+
if (layout.isGrouped()) {
|
|
125931
|
+
output.objects = this.mergeDDIC(reg, layout, output.objects);
|
|
125932
|
+
}
|
|
125880
125933
|
return output;
|
|
125881
125934
|
}
|
|
125935
|
+
/** One module per output folder with all its DDIC definitions, which the initialization
|
|
125936
|
+
* scripts import. Each module is created for exactly the folders the initialization
|
|
125937
|
+
* derives from the registry, so no import can point to a missing module. */
|
|
125938
|
+
mergeDDIC(reg, layout, objects) {
|
|
125939
|
+
const modules = new Map();
|
|
125940
|
+
for (const obj of reg.getObjects()) {
|
|
125941
|
+
if (output_layout_1.DDIC_TYPES.has(obj.getType())) {
|
|
125942
|
+
modules.set(layout.ddicModule({ type: obj.getType(), name: obj.getName() }), []);
|
|
125943
|
+
}
|
|
125944
|
+
}
|
|
125945
|
+
const result = [];
|
|
125946
|
+
for (const file of objects) {
|
|
125947
|
+
if (output_layout_1.DDIC_TYPES.has(file.object.type.toUpperCase())) {
|
|
125948
|
+
modules.get(layout.ddicModule(file.object)).push(file);
|
|
125949
|
+
}
|
|
125950
|
+
else {
|
|
125951
|
+
result.push(file);
|
|
125952
|
+
}
|
|
125953
|
+
}
|
|
125954
|
+
for (const filename of [...modules.keys()].sort()) {
|
|
125955
|
+
// type factory names carry their original module name, so the definitions can be
|
|
125956
|
+
// concatenated without clashes; sorted, so the module does not depend on file order
|
|
125957
|
+
const code = modules.get(filename)
|
|
125958
|
+
.sort((a, b) => a.filename < b.filename ? -1 : a.filename > b.filename ? 1 : 0)
|
|
125959
|
+
.map(file => file.chunk.getCode()).join("\n");
|
|
125960
|
+
result.push({
|
|
125961
|
+
object: { type: "DDIC", name: filename.split("/")[0] },
|
|
125962
|
+
filename,
|
|
125963
|
+
chunk: new chunk_1.Chunk(code === "" ? "" : code + "\n"),
|
|
125964
|
+
requires: [],
|
|
125965
|
+
exports: [],
|
|
125966
|
+
});
|
|
125967
|
+
}
|
|
125968
|
+
return result;
|
|
125969
|
+
}
|
|
125882
125970
|
// ///////////////////////////////
|
|
125883
125971
|
validate(reg) {
|
|
125884
125972
|
const issues = new validation_1.Validation(this.options).run(reg);
|
|
@@ -126027,8 +126115,13 @@ globalThis.abap = new runtime.ABAP();\n`;
|
|
|
126027
126115
|
code: useImport === true ? `import "${specifier}";` : `await import("${specifier}");`,
|
|
126028
126116
|
};
|
|
126029
126117
|
};
|
|
126118
|
+
// grouped output merges the DDIC definitions of each folder, see DDIC_MODULE
|
|
126119
|
+
const ddic = new Set();
|
|
126030
126120
|
for (const obj of reg.getObjects()) {
|
|
126031
|
-
if (
|
|
126121
|
+
if (this.layout.isGrouped() && output_layout_1.DDIC_TYPES.has(obj.getType())) {
|
|
126122
|
+
ddic.add(this.layout.ddicModule({ type: obj.getType(), name: obj.getName() }));
|
|
126123
|
+
}
|
|
126124
|
+
else if (obj instanceof abaplint.Objects.Table
|
|
126032
126125
|
|| obj instanceof abaplint.Objects.DataElement
|
|
126033
126126
|
|| obj instanceof abaplint.Objects.LockObject
|
|
126034
126127
|
|| obj instanceof abaplint.Objects.MessageClass
|
|
@@ -126064,7 +126157,9 @@ globalThis.abap = new runtime.ABAP();\n`;
|
|
|
126064
126157
|
}
|
|
126065
126158
|
// Folder names must not change the original module initialization order.
|
|
126066
126159
|
list.sort((a, b) => a.filename < b.filename ? -1 : a.filename > b.filename ? 1 : 0);
|
|
126067
|
-
|
|
126160
|
+
// DDIC definitions only register lazy types, loading them first is always safe
|
|
126161
|
+
const early = [...ddic].sort().map(imp);
|
|
126162
|
+
return [...early, ...list, ...late].map(entry => entry.code).join("\n");
|
|
126068
126163
|
}
|
|
126069
126164
|
// class constructors might make early use of eg. constants from interfaces
|
|
126070
126165
|
// sub classes will import() super classes and trigger a class constructor of the super
|
|
@@ -126234,8 +126329,14 @@ exports.DEFAULT_KEYWORDS = new Set([
|
|
|
126234
126329
|
"use strict";
|
|
126235
126330
|
|
|
126236
126331
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
126237
|
-
exports.OutputLayout = void 0;
|
|
126332
|
+
exports.OutputLayout = exports.DDIC_MODULE = exports.DDIC_TYPES = void 0;
|
|
126238
126333
|
exports.importPath = importPath;
|
|
126334
|
+
/** Object types whose module only sets abap.DDIC[...] */
|
|
126335
|
+
exports.DDIC_TYPES = new Set(["DTEL", "TABL", "TTYP", "VIEW"]);
|
|
126336
|
+
/** Per folder module holding all its DDIC definitions. Object filenames never start
|
|
126337
|
+
* with an underscore, so it cannot collide with an object module. Loading tens of
|
|
126338
|
+
* thousands of tiny modules dominates startup, one module per folder avoids that. */
|
|
126339
|
+
exports.DDIC_MODULE = "_ddic.mjs";
|
|
126239
126340
|
/** Browser-safe paths: generated modules use POSIX paths on every platform. */
|
|
126240
126341
|
class OutputLayout {
|
|
126241
126342
|
grouped;
|
|
@@ -126285,6 +126386,17 @@ class OutputLayout {
|
|
|
126285
126386
|
const module = filename.replace(/\.abap$/i, ".mjs").toLowerCase();
|
|
126286
126387
|
return folder === undefined ? module : folder + "/" + module;
|
|
126287
126388
|
}
|
|
126389
|
+
/** With folders, the DDIC definitions of each folder share one module, see DDIC_MODULE */
|
|
126390
|
+
isGrouped() {
|
|
126391
|
+
return this.grouped;
|
|
126392
|
+
}
|
|
126393
|
+
/** The module defining this DDIC object's abap.DDIC entry */
|
|
126394
|
+
ddicModule(obj) {
|
|
126395
|
+
if (this.grouped === false) {
|
|
126396
|
+
throw new Error("DDIC modules are only merged in grouped output");
|
|
126397
|
+
}
|
|
126398
|
+
return this.file(obj, exports.DDIC_MODULE);
|
|
126399
|
+
}
|
|
126288
126400
|
objectModule(obj, suffix = "") {
|
|
126289
126401
|
const identifier = { name: obj.getName(), type: obj.getType() };
|
|
126290
126402
|
const filename = obj.getName().toLowerCase().replace(/\//g, "#") + "." + obj.getType().toLowerCase() + suffix + ".mjs";
|
|
@@ -143224,49 +143336,167 @@ class TypeFactoryRegistry {
|
|
|
143224
143336
|
this.inProgress.delete(type);
|
|
143225
143337
|
}
|
|
143226
143338
|
}
|
|
143339
|
+
/** Matches every call to a factory of this module, the name is the match minus "()" */
|
|
143340
|
+
callPattern() {
|
|
143341
|
+
const prefix = ("$t_" + this.modulePrefix + "_").replace(/[$]/g, "\\$");
|
|
143342
|
+
return new RegExp(prefix + "\\d+\\(\\)", "g");
|
|
143343
|
+
}
|
|
143344
|
+
countCalls(text, into) {
|
|
143345
|
+
for (const match of text.matchAll(this.callPattern())) {
|
|
143346
|
+
const name = match[0].slice(0, -2);
|
|
143347
|
+
into.set(name, (into.get(name) ?? 0) + 1);
|
|
143348
|
+
}
|
|
143349
|
+
}
|
|
143227
143350
|
/** Inline factories whose declaration and calls cost more than their use-site
|
|
143228
|
-
* expressions. This keeps opting in safe for small, mostly unique modules.
|
|
143351
|
+
* expressions. This keeps opting in safe for small, mostly unique modules.
|
|
143352
|
+
*
|
|
143353
|
+
* Factories are considered in registration order and the first one worth
|
|
143354
|
+
* inlining is inlined, until none is left. Inlining a factory only changes the
|
|
143355
|
+
* use counts of the factories it calls and the sizes of the factories calling
|
|
143356
|
+
* it, so these are updated in place instead of recounting all text, and the
|
|
143357
|
+
* text itself is rewritten once at the end. */
|
|
143229
143358
|
finalize(body) {
|
|
143230
|
-
|
|
143231
|
-
|
|
143232
|
-
|
|
143233
|
-
|
|
143234
|
-
|
|
143235
|
-
|
|
143236
|
-
|
|
143237
|
-
|
|
143238
|
-
|
|
143239
|
-
|
|
143359
|
+
const states = new Map();
|
|
143360
|
+
const ordered = [];
|
|
143361
|
+
for (const factory of this.factories.values()) {
|
|
143362
|
+
const state = {
|
|
143363
|
+
factory,
|
|
143364
|
+
order: ordered.length,
|
|
143365
|
+
uses: 0,
|
|
143366
|
+
expressionBytes: this.utf8Bytes(factory.expression),
|
|
143367
|
+
callBytes: this.utf8Bytes(factory.name + "()"),
|
|
143368
|
+
declarationBytes: this.utf8Bytes("function " + factory.name + "() { return ; }\n"),
|
|
143369
|
+
children: new Map(),
|
|
143370
|
+
parents: new Set(),
|
|
143371
|
+
inlined: false,
|
|
143372
|
+
};
|
|
143373
|
+
states.set(factory.name, state);
|
|
143374
|
+
ordered.push(state);
|
|
143375
|
+
}
|
|
143376
|
+
const bodyCalls = new Map();
|
|
143377
|
+
this.countCalls(body.getCode(), bodyCalls);
|
|
143378
|
+
for (const [name, count] of bodyCalls) {
|
|
143379
|
+
const state = states.get(name);
|
|
143380
|
+
if (state !== undefined) {
|
|
143381
|
+
state.uses += count;
|
|
143382
|
+
}
|
|
143383
|
+
}
|
|
143384
|
+
for (const state of ordered) {
|
|
143385
|
+
const calls = new Map();
|
|
143386
|
+
this.countCalls(state.factory.expression, calls);
|
|
143387
|
+
for (const [name, count] of calls) {
|
|
143388
|
+
const child = states.get(name);
|
|
143389
|
+
if (child !== undefined && child !== state) {
|
|
143390
|
+
state.children.set(name, count);
|
|
143391
|
+
child.parents.add(state.factory.name);
|
|
143392
|
+
child.uses += count;
|
|
143393
|
+
}
|
|
143394
|
+
}
|
|
143395
|
+
}
|
|
143396
|
+
const shouldInline = (state) => {
|
|
143397
|
+
const inlineBytes = state.expressionBytes * state.uses;
|
|
143398
|
+
const helperBytes = state.declarationBytes + state.expressionBytes + state.callBytes * state.uses;
|
|
143399
|
+
return state.uses === 0 || helperBytes >= inlineBytes;
|
|
143400
|
+
};
|
|
143401
|
+
// min-heap of registration order, entries are validated when popped
|
|
143402
|
+
const heap = [];
|
|
143403
|
+
const push = (value) => {
|
|
143404
|
+
heap.push(value);
|
|
143405
|
+
let index = heap.length - 1;
|
|
143406
|
+
while (index > 0) {
|
|
143407
|
+
const parent = Math.floor((index - 1) / 2);
|
|
143408
|
+
if (heap[parent] <= value) {
|
|
143409
|
+
break;
|
|
143240
143410
|
}
|
|
143241
|
-
|
|
143242
|
-
|
|
143243
|
-
|
|
143244
|
-
|
|
143245
|
-
|
|
143246
|
-
|
|
143247
|
-
|
|
143248
|
-
|
|
143249
|
-
|
|
143411
|
+
heap[index] = heap[parent];
|
|
143412
|
+
index = parent;
|
|
143413
|
+
}
|
|
143414
|
+
heap[index] = value;
|
|
143415
|
+
};
|
|
143416
|
+
const pop = () => {
|
|
143417
|
+
const top = heap[0];
|
|
143418
|
+
const last = heap.pop();
|
|
143419
|
+
if (heap.length > 0) {
|
|
143420
|
+
let index = 0;
|
|
143421
|
+
while (true) {
|
|
143422
|
+
let child = index * 2 + 1;
|
|
143423
|
+
if (child >= heap.length) {
|
|
143424
|
+
break;
|
|
143250
143425
|
}
|
|
143251
|
-
|
|
143252
|
-
|
|
143253
|
-
|
|
143426
|
+
if (child + 1 < heap.length && heap[child + 1] < heap[child]) {
|
|
143427
|
+
child++;
|
|
143428
|
+
}
|
|
143429
|
+
if (heap[child] >= last) {
|
|
143430
|
+
break;
|
|
143431
|
+
}
|
|
143432
|
+
heap[index] = heap[child];
|
|
143433
|
+
index = child;
|
|
143254
143434
|
}
|
|
143435
|
+
heap[index] = last;
|
|
143436
|
+
}
|
|
143437
|
+
return top;
|
|
143438
|
+
};
|
|
143439
|
+
for (const state of ordered) {
|
|
143440
|
+
if (shouldInline(state)) {
|
|
143441
|
+
push(state.order);
|
|
143255
143442
|
}
|
|
143256
143443
|
}
|
|
143257
|
-
|
|
143258
|
-
|
|
143259
|
-
|
|
143260
|
-
|
|
143261
|
-
|
|
143262
|
-
|
|
143263
|
-
const
|
|
143264
|
-
|
|
143265
|
-
|
|
143444
|
+
while (heap.length > 0) {
|
|
143445
|
+
const state = ordered[pop()];
|
|
143446
|
+
if (state.inlined || !shouldInline(state)) {
|
|
143447
|
+
continue;
|
|
143448
|
+
}
|
|
143449
|
+
state.inlined = true;
|
|
143450
|
+
const name = state.factory.name;
|
|
143451
|
+
for (const parentName of state.parents) {
|
|
143452
|
+
const parent = states.get(parentName);
|
|
143453
|
+
const occurrences = parent.children.get(name);
|
|
143454
|
+
parent.children.delete(name);
|
|
143455
|
+
parent.expressionBytes += occurrences * (state.expressionBytes - state.callBytes);
|
|
143456
|
+
for (const [childName, count] of state.children) {
|
|
143457
|
+
parent.children.set(childName, (parent.children.get(childName) ?? 0) + occurrences * count);
|
|
143458
|
+
states.get(childName).parents.add(parentName);
|
|
143459
|
+
}
|
|
143460
|
+
}
|
|
143461
|
+
for (const [childName, count] of state.children) {
|
|
143462
|
+
const child = states.get(childName);
|
|
143463
|
+
child.uses += count * (state.uses - 1);
|
|
143464
|
+
child.parents.delete(name);
|
|
143465
|
+
}
|
|
143466
|
+
for (const affected of [...state.parents, ...state.children.keys()]) {
|
|
143467
|
+
const other = states.get(affected);
|
|
143468
|
+
if (shouldInline(other)) {
|
|
143469
|
+
push(other.order);
|
|
143470
|
+
}
|
|
143266
143471
|
}
|
|
143267
|
-
count++;
|
|
143268
|
-
cursor = index + search.length;
|
|
143269
143472
|
}
|
|
143473
|
+
// rewrite all text once, expanding inlined calls recursively
|
|
143474
|
+
const expanded = new Map();
|
|
143475
|
+
const expand = (text) => text.replace(this.callPattern(), call => {
|
|
143476
|
+
const state = states.get(call.slice(0, -2));
|
|
143477
|
+
if (state === undefined || state.inlined === false) {
|
|
143478
|
+
return call;
|
|
143479
|
+
}
|
|
143480
|
+
let result = expanded.get(state.factory.name);
|
|
143481
|
+
if (result === undefined) {
|
|
143482
|
+
result = expand(state.factory.expression);
|
|
143483
|
+
expanded.set(state.factory.name, result);
|
|
143484
|
+
}
|
|
143485
|
+
return result;
|
|
143486
|
+
});
|
|
143487
|
+
body.replaceMatches(this.callPattern(), match => {
|
|
143488
|
+
const state = states.get(match[0].slice(0, -2));
|
|
143489
|
+
return state?.inlined === true ? expand(match[0]) : undefined;
|
|
143490
|
+
});
|
|
143491
|
+
for (const [key, factory] of this.factories) {
|
|
143492
|
+
if (states.get(factory.name).inlined) {
|
|
143493
|
+
this.factories.delete(key);
|
|
143494
|
+
}
|
|
143495
|
+
else {
|
|
143496
|
+
factory.expression = expand(factory.expression);
|
|
143497
|
+
}
|
|
143498
|
+
}
|
|
143499
|
+
return this.render();
|
|
143270
143500
|
}
|
|
143271
143501
|
utf8Bytes(input) {
|
|
143272
143502
|
let bytes = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.33",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@abaplint/core": "^2.120.105",
|
|
31
|
-
"@abaplint/transpiler": "^2.14.
|
|
31
|
+
"@abaplint/transpiler": "^2.14.33",
|
|
32
32
|
"@types/glob": "^9.0.0",
|
|
33
33
|
"@types/node": "^26.6.6",
|
|
34
34
|
"@types/progress": "^2.0.7",
|