Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Term context. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__EXPR__TERM_CONTEXT_STACK_H 16 : : #define CVC5__EXPR__TERM_CONTEXT_STACK_H 17 : : 18 : : #include "expr/term_context_node.h" 19 : : 20 : : namespace cvc5::internal { 21 : : 22 : : /** 23 : : * A stack for term-context-sensitive terms. Its main advantage is that 24 : : * it does not rely on explicit construction of TCtxNode for efficiency. 25 : : */ 26 : : class TCtxStack 27 : : { 28 : : public: 29 : : TCtxStack(const TermContext* tctx); 30 : 1909428 : virtual ~TCtxStack() {} 31 : : /** Push t to the stack */ 32 : : void pushInitial(Node t); 33 : : /** 34 : : * Push all children of t to the stack, where tval is the term context hash 35 : : * of t. */ 36 : : void pushChildren(Node t, uint32_t tval); 37 : : /** 38 : : * Push the child of t with the given index to the stack, where tval is 39 : : * the term context hash of t. 40 : : */ 41 : : void pushChild(Node t, uint32_t tval, size_t index); 42 : : /** 43 : : * Push the operator of t to the stack, where tval is the term context has 44 : : * of t. 45 : : */ 46 : : void pushOp(Node t, uint32_t tval); 47 : : /** Push t to the stack with term context hash tval. */ 48 : : void push(Node t, uint32_t tval); 49 : : /** Pop a term from the context */ 50 : : void pop(); 51 : : /** Clear the stack */ 52 : : void clear(); 53 : : /** Return the size of the stack */ 54 : : size_t size() const; 55 : : /** Return true if the stack is empty */ 56 : : bool empty() const; 57 : : /** Get the current stack element */ 58 : : std::pair<Node, uint32_t> getCurrent() const; 59 : : /** Get the current stack element, node version */ 60 : : TCtxNode getCurrentNode() const; 61 : : 62 : : private: 63 : : /** The stack */ 64 : : std::vector<std::pair<Node, uint32_t>> d_stack; 65 : : /** The term context */ 66 : : const TermContext* d_tctx; 67 : : }; 68 : : 69 : : } // namespace cvc5::internal 70 : : 71 : : #endif /* CVC5__EXPR__TERM_CONTEXT_STACK_H */