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/env.h" |
23 |
|
#include "smt/output_manager.h" |
24 |
|
#include "smt/smt_engine_scope.h" |
25 |
|
#include "smt/smt_statistics_registry.h" |
26 |
|
#include "util/statistics_stats.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace preprocessing { |
30 |
|
|
31 |
117474 |
PreprocessingPassResult PreprocessingPass::apply( |
32 |
|
AssertionPipeline* assertionsToPreprocess) { |
33 |
234948 |
TimerStat::CodeTimer codeTimer(d_timer); |
34 |
117474 |
Trace("preprocessing") << "PRE " << d_name << std::endl; |
35 |
117474 |
Chat() << d_name << "..." << std::endl; |
36 |
117474 |
dumpAssertions(("pre-" + d_name).c_str(), *assertionsToPreprocess); |
37 |
117474 |
PreprocessingPassResult result = applyInternal(assertionsToPreprocess); |
38 |
117464 |
dumpAssertions(("post-" + d_name).c_str(), *assertionsToPreprocess); |
39 |
117464 |
Trace("preprocessing") << "POST " << d_name << std::endl; |
40 |
234928 |
return result; |
41 |
|
} |
42 |
|
|
43 |
234938 |
void PreprocessingPass::dumpAssertions(const char* key, |
44 |
|
const AssertionPipeline& assertionList) { |
45 |
234938 |
if (Dump.isOn("assertions") && Dump.isOn(std::string("assertions:") + key)) |
46 |
|
{ |
47 |
|
// Push the simplified assertions to the dump output stream |
48 |
1 |
Env& env = d_preprocContext->getEnv(); |
49 |
1 |
const Printer& printer = env.getPrinter(); |
50 |
1 |
std::ostream& out = env.getDumpOut(); |
51 |
|
|
52 |
5 |
for (const auto& n : assertionList) |
53 |
|
{ |
54 |
4 |
printer.toStreamCmdAssert(out, n); |
55 |
|
} |
56 |
|
} |
57 |
234938 |
} |
58 |
|
|
59 |
337558 |
PreprocessingPass::PreprocessingPass(PreprocessingPassContext* preprocContext, |
60 |
337558 |
const std::string& name) |
61 |
|
: EnvObj(preprocContext->getEnv()), |
62 |
|
d_preprocContext(preprocContext), |
63 |
|
d_name(name), |
64 |
337558 |
d_timer(smtStatisticsRegistry().registerTimer("preprocessing::" + name)) |
65 |
|
{ |
66 |
337558 |
} |
67 |
|
|
68 |
674912 |
PreprocessingPass::~PreprocessingPass() { |
69 |
337456 |
Assert(smt::smtEngineInScope()); |
70 |
337456 |
} |
71 |
|
|
72 |
|
} // namespace preprocessing |
73 |
29505 |
} // namespace cvc5 |