blob: 17f3b64c3484f2e829ec9a7810a55514641bfc07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/********************* -*- C++ -*- */
/** expr_value.cpp
** This file is part of the CVC4 prototype.
** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys)
** Courant Institute of Mathematical Sciences
** New York University
** See the file COPYING in the top-level source directory for licensing
** information.
**
** An expression node.
**
** Instances of this class are generally referenced through
** cvc4::Expr rather than by pointer; cvc4::Expr maintains the
** reference count on ExprValue instances and
**/
#include "expr_value.h"
namespace CVC4 {
size_t ExprValue::next_id = 1;
ExprValue::ExprValue() :
d_id(0), d_rc(MAX_RC), d_kind(NULL_EXPR), d_nchildren(0) {
}
uint64_t ExprValue::hash() const {
return computeHash<const_iterator>(d_kind, begin(), end());
}
ExprValue* ExprValue::inc() {
// FIXME multithreading
if(d_rc < MAX_RC)
++d_rc;
return this;
}
ExprValue* ExprValue::dec() {
// FIXME multithreading
if(d_rc < MAX_RC)
if(--d_rc == 0) {
// FIXME gc
return 0;
}
return this;
}
ExprValue::iterator ExprValue::begin() {
return d_children;
}
ExprValue::iterator ExprValue::end() {
return d_children + d_nchildren;
}
ExprValue::iterator ExprValue::rbegin() {
return d_children + d_nchildren - 1;
}
ExprValue::iterator ExprValue::rend() {
return d_children - 1;
}
ExprValue::const_iterator ExprValue::begin() const {
return d_children;
}
ExprValue::const_iterator ExprValue::end() const {
return d_children + d_nchildren;
}
ExprValue::const_iterator ExprValue::rbegin() const {
return d_children + d_nchildren - 1;
}
ExprValue::const_iterator ExprValue::rend() const {
return d_children - 1;
}
void ExprValue::toString(std::ostream& out) const {
out << "(" << Kind(d_kind);
if(d_kind == VARIABLE) {
out << ":" << this;
} else {
for(const_iterator i = begin(); i != end(); ++i) {
if(i != end())
out << " ";
out << *i;
}
}
out << ")";
}
}/* CVC4 namespace */
|