1 /********************* */
2 /*! \file rewriter_attributes.h
4 ** Top contributors (to current version):
5 ** Dejan Jovanovic, Tim King, Morgan Deters
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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.\endverbatim
12 ** \brief Rewriter attributes
14 ** Rewriter attributes.
17 #include "cvc4_private.h"
21 #include "expr/attribute.h"
26 template <bool pre
, theory::TheoryId theoryId
>
27 struct RewriteCacheTag
{};
29 template <theory::TheoryId theoryId
>
30 struct RewriteAttibute
{
32 typedef expr::Attribute
< RewriteCacheTag
<true, theoryId
>, Node
> pre_rewrite
;
33 typedef expr::Attribute
< RewriteCacheTag
<false, theoryId
>, Node
> post_rewrite
;
36 * Get the value of the pre-rewrite cache.
38 static Node
getPreRewriteCache(TNode node
)
41 if (node
.hasAttribute(pre_rewrite())) {
42 node
.getAttribute(pre_rewrite(), cache
);
54 * Set the value of the pre-rewrite cache.
56 static void setPreRewriteCache(TNode node
, TNode cache
)
58 Trace("rewriter") << "setting pre-rewrite of " << node
<< " to " << cache
<< std::endl
;
59 Assert(!cache
.isNull());
61 node
.setAttribute(pre_rewrite(), Node::null());
63 node
.setAttribute(pre_rewrite(), cache
);
68 * Get the value of the post-rewrite cache.
71 static Node
getPostRewriteCache(TNode node
)
74 if (node
.hasAttribute(post_rewrite())) {
75 node
.getAttribute(post_rewrite(), cache
);
87 * Set the value of the post-rewrite cache. v cannot be a null Node.
89 static void setPostRewriteCache(TNode node
, TNode cache
)
91 Assert(!cache
.isNull());
92 Trace("rewriter") << "setting rewrite of " << node
<< " to " << cache
<< std::endl
;
94 node
.setAttribute(post_rewrite(), Node::null());
96 node
.setAttribute(post_rewrite(), cache
);
99 };/* struct RewriteAttribute */
101 }/* CVC4::theory namespace */
102 }/* CVC4 namespace */