1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Justin Xu, Abdalrhman Mohamed, Andres Noetzli |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* The preprocessing pass super class. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "preprocessing/preprocessing_pass.h" |
17 |
|
|
18 |
|
#include "preprocessing/assertion_pipeline.h" |
19 |
|
#include "preprocessing/preprocessing_pass_context.h" |
20 |
|
#include "printer/printer.h" |
21 |
|
#include "smt/dump.h" |
22 |
|
#include "smt/output_manager.h" |
23 |
|
#include "smt/smt_engine_scope.h" |
24 |
|
#include "smt/smt_statistics_registry.h" |
25 |
|
#include "util/statistics_stats.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
namespace preprocessing { |
29 |
|
|
30 |
117077 |
PreprocessingPassResult PreprocessingPass::apply( |
31 |
|
AssertionPipeline* assertionsToPreprocess) { |
32 |
234154 |
TimerStat::CodeTimer codeTimer(d_timer); |
33 |
117077 |
Trace("preprocessing") << "PRE " << d_name << std::endl; |
34 |
117077 |
Chat() << d_name << "..." << std::endl; |
35 |
117077 |
dumpAssertions(("pre-" + d_name).c_str(), *assertionsToPreprocess); |
36 |
117077 |
PreprocessingPassResult result = applyInternal(assertionsToPreprocess); |
37 |
117067 |
dumpAssertions(("post-" + d_name).c_str(), *assertionsToPreprocess); |
38 |
117067 |
Trace("preprocessing") << "POST " << d_name << std::endl; |
39 |
234134 |
return result; |
40 |
|
} |
41 |
|
|
42 |
234144 |
void PreprocessingPass::dumpAssertions(const char* key, |
43 |
|
const AssertionPipeline& assertionList) { |
44 |
234144 |
if (Dump.isOn("assertions") && Dump.isOn(std::string("assertions:") + key)) |
45 |
|
{ |
46 |
|
// Push the simplified assertions to the dump output stream |
47 |
1 |
OutputManager& outMgr = d_preprocContext->getSmt()->getOutputManager(); |
48 |
1 |
const Printer& printer = outMgr.getPrinter(); |
49 |
1 |
std::ostream& out = outMgr.getDumpOut(); |
50 |
|
|
51 |
5 |
for (const auto& n : assertionList) |
52 |
|
{ |
53 |
4 |
printer.toStreamCmdAssert(out, n); |
54 |
|
} |
55 |
|
} |
56 |
234144 |
} |
57 |
|
|
58 |
335008 |
PreprocessingPass::PreprocessingPass(PreprocessingPassContext* preprocContext, |
59 |
335008 |
const std::string& name) |
60 |
|
: d_name(name), |
61 |
335008 |
d_timer(smtStatisticsRegistry().registerTimer("preprocessing::" + name)) |
62 |
|
{ |
63 |
335008 |
d_preprocContext = preprocContext; |
64 |
335008 |
} |
65 |
|
|
66 |
670016 |
PreprocessingPass::~PreprocessingPass() { |
67 |
335008 |
Assert(smt::smtEngineInScope()); |
68 |
335008 |
} |
69 |
|
|
70 |
|
} // namespace preprocessing |
71 |
29340 |
} // namespace cvc5 |