()
| 80 | }; |
| 81 | |
| 82 | const main = async () => { |
| 83 | const file = await fs.readFile(JVMS_SPECIFICATION, 'utf-8'); |
| 84 | const $ = cheerio.load(file); |
| 85 | const sections = $('div.section-execution'); |
| 86 | const instructions = sections.toArray() |
| 87 | .slice(1) // Drop 1 because the first is the "mne monic" |
| 88 | .map(it => extract($(it), $)) |
| 89 | .flat(); |
| 90 | console.log('import type {AssemblyInstructionInfo} from \'../../../types/assembly-docs.interfaces.js\';'); |
| 91 | console.log(''); |
| 92 | console.log('export function getAsmOpcode(opcode: string | undefined): AssemblyInstructionInfo | undefined {'); |
| 93 | console.log(' if (!opcode) return;'); |
| 94 | console.log(' switch (opcode.toUpperCase()) {'); |
| 95 | for (const instruction of instructions) { |
| 96 | console.log(` case '${instruction.name.toUpperCase()}':`); |
| 97 | console.log(' return {'); |
| 98 | console.log(` url: \`https://docs.oracle.com/javase/specs/jvms/se18/html/jvms-6.html#${instruction.anchor}\`,`); |
| 99 | const body = `<p>Instruction ${instruction.name}: ${instruction.tooltip}</p><p>Format: ${instruction.format.join(' ')}</p>${instruction.stack[0] && `<p>Operand Stack: ${instruction.stack[0]} ${instruction.stack[1]}</p>`}<p>${instruction.description}</p>`; |
| 100 | console.log(` html: \`${body.replace(/\s\s+/g, ' ')}\`,`); |
| 101 | console.log(` tooltip: \`${instruction.tooltip.replace(/\s\s+/g, ' ')}\`,`); |
| 102 | console.log(' };'); |
| 103 | } |
| 104 | console.log(' }'); |
| 105 | console.log('}'); |
| 106 | }; |
| 107 | |
| 108 | main().then(() =>{}).catch(e => console.error("Caught error", e)); |
no test coverage detected