summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/callgraph/parent-graph-visitor.hh
blob: be16987e8946cc2a67553c0264b5097adc2e5fee (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
/**
 ** \file callgraph/parent-graph-visitor.hh
 ** \brief Definition of callgraph::ParentGraphVisitor.
 **/
#pragma once

#include <ast/default-visitor.hh>
#include <ast/non-assert-visitor.hh>
#include <ast/non-object-visitor.hh>
#include <callgraph/fundec-graph.hh>

namespace callgraph
{
  /// Compute the ParentGraph.
  class ParentGraphVisitor
    : public ast::DefaultVisitor
    , public ast::NonObjectVisitor
    , public ast::NonAssertVisitor
  {
    using super_type = ast::DefaultVisitor;
    using super_type::operator();

  public:
    ParentGraph* create(ast::Ast& tree);

    void operator()(ast::FunctionChunk& e) override;
    void operator()(ast::FunctionDec& e) override;

  protected:
    /// Current function.
    ast::FunctionDec* parent = nullptr;
    /// Parent graph.
    ParentGraph* parentgraph = nullptr;
  };

} // namespace callgraph