GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/abstract_values.cpp Lines: 16 16 100.0 %
Date: 2021-08-16 Branches: 23 58 39.7 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters
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
 * Utility for constructing and maintaining abstract values.
14
 */
15
16
#include "smt/abstract_values.h"
17
18
#include "expr/ascription_type.h"
19
#include "options/smt_options.h"
20
21
namespace cvc5 {
22
namespace smt {
23
24
10497
AbstractValues::AbstractValues(NodeManager* nm)
25
    : d_nm(nm),
26
      d_fakeContext(),
27
      d_abstractValueMap(&d_fakeContext),
28
10497
      d_abstractValues()
29
{
30
10497
}
31
10497
AbstractValues::~AbstractValues() {}
32
33
101875
Node AbstractValues::substituteAbstractValues(TNode n)
34
{
35
  // We need to do this even if options::abstractValues() is off,
36
  // since the setting might have changed after we already gave out
37
  // some abstract values.
38
101875
  return d_abstractValueMap.apply(n);
39
}
40
41
8
Node AbstractValues::mkAbstractValue(TNode n)
42
{
43
8
  Assert(options::abstractValues());
44
8
  Node& val = d_abstractValues[n];
45
8
  if (val.isNull())
46
  {
47
8
    val = d_nm->mkAbstractValue(n.getType());
48
8
    d_abstractValueMap.addSubstitution(val, n);
49
  }
50
  // We are supposed to ascribe types to all abstract values that go out.
51
16
  Node ascription = d_nm->mkConst(AscriptionType(n.getType()));
52
8
  Node retval = d_nm->mkNode(kind::APPLY_TYPE_ASCRIPTION, ascription, val);
53
16
  return retval;
54
}
55
56
}  // namespace smt
57
29340
}  // namespace cvc5