GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/term_context_stack.cpp Lines: 26 36 72.2 %
Date: 2021-08-01 Branches: 38 134 28.4 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
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
 * Term context stack.
14
 */
15
16
#include "expr/term_context_stack.h"
17
18
#include "expr/term_context.h"
19
20
namespace cvc5 {
21
22
651565
TCtxStack::TCtxStack(const TermContext* tctx) : d_tctx(tctx) {}
23
24
651565
void TCtxStack::pushInitial(Node t)
25
{
26
651565
  Assert(d_stack.empty());
27
651565
  d_stack.push_back(std::pair<Node, uint32_t>(t, d_tctx->initialValue()));
28
651565
}
29
30
313774
void TCtxStack::pushChildren(Node t, uint32_t tval)
31
{
32
892274
  for (size_t i = 0, nchild = t.getNumChildren(); i < nchild; i++)
33
  {
34
578500
    pushChild(t, tval, i);
35
  }
36
313774
}
37
38
2848869
void TCtxStack::pushChild(Node t, uint32_t tval, size_t index)
39
{
40
2848869
  Assert(index < t.getNumChildren());
41
5697738
  Trace("tctx-debug") << "TCtxStack::pushChild: computing " << t << "[" << index
42
2848869
                      << "] / " << tval << std::endl;
43
2848869
  uint32_t tcval = d_tctx->computeValue(t, tval, index);
44
5697738
  Trace("tctx-debug") << "TCtxStack::pushChild: returned " << t << "[" << index
45
2848869
                      << "] / " << tval << " ---> " << tcval << std::endl;
46
2848869
  d_stack.push_back(std::pair<Node, uint32_t>(t[index], tcval));
47
2848869
}
48
49
void TCtxStack::pushOp(Node t, uint32_t tval)
50
{
51
  Assert(t.hasOperator());
52
  uint32_t toval = d_tctx->computeValueOp(t, tval);
53
  d_stack.push_back(std::pair<Node, uint32_t>(t.getOperator(), toval));
54
}
55
56
387686
void TCtxStack::push(Node t, uint32_t tval)
57
{
58
387686
  d_stack.push_back(std::pair<Node, uint32_t>(t, tval));
59
387686
}
60
61
3888120
void TCtxStack::pop() { d_stack.pop_back(); }
62
63
void TCtxStack::clear() { d_stack.clear(); }
64
size_t TCtxStack::size() const { return d_stack.size(); }
65
66
5569402
bool TCtxStack::empty() const { return d_stack.empty(); }
67
68
5568328
std::pair<Node, uint32_t> TCtxStack::getCurrent() const
69
{
70
5568328
  return d_stack.back();
71
}
72
73
TCtxNode TCtxStack::getCurrentNode() const
74
{
75
  std::pair<Node, uint32_t> curr = TCtxStack::getCurrent();
76
  return TCtxNode(curr.first, curr.second, d_tctx);
77
}
78
79
29280
}  // namespace cvc5