from typing import (
    Dict,
)

from .binary import (
    BinaryOpcode,
)

OPCODE_TO_TEXT: Dict[BinaryOpcode, str] = {
    BinaryOpcode.UNREACHABLE: "unreachable",
    BinaryOpcode.NOP: "nop",
    BinaryOpcode.BLOCK: "block",
    BinaryOpcode.LOOP: "loop",
    BinaryOpcode.IF: "if",
    BinaryOpcode.ELSE: "else",
    BinaryOpcode.END: "end",
    BinaryOpcode.BR: "br",
    BinaryOpcode.BR_IF: "br_if",
    BinaryOpcode.BR_TABLE: "br_table",
    BinaryOpcode.RETURN: "return",
    BinaryOpcode.CALL: "call",
    BinaryOpcode.CALL_INDIRECT: "call_indirect",
    BinaryOpcode.DROP: "drop",
    BinaryOpcode.SELECT: "select",
    BinaryOpcode.GET_LOCAL: "get_local",
    BinaryOpcode.SET_LOCAL: "set_local",
    BinaryOpcode.TEE_LOCAL: "tee_local",
    BinaryOpcode.GET_GLOBAL: "get_global",
    BinaryOpcode.SET_GLOBAL: "set_global",
    BinaryOpcode.I32_LOAD: "i32.load",
    BinaryOpcode.I64_LOAD: "i64.load",
    BinaryOpcode.F32_LOAD: "f32.load",
    BinaryOpcode.F64_LOAD: "f64.load",
    BinaryOpcode.I32_LOAD8_S: "i32.load8_s",
    BinaryOpcode.I32_LOAD8_U: "i32.load8_u",
    BinaryOpcode.I32_LOAD16_S: "i32.load16_s",
    BinaryOpcode.I32_LOAD16_U: "i32.load16_u",
    BinaryOpcode.I64_LOAD8_S: "i64.load8_s",
    BinaryOpcode.I64_LOAD8_U: "i64.load8_u",
    BinaryOpcode.I64_LOAD16_S: "i64.load16_s",
    BinaryOpcode.I64_LOAD16_U: "i64.load16_u",
    BinaryOpcode.I64_LOAD32_S: "i64.load32_s",
    BinaryOpcode.I64_LOAD32_U: "i64.load32_u",
    BinaryOpcode.I32_STORE: "i32.store",
    BinaryOpcode.I64_STORE: "i64.store",
    BinaryOpcode.F32_STORE: "f32.store",
    BinaryOpcode.F64_STORE: "f64.store",
    BinaryOpcode.I32_STORE8: "i32.store8",
    BinaryOpcode.I32_STORE16: "i32.store16",
    BinaryOpcode.I64_STORE8: "i64.store8",
    BinaryOpcode.I64_STORE16: "i64.store16",
    BinaryOpcode.I64_STORE32: "i64.store32",
    BinaryOpcode.MEMORY_SIZE: "memory.size",
    BinaryOpcode.MEMORY_GROW: "memory.grow",
    BinaryOpcode.I32_CONST: "i32.const",
    BinaryOpcode.I64_CONST: "i64.const",
    BinaryOpcode.F32_CONST: "f32.const",
    BinaryOpcode.F64_CONST: "f64.const",
    BinaryOpcode.I32_EQZ: "i32.eqz",
    BinaryOpcode.I32_EQ: "i32.eq",
    BinaryOpcode.I32_NE: "i32.ne",
    BinaryOpcode.I32_LT_S: "i32.lt_s",
    BinaryOpcode.I32_LT_U: "i32.lt_u",
    BinaryOpcode.I32_GT_S: "i32.gt_s",
    BinaryOpcode.I32_GT_U: "i32.gt_u",
    BinaryOpcode.I32_LE_S: "i32.le_s",
    BinaryOpcode.I32_LE_U: "i32.le_u",
    BinaryOpcode.I32_GE_S: "i32.ge_s",
    BinaryOpcode.I32_GE_U: "i32.ge_u",
    BinaryOpcode.I64_EQZ: "i64.eqz",
    BinaryOpcode.I64_EQ: "i64.eq",
    BinaryOpcode.I64_NE: "i64.ne",
    BinaryOpcode.I64_LT_S: "i64.lt_s",
    BinaryOpcode.I64_LT_U: "i64.lt_u",
    BinaryOpcode.I64_GT_S: "i64.gt_s",
    BinaryOpcode.I64_GT_U: "i64.gt_u",
    BinaryOpcode.I64_LE_S: "i64.le_s",
    BinaryOpcode.I64_LE_U: "i64.le_u",
    BinaryOpcode.I64_GE_S: "i64.ge_s",
    BinaryOpcode.I64_GE_U: "i64.ge_u",
    BinaryOpcode.F32_EQ: "f32.eq",
    BinaryOpcode.F32_NE: "f32.ne",
    BinaryOpcode.F32_LT: "f32.lt",
    BinaryOpcode.F32_GT: "f32.gt",
    BinaryOpcode.F32_LE: "f32.le",
    BinaryOpcode.F32_GE: "f32.ge",
    BinaryOpcode.F64_EQ: "f64.eq",
    BinaryOpcode.F64_NE: "f64.ne",
    BinaryOpcode.F64_LT: "f64.lt",
    BinaryOpcode.F64_GT: "f64.gt",
    BinaryOpcode.F64_LE: "f64.le",
    BinaryOpcode.F64_GE: "f64.ge",
    BinaryOpcode.I32_CLZ: "i32.clz",
    BinaryOpcode.I32_CTZ: "i32.ctz",
    BinaryOpcode.I32_POPCNT: "i32.popcnt",
    BinaryOpcode.I32_ADD: "i32.add",
    BinaryOpcode.I32_SUB: "i32.sub",
    BinaryOpcode.I32_MUL: "i32.mul",
    BinaryOpcode.I32_DIV_S: "i32.div_s",
    BinaryOpcode.I32_DIV_U: "i32.div_u",
    BinaryOpcode.I32_REM_S: "i32.rem_s",
    BinaryOpcode.I32_REM_U: "i32.rem_u",
    BinaryOpcode.I32_AND: "i32.and",
    BinaryOpcode.I32_OR: "i32.or",
    BinaryOpcode.I32_XOR: "i32.xor",
    BinaryOpcode.I32_SHL: "i32.shl",
    BinaryOpcode.I32_SHR_S: "i32.shr_s",
    BinaryOpcode.I32_SHR_U: "i32.shr_u",
    BinaryOpcode.I32_ROTL: "i32.rotl",
    BinaryOpcode.I32_ROTR: "i32.rotr",
    BinaryOpcode.I64_CLZ: "i64.clz",
    BinaryOpcode.I64_CTZ: "i64.ctz",
    BinaryOpcode.I64_POPCNT: "i64.popcnt",
    BinaryOpcode.I64_ADD: "i64.add",
    BinaryOpcode.I64_SUB: "i64.sub",
    BinaryOpcode.I64_MUL: "i64.mul",
    BinaryOpcode.I64_DIV_S: "i64.div_s",
    BinaryOpcode.I64_DIV_U: "i64.div_u",
    BinaryOpcode.I64_REM_S: "i64.rem_s",
    BinaryOpcode.I64_REM_U: "i64.rem_u",
    BinaryOpcode.I64_AND: "i64.and",
    BinaryOpcode.I64_OR: "i64.or",
    BinaryOpcode.I64_XOR: "i64.xor",
    BinaryOpcode.I64_SHL: "i64.shl",
    BinaryOpcode.I64_SHR_S: "i64.shr_s",
    BinaryOpcode.I64_SHR_U: "i64.shr_u",
    BinaryOpcode.I64_ROTL: "i64.rotl",
    BinaryOpcode.I64_ROTR: "i64.rotr",
    BinaryOpcode.F32_ABS: "f32.abs",
    BinaryOpcode.F32_NEG: "f32.neg",
    BinaryOpcode.F32_CEIL: "f32.ceil",
    BinaryOpcode.F32_FLOOR: "f32.floor",
    BinaryOpcode.F32_TRUNC: "f32.trunc",
    BinaryOpcode.F32_NEAREST: "f32.nearest",
    BinaryOpcode.F32_SQRT: "f32.sqrt",
    BinaryOpcode.F32_ADD: "f32.add",
    BinaryOpcode.F32_SUB: "f32.sub",
    BinaryOpcode.F32_MUL: "f32.mul",
    BinaryOpcode.F32_DIV: "f32.div",
    BinaryOpcode.F32_MIN: "f32.min",
    BinaryOpcode.F32_MAX: "f32.max",
    BinaryOpcode.F32_COPYSIGN: "f32.copysign",
    BinaryOpcode.F64_ABS: "f64.abs",
    BinaryOpcode.F64_NEG: "f64.neg",
    BinaryOpcode.F64_CEIL: "f64.ceil",
    BinaryOpcode.F64_FLOOR: "f64.floor",
    BinaryOpcode.F64_TRUNC: "f64.trunc",
    BinaryOpcode.F64_NEAREST: "f64.nearest",
    BinaryOpcode.F64_SQRT: "f64.sqrt",
    BinaryOpcode.F64_ADD: "f64.add",
    BinaryOpcode.F64_SUB: "f64.sub",
    BinaryOpcode.F64_MUL: "f64.mul",
    BinaryOpcode.F64_DIV: "f64.div",
    BinaryOpcode.F64_MIN: "f64.min",
    BinaryOpcode.F64_MAX: "f64.max",
    BinaryOpcode.F64_COPYSIGN: "f64.copysign",
    BinaryOpcode.I32_WRAP_I64: "i32.wrap/i64",
    BinaryOpcode.I32_TRUNC_S_F32: "i32.trunc_s/f32",
    BinaryOpcode.I32_TRUNC_U_F32: "i32.trunc_u/f32",
    BinaryOpcode.I32_TRUNC_S_F64: "i32.trunc_s/f64",
    BinaryOpcode.I32_TRUNC_U_F64: "i32.trunc_u/f64",
    BinaryOpcode.I64_EXTEND_S_I32: "i64.extend_s/i32",
    BinaryOpcode.I64_EXTEND_U_I32: "i64.extend_u/i32",
    BinaryOpcode.I64_TRUNC_S_F32: "i64.trunc_s/f32",
    BinaryOpcode.I64_TRUNC_U_F32: "i64.trunc_u/f32",
    BinaryOpcode.I64_TRUNC_S_F64: "i64.trunc_s/f64",
    BinaryOpcode.I64_TRUNC_U_F64: "i64.trunc_u/f64",
    BinaryOpcode.F32_CONVERT_S_I32: "f32.convert_s/i32",
    BinaryOpcode.F32_CONVERT_U_I32: "f32.convert_u/i32",
    BinaryOpcode.F32_CONVERT_S_I64: "f32.convert_s/i64",
    BinaryOpcode.F32_CONVERT_U_I64: "f32.convert_u/i64",
    BinaryOpcode.F32_DEMOTE_F64: "f32.demote/f64",
    BinaryOpcode.F64_CONVERT_S_I32: "f64.convert_s/i32",
    BinaryOpcode.F64_CONVERT_U_I32: "f64.convert_u/i32",
    BinaryOpcode.F64_CONVERT_S_I64: "f64.convert_s/i64",
    BinaryOpcode.F64_CONVERT_U_I64: "f64.convert_u/i64",
    BinaryOpcode.F64_PROMOTE_F32: "f64.promote/f32",
    BinaryOpcode.I32_REINTERPRET_F32: "i32.reinterpret/f32",
    BinaryOpcode.I64_REINTERPRET_F64: "i64.reinterpret/f64",
    BinaryOpcode.F32_REINTERPRET_I32: "f32.reinterpret/i32",
    BinaryOpcode.F64_REINTERPRET_I64: "f64.reinterpret/i64",
}
