PECastType: Use elaborated data type
PECastType currently uses the unelaborated data type to make the decision how to implement the cast. The unelaborated data type is provided by the parser and this works as long as the parser knows the data type. But for example with type parameters the actual data type is not known until elaboration. In preparation for supporting type parameters make sure to only use the elaborated type in the PECastType implementation. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
5da2951c12
commit
227cf20684
23
elab_expr.cc
23
elab_expr.cc
|
|
@ -3453,12 +3453,16 @@ NetExpr* PECastType::elaborate_expr(Design*des, NetScope*scope,
|
|||
if (sub == 0)
|
||||
return 0;
|
||||
|
||||
if (dynamic_cast<const real_type_t*>(target_)) {
|
||||
return cast_to_real(sub);
|
||||
}
|
||||
|
||||
NetExpr*tmp = 0;
|
||||
if (target_type_ && target_type_->packed()) {
|
||||
if (dynamic_cast<const netreal_t*>(target_type_)) {
|
||||
return cast_to_real(sub);
|
||||
} else if (dynamic_cast<const netstring_t*>(target_type_)) {
|
||||
if (base_->expr_type() == IVL_VT_STRING)
|
||||
return sub; // no conversion
|
||||
if (base_->expr_type() == IVL_VT_LOGIC ||
|
||||
base_->expr_type() == IVL_VT_BOOL)
|
||||
return sub; // handled by the target as special cases
|
||||
} else if (target_type_ && target_type_->packed()) {
|
||||
switch (target_type_->base_type()) {
|
||||
case IVL_VT_BOOL:
|
||||
tmp = cast_to_int2(sub, expr_width_);
|
||||
|
|
@ -3483,15 +3487,6 @@ NetExpr* PECastType::elaborate_expr(Design*des, NetScope*scope,
|
|||
return pad_to_width(tmp, expr_wid, signed_flag_, *this, target_type_);
|
||||
}
|
||||
|
||||
if (dynamic_cast<const string_type_t*>(target_)) {
|
||||
if (base_->expr_type() == IVL_VT_STRING)
|
||||
return sub; // no conversion
|
||||
|
||||
if (base_->expr_type() == IVL_VT_LOGIC
|
||||
|| base_->expr_type() == IVL_VT_BOOL)
|
||||
return sub; // handled by the target as special cases
|
||||
}
|
||||
|
||||
cerr << get_fileline() << ": sorry: This cast operation is not yet supported." << endl;
|
||||
des->errors += 1;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue