summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/field-init.hh
blob: 9ea18b23344120b0ab7192037d359bbcdc3aa9c4 (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-init.hh
 ** \brief Declaration of ast::FieldInit.
 */

#pragma once

#include <ast/ast.hh>
#include <ast/exp.hh>
#include <misc/symbol.hh>

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

  protected:
    /// Name of the field.
    misc::symbol name_;
    /// Initial value of the field.
    Exp* init_;
  };
} // namespace ast
#include <ast/field-init.hxx>