UNPKG

@abaplint/transpiler

Version:
49 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HandleFUGR = void 0; const abaplint = require("@abaplint/core"); const traversal_1 = require("../traversal"); const rearranger_1 = require("../rearranger"); const chunk_1 = require("../chunk"); class HandleFUGR { options; constructor(options) { this.options = options; } static shouldSkip(obj, reg) { // @ts-ignore todo return new abaplint.SkipLogic(reg).isGeneratedFunctionGroup(obj); } // function groups are compiled into a single file, with one closure for the function groups top variables runObject(obj, reg) { const spaghetti = new abaplint.SyntaxLogic(reg, obj).run().spaghetti; const chunk = new chunk_1.Chunk().appendString("{\n"); if (HandleFUGR.shouldSkip(obj, reg)) { return []; } for (const file of obj.getSequencedFiles()) { if (this.options?.addFilenames === true) { chunk.appendString("// " + file.getFilename() + "\n"); } const rearranged = new rearranger_1.Rearranger().run(obj.getType(), file.getStructure()); const contents = new traversal_1.Traversal(spaghetti, file, obj, reg, this.options).traverse(rearranged); chunk.appendChunk(contents); chunk.stripLastNewline(); chunk.runIndentationLogic(this.options?.ignoreSourceMap); } chunk.appendString("\n}"); const output = { object: { name: obj.getName(), type: obj.getType(), }, filename: obj.getName().toLowerCase().replace(/\//g, "#") + ".fugr.mjs", chunk: chunk, requires: [], exports: [], }; return [output]; } } exports.HandleFUGR = HandleFUGR; //# sourceMappingURL=handle_fugr.js.map