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/if-exp.hh | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tiger-compiler/src/ast/if-exp.hh (limited to 'tiger-compiler/src/ast/if-exp.hh') diff --git a/tiger-compiler/src/ast/if-exp.hh b/tiger-compiler/src/ast/if-exp.hh new file mode 100644 index 0000000..6b27452 --- /dev/null +++ b/tiger-compiler/src/ast/if-exp.hh @@ -0,0 +1,71 @@ +/** + ** \file ast/if-exp.hh + ** \brief Declaration of ast::IfExp. + */ + +#pragma once + +#include +#include + +namespace ast +{ + /// IfExp. + class IfExp : public Exp + { + public: + IfExp(const Location& location, Exp* test, Exp* thenclause) + : Exp(location) + , test_(test) + , thenclause_(thenclause) + , elseclause_(new SeqExp(location, new exps_type())) + {} + + public: + /** \name Ctor & dtor. + ** \{ */ + /// Construct an IfExp node. + IfExp(const Location& location, + Exp* test, + Exp* thenclause, + Exp* elseclause); + IfExp(const IfExp&) = delete; + IfExp& operator=(const IfExp&) = delete; + /// Destroy an IfExp node. + ~IfExp() 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 condition. + const Exp& test_get() const; + /// Return condition. + Exp& test_get(); + /// Return instructions executed if condition is true. + const Exp& thenclause_get() const; + /// Return instructions executed if condition is true. + Exp& thenclause_get(); + /// Return instructions executed if condition is false. + const Exp& elseclause_get() const; + /// Return instructions executed if condition is false. + Exp& elseclause_get(); + /** \} */ + + protected: + /// Condition. + Exp* test_; + /// Instructions executed if condition is true. + Exp* thenclause_; + /// Instructions executed if condition is false. + Exp* elseclause_; + }; +} // namespace ast +#include -- cgit v1.2.3