diff options
Diffstat (limited to 'tiger-compiler/src/ast/for-exp.hh')
| -rw-r--r-- | tiger-compiler/src/ast/for-exp.hh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/for-exp.hh b/tiger-compiler/src/ast/for-exp.hh new file mode 100644 index 0000000..b06a9be --- /dev/null +++ b/tiger-compiler/src/ast/for-exp.hh @@ -0,0 +1,60 @@ +/** + ** \file ast/for-exp.hh + ** \brief Declaration of ast::ForExp. + */ + +#pragma once + +#include <ast/exp.hh> +#include <ast/var-dec.hh> + +namespace ast +{ + /// ForExp. + class ForExp : public Exp + { + public: + /** \name Ctor & dtor. + ** \{ */ + /// Construct a ForExp node. + ForExp(const Location& location, VarDec* vardec, Exp* hi, Exp* body); + ForExp(const ForExp&) = delete; + ForExp& operator=(const ForExp&) = delete; + /// Destroy a ForExp node. + ~ForExp() override; + /** \} */ + + /// \name Visitors entry point. + /// \{ */ + /// Accept a const visitor \a v. + void accept(ConstVisitor& v) const override; + /// Accept a non-const visitor \a v. + void accept(Visitor& v) override; + /// \} + + /** \name Accessors. + ** \{ */ + /// Return implicit variable declaration. + const VarDec& vardec_get() const; + /// Return implicit variable declaration. + VarDec& vardec_get(); + /// Return high bound of the loop. + const Exp& hi_get() const; + /// Return high bound of the loop. + Exp& hi_get(); + /// Return instructions executed in the loop. + const Exp& body_get() const; + /// Return instructions executed in the loop. + Exp& body_get(); + /** \} */ + + protected: + /// Implicit variable declaration. + VarDec* vardec_; + /// High bound of the loop. + Exp* hi_; + /// Instructions executed in the loop. + Exp* body_; + }; +} // namespace ast +#include <ast/for-exp.hxx> |
