1 |
|
/* |
2 |
|
** Copyright (C) 2018 Martin Brain |
3 |
|
** |
4 |
|
** See the file LICENSE for licensing information. |
5 |
|
*/ |
6 |
|
|
7 |
|
/* |
8 |
|
** ite.h |
9 |
|
** |
10 |
|
** Martin Brain |
11 |
|
** martin.brain@cs.ox.ac.uk |
12 |
|
** 03/12/14 |
13 |
|
** |
14 |
|
** The handling of if-then-else depends on the type of both the condition |
15 |
|
** (i.e. is it concrete or is it symbolic) and the type of the data |
16 |
|
** (i.e. is it a symbolic class that wraps a tree node, is it a structure |
17 |
|
** containing them, etc.). Some of the handling will work for any condition, |
18 |
|
** any of the data, etc. So far not difficult in a language with multiple |
19 |
|
** dispatch including type variables. |
20 |
|
** |
21 |
|
** However, we are using C++, so there are a few extra hoops to jump |
22 |
|
** through. We declare ITEs as a struct containing a static function |
23 |
|
** as then we can partially specialise templates of them. |
24 |
|
** Specialisations of these are then given when appropriate types are |
25 |
|
** introduced. Care must be taken with these to ensure that we don't |
26 |
|
** get ambigious template instantiations. |
27 |
|
** |
28 |
|
*/ |
29 |
|
|
30 |
|
#ifndef SYMFPU_ITE |
31 |
|
#define SYMFPU_ITE |
32 |
|
|
33 |
|
namespace symfpu { |
34 |
|
|
35 |
|
template <class prop, class data> |
36 |
|
struct ite; |
37 |
|
|
38 |
|
// To avoid the need for putting the types *everywhere* we use a |
39 |
|
// helper function as C++ can perform type inference for functions |
40 |
|
// but not classes. |
41 |
|
template <class prop, class data> |
42 |
193675 |
const data ITE (const prop &c, const data &l, const data &r) { |
43 |
193675 |
return ite<prop, data>::iteOp(c, l, r); |
44 |
|
} |
45 |
|
|
46 |
|
} |
47 |
|
|
48 |
|
#endif |