1 /********************* */
2 /*! \file skolem_cache.cpp
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2018 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 Implementation of a cache of skolems for theory of strings.
15 #include "theory/strings/skolem_cache.h"
17 #include "theory/rewriter.h"
23 SkolemCache::SkolemCache() {}
25 Node
SkolemCache::mkSkolemCached(Node a
, Node b
, SkolemId id
, const char* c
)
27 a
= a
.isNull() ? a
: Rewriter::rewrite(a
);
28 b
= b
.isNull() ? b
: Rewriter::rewrite(b
);
29 std::map
<SkolemId
, Node
>::iterator it
= d_skolemCache
[a
][b
].find(id
);
30 if (it
== d_skolemCache
[a
][b
].end())
32 Node sk
= mkSkolem(c
);
33 d_skolemCache
[a
][b
][id
] = sk
;
39 Node
SkolemCache::mkSkolemCached(Node a
, SkolemId id
, const char* c
)
41 return mkSkolemCached(a
, Node::null(), id
, c
);
44 Node
SkolemCache::mkSkolem(const char* c
)
46 NodeManager
* nm
= NodeManager::currentNM();
47 Node n
= nm
->mkSkolem(c
, nm
->stringType(), "string skolem");
48 d_allSkolems
.insert(n
);
52 bool SkolemCache::isSkolem(Node n
) const
54 return d_allSkolems
.find(n
) != d_allSkolems
.end();
57 } // namespace strings