summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/combine/tasks.cc
blob: 48470ac8e52bcb2d2ae3351459643e4a91e00b89 (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
71
72
73
74
/**
 ** \file combine/tasks.cc
 ** \brief Combine module related tasks' implementation.
 */

#include <ast/tasks.hh>
#include <bind/tasks.hh>
#include <desugar/tasks.hh>
#include <escapes/tasks.hh>
#include <object/tasks.hh>

#include <astclone/libastclone.hh>
#include <desugar/libdesugar.hh>
#include <inlining/libinlining.hh>

#include <common.hh>

#include <combine/libcombine.hh>
#define DEFINE_TASKS 1
#include <combine/tasks.hh>
#undef DEFINE_TASKS

namespace combine::tasks
{
  std::unique_ptr<overload::overfun_bindings_type> the_overfun_bindings =
    nullptr;

  void combine_bindings_compute()
  {
    auto result =
      ::combine::combine_bind(*ast::tasks::the_program, c_overload_p);
    ::combine::tasks::the_overfun_bindings =
      std::make_unique<overload::overfun_bindings_type>(
        std::move(result.first));

    task_error() << result.second << &misc::error::exit_on_error;
  }

  void combine_types_compute()
  {
    task_error() << ::combine::combine_types_check(
      *ast::tasks::the_program, *::combine::tasks::the_overfun_bindings,
      c_overload_p);
    the_overfun_bindings.reset();
    task_error().exit_on_error();
  }

  void combine_rename()
  {
    // FIXME: Some code was deleted here (Call appropriate renaming tasks).
  }

  void combine_desugar()
  {
    if (c_object_p)
      ::object::tasks::object_desugar();

    if (c_desugar_p)
      ::desugar::tasks::desugar();

    if (c_bounds_p)
      astclone::apply(::desugar::bounds_checks_add, ast::tasks::the_program);

    if (c_inline_p)
      astclone::apply(::inlining::inline_expand, ast::tasks::the_program);

    if (c_prune_p)
      astclone::apply(::inlining::prune, ast::tasks::the_program);

    if (c_escapes_p)
      ::escapes::tasks::escapes_compute();
  }

} // namespace combine::tasks