vhdlpp: Refactored code for format matching in read/write() sys functions.

This commit is contained in:
Maciej Suminski 2016-02-17 13:47:50 +01:00
parent a7f4d65aaa
commit 83330c22fb
1 changed files with 21 additions and 11 deletions

View File

@ -116,21 +116,31 @@ class SubprogramReadWrite : public SubprogramBuiltin {
} }
const VType*arg_type = argv[1]->probe_type(ent, scope); const VType*arg_type = argv[1]->probe_type(ent, scope);
const VTypeArray*arr = dynamic_cast<const VTypeArray*>(arg_type);
const VTypePrimitive*prim = dynamic_cast<const VTypePrimitive*>(arg_type); while(const VTypeDef*tdef = dynamic_cast<const VTypeDef*>(arg_type))
arg_type = tdef->peek_definition();
// Pick the right format // Pick the right format
if(hex_format_) if(hex_format_) {
out << FORMAT_HEX; out << FORMAT_HEX;
else if(prim && prim->type() == VTypePrimitive::TIME) } else if(arg_type) {
out << FORMAT_TIME; if(arg_type->type_match(&primitive_TIME)) {
else if(arg_type && arg_type->type_match(&type_BOOLEAN)) out << FORMAT_TIME;
out << FORMAT_BOOL; } else if(arg_type->type_match(&type_BOOLEAN)) {
else if((arg_type && arg_type->type_match(&primitive_CHARACTER)) || out << FORMAT_BOOL;
(arr && arr->element_type() == &primitive_CHARACTER)) } else if(arg_type->type_match(&primitive_CHARACTER)) {
out << FORMAT_STRING; out << FORMAT_STRING;
else } else {
const VTypeArray*arr = dynamic_cast<const VTypeArray*>(arg_type);
if(arr && arr->element_type() == &primitive_CHARACTER)
out << FORMAT_STRING;
else
out << FORMAT_STD;
}
} else {
out << FORMAT_STD; out << FORMAT_STD;
}
return errors; return errors;
} }