Finish cast.cc cleanup

Replace big if statement with switch statemetn
This commit is contained in:
Nick Gasson 2008-08-27 16:59:05 +01:00
parent b5e65ac9ed
commit 8323d5d01d
1 changed files with 16 additions and 12 deletions

View File

@ -39,18 +39,22 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to)
else else
return resize(to->get_width()); return resize(to->get_width());
} }
else if (to->get_name() == VHDL_TYPE_BOOLEAN) else {
return to_boolean(); switch (to->get_name()) {
else if (to->get_name() == VHDL_TYPE_INTEGER) case VHDL_TYPE_BOOLEAN:
return to_integer(); return to_boolean();
else if (to->get_name() == VHDL_TYPE_UNSIGNED case VHDL_TYPE_INTEGER:
|| to->get_name() == VHDL_TYPE_SIGNED return to_integer();
|| to->get_name() == VHDL_TYPE_STD_LOGIC_VECTOR) case VHDL_TYPE_UNSIGNED:
return to_vector(to->get_name(), to->get_width()); case VHDL_TYPE_SIGNED:
else if (to->get_name() == VHDL_TYPE_STD_LOGIC) case VHDL_TYPE_STD_LOGIC_VECTOR:
return to_std_logic(); return to_vector(to->get_name(), to->get_width());
else case VHDL_TYPE_STD_LOGIC:
assert(false); return to_std_logic();
default:
assert(false);
}
}
} }
/* /*