-
Notifications
You must be signed in to change notification settings - Fork 2
/
builtins_impl.hh
207 lines (162 loc) · 5.29 KB
/
builtins_impl.hh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* Copyright (C) 2020 SUSE Software Solutions Germany GmbH
*
* This file is part of klp-ccp.
*
* klp-ccp is free software: you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* klp-ccp is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with klp-ccp. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef BUILTINS_IMPL_HH
#define BUILTINS_IMPL_HH
#include "builtins.hh"
#include <vector>
#include <functional>
namespace klp
{
namespace ccp
{
namespace builtins
{
namespace impl
{
class builtin_func_simple_proto final : public builtin_func
{
private:
typedef std::vector<std::shared_ptr<const types::addressable_type>>
exp_arg_types_type;
public:
virtual ~builtin_func_simple_proto() noexcept override;
virtual evaluation_result_type
evaluate(klp::ccp::ast::ast &a, const target &tgt,
ast::expr_func_invocation &efi) const override;
template<typename target_type,
typename ret_type_fac_type,
typename... exp_arg_types_facs_types>
static builtin_func::factory
factory(const target_type &tgt, const bool variadic,
const ret_type_fac_type &ret_type_fac,
const exp_arg_types_facs_types &...exp_arg_types_facs);
private:
builtin_func_simple_proto
(const bool variadic,
std::shared_ptr<const types::addressable_type> &&ret_type,
exp_arg_types_type &&exp_arg_types) noexcept;
public:
template <typename target_type,
typename ret_type_fac_type,
typename... exp_arg_types_facs_types>
static std::unique_ptr<builtin_func>
_create(const std::reference_wrapper<const target_type> &tgt,
const bool variadic,
const ret_type_fac_type &ret_type_fac,
const exp_arg_types_facs_types &...exp_arg_types_facs)
{
exp_arg_types_type exp_arg_types =
{ exp_arg_types_facs(tgt.get())... };
return (std::unique_ptr<builtin_func>
{new builtin_func_simple_proto(variadic,
ret_type_fac(tgt.get()),
std::move(exp_arg_types))});
}
const bool _variadic;
std::shared_ptr<const types::addressable_type> _ret_type;
exp_arg_types_type _exp_arg_types;
};
template<typename target_type,
typename ret_type_fac_type,
typename... exp_arg_types_facs_types>
builtin_func::factory builtin_func_simple_proto::
factory(const target_type &tgt, const bool variadic,
const ret_type_fac_type &ret_type_fac,
const exp_arg_types_facs_types &...exp_arg_types_facs)
{
auto b = std::bind
(_create<target_type,
typename std::decay<ret_type_fac_type>::type,
typename std::decay<exp_arg_types_facs_types>::type...>,
std::cref(tgt),
variadic,
ret_type_fac,
exp_arg_types_facs...);
return b;
}
std::shared_ptr<const types::addressable_type>
mk_v(const target&);
std::shared_ptr<const types::int_type>
mk_i(const target&);
std::shared_ptr<const types::int_type>
mk_u(const target&);
std::shared_ptr<const types::int_type>
mk_l(const target&);
std::shared_ptr<const types::int_type>
mk_ul(const target&);
std::shared_ptr<const types::int_type>
mk_ll(const target&);
std::shared_ptr<const types::int_type>
mk_ull(const target&);
std::shared_ptr<const types::addressable_type>
mk_b(const target&);
std::shared_ptr<const types::int_type>
mk_imax(const target &tgt);
std::shared_ptr<const types::int_type>
mk_umax(const target &tgt);
std::shared_ptr<const types::int_type>
mk_sz(const target &tgt);
std::shared_ptr<const types::int_type>
mk_ssz(const target &tgt);
std::shared_ptr<const types::addressable_type>
mk_f(const target&);
std::shared_ptr<const types::addressable_type>
mk_d(const target&);
std::shared_ptr<const types::addressable_type>
mk_ld(const target&);
std::shared_ptr<const types::addressable_type>
mk_fC(const target&);
std::shared_ptr<const types::addressable_type>
mk_dC(const target&);
std::shared_ptr<const types::addressable_type>
mk_ldC(const target&);
std::shared_ptr<const types::addressable_type>
mk_pv(const target&);
std::shared_ptr<const types::addressable_type>
mk_pcv(const target&);
std::shared_ptr<const types::addressable_type>
mk_pvv(const target&);
std::shared_ptr<const types::addressable_type>
mk_pcvv(const target&);
std::shared_ptr<const types::addressable_type>
mk_pc(const target&);
std::shared_ptr<const types::addressable_type>
mk_pcc(const target&);
std::shared_ptr<const types::addressable_type>
mk_pi(const target&);
std::shared_ptr<const types::addressable_type>
mk_pf(const target&);
std::shared_ptr<const types::addressable_type>
mk_pd(const target&);
std::shared_ptr<const types::addressable_type>
mk_pld(const target&);
class builtin_func_constant_p final : public builtin_func
{
public:
builtin_func_constant_p() noexcept;
virtual ~builtin_func_constant_p() noexcept override;
virtual evaluation_result_type
evaluate(klp::ccp::ast::ast &a, const target &tgt,
ast::expr_func_invocation &efi) const override;
static std::unique_ptr<builtin_func> create();
};
}
}
}
}
#endif