OPAL (Object Oriented Parallel Accelerator Library)
2.2.0
OPAL
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
optimizer
Expression
Parser
annotation.hpp
Go to the documentation of this file.
1
/*=============================================================================
2
Copyright (c) 2001-2011 Joel de Guzman
3
4
Distributed under the Boost Software License, Version 1.0. (See accompanying
5
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
=============================================================================*/
7
#if !defined(ANNOTATION_HPP)
8
#define ANNOTATION_HPP
9
10
#include <map>
11
#include <boost/variant/apply_visitor.hpp>
12
#include <boost/type_traits/is_base_of.hpp>
13
#include <boost/mpl/bool.hpp>
14
#include "
ast.hpp
"
15
16
namespace
client
17
{
19
// The annotation handler links the AST to a map of iterator positions
20
// for the purpose of subsequent semantic error handling when the
21
// program is being compiled.
23
template
<
typename
Iterator>
24
struct
annotation
25
{
26
#if BOOST_VERSION >= 106200
27
template
<
typename
>
28
#else
29
template
<
typename
,
typename
>
30
#endif
31
struct
result
{
typedef
void
type
; };
32
33
std::vector<Iterator>&
iters
;
34
annotation
(std::vector<Iterator>&
iters
)
35
: iters(iters) {}
36
37
struct
set_id
38
{
39
typedef
void
result_type
;
40
41
int
id
;
42
set_id
(
int
id
) : id(id) {}
43
44
void
operator()
(
ast::function_call
& x)
const
45
{
46
x.
function_name
.
id
=
id
;
47
}
48
49
void
operator()
(
ast::identifier
& x)
const
50
{
51
x.
id
=
id
;
52
}
53
54
template
<
typename
T>
55
void
operator()
(
T
& x)
const
56
{
57
// no-op
58
}
59
};
60
61
void
operator()
(
ast::operand
& ast, Iterator pos)
const
62
{
63
int
id
=
iters
.size();
64
iters
.push_back(pos);
65
boost::apply_visitor(
set_id
(
id
), ast);
66
}
67
68
void
operator()
(
ast::identifier
& ast, Iterator pos)
const
69
{
70
int
id
=
iters
.size();
71
iters
.push_back(pos);
72
ast.
id
= id;
73
}
74
};
75
}
76
77
#endif
client::annotation::set_id::operator()
void operator()(ast::function_call &x) const
Definition:
annotation.hpp:44
client::annotation::result
Definition:
annotation.hpp:31
T
Definition:
rbendmap.h:8
client::annotation::annotation
annotation(std::vector< Iterator > &iters)
Definition:
annotation.hpp:34
client::annotation::operator()
void operator()(ast::operand &ast, Iterator pos) const
Definition:
annotation.hpp:61
client::annotation::set_id::operator()
void operator()(T &x) const
Definition:
annotation.hpp:55
ast.hpp
client::annotation::set_id::id
int id
Definition:
annotation.hpp:41
client::annotation::operator()
void operator()(ast::identifier &ast, Iterator pos) const
Definition:
annotation.hpp:68
client::annotation::iters
std::vector< Iterator > & iters
Definition:
annotation.hpp:33
client::annotation::set_id::set_id
set_id(int id)
Definition:
annotation.hpp:42
client::annotation::set_id
Definition:
annotation.hpp:37
client::annotation::set_id::result_type
void result_type
Definition:
annotation.hpp:39
client::ast::function_call
Definition:
ast.hpp:92
client::ast::function_call::function_name
identifier function_name
Definition:
ast.hpp:94
client::annotation
Definition:
annotation.hpp:24
client::ast::identifier
Definition:
ast.hpp:31
client::annotation::result::type
void type
Definition:
annotation.hpp:31
client::ast::operand
boost::variant< nil, bool, unsigned int, double, identifier, boost::recursive_wrapper< unary >, boost::recursive_wrapper< function_call >, boost::recursive_wrapper< expression > > operand
Definition:
ast.hpp:53
client::annotation::set_id::operator()
void operator()(ast::identifier &x) const
Definition:
annotation.hpp:49
client::ast::tagged::id
int id
Definition:
ast.hpp:21
Generated on Sat Jan 4 2020 14:47:40 for OPAL (Object Oriented Parallel Accelerator Library) by
1.8.5