Convert string to bitstring in SigVarBase
constructor if applicable (vhdlpp).
This commit is contained in:
parent
4786f80b0b
commit
9031f392ba
|
|
@ -639,6 +639,7 @@ class ExpString : public Expression {
|
|||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||
bool is_primary(void) const;
|
||||
void dump(ostream&out, int indent = 0) const;
|
||||
const std::vector<char>& get_value() const { return value_; }
|
||||
|
||||
private:
|
||||
int emit_as_array_(ostream&out, Entity*ent, Architecture*arc, const VTypeArray*arr);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,21 @@ using namespace std;
|
|||
SigVarBase::SigVarBase(perm_string nam, const VType*typ, Expression*exp)
|
||||
: name_(nam), type_(typ), init_expr_(exp), refcnt_sequ_(0)
|
||||
{
|
||||
if(init_expr_)
|
||||
{
|
||||
// convert the initializing string to bitstring if applicable
|
||||
const ExpString *string = dynamic_cast<const ExpString*>(init_expr_);
|
||||
if(string) {
|
||||
const std::vector<char>& val = string->get_value();
|
||||
char buf[val.size() + 1];
|
||||
std::copy(val.begin(), val.end(), buf);
|
||||
buf[val.size()] = 0;
|
||||
|
||||
ExpBitstring *bitstring = new ExpBitstring(buf);
|
||||
delete init_expr_;
|
||||
init_expr_ = bitstring;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SigVarBase::~SigVarBase()
|
||||
|
|
|
|||
Loading…
Reference in New Issue