vhdlpp: Added ExpNew class.
This commit is contained in:
parent
c287281bbe
commit
d4dd635bf6
|
|
@ -439,3 +439,12 @@ ExpCast::~ExpCast()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExpNew::ExpNew(Expression*size) :
|
||||||
|
size_(size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpNew::~ExpNew()
|
||||||
|
{
|
||||||
|
delete size_;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -696,4 +696,23 @@ class ExpCast : public Expression {
|
||||||
const VType*type_;
|
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 */
|
#endif /* IVL_expression_H */
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,9 @@ void ExpCast::dump(ostream&out, int indent) const
|
||||||
out << " to ";
|
out << " to ";
|
||||||
type_->emit_def(out, empty_perm_string);
|
type_->emit_def(out, empty_perm_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpNew::dump(ostream&out, int indent) const
|
||||||
|
{
|
||||||
|
out << "New dynamic array size: ";
|
||||||
|
size_->dump(out, indent);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -870,3 +870,12 @@ int ExpCast::emit(ostream&out, Entity*ent, Architecture*arc)
|
||||||
out << ")";
|
out << ")";
|
||||||
return errors;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue