CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpp_template_type.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@cs.cmu.edu
6
7\*******************************************************************/
8
9
10#ifndef CPROVER_CPP_CPP_TEMPLATE_TYPE_H
11#define CPROVER_CPP_CPP_TEMPLATE_TYPE_H
12
13#include <util/invariant.h>
14#include <util/type.h>
15
17
19{
20public:
24
25 typedef std::vector<template_parametert> template_parameterst;
26
31
33 {
34 return (const template_parameterst &)find(ID_template_parameters).get_sub();
35 }
36
37 const typet &subtype() const
38 {
39 if(get_sub().empty())
40 return static_cast<const typet &>(get_nil_irep());
41 return static_cast<const typet &>(get_sub().front());
42 }
43
45 {
46 return add_subtype();
47 }
48};
49
51{
52 PRECONDITION(type.id() == ID_template);
53 return static_cast<template_typet &>(type);
54}
55
56inline const template_typet &to_template_type(const typet &type)
57{
58 PRECONDITION(type.id() == ID_template);
59 return static_cast<const template_typet &>(type);
60}
61
62inline const typet &template_subtype(const typet &type)
63{
64 if(type.id()==ID_template)
65 return to_type_with_subtype(type).subtype();
66
67 return type;
68}
69
71{
72 if(type.id()==ID_template)
73 return to_template_type(type).subtype();
74
75 return type;
76}
77
78#endif // CPROVER_CPP_CPP_TEMPLATE_TYPE_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
const irept & find(const irep_idt &name) const
Definition irep.cpp:93
subt & get_sub()
Definition irep.h:448
const irep_idt & id() const
Definition irep.h:388
irept & add(const irep_idt &name)
Definition irep.cpp:103
const template_parameterst & template_parameters() const
template_parameterst & template_parameters()
std::vector< template_parametert > template_parameterst
const typet & subtype() const
The type of an expression, extends irept.
Definition type.h:29
typet & add_subtype()
Definition type.h:53
const typet & template_subtype(const typet &type)
template_typet & to_template_type(typet &type)
const irept & get_nil_irep()
Definition irep.cpp:19
#define PRECONDITION(CONDITION)
Definition invariant.h:463
Defines typet, type_with_subtypet and type_with_subtypest.
const type_with_subtypet & to_type_with_subtype(const typet &type)
Definition type.h:208