vhdlpp: Added ExpNew class.

This commit is contained in:
Maciej Suminski 2015-01-23 12:13:28 +01:00
parent c287281bbe
commit d4dd635bf6
4 changed files with 43 additions and 0 deletions

View File

@ -439,3 +439,12 @@ ExpCast::~ExpCast()
{
}
ExpNew::ExpNew(Expression*size) :
size_(size)
{
}
ExpNew::~ExpNew()
{
delete size_;
}

View File

@ -696,4 +696,23 @@ class ExpCast : public Expression {
const VType*type_;
};
/*
* Class that handles 'new' statement. VHDL is not capable of dynamic memory
* allocation, but it is useful for emitting some cases.
*/
class ExpNew : public Expression {
public:
ExpNew(Expression*size);
~ExpNew();
// There is no 'new' in VHDL - do not emit anything
void write_to_stream(std::ostream&) {};
int emit(ostream&out, Entity*ent, Architecture*arc);
void dump(ostream&out, int indent = 0) const;
private:
Expression*size_;
};
#endif /* IVL_expression_H */

View File

@ -76,3 +76,9 @@ void ExpCast::dump(ostream&out, int indent) const
out << " to ";
type_->emit_def(out, empty_perm_string);
}
void ExpNew::dump(ostream&out, int indent) const
{
out << "New dynamic array size: ";
size_->dump(out, indent);
}

View File

@ -870,3 +870,12 @@ int ExpCast::emit(ostream&out, Entity*ent, Architecture*arc)
out << ")";
return errors;
}
int ExpNew::emit(ostream&out, Entity*ent, Architecture*arc)
{
int errors = 0;
out << "new[";
errors += size_->emit(out, ent, arc);
out << "]";
return errors;
}