summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/escapes/escapes-visitor.cc
blob: f0fd5e27f57acf7fa60510c6d8ca79d3729ed2e9 (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
/**
 ** \file escapes/escapes-visitor.cc
 ** \brief Implementation for escapes/escapes-visitor.hh.
 */

#include <ast/all.hh>
#include <escapes/escapes-visitor.hh>
#include <misc/contract.hh>

namespace escapes
{
  // FIXME DONE: Some code was deleted here.

  void EscapesVisitor::operator()(ast::SimpleVar& e)
  {
    if (depth_map_.at(e.def_get()) < current_depth_)
      e.def_get()->escape_set(true);
  }
  void EscapesVisitor::operator()(ast::VarDec& e)
  {
    e.escape_set(false);
    depth_map_.insert_or_assign(&e, current_depth_);
    super_type::operator()(e);
  }
  void EscapesVisitor::operator()(ast::FunctionDec& e)
  {
    current_depth_++;
    super_type::operator()(e);
    current_depth_--;
  }
} // namespace escapes