vhdlpp: While loops.
This commit is contained in:
parent
bb695c6e11
commit
9df470c341
|
|
@ -1614,14 +1614,8 @@ loop_statement
|
||||||
if($1) delete[]$1;
|
if($1) delete[]$1;
|
||||||
if($8) delete[]$8;
|
if($8) delete[]$8;
|
||||||
|
|
||||||
ExpLogical* cond = dynamic_cast<ExpLogical*>($3);
|
WhileLoopStatement* tmp = new WhileLoopStatement(loop_name, $3, $5);
|
||||||
if(!cond) {
|
|
||||||
errormsg(@3, "Iteration condition is not a correct logical expression.\n");
|
|
||||||
}
|
|
||||||
WhileLoopStatement* tmp = new WhileLoopStatement(loop_name, cond, $5);
|
|
||||||
FILE_NAME(tmp, @1);
|
FILE_NAME(tmp, @1);
|
||||||
|
|
||||||
sorrymsg(@1, "Loop statements are not supported.\n");
|
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ VariableSeqAssignment::~VariableSeqAssignment()
|
||||||
delete rval_;
|
delete rval_;
|
||||||
}
|
}
|
||||||
|
|
||||||
WhileLoopStatement::WhileLoopStatement(perm_string lname, ExpLogical* cond, list<SequentialStmt*>* stmts)
|
WhileLoopStatement::WhileLoopStatement(perm_string lname, Expression* cond, list<SequentialStmt*>* stmts)
|
||||||
: LoopStatement(lname, stmts), cond_(cond)
|
: LoopStatement(lname, stmts), cond_(cond)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,14 +235,16 @@ class VariableSeqAssignment : public SequentialStmt {
|
||||||
class WhileLoopStatement : public LoopStatement {
|
class WhileLoopStatement : public LoopStatement {
|
||||||
public:
|
public:
|
||||||
WhileLoopStatement(perm_string loop_name,
|
WhileLoopStatement(perm_string loop_name,
|
||||||
ExpLogical*, list<SequentialStmt*>*);
|
Expression*, list<SequentialStmt*>*);
|
||||||
~WhileLoopStatement();
|
~WhileLoopStatement();
|
||||||
|
|
||||||
int elaborate(Entity*ent, ScopeBase*scope);
|
int elaborate(Entity*ent, ScopeBase*scope);
|
||||||
|
int emit(ostream&out, Entity*ent, ScopeBase*scope);
|
||||||
|
void write_to_stream(std::ostream&fd);
|
||||||
void dump(ostream&out, int indent) const;
|
void dump(ostream&out, int indent) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExpLogical* cond_;
|
Expression* cond_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ForLoopStatement : public LoopStatement {
|
class ForLoopStatement : public LoopStatement {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
# include "scope.h"
|
# include "scope.h"
|
||||||
# include "library.h"
|
# include "library.h"
|
||||||
# include "subprogram.h"
|
# include "subprogram.h"
|
||||||
|
# include "std_types.h"
|
||||||
|
|
||||||
int SequentialStmt::elaborate(Entity*, ScopeBase*)
|
int SequentialStmt::elaborate(Entity*, ScopeBase*)
|
||||||
{
|
{
|
||||||
|
|
@ -203,10 +204,12 @@ int VariableSeqAssignment::elaborate(Entity*ent, ScopeBase*scope)
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WhileLoopStatement::elaborate(Entity*, ScopeBase*)
|
int WhileLoopStatement::elaborate(Entity*ent, ScopeBase*scope)
|
||||||
{
|
{
|
||||||
//TODO:check whether there is any wait statement in the statements (there should be)
|
int errors = 0;
|
||||||
return 0;
|
errors += elaborate_substatements(ent, scope);
|
||||||
|
errors += cond_->elaborate_expr(ent, scope, cond_->probe_type(ent, scope));
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BasicLoopStatement::elaborate(Entity*, ScopeBase*)
|
int BasicLoopStatement::elaborate(Entity*, ScopeBase*)
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,28 @@ void CaseSeqStmt::CaseStmtAlternative::write_to_stream(ostream&fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WhileLoopStatement::emit(ostream&out, Entity*ent, ScopeBase*scope)
|
||||||
|
{
|
||||||
|
int errors = 0;
|
||||||
|
|
||||||
|
out << "while(";
|
||||||
|
errors += cond_->emit(out, ent, scope);
|
||||||
|
out << ") begin" << endl;
|
||||||
|
errors += emit_substatements(out, ent, scope);
|
||||||
|
out << "end" << endl;
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WhileLoopStatement::write_to_stream(ostream&out)
|
||||||
|
{
|
||||||
|
out << "while(";
|
||||||
|
cond_->write_to_stream(out);
|
||||||
|
out << ") loop" << endl;
|
||||||
|
write_to_stream_substatements(out);
|
||||||
|
out << "end loop;" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
int ForLoopStatement::emit(ostream&out, Entity*ent, ScopeBase*scope)
|
int ForLoopStatement::emit(ostream&out, Entity*ent, ScopeBase*scope)
|
||||||
{
|
{
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue