summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/method-call-exp.hh
blob: ef728d9a8943bdb035a8f685eb42860848610885 (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
61
62
63
64
65
66
67
68
69
70
/**
 ** \file ast/method-call-exp.hh
 ** \brief Declaration of ast::MethodCallExp.
 */

#pragma once

#include <ast/call-exp.hh>
#include <ast/method-dec.hh>
#include <ast/var.hh>

namespace ast
{
  /** \class ast::MethodCallExp
   ** \brief Method call.
   **
   ** A method call is \em not a function call in the strict sense
   ** of object-oriented programming.  Inheritance is used as a
   ** factoring tool here.
   */

  class MethodCallExp : public CallExp
  {
  public:
    /** \name Ctor & dtor.
     ** \{ */
    /// Construct a MethodCallExp node.
    MethodCallExp(const Location& location,
                  misc::symbol name,
                  exps_type* args,
                  Var* object);
    MethodCallExp(const MethodCallExp&) = delete;
    MethodCallExp& operator=(const MethodCallExp&) = delete;
    /// Destroy a MethodCallExp node.
    ~MethodCallExp() 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 object on which the method is called.
    const Var& object_get() const;
    /// Return the object on which the method is called.
    Var& object_get();
    // FIXME DONE: Some code was deleted here.
    /// Return definition site.
    const MethodDec* def_get() const;
    MethodDec* def_get();

    // FIXME DONE: Some code was deleted here.
    /// Set definition site.
    void def_set(MethodDec*);

    /** \} */

  protected:
    /// The object on which the method is called.
    Var* object_;
    /// Definition site.
    MethodDec* def_ = nullptr;
  };
} // namespace ast
#include <ast/method-call-exp.hxx>