summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/subscript-var.hh
blob: d7713913463ad9c8dce738e6020e3bc5b4f29738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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>