@@ -61,26 +61,24 @@ class irept
61
61
{
62
62
public:
63
63
typedef std::vector<irept> subt;
64
- // typedef std::list<irept> subt;
65
-
66
64
typedef std::map<irep_namet, irept> named_subt;
67
65
68
- bool is_nil () const { return id ()==ID_nil; }
69
- bool is_not_nil () const { return id ()!=ID_nil; }
66
+ inline bool is_nil () const { return id ()==ID_nil; }
67
+ inline bool is_not_nil () const { return id ()!=ID_nil; }
70
68
71
- inline explicit irept (const irep_idt &_id):data(NULL )
69
+ inline explicit irept (const irep_idt &_id):data(&empty_d )
72
70
{
73
71
id (_id);
74
72
}
75
73
76
74
#ifdef SHARING
77
- inline irept ():data(NULL )
75
+ inline irept ():data(&empty_d )
78
76
{
79
77
}
80
78
81
79
inline irept (const irept &irep):data(irep.data)
82
80
{
83
- if (data!=NULL )
81
+ if (data!=&empty_d )
84
82
{
85
83
assert (data->ref_count !=0 );
86
84
data->ref_count ++;
@@ -99,21 +97,21 @@ class irept
99
97
// Ordering is very important here!
100
98
// Consider self-assignment, which may destroy 'irep'
101
99
dt *irep_data=irep.data ;
102
- if (irep_data!=NULL ) irep_data->ref_count ++;
100
+ if (irep_data!=&empty_d ) irep_data->ref_count ++;
103
101
104
102
remove_ref (data); // this may kill 'irep'
105
103
data=irep_data;
106
104
107
105
return *this ;
108
106
}
109
107
110
- ~irept ()
108
+ inline ~irept ()
111
109
{
112
110
remove_ref (data);
113
111
data=NULL ;
114
112
}
115
113
#else
116
- irept ()
114
+ inline irept ()
117
115
{
118
116
}
119
117
#endif
@@ -135,7 +133,7 @@ class irept
135
133
const irept &find (const irep_namet &name) const ;
136
134
irept &add (const irep_namet &name);
137
135
138
- const std::string &get_string (const irep_namet &name) const
136
+ inline const std::string &get_string (const irep_namet &name) const
139
137
{
140
138
#ifdef USE_DSTRING
141
139
return get (name).as_string ();
@@ -166,7 +164,7 @@ class irept
166
164
167
165
std::string to_string () const ;
168
166
169
- void swap (irept &irep)
167
+ inline void swap (irept &irep)
170
168
{
171
169
std::swap (irep.data , data);
172
170
}
@@ -178,14 +176,14 @@ class irept
178
176
179
177
void clear ();
180
178
181
- void make_nil () { clear (); id (ID_nil); }
179
+ inline void make_nil () { clear (); id (ID_nil); }
182
180
183
- subt &get_sub () { return write ().sub ; } // DANGEROUS
184
- const subt &get_sub () const { return read ().sub ; }
185
- named_subt &get_named_sub () { return write ().named_sub ; } // DANGEROUS
186
- const named_subt &get_named_sub () const { return read ().named_sub ; }
187
- named_subt &get_comments () { return write ().comments ; } // DANGEROUS
188
- const named_subt &get_comments () const { return read ().comments ; }
181
+ inline subt &get_sub () { return write ().sub ; } // DANGEROUS
182
+ inline const subt &get_sub () const { return read ().sub ; }
183
+ inline named_subt &get_named_sub () { return write ().named_sub ; } // DANGEROUS
184
+ inline const named_subt &get_named_sub () const { return read ().named_sub ; }
185
+ inline named_subt &get_comments () { return write ().comments ; } // DANGEROUS
186
+ inline const named_subt &get_comments () const { return read ().comments ; }
189
187
190
188
size_t hash () const ;
191
189
size_t full_hash () const ;
@@ -195,7 +193,7 @@ class irept
195
193
std::string pretty (unsigned indent=0 , unsigned max_indent=0 ) const ;
196
194
197
195
protected:
198
- static bool is_comment (const irep_namet &name)
196
+ inline static bool is_comment (const irep_namet &name)
199
197
{ return !name.empty () && name[0 ]==' #' ; }
200
198
201
199
public:
@@ -250,12 +248,16 @@ class irept
250
248
protected:
251
249
#ifdef SHARING
252
250
dt *data;
251
+ static dt empty_d;
253
252
254
253
void remove_ref (dt *old_data);
255
254
void detatch ();
256
255
257
256
public:
258
- const dt &read () const ;
257
+ inline const dt &read () const
258
+ {
259
+ return *data;
260
+ }
259
261
260
262
inline dt &write ()
261
263
{
@@ -299,17 +301,17 @@ extern inline const std::string &name2string(const irep_namet &n)
299
301
300
302
struct irep_hash
301
303
{
302
- size_t operator ()(const irept &irep) const { return irep.hash (); }
304
+ inline size_t operator ()(const irept &irep) const { return irep.hash (); }
303
305
};
304
306
305
307
struct irep_full_hash
306
308
{
307
- size_t operator ()(const irept &irep) const { return irep.full_hash (); }
309
+ inline size_t operator ()(const irept &irep) const { return irep.full_hash (); }
308
310
};
309
311
310
312
struct irep_full_eq
311
313
{
312
- bool operator ()(const irept &i1, const irept &i2) const
314
+ inline bool operator ()(const irept &i1, const irept &i2) const
313
315
{
314
316
return full_eq (i1, i2);
315
317
}
0 commit comments