Last active
May 18, 2024 02:40
-
-
Save ikasoba/0f423ec78096d4ddcd76530f0e500ba5 to your computer and use it in GitHub Desktop.
instructionの名前とオペコードを https://webassembly.github.io/spec/core/appendix/index-instructions.html からスクレイピングするコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const convChr = (x) => | |
x | |
.replaceAll(/[\u{1d400}-\u{1d419}]/gu, (x) => | |
String.fromCodePoint(x.codePointAt(0) - 0x1d400 + "A".codePointAt(0)), | |
) | |
.replaceAll(/[\u{1d434}-\u{1d44d}]/gu, (x) => | |
String.fromCodePoint(x.codePointAt(0) - 0x1d434 + "A".codePointAt(0)), | |
) | |
.replaceAll(/[\u{1d468}-\u{1d481}]/gu, (x) => | |
String.fromCodePoint(x.codePointAt(0) - 0x1d468 + "A".codePointAt(0)), | |
) | |
.replaceAll(/[\u{1d41a}-\u{1d433}]/gu, (x) => | |
String.fromCodePoint(x.codePointAt(0) - 0x1d41a + "a".codePointAt(0)), | |
) | |
.replaceAll(/[\u{1d44e}-\u{1d467}]/gu, (x) => | |
String.fromCodePoint(x.codePointAt(0) - 0x1d44e + "a".codePointAt(0)), | |
); | |
export const opcode = [...document.querySelector("#index-of-instructions > table > tbody").children] | |
.map((x, i) => [ | |
convChr(x.children[0].innerText.replaceAll("\n", "").split(/\s+/)[0]), | |
convChr(x.children[1].innerText.replaceAll("\n", "")) | |
.split(/\s+/) | |
.map((x) => parseInt(x.replace(/^0x/, ""), 16)), | |
]) | |
.filter(([k]) => k != "(reserved)"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment