|
10 | 10 | #ifndef CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H
|
11 | 11 | #define CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H
|
12 | 12 |
|
13 |
| -#include <util/expr.h> |
| 13 | +#include <util/std_expr.h> |
14 | 14 |
|
15 | 15 | // A data structure for expressions of the form
|
16 | 16 | // <typename T, int x, ...>
|
@@ -61,4 +61,46 @@ struct template_parametert:public exprt
|
61 | 61 | }
|
62 | 62 | };
|
63 | 63 |
|
| 64 | +/// a template parameter symbol that is a type |
| 65 | +struct template_parameter_symbol_typet:public typet |
| 66 | +{ |
| 67 | +public: |
| 68 | + explicit template_parameter_symbol_typet( |
| 69 | + const irep_idt &identifier):typet(ID_template_parameter_symbol_type) |
| 70 | + { |
| 71 | + set_identifier(identifier); |
| 72 | + } |
| 73 | + |
| 74 | + void set_identifier(const irep_idt &identifier) |
| 75 | + { |
| 76 | + set(ID_identifier, identifier); |
| 77 | + } |
| 78 | + |
| 79 | + const irep_idt &get_identifier() const |
| 80 | + { |
| 81 | + return get(ID_identifier); |
| 82 | + } |
| 83 | +}; |
| 84 | + |
| 85 | +/// \brief Cast a typet to a \ref template_parameter_symbol_typet. |
| 86 | +/// |
| 87 | +/// This is an unchecked conversion. \a type must be known to be |
| 88 | +/// \ref template_parameter_symbol_typet. Will fail with a |
| 89 | +/// precondition violation if type doesn't match. |
| 90 | +/// |
| 91 | +/// \param type: Source type. |
| 92 | +/// \return Object of type \ref template_parameter_symbol_typet. |
| 93 | +inline const template_parameter_symbol_typet &to_template_parameter_symbol_type(const typet &type) |
| 94 | +{ |
| 95 | + PRECONDITION(type.id()==ID_template_parameter_symbol_type); |
| 96 | + return static_cast<const template_parameter_symbol_typet &>(type); |
| 97 | +} |
| 98 | + |
| 99 | +/// \copydoc to_template_parameter_symbol_type(const typet &) |
| 100 | +inline template_parameter_symbol_typet &to_template_parameter_symbol_type(typet &type) |
| 101 | +{ |
| 102 | + PRECONDITION(type.id()==ID_template_parameter_symbol_type); |
| 103 | + return static_cast<template_parameter_symbol_typet &>(type); |
| 104 | +} |
| 105 | + |
64 | 106 | #endif // CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H
|
0 commit comments