Skip to content

Commit

Permalink
Added commento to ast equations.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinffernandez committed Apr 20, 2023
1 parent d126bac commit eb078a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/mmoc/ast/equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ void AST_Equation_Equality_::setLeft(AST_Expression e) { _left = e; }

void AST_Equation_Equality_::setRight(AST_Expression e) { _right = e; }

AST_Equation_Equality_::AST_Equation_Equality_(AST_Expression left, AST_Expression right, AST_Comment comment) : _left(left), _right(right), _comment(comment) {}
AST_Equation_Equality_::AST_Equation_Equality_(AST_Expression left, AST_Expression right, AST_Comment comment)
: _left(left), _right(right), _comment(comment)
{
}

AST_Expression AST_Equation_Equality_::left() const { return _left; }

Expand Down Expand Up @@ -205,8 +208,8 @@ void AST_ForIndex_::accept(AST_Visitor *visitor)

/* When Equation Class */

AST_Equation_When_::AST_Equation_When_(AST_Expression cond, AST_EquationList eql, AST_Equation_ElseList elsewhen)
: _cond(cond), _eql(eql), _else_when(elsewhen)
AST_Equation_When_::AST_Equation_When_(AST_Expression cond, AST_EquationList eql, AST_Equation_ElseList elsewhen, AST_Comment c)
: _cond(cond), _eql(eql), _else_when(elsewhen), _comment(c)
{
}

Expand All @@ -220,6 +223,10 @@ AST_Equation_ElseList AST_Equation_When_::equationElseWhen() const { return _els

void AST_Equation_When_::setCondition(AST_Expression e) { _cond = e; }

AST_Comment AST_Equation_When_::comment() const { return _comment; }

bool AST_Equation_When_::hasComment() { return _comment != nullptr; }

string AST_Equation_When_::print() const
{
stringstream ret(stringstream::out);
Expand Down
5 changes: 4 additions & 1 deletion src/mmoc/ast/equation.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,19 @@ class AST_Equation_Else_ : public AST_Node_ {

class AST_Equation_When_ : public AST_Equation_ {
public:
AST_Equation_When_(AST_Expression cond, AST_EquationList eql, AST_Equation_ElseList elsewhen);
AST_Equation_When_(AST_Expression cond, AST_EquationList eql, AST_Equation_ElseList elsewhen, AST_Comment c);
string print() const;
AST_Expression condition() const;
AST_EquationList equationList() const;
EquationType equationType();
AST_Equation_ElseList equationElseWhen() const;
void setCondition(AST_Expression e);
AST_Comment comment() const;
bool hasComment();

private:
AST_Expression _cond;
AST_EquationList _eql;
AST_Equation_ElseList _else_when;
AST_Comment _comment;
};

0 comments on commit eb078a3

Please sign in to comment.