RCS file: /cvsroot/boost/boost/boost/xpressive/detail/core/state.hpp,v
retrieving revision 1.6
diff -b -d -u -r1.6 state.hpp
|
|
|
107 | 107 | bool found_partial_match_; |
108 | 108 | |
109 | 109 | match_context context_; |
110 | | results_extras &extras_; |
| 110 | results_extras *extras_; |
111 | 111 | action_state action_state_; |
112 | 112 | |
113 | 113 | /////////////////////////////////////////////////////////////////////////////// |
… |
… |
|
128 | 128 | , flags_(flags) |
129 | 129 | , found_partial_match_(false) |
130 | 130 | , context_() // zero-initializes the fields of context_ |
131 | | , extras_(core_access<BidiIter>::get_extras(what)) |
| 131 | , extras_(&core_access<BidiIter>::get_extras(what)) |
132 | 132 | , action_state_(core_access<BidiIter>::get_action_state(what)) |
133 | 133 | { |
134 | 134 | // reclaim any cached memory in the match_results struct |
135 | | this->extras_.sub_match_stack_.unwind(); |
| 135 | this->extras_->sub_match_stack_.unwind(); |
136 | 136 | |
137 | 137 | // initialize the context_ struct |
138 | 138 | this->init_(impl, what); |
139 | 139 | |
140 | 140 | // move all the nested match_results structs into the match_results cache |
141 | | this->extras_.results_cache_.reclaim_all(access::get_nested_results(what)); |
| 141 | this->extras_->results_cache_.reclaim_all(access::get_nested_results(what)); |
142 | 142 | } |
143 | 143 | |
144 | 144 | /////////////////////////////////////////////////////////////////////////////// |
… |
… |
|
146 | 146 | //void reset(match_results &what, basic_regex const &rex) |
147 | 147 | void reset(match_results &what, regex_impl const &impl) |
148 | 148 | { |
| 149 | this->extras_ = &core_access<BidiIter>::get_extras(what); |
149 | 150 | this->context_.prev_context_ = 0; |
150 | 151 | this->found_partial_match_ = false; |
151 | | this->extras_.sub_match_stack_.unwind(); |
| 152 | this->extras_->sub_match_stack_.unwind(); |
152 | 153 | this->init_(impl, what); |
153 | | this->extras_.results_cache_.reclaim_all(access::get_nested_results(what)); |
| 154 | this->extras_->results_cache_.reclaim_all(access::get_nested_results(what)); |
154 | 155 | } |
155 | 156 | |
156 | 157 | /////////////////////////////////////////////////////////////////////////////// |
… |
… |
|
163 | 164 | |
164 | 165 | // create a new nested match_results for this regex |
165 | 166 | nested_results<BidiIter> &nested = access::get_nested_results(*context.results_ptr_); |
166 | | match_results &what = this->extras_.results_cache_.append_new(nested); |
| 167 | match_results &what = this->extras_->results_cache_.append_new(nested); |
167 | 168 | |
168 | 169 | // (re)initialize the match context |
169 | 170 | this->init_(impl, what); |
… |
… |
|
191 | 192 | |
192 | 193 | // send the match_results struct back to the cache |
193 | 194 | nested_results<BidiIter> &nested = access::get_nested_results(what); |
194 | | this->extras_.results_cache_.reclaim_last(nested); |
| 195 | this->extras_->results_cache_.reclaim_last(nested); |
195 | 196 | } |
196 | 197 | |
197 | 198 | // restore the state |
… |
… |
|
255 | 256 | this->context_.results_ptr_ = &what; |
256 | 257 | this->context_.traits_ = impl.traits_.get(); |
257 | 258 | this->mark_count_ = impl.mark_count_ + 1; |
258 | | this->sub_matches_ = this->extras_.sub_match_stack_.push_sequence(total_mark_count); |
| 259 | this->sub_matches_ = this->extras_->sub_match_stack_.push_sequence(total_mark_count); |
259 | 260 | this->sub_matches_ += impl.hidden_mark_count_; |
260 | 261 | |
261 | 262 | // initialize the match_results struct |
… |
… |
|
264 | 265 | |
265 | 266 | void uninit_(regex_impl const &impl, match_results &) |
266 | 267 | { |
267 | | extras_.sub_match_stack_.unwind_to(this->sub_matches_ - impl.hidden_mark_count_); |
| 268 | extras_->sub_match_stack_.unwind_to(this->sub_matches_ - impl.hidden_mark_count_); |
268 | 269 | } |
269 | 270 | |
270 | 271 | bool found_partial_match() |
… |
… |
|
292 | 293 | { |
293 | 294 | memento<BidiIter> mem = |
294 | 295 | { |
295 | | state.extras_.sub_match_stack_.push_sequence(state.mark_count_, no_fill) |
| 296 | state.extras_->sub_match_stack_.push_sequence(state.mark_count_, no_fill) |
296 | 297 | , state.context_.results_ptr_->nested_results().size() |
297 | 298 | }; |
298 | 299 | std::copy(state.sub_matches_, state.sub_matches_ + state.mark_count_, mem.old_sub_matches_); |
… |
… |
|
308 | 309 | typedef core_access<BidiIter> access; |
309 | 310 | nested_results<BidiIter> &nested = access::get_nested_results(*state.context_.results_ptr_); |
310 | 311 | std::size_t count = state.context_.results_ptr_->nested_results().size() - mem.nested_results_count_; |
311 | | state.extras_.results_cache_.reclaim_last_n(nested, count); |
| 312 | state.extras_->results_cache_.reclaim_last_n(nested, count); |
312 | 313 | std::copy(mem.old_sub_matches_, mem.old_sub_matches_ + state.mark_count_, state.sub_matches_); |
313 | | state.extras_.sub_match_stack_.unwind_to(mem.old_sub_matches_); |
| 314 | state.extras_->sub_match_stack_.unwind_to(mem.old_sub_matches_); |
314 | 315 | } |
315 | 316 | |
316 | 317 | /////////////////////////////////////////////////////////////////////////////// |
… |
… |
|
322 | 323 | std::size_t count = state.context_.results_ptr_->nested_results().size() - mem.nested_results_count_; |
323 | 324 | if(count == 0) |
324 | 325 | { |
325 | | state.extras_.sub_match_stack_.unwind_to(mem.old_sub_matches_); |
| 326 | state.extras_->sub_match_stack_.unwind_to(mem.old_sub_matches_); |
326 | 327 | } |
327 | 328 | // else we have we must orphan this block of backrefs because we are using the stack |
328 | 329 | // space above it. |