summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/subscript-var.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/subscript-var.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/ast/subscript-var.hh')
-rw-r--r--tiger-compiler/src/ast/subscript-var.hh54
1 files changed, 54 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/subscript-var.hh b/tiger-compiler/src/ast/subscript-var.hh
new file mode 100644
index 0000000..d771391
--- /dev/null
+++ b/tiger-compiler/src/ast/subscript-var.hh
@@ -0,0 +1,54 @@
+/**
+ ** \file ast/subscript-var.hh
+ ** \brief Declaration of ast::SubscriptVar.
+ */
+
+#pragma once
+
+#include <ast/exp.hh>
+#include <ast/var.hh>
+
+namespace ast
+{
+ /// SubscriptVar.
+ class SubscriptVar : public Var
+ {
+ public:
+ /** \name Ctor & dtor.
+ ** \{ */
+ /// Construct a SubscriptVar node.
+ SubscriptVar(const Location& location, Var* var, Exp* index);
+ SubscriptVar(const SubscriptVar&) = delete;
+ SubscriptVar& operator=(const SubscriptVar&) = delete;
+ /// Destroy a SubscriptVar node.
+ ~SubscriptVar() 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 the mother variable.
+ const Var& var_get() const;
+ /// Return the mother variable.
+ Var& var_get();
+ /// Return the offset expression.
+ const Exp& index_get() const;
+ /// Return the offset expression.
+ Exp& index_get();
+ /** \} */
+
+ protected:
+ /// The mother variable.
+ Var* var_;
+ /// The offset expression.
+ Exp* index_;
+ };
+} // namespace ast
+#include <ast/subscript-var.hxx>