<reponame>Nanoteck137/Mass
types = ["S8", "S16", "S32", "S64",
         "U8", "U16", "U32", "U64",
         "F32", "F64"]

type_to_csharp = {
    "S8": "sbyte",
    "S16": "short",
    "S32": "int",
    "S64": "long",

    "U8": "byte",
    "U16": "ushort",
    "U32": "uint",
    "U64": "ulong",

    "F32": "float",
    "F64": "double",
}

result = ""

first = True

result += "#region AutoGenerated from Script GenTypeConvertCode.py\n"
for type in types:
    if not first:
        result += "else "

    result += "if(operand.Type == Type.{0})\n".format(type)
    result += "{\n"
    first_inner = True
    for inner_type in types:
        if not first_inner:
            result += "    else "
        else:
            result += "    "
        result += "if(type == Type.{0})\n".format(inner_type)
        result += "    {\n"
        ctype = type_to_csharp[str(inner_type)]
        result += "        operand.Val.{0} = ({1})operand.Val.{2};\n".format(
            inner_type.lower(), ctype, type.lower())
        result += "    }\n"
        first_inner = False
    result += "    else\n"
    result += "    {\n"
    result += "        Debug.Assert(false);\n"
    result += "    }\n"
    result += "}\n"

    first = False
result += "else\n"
result += "{\n"
result += "    operand.IsConst = false;\n"
result += "}\n"

result += "#endregion"

print(result)

types = ["S8", "S16", "S32", "S64",
         "U8", "U16", "U32", "U64",
         "F32", "F64"]

type_to_csharp = {
    "S8": "sbyte",
    "S16": "short",
    "S32": "int",
    "S64": "long",

    "U8": "byte",
    "U16": "ushort",
    "U32": "uint",
    "U64": "ulong",

    "F32": "float",
    "F64": "double",
}

result = ""

first = True

result += "#region AutoGenerated from Script GenTypeConvertCode.py\n"
for type in types:
    if not first:
        result += "else "

    result += "if(operand.Type == Type.{0})\n".format(type)
    result += "{\n"
    first_inner = True
    for inner_type in types:
        if not first_inner:
            result += "    else "
        else:
            result += "    "
        result += "if(type == Type.{0})\n".format(inner_type)
        result += "    {\n"
        ctype = type_to_csharp[str(inner_type)]
        result += "        operand.Val.{0} = ({1})operand.Val.{2};\n".format(
            inner_type.lower(), ctype, type.lower())
        result += "    }\n"
        first_inner = False
    result += "    else\n"
    result += "    {\n"
    result += "        Debug.Assert(false);\n"
    result += "    }\n"
    result += "}\n"

    first = False
result += "else\n"
result += "{\n"
result += "    operand.IsConst = false;\n"
result += "}\n"

result += "#endregion"

print(result)