MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / main

Function main

etc/scripts/docenizers/docenizer-java.ts:82–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80};
81
82const 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
108main().then(() =>{}).catch(e => console.error("Caught error", e));

Callers 1

docenizer-java.tsFile · 0.70

Calls 4

readFileMethod · 0.80
extractFunction · 0.70
loadMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected