summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/array-exp.hh
blob: ceab38516f71910d00fb63de0ca501e15cde3599 (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
57
58
59
60
/**
 ** \file ast/array-exp.hh
 ** \brief Declaration of ast::ArrayExp.
 */

#pragma once

#include <ast/exp.hh>
#include <ast/name-ty.hh>

namespace ast
{
  /// ArrayExp.
  class ArrayExp : public Exp
  {
  public:
    /** \name Ctor & dtor.
     ** \{ */
    /// Construct an ArrayExp node.
    ArrayExp(const Location& location, NameTy* type_name, Exp* size, Exp* init);
    ArrayExp(const ArrayExp&) = delete;
    ArrayExp& operator=(const ArrayExp&) = delete;
    /// Destroy an ArrayExp node.
    ~ArrayExp() 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 identifier of the stored elements type.
    const NameTy& type_name_get() const;
    /// Return identifier of the stored elements type.
    NameTy& type_name_get();
    /// Return size of the array.
    const Exp& size_get() const;
    /// Return size of the array.
    Exp& size_get();
    /// Return initial value assigned to all elements of the array.
    const Exp& init_get() const;
    /// Return initial value assigned to all elements of the array.
    Exp& init_get();
    /** \} */

  protected:
    /// Identifier of the stored elements type.
    NameTy* type_name_;
    /// Size of the array.
    Exp* size_;
    /// Initial value assigned to all elements of the array.
    Exp* init_;
  };
} // namespace ast
#include <ast/array-exp.hxx>