GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/strings_eager_pp.cpp Lines: 19 19 100.0 %
Date: 2021-09-29 Branches: 24 42 57.1 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Aina Niemetz
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 strings eager preprocess utility.
14
 */
15
16
#include "preprocessing/passes/strings_eager_pp.h"
17
18
#include "preprocessing/assertion_pipeline.h"
19
#include "theory/rewriter.h"
20
#include "theory/strings/theory_strings_preprocess.h"
21
22
using namespace cvc5::theory;
23
24
namespace cvc5 {
25
namespace preprocessing {
26
namespace passes {
27
28
6271
StringsEagerPp::StringsEagerPp(PreprocessingPassContext* preprocContext)
29
6271
    : PreprocessingPass(preprocContext, "strings-eager-pp"){};
30
31
30
PreprocessingPassResult StringsEagerPp::applyInternal(
32
    AssertionPipeline* assertionsToPreprocess)
33
{
34
30
  NodeManager* nm = NodeManager::currentNM();
35
60
  theory::strings::SkolemCache skc(false);
36
60
  theory::strings::StringsPreprocess pp(&skc);
37
105
  for (size_t i = 0, nasserts = assertionsToPreprocess->size(); i < nasserts;
38
       ++i)
39
  {
40
150
    Node prev = (*assertionsToPreprocess)[i];
41
150
    std::vector<Node> asserts;
42
150
    Node rew = pp.processAssertion(prev, asserts);
43
75
    if (!asserts.empty())
44
    {
45
58
      std::vector<Node> conj;
46
29
      conj.push_back(rew);
47
29
      conj.insert(conj.end(), asserts.begin(), asserts.end());
48
29
      rew = nm->mkAnd(conj);
49
    }
50
75
    if (prev != rew)
51
    {
52
29
      assertionsToPreprocess->replace(i, rewrite(rew));
53
    }
54
  }
55
56
60
  return PreprocessingPassResult::NO_CONFLICT;
57
}
58
59
}  // namespace passes
60
}  // namespace preprocessing
61
22746
}  // namespace cvc5