GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/strings_eager_pp.cpp Lines: 19 19 100.0 %
Date: 2021-09-18 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
9940
StringsEagerPp::StringsEagerPp(PreprocessingPassContext* preprocContext)
29
9940
    : PreprocessingPass(preprocContext, "strings-eager-pp"){};
30
31
40
PreprocessingPassResult StringsEagerPp::applyInternal(
32
    AssertionPipeline* assertionsToPreprocess)
33
{
34
40
  NodeManager* nm = NodeManager::currentNM();
35
80
  theory::strings::SkolemCache skc(false);
36
80
  theory::strings::StringsPreprocess pp(&skc);
37
141
  for (size_t i = 0, nasserts = assertionsToPreprocess->size(); i < nasserts;
38
       ++i)
39
  {
40
202
    Node prev = (*assertionsToPreprocess)[i];
41
202
    std::vector<Node> asserts;
42
202
    Node rew = pp.processAssertion(prev, asserts);
43
101
    if (!asserts.empty())
44
    {
45
70
      std::vector<Node> conj;
46
35
      conj.push_back(rew);
47
35
      conj.insert(conj.end(), asserts.begin(), asserts.end());
48
35
      rew = nm->mkAnd(conj);
49
    }
50
101
    if (prev != rew)
51
    {
52
35
      assertionsToPreprocess->replace(i, rewrite(rew));
53
    }
54
  }
55
56
80
  return PreprocessingPassResult::NO_CONFLICT;
57
}
58
59
}  // namespace passes
60
}  // namespace preprocessing
61
29574
}  // namespace cvc5