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. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__EXPR__TERM_CONTEXT_STACK_H |
19 |
|
#define CVC5__EXPR__TERM_CONTEXT_STACK_H |
20 |
|
|
21 |
|
#include "expr/term_context_node.h" |
22 |
|
|
23 |
|
namespace cvc5 { |
24 |
|
|
25 |
|
/** |
26 |
|
* A stack for term-context-sensitive terms. Its main advantage is that |
27 |
|
* it does not rely on explicit construction of TCtxNode for efficiency. |
28 |
|
*/ |
29 |
|
class TCtxStack |
30 |
|
{ |
31 |
|
public: |
32 |
|
TCtxStack(const TermContext* tctx); |
33 |
646593 |
virtual ~TCtxStack() {} |
34 |
|
/** Push t to the stack */ |
35 |
|
void pushInitial(Node t); |
36 |
|
/** |
37 |
|
* Push all children of t to the stack, where tval is the term context hash |
38 |
|
* of t. */ |
39 |
|
void pushChildren(Node t, uint32_t tval); |
40 |
|
/** |
41 |
|
* Push the child of t with the given index to the stack, where tval is |
42 |
|
* the term context hash of t. |
43 |
|
*/ |
44 |
|
void pushChild(Node t, uint32_t tval, size_t index); |
45 |
|
/** |
46 |
|
* Push the operator of t to the stack, where tval is the term context has |
47 |
|
* of t. |
48 |
|
*/ |
49 |
|
void pushOp(Node t, uint32_t tval); |
50 |
|
/** Push t to the stack with term context hash tval. */ |
51 |
|
void push(Node t, uint32_t tval); |
52 |
|
/** Pop a term from the context */ |
53 |
|
void pop(); |
54 |
|
/** Clear the stack */ |
55 |
|
void clear(); |
56 |
|
/** Return the size of the stack */ |
57 |
|
size_t size() const; |
58 |
|
/** Return true if the stack is empty */ |
59 |
|
bool empty() const; |
60 |
|
/** Get the current stack element */ |
61 |
|
std::pair<Node, uint32_t> getCurrent() const; |
62 |
|
/** Get the current stack element, node version */ |
63 |
|
TCtxNode getCurrentNode() const; |
64 |
|
|
65 |
|
private: |
66 |
|
/** The stack */ |
67 |
|
std::vector<std::pair<Node, uint32_t>> d_stack; |
68 |
|
/** The term context */ |
69 |
|
const TermContext* d_tctx; |
70 |
|
}; |
71 |
|
|
72 |
|
} // namespace cvc5 |
73 |
|
|
74 |
|
#endif /* CVC5__EXPR__TERM_CONTEXT_STACK_H */ |