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,19 +39,23 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to)
else
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();
else if (to->get_name() == VHDL_TYPE_INTEGER)
case VHDL_TYPE_INTEGER:
return to_integer();
else if (to->get_name() == VHDL_TYPE_UNSIGNED
|| to->get_name() == VHDL_TYPE_SIGNED
|| to->get_name() == VHDL_TYPE_STD_LOGIC_VECTOR)
case VHDL_TYPE_UNSIGNED:
case VHDL_TYPE_SIGNED:
case VHDL_TYPE_STD_LOGIC_VECTOR:
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();
else
default:
assert(false);
}
}
}
/*
* Generate code to cast an expression to a vector type (std_logic_vector,