CBMC
cpp_template_parameter.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H
11 #define CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H
12 
13 #include <util/expr.h>
14 
15 // A data structure for expressions of the form
16 // <typename T, int x, ...>
17 // Not to be confused with template arguments!
18 
20 {
21 public:
22  template_parametert():exprt(ID_template_parameter)
23  {
24  }
25 
26  #if 0
27  bool get_is_type() const
28  {
29  return get_bool(ID_is_type);
30  }
31 
32  void set_is_type(bool value)
33  {
34  set(ID_is_type, value);
35  }
36 
37  irep_idt get_identifier() const
38  {
39  return get(ID_identifier);
40  }
41 
42  void set_identifier(const irep_idt &identifier)
43  {
44  return set(ID_identifier, identifier);
45  }
46  #endif
47 
49  {
50  return static_cast<exprt &>(add(ID_C_default_value));
51  }
52 
53  const exprt &default_argument() const
54  {
55  return static_cast<const exprt &>(find(ID_C_default_value));
56  }
57 
58  bool has_default_argument() const
59  {
60  return find(ID_C_default_value).is_not_nil();
61  }
62 };
63 
66 {
67 public:
68  explicit template_parameter_symbol_typet(const irep_idt &identifier)
69  : 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 
95 {
96  PRECONDITION(type.id() == ID_template_parameter_symbol_type);
97  return static_cast<const template_parameter_symbol_typet &>(type);
98 }
99 
103 {
104  PRECONDITION(type.id() == ID_template_parameter_symbol_type);
105  return static_cast<template_parameter_symbol_typet &>(type);
106 }
107 
108 #endif // CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Base class for all expressions.
Definition: expr.h:56
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:57
const irept & find(const irep_idt &name) const
Definition: irep.cpp:93
const irep_idt & get(const irep_idt &name) const
Definition: irep.cpp:44
void set(const irep_idt &name, const irep_idt &value)
Definition: irep.h:408
bool is_not_nil() const
Definition: irep.h:368
const irep_idt & id() const
Definition: irep.h:384
irept & add(const irep_idt &name)
Definition: irep.cpp:103
The type of an expression, extends irept.
Definition: type.h:29
const template_parameter_symbol_typet & to_template_parameter_symbol_type(const typet &type)
Cast a typet to a template_parameter_symbol_typet.
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
a template parameter symbol that is a type
template_parameter_symbol_typet(const irep_idt &identifier)
const irep_idt & get_identifier() const
void set_identifier(const irep_idt &identifier)
const exprt & default_argument() const