Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 1x 34x 34x 34x 34x 34x 1x | /** * Universidad de La Laguna * Escuela Superior de Ingeniería y Tecnología * Grado en Ingeniería Informática * Procesadores de Lenguajes * * @author Juan Rodríguez Suárez * @since Mar 04 2024 * @desc Contains a function to generate the JavaScript code from the AST. */ const recast = require("recast"); const { renderFile } = require('template-file'); /** * @brief Generates the JavaScript code from the AST * @param {object} ast - The AST * @returns {string} The JavaScript code */ async function codeGen(ast) { let code = recast.print(ast.ast).code; const USED_FUNCTIONS = Array.from(ast.dependencies); const ROOT = __dirname.replace(/\\/g, '/'); code = await renderFile(`${ROOT}/template.js`, { USED_FUNCTIONS, ROOT, code }); return code; } module.exports = codeGen; |