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 {
switch (to->get_name()) {
case VHDL_TYPE_BOOLEAN:
return to_boolean(); return to_boolean();
else if (to->get_name() == VHDL_TYPE_INTEGER) case VHDL_TYPE_INTEGER:
return to_integer(); return to_integer();
else if (to->get_name() == VHDL_TYPE_UNSIGNED case VHDL_TYPE_UNSIGNED:
|| to->get_name() == VHDL_TYPE_SIGNED case VHDL_TYPE_SIGNED:
|| to->get_name() == VHDL_TYPE_STD_LOGIC_VECTOR) case VHDL_TYPE_STD_LOGIC_VECTOR:
return to_vector(to->get_name(), to->get_width()); return to_vector(to->get_name(), to->get_width());
else if (to->get_name() == VHDL_TYPE_STD_LOGIC) case VHDL_TYPE_STD_LOGIC:
return to_std_logic(); return to_std_logic();
else default:
assert(false); assert(false);
}
}
} }
/* /*