macro_rules! c {
    ($x:ident, $y:expr) => {
        #[allow(dead_code)]
        pub const $x: u8 = $y;
    };
}

// https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#high-level-structure
c!(WASM_VERSION, 0x1);

// Section codes
c!(SC_TYPE, 1);
c!(SC_IMPORT, 2);
c!(SC_FUNCTION, 3);
c!(SC_TABLE, 4);
c!(SC_MEMORY, 5);
c!(SC_GLOBAL, 6);
c!(SC_EXPORT, 7);
c!(SC_START, 8);
c!(SC_ELEMENT, 9);
c!(SC_CODE, 10);
c!(SC_DATA, 11);

// https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#language-types
c!(TYPE_I32, 0x7f);
c!(TYPE_I64, 0x7e);
c!(TYPE_F32, 0x7d);
c!(TYPE_F64, 0x7c);
c!(TYPE_ANYFUNC, 0x70);
c!(TYPE_FUNC, 0x60);
c!(TYPE_VOID_BLOCK, 0x40);

// https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#external_kind
c!(EXT_FUNCTION, 0);
c!(EXT_TABLE, 1);
c!(EXT_MEMORY, 2);
c!(EXT_GLOBAL, 3);

// Taken from wasm2ast's source code and modified with vim magic
c!(OP_UNREACHABLE, 0x00);
c!(OP_NOP, 0x01);
c!(OP_BLOCK, 0x02);
c!(OP_LOOP, 0x03);
c!(OP_IF, 0x04);
c!(OP_ELSE, 0x05);
c!(OP_TRY, 0x06);
c!(OP_CATCH, 0x07);
c!(OP_THROW, 0x08);
c!(OP_RETHROW, 0x09);
c!(OP_CATCHALL, 0x0a);
c!(OP_END, 0x0b);
c!(OP_BR, 0x0c);
c!(OP_BRIF, 0x0d);
c!(OP_BRTABLE, 0x0e);
c!(OP_RETURN, 0x0f);
c!(OP_CALL, 0x10);
c!(OP_CALLINDIRECT, 0x11);
c!(OP_DROP, 0x1a);
c!(OP_SELECT, 0x1b);
c!(OP_GETLOCAL, 0x20);
c!(OP_SETLOCAL, 0x21);
c!(OP_TEELOCAL, 0x22);
c!(OP_GETGLOBAL, 0x23);
c!(OP_SETGLOBAL, 0x24);
c!(OP_I32LOAD, 0x28);
c!(OP_I64LOAD, 0x29);
c!(OP_F32LOAD, 0x2a);
c!(OP_F64LOAD, 0x2b);
c!(OP_I32LOAD8S, 0x2c);
c!(OP_I32LOAD8U, 0x2d);
c!(OP_I32LOAD16S, 0x2e);
c!(OP_I32LOAD16U, 0x2f);
c!(OP_I64LOAD8S, 0x30);
c!(OP_I64LOAD8U, 0x31);
c!(OP_I64LOAD16S, 0x32);
c!(OP_I64LOAD16U, 0x33);
c!(OP_I64LOAD32S, 0x34);
c!(OP_I64LOAD32U, 0x35);
c!(OP_I32STORE, 0x36);
c!(OP_I64STORE, 0x37);
c!(OP_F32STORE, 0x38);
c!(OP_F64STORE, 0x39);
c!(OP_I32STORE8, 0x3a);
c!(OP_I32STORE16, 0x3b);
c!(OP_I64STORE8, 0x3c);
c!(OP_I64STORE16, 0x3d);
c!(OP_I64STORE32, 0x3e);
c!(OP_CURRENTMEMORY, 0x3f);
c!(OP_GROWMEMORY, 0x40);
c!(OP_I32CONST, 0x41);
c!(OP_I64CONST, 0x42);
c!(OP_F32CONST, 0x43);
c!(OP_F64CONST, 0x44);
c!(OP_I32EQZ, 0x45);
c!(OP_I32EQ, 0x46);
c!(OP_I32NE, 0x47);
c!(OP_I32LTS, 0x48);
c!(OP_I32LTU, 0x49);
c!(OP_I32GTS, 0x4a);
c!(OP_I32GTU, 0x4b);
c!(OP_I32LES, 0x4c);
c!(OP_I32LEU, 0x4d);
c!(OP_I32GES, 0x4e);
c!(OP_I32GEU, 0x4f);
c!(OP_I64EQZ, 0x50);
c!(OP_I64EQ, 0x51);
c!(OP_I64NE, 0x52);
c!(OP_I64LTS, 0x53);
c!(OP_I64LTU, 0x54);
c!(OP_I64GTS, 0x55);
c!(OP_I64GTU, 0x56);
c!(OP_I64LES, 0x57);
c!(OP_I64LEU, 0x58);
c!(OP_I64GES, 0x59);
c!(OP_I64GEU, 0x5a);
c!(OP_F32EQ, 0x5b);
c!(OP_F32NE, 0x5c);
c!(OP_F32LT, 0x5d);
c!(OP_F32GT, 0x5e);
c!(OP_F32LE, 0x5f);
c!(OP_F32GE, 0x60);
c!(OP_F64EQ, 0x61);
c!(OP_F64NE, 0x62);
c!(OP_F64LT, 0x63);
c!(OP_F64GT, 0x64);
c!(OP_F64LE, 0x65);
c!(OP_F64GE, 0x66);
c!(OP_I32CLZ, 0x67);
c!(OP_I32CTZ, 0x68);
c!(OP_I32POPCNT, 0x69);
c!(OP_I32ADD, 0x6a);
c!(OP_I32SUB, 0x6b);
c!(OP_I32MUL, 0x6c);
c!(OP_I32DIVS, 0x6d);
c!(OP_I32DIVU, 0x6e);
c!(OP_I32REMS, 0x6f);
c!(OP_I32REMU, 0x70);
c!(OP_I32AND, 0x71);
c!(OP_I32OR, 0x72);
c!(OP_I32XOR, 0x73);
c!(OP_I32SHL, 0x74);
c!(OP_I32SHRS, 0x75);
c!(OP_I32SHRU, 0x76);
c!(OP_I32ROTL, 0x77);
c!(OP_I32ROTR, 0x78);
c!(OP_I64CLZ, 0x79);
c!(OP_I64CTZ, 0x7a);
c!(OP_I64POPCNT, 0x7b);
c!(OP_I64ADD, 0x7c);
c!(OP_I64SUB, 0x7d);
c!(OP_I64MUL, 0x7e);
c!(OP_I64DIVS, 0x7f);
c!(OP_I64DIVU, 0x80);
c!(OP_I64REMS, 0x81);
c!(OP_I64REMU, 0x82);
c!(OP_I64AND, 0x83);
c!(OP_I64OR, 0x84);
c!(OP_I64XOR, 0x85);
c!(OP_I64SHL, 0x86);
c!(OP_I64SHRS, 0x87);
c!(OP_I64SHRU, 0x88);
c!(OP_I64ROTL, 0x89);
c!(OP_I64ROTR, 0x8a);
c!(OP_F32ABS, 0x8b);
c!(OP_F32NEG, 0x8c);
c!(OP_F32CEIL, 0x8d);
c!(OP_F32FLOOR, 0x8e);
c!(OP_F32TRUNC, 0x8f);
c!(OP_F32NEAREST, 0x90);
c!(OP_F32SQRT, 0x91);
c!(OP_F32ADD, 0x92);
c!(OP_F32SUB, 0x93);
c!(OP_F32MUL, 0x94);
c!(OP_F32DIV, 0x95);
c!(OP_F32MIN, 0x96);
c!(OP_F32MAX, 0x97);
c!(OP_F32COPYSIGN, 0x98);
c!(OP_F64ABS, 0x99);
c!(OP_F64NEG, 0x9a);
c!(OP_F64CEIL, 0x9b);
c!(OP_F64FLOOR, 0x9c);
c!(OP_F64TRUNC, 0x9d);
c!(OP_F64NEAREST, 0x9e);
c!(OP_F64SQRT, 0x9f);
c!(OP_F64ADD, 0xa0);
c!(OP_F64SUB, 0xa1);
c!(OP_F64MUL, 0xa2);
c!(OP_F64DIV, 0xa3);
c!(OP_F64MIN, 0xa4);
c!(OP_F64MAX, 0xa5);
c!(OP_F64COPYSIGN, 0xa6);
c!(OP_I32WRAPI64, 0xa7);
c!(OP_I32TRUNCSF32, 0xa8);
c!(OP_I32TRUNCUF32, 0xa9);
c!(OP_I32TRUNCSF64, 0xaa);
c!(OP_I32TRUNCUF64, 0xab);
c!(OP_I64EXTENDSI32, 0xac);
c!(OP_I64EXTENDUI32, 0xad);
c!(OP_I64TRUNCSF32, 0xae);
c!(OP_I64TRUNCUF32, 0xaf);
c!(OP_I64TRUNCSF64, 0xb0);
c!(OP_I64TRUNCUF64, 0xb1);
c!(OP_F32CONVERTSI32, 0xb2);
c!(OP_F32CONVERTUI32, 0xb3);
c!(OP_F32CONVERTSI64, 0xb4);
c!(OP_F32CONVERTUI64, 0xb5);
c!(OP_F32DEMOTEF64, 0xb6);
c!(OP_F64CONVERTSI32, 0xb7);
c!(OP_F64CONVERTUI32, 0xb8);
c!(OP_F64CONVERTSI64, 0xb9);
c!(OP_F64CONVERTUI64, 0xba);
c!(OP_F64PROMOTEF32, 0xbb);
c!(OP_I32REINTERPRETF32, 0xbc);
c!(OP_I64REINTERPRETF64, 0xbd);
c!(OP_F32REINTERPRETI32, 0xbe);
c!(OP_F64REINTERPRETI64, 0xbf);

c!(MEM_NO_ALIGN, 0);
c!(MEM_ALIGN16, 1);
c!(MEM_ALIGN32, 2);
c!(MEM_ALIGN64, 3);
