summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/assign-exp.hh
blob: ca575ec9b3640767cbe424840d6fcd78a27d21d9 (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/assign-exp.hh
 ** \brief Declaration of ast::AssignExp.
 */

#pragma once

#include <ast/exp.hh>
#include <ast/var.hh>

namespace ast
{
  /// AssignExp.
  class AssignExp : public Exp
  {
  public:
    /** \name Ctor & dtor.
     ** \{ */
    /// Construct an AssignExp node.
    AssignExp(const Location& location, Var* var, Exp* exp);
    AssignExp(const AssignExp&) = delete;
    AssignExp& operator=(const AssignExp&) = delete;
    /// Destroy an AssignExp node.
    ~AssignExp() 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 reference to the affected variable.
    const Var& var_get() const;
    /// Return reference to the affected variable.
    Var& var_get();
    /// Return assigned value.
    const Exp& exp_get() const;
    /// Return assigned value.
    Exp& exp_get();
    /** \} */

  protected:
    /// Reference to the affected variable.
    Var* var_;
    /// Assigned value.
    Exp* exp_;
  };
} // namespace ast
#include <ast/assign-exp.hxx>