1
- #include < kllvm/binary/ProofTraceParser .h>
1
+ #include < kllvm/binary/ProofTraceUtils .h>
2
2
3
3
#include < fmt/format.h>
4
4
#include < fstream>
@@ -174,24 +174,74 @@ llvm_rewrite_trace_iterator::get_next_event() {
174
174
}
175
175
176
176
void llvm_rewrite_trace_iterator::print (
177
- std::ostream &out, bool expand_terms, unsigned ind) {
177
+ std::ostream &out, bool expand_terms, unsigned ind,
178
+ bool intermediate_configs) {
178
179
std::string indent (ind * indent_size, ' ' );
179
180
out << fmt::format (" {}version: {}\n " , indent, version_);
180
181
while (auto event = get_next_event ()) {
181
182
event.value ().event .print (out, expand_terms, false , ind);
183
+ if (intermediate_configs) {
184
+ if (event.value ().type == llvm_event_type::InitialConfig) {
185
+ current_config_ = std::dynamic_pointer_cast<kore_composite_pattern>(
186
+ event.value ().event .getkore_pattern ());
187
+ } else if (event.value ().type == llvm_event_type::Trace) {
188
+ if (event.value ().event .is_pattern ()) {
189
+ current_config_ = std::dynamic_pointer_cast<kore_composite_pattern>(
190
+ event.value ().event .getkore_pattern ());
191
+ } else {
192
+ if (auto function_event
193
+ = std::dynamic_pointer_cast<llvm_function_event>(
194
+ event.value ().event .get_step_event ())) {
195
+ auto *new_config_event = build_post_function_event (
196
+ current_config_, function_event, expand_terms);
197
+ if (new_config_event) {
198
+ current_config_
199
+ = std::dynamic_pointer_cast<kore_composite_pattern>(
200
+ new_config_event->getkore_pattern ());
201
+ new_config_event->print (out, expand_terms, false , ind);
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
182
207
}
183
208
}
184
209
185
210
void llvm_rewrite_trace::print (
186
- std::ostream &out, bool expand_terms, unsigned ind) const {
211
+ std::ostream &out, bool expand_terms, unsigned ind,
212
+ bool intermediate_configs) const {
187
213
std::string indent (ind * indent_size, ' ' );
188
214
out << fmt::format (" {}version: {}\n " , indent, version_);
189
215
for (auto const &pre_trace_event : pre_trace_) {
190
216
pre_trace_event.print (out, expand_terms, false , ind);
191
217
}
192
218
initial_config_.print (out, expand_terms, false , ind);
193
- for (auto const &trace_event : trace_) {
194
- trace_event.print (out, expand_terms, false , ind);
219
+ if (intermediate_configs) {
220
+ auto current_config = std::dynamic_pointer_cast<kore_composite_pattern>(
221
+ initial_config_.getkore_pattern ());
222
+ for (auto const &trace_event : trace_) {
223
+ trace_event.print (out, expand_terms, false , ind);
224
+ if (trace_event.is_pattern ()) {
225
+ current_config = std::dynamic_pointer_cast<kore_composite_pattern>(
226
+ trace_event.getkore_pattern ());
227
+ } else {
228
+ if (auto function_event
229
+ = std::dynamic_pointer_cast<llvm_function_event>(
230
+ trace_event.get_step_event ())) {
231
+ auto *new_config_event = build_post_function_event (
232
+ current_config, function_event, expand_terms);
233
+ if (new_config_event) {
234
+ current_config = std::dynamic_pointer_cast<kore_composite_pattern>(
235
+ new_config_event->getkore_pattern ());
236
+ new_config_event->print (out, expand_terms, false , ind);
237
+ }
238
+ }
239
+ }
240
+ }
241
+ } else {
242
+ for (auto const &trace_event : trace_) {
243
+ trace_event.print (out, expand_terms, false , ind);
244
+ }
195
245
}
196
246
}
197
247
@@ -203,8 +253,8 @@ proof_trace_parser::proof_trace_parser(
203
253
, header_(header)
204
254
, kore_definition_(std::move(kore_definition)) { }
205
255
206
- std::optional<llvm_rewrite_trace>
207
- proof_trace_parser::parse_proof_trace ( std::string const &data) {
256
+ std::optional<llvm_rewrite_trace> proof_trace_parser::parse_proof_trace (
257
+ std::string const &data, bool intermediate_configs ) {
208
258
proof_trace_memory_buffer buffer (data.data (), data.data () + data.length ());
209
259
llvm_rewrite_trace trace;
210
260
bool result = parse_trace (buffer, trace);
@@ -214,14 +264,15 @@ proof_trace_parser::parse_proof_trace(std::string const &data) {
214
264
}
215
265
216
266
if (verbose_) {
217
- trace.print (std::cout, expand_terms_);
267
+ trace.print (std::cout, expand_terms_, 0U , intermediate_configs );
218
268
}
219
269
220
270
return trace;
221
271
}
222
272
223
273
std::optional<llvm_rewrite_trace>
224
- proof_trace_parser::parse_proof_trace_from_file (std::string const &filename) {
274
+ proof_trace_parser::parse_proof_trace_from_file (
275
+ std::string const &filename, bool intermediate_configs) {
225
276
std::ifstream file (filename, std::ios_base::binary);
226
277
proof_trace_file_buffer buffer (std::move (file));
227
278
llvm_rewrite_trace trace;
@@ -232,7 +283,7 @@ proof_trace_parser::parse_proof_trace_from_file(std::string const &filename) {
232
283
}
233
284
234
285
if (verbose_) {
235
- trace.print (std::cout, expand_terms_);
286
+ trace.print (std::cout, expand_terms_, 0U , intermediate_configs );
236
287
}
237
288
238
289
return trace;
0 commit comments