cprover
cpp_template_args.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C++ Language Type Checking
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CPP_CPP_TEMPLATE_ARGS_H
13 #define CPROVER_CPP_CPP_TEMPLATE_ARGS_H
14 
15 #include <util/expr.h>
16 
17 // A data structures for template arguments, i.e.,
18 // a sequence of types/expressions of the form <E1, T2, ...>.
19 // Not to be confused with the template parameters!
20 
22 {
23 public:
24  cpp_template_args_baset():irept(ID_template_args)
25  {
26  }
27 
29 
31  {
32  return (argumentst &)(add(ID_arguments).get_sub());
33  }
34 
35  const argumentst &arguments() const
36  {
37  return (const argumentst &)(find(ID_arguments).get_sub());
38  }
39 };
40 
41 // the non-yet typechecked variant
42 
44 {
45 };
46 
48  irept &irep)
49 {
50  assert(irep.id()==ID_template_args);
51  return static_cast<cpp_template_args_non_tct &>(irep);
52 }
53 
55  const irept &irep)
56 {
57  assert(irep.id()==ID_template_args);
58  return static_cast<const cpp_template_args_non_tct &>(irep);
59 }
60 
61 // the already typechecked variant
62 
64 {
65 public:
66  bool has_unassigned() const
67  {
68  const argumentst &_arguments=arguments();
69  for(argumentst::const_iterator
70  it=_arguments.begin();
71  it!=_arguments.end();
72  it++)
73  if(it->id()==ID_unassigned ||
74  it->type().id()==ID_unassigned)
75  return true;
76 
77  return false;
78  }
79 };
80 
82 {
83  assert(irep.id()==ID_template_args);
84  return static_cast<cpp_template_args_tct &>(irep);
85 }
86 
88 {
89  assert(irep.id()==ID_template_args);
90  return static_cast<const cpp_template_args_tct &>(irep);
91 }
92 
93 #endif // CPROVER_CPP_CPP_TEMPLATE_ARGS_H
exprt::operandst argumentst
cpp_template_args_tct & to_cpp_template_args_tc(irept &irep)
cpp_template_args_non_tct & to_cpp_template_args_non_tc(irept &irep)
subt & get_sub()
Definition: irep.h:245
const irep_idt & id() const
Definition: irep.h:189
const argumentst & arguments() const
Base class for tree-like data structures with sharing.
Definition: irep.h:87
std::vector< exprt > operandst
Definition: expr.h:49
irept & add(const irep_namet &name)
Definition: irep.cpp:306
const irept & find(const irep_namet &name) const
Definition: irep.cpp:285