summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/if-exp.hh
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/ast/if-exp.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/ast/if-exp.hh')
-rw-r--r--tiger-compiler/src/ast/if-exp.hh71
1 files changed, 71 insertions, 0 deletions
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 <ast/exp.hh>
+#include <ast/seq-exp.hh>
+
+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 <ast/if-exp.hxx>