summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/name-ty.hh
blob: de08848c49ac34b240d8bc000bf05461e8367d5a (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/name-ty.hh
 ** \brief Declaration of ast::NameTy.
 */

#pragma once

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

namespace ast
{
  /// NameTy.
  class NameTy : public Ty
  {
  public:
    /** \name Ctor & dtor.
     ** \{ */
    /// Construct a NameTy node.
    NameTy(const Location& location, misc::symbol name);
    NameTy(const NameTy&) = delete;
    NameTy& operator=(const NameTy&) = delete;
    /// Destroy a NameTy 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 the name of the type.
    misc::symbol name_get() const;
    /// Set the name of the type.
    void name_set(misc::symbol);
    /// Return definition site.
    const TypeDec* def_get() const;
    /// Return definition site.
    TypeDec* def_get();
    /// Set definition site.
    void def_set(TypeDec*);
    /** \} */

  protected:
    /// The name of the type.
    misc::symbol name_;
    /// Definition site.
    TypeDec* def_ = nullptr;
  };
} // namespace ast
#include <ast/name-ty.hxx>