[analyzer] add `awkward_get_enum_index` and use it to optimize TSwitch (see #2216)