From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/ast/for-exp.hh | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tiger-compiler/src/ast/for-exp.hh (limited to 'tiger-compiler/src/ast/for-exp.hh') 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 +#include + +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 -- cgit v1.2.3