blob: 7c75b08e12d45a493c90995dc0363e74625df1a4 (
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
|
#pragma once
/**
** \file object/libobject.hxx
** \brief Functions exported by the object module.
*/
#include <memory>
#include <desugar/libdesugar.hh>
#include <object/desugar-visitor.hh>
#include <object/fwd.hh>
namespace object
{
/*------------------.
| Desugar objects. |
`------------------*/
template <typename A>
A* raw_desugar(const A& tree, const class_names_type& class_names)
{
// Desugar.
::object::DesugarVisitor desugar(class_names);
desugar(tree);
return dynamic_cast<A*>(desugar.result_get());
}
template <typename A>
A* desugar(const A& tree, const class_names_type& class_names)
{
// Desugar.
A* desugared = raw_desugar(tree, class_names);
assertion(desugared);
std::unique_ptr<A> desugared_ptr(desugared);
// Recompute the bindings and the types.
::desugar::bind_and_types_check(*desugared_ptr);
return desugared_ptr.release();
}
/// Explicit instantiations.
template ast::ChunkList* raw_desugar(const ast::ChunkList&,
const class_names_type&);
template ast::ChunkList* desugar(const ast::ChunkList&,
const class_names_type&);
} // namespace object
|