diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index 07a26f5d3..aa3b419d8 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -761,9 +761,8 @@ void vhdl_while_stmt::emit(std::ostream &of, int level) const { of << "while "; test_->emit(of, level); - of << " loop"; - stmts_.emit(of, level); - of << "end loop;"; + of << " "; + vhdl_loop_stmt::emit(of, level); } void vhdl_loop_stmt::emit(std::ostream &of, int level) const @@ -786,7 +785,7 @@ void vhdl_for_stmt::emit(std::ostream &of, int level) const of << " to "; to_->emit(of, level); of << " "; - loop_.emit(of, level); + vhdl_loop_stmt::emit(of, level); } vhdl_function::vhdl_function(const char *name, vhdl_type *ret_type) diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 50c3d305d..551e4636f 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -395,38 +395,36 @@ private: }; -class vhdl_while_stmt : public vhdl_seq_stmt { +class vhdl_loop_stmt : public vhdl_seq_stmt { +public: + virtual ~vhdl_loop_stmt() {} + + stmt_container *get_container() { return &stmts_; } + void emit(std::ostream &of, int level) const; +private: + stmt_container stmts_; +}; + + +class vhdl_while_stmt : public vhdl_loop_stmt { public: vhdl_while_stmt(vhdl_expr *test) : test_(test) {} ~vhdl_while_stmt(); - stmt_container *get_container() { return &stmts_; } void emit(std::ostream &of, int level) const; private: vhdl_expr *test_; - stmt_container stmts_; }; -class vhdl_loop_stmt : public vhdl_seq_stmt { -public: - stmt_container *get_container() { return &stmts_; } - void emit(std::ostream &of, int level) const; -private: - stmt_container stmts_; -}; - - -class vhdl_for_stmt : public vhdl_seq_stmt { +class vhdl_for_stmt : public vhdl_loop_stmt { public: vhdl_for_stmt(const char *lname, vhdl_expr *from, vhdl_expr *to) : lname_(lname), from_(from), to_(to) {} ~vhdl_for_stmt(); - stmt_container *get_container() { return loop_.get_container(); } void emit(std::ostream &of, int level) const; private: - vhdl_loop_stmt loop_; const char *lname_; vhdl_expr *from_, *to_; };