diff --git a/src/mmoc/ir/expression.cpp b/src/mmoc/ir/expression.cpp index c88a9099..4f23957e 100644 --- a/src/mmoc/ir/expression.cpp +++ b/src/mmoc/ir/expression.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -161,8 +162,8 @@ std::ostream& operator<<(std::ostream& out, const Expression& s) out << s.print(); return out; } -bool Expression::operator<(const Expression &other) const -{ +bool Expression::operator<(const Expression& other) const +{ std::stringstream cmp_this; std::stringstream cmp_other; cmp_this << *this; @@ -170,5 +171,11 @@ bool Expression::operator<(const Expression &other) const return cmp_this.str() < cmp_other.str(); } +std::multimap Expression::usedVariables() const +{ + GetIndexVariables used_variables; + return used_variables.apply(_exp); +} + } // namespace IR } // namespace MicroModelica diff --git a/src/mmoc/ir/expression.h b/src/mmoc/ir/expression.h index ed0aecfd..fb0ae688 100644 --- a/src/mmoc/ir/expression.h +++ b/src/mmoc/ir/expression.h @@ -43,10 +43,12 @@ class Expression { bool isScalar() const; list indexes() const; static Expression generate(std::string var_name, std::vector indices); - bool operator<(const Expression &other) const; + bool operator<(const Expression& other) const; friend std::ostream& operator<<(std::ostream& out, const Expression& s); + std::multimap usedVariables() const; + protected: std::vector usageExps() const;