summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/simple-var.hh
blob: be47767b3a002eca6312b409db73d99cf04a8581 (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
55
56
/**
 ** \file ast/simple-var.hh
 ** \brief Declaration of ast::SimpleVar.
 */

#pragma once

#include <ast/var-dec.hh>
#include <ast/var.hh>
#include <misc/symbol.hh>

namespace ast
{
  /// SimpleVar.
  class SimpleVar : public Var
  {
  public:
    /** \name Ctor & dtor.
     ** \{ */
    /// Construct a SimpleVar node.
    SimpleVar(const Location& location, misc::symbol name);
    SimpleVar(const SimpleVar&) = delete;
    SimpleVar& operator=(const SimpleVar&) = delete;
    /// Destroy a SimpleVar node.
    /** \} */

    /// \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 variable's name.
    misc::symbol name_get() const;
    /// Set variable's name.
    void name_set(misc::symbol);
    /// Return definition site.
    const VarDec* def_get() const;
    /// Return definition site.
    VarDec* def_get();
    /// Set definition site.
    void def_set(VarDec*);
    /** \} */

  protected:
    /// Variable's name.
    misc::symbol name_;
    /// Definition site.
    VarDec* def_ = nullptr;
  };
} // namespace ast
#include <ast/simple-var.hxx>