Skip to content

Commit

Permalink
Added autonomous method to statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinffernandez committed Aug 27, 2024
1 parent 8f417c8 commit e225f11
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
25 changes: 17 additions & 8 deletions src/mmoc/ir/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
******************************************************************************/
#include <sstream>

#include "../ast/ast_builder.h"
#include "../ast/statement.h"
#include "../util/model_config.h"
#include "../util/util.h"
#include "../util/process_statement.h"
#include "../util/visitors/called_functions.h"
#include "helpers.h"
#include "statement.h"
#include <ast/ast_builder.h>
#include <ast/statement.h>
#include <ir/helpers.h>
#include <ir/statement.h>
#include <util/model_config.h>
#include <util/util.h>
#include <util/process_statement.h>
#include <util/visitors/called_functions.h>

namespace MicroModelica {
using namespace Util;
Expand Down Expand Up @@ -268,6 +268,15 @@ ExpressionList Statement::assignments(STATEMENT::AssignTerm asg) const
return ExpressionList();
}

bool Statement::autonomous() const
{
bool autonomous = true;
for (const auto& exp : _rhs_assignments) {
autonomous = autonomous && exp.autonomous();
}
return autonomous;
}

std::ostream& operator<<(std::ostream& out, const Statement& s) { return out << s.print(); }
} // namespace IR
} // namespace MicroModelica
15 changes: 6 additions & 9 deletions src/mmoc/ir/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
******************************************************************************/

#ifndef MMO_STATEMENT_H_
#define MMO_STATEMENT_H_
#pragma once

#include "../ast/ast_types.h"
#include "../util/table.h"
#include "index.h"
#include <ast/ast_types.h>
#include <ir/index.h>
#include <util/table.h>

namespace MicroModelica {

Expand All @@ -38,8 +37,7 @@ typedef enum { LHS, RHS, LHS_DISCRETES, LHS_STATES } AssignTerm;
class Statement {
public:
Statement(AST_Statement stm, bool initial = false, const std::string& block = "");
Statement(AST_Statement stm, Option<Range> range, bool initial = false,
const std::string& block = "");
Statement(AST_Statement stm, Option<Range> range, bool initial = false, const std::string& block = "");
Statement() : _stm(nullptr), _range(), _block(), _lhs_assignments(), _rhs_assignments(), _lhs_discretes(), _lhs_states(){};
~Statement() = default;

Expand All @@ -59,6 +57,7 @@ class Statement {
bool isAssignment() const;
bool isForStatement() const;
inline Option<Range> range() { return _range; };
bool autonomous() const;

protected:
void initialize();
Expand All @@ -82,5 +81,3 @@ class Statement {
typedef ModelTable<int, Statement> StatementTable;
} // namespace IR
} // namespace MicroModelica

#endif /* MMO_STATEMENT_H_ */

0 comments on commit e225f11

Please sign in to comment.