summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/field.hh
blob: cbb6352da92b588f917e8371062add0a62178749 (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
/**
 ** \file ast/field.hh
 ** \brief Declaration of ast::Field.
 */

#pragma once

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

namespace ast
{
  /// Field.
  class Field : public Ast
  {
  public:
    /** \name Ctor & dtor.
     ** \{ */
    /// Construct a Field node.
    Field(const Location& location, misc::symbol name, NameTy* type_name);
    Field(const Field&) = delete;
    Field& operator=(const Field&) = delete;
    /// Destroy a Field node.
    ~Field() 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 field name.
    misc::symbol name_get() const;
    /// Set the field name.
    void name_set(misc::symbol);
    /// Return the field type name.
    const NameTy& type_name_get() const;
    /// Return the field type name.
    NameTy& type_name_get();
    /** \} */

  protected:
    /// The field name.
    misc::symbol name_;
    /// The field type name.
    NameTy* type_name_;
  };
} // namespace ast
#include <ast/field.hxx>