OPAL (Object Oriented Parallel Accelerator Library)
2024.1
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
template
<
typename
>
27
struct
result
{
typedef
void
type
; };
28
29
std::vector<Iterator>&
iters
;
30
annotation
(std::vector<Iterator>&
iters
)
31
: iters(iters) {}
32
33
struct
set_id
34
{
35
typedef
void
result_type
;
36
37
int
id
;
38
set_id
(
int
id
) : id(id) {}
39
40
void
operator()
(
ast::function_call
& x)
const
41
{
42
x.
function_name
.
id
=
id
;
43
}
44
45
void
operator()
(
ast::identifier
& x)
const
46
{
47
x.
id
=
id
;
48
}
49
50
template
<
typename
T>
51
void
operator()
(
T
&
/*x*/
)
const
52
{
53
// no-op
54
}
55
};
56
57
void
operator()
(
ast::operand
& ast, Iterator pos)
const
58
{
59
int
id
=
iters
.size();
60
iters
.push_back(pos);
61
boost::apply_visitor(
set_id
(
id
), ast);
62
}
63
64
void
operator()
(
ast::identifier
& ast, Iterator pos)
const
65
{
66
int
id
=
iters
.size();
67
iters
.push_back(pos);
68
ast.
id
= id;
69
}
70
};
71
}
72
73
#endif
client::annotation::set_id::operator()
void operator()(ast::identifier &x) const
Definition:
annotation.hpp:45
client::annotation::operator()
void operator()(ast::operand &ast, Iterator pos) const
Definition:
annotation.hpp:57
client::annotation::set_id::operator()
void operator()(T &) const
Definition:
annotation.hpp:51
client::annotation::set_id::operator()
void operator()(ast::function_call &x) const
Definition:
annotation.hpp:40
client::ast::tagged::id
int id
Definition:
ast.hpp:21
client::annotation::annotation
annotation(std::vector< Iterator > &iters)
Definition:
annotation.hpp:30
client::annotation::set_id::set_id
set_id(int id)
Definition:
annotation.hpp:38
client::ast::identifier
Definition:
ast.hpp:31
client::annotation::operator()
void operator()(ast::identifier &ast, Iterator pos) const
Definition:
annotation.hpp:64
client::annotation::set_id
Definition:
annotation.hpp:33
client::annotation::iters
std::vector< Iterator > & iters
Definition:
annotation.hpp:29
Attrib::Legacy::Distribution::T
Definition:
Distribution.h:171
client::ast::function_call::function_name
identifier function_name
Definition:
ast.hpp:94
client::ast::function_call
Definition:
ast.hpp:92
client::annotation::set_id::result_type
void result_type
Definition:
annotation.hpp:35
ast.hpp
client::annotation::set_id::id
int id
Definition:
annotation.hpp:37
client::annotation::result::type
void type
Definition:
annotation.hpp:27
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
Definition:
annotation.hpp:24
client::annotation::result
Definition:
annotation.hpp:27
Generated on Tue Jul 2 2024 15:05:16 for OPAL (Object Oriented Parallel Accelerator Library) by
1.8.5