blob: ff355dedd3a47ea311cc6a9b44146e48243493d2 (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/********************* */
/*! \file pickle_data.h
** \verbatim
** Top contributors (to current version):
** Morgan Deters, Paul Meng, Tim King
** This file is part of the CVC4 project.
** Copyright (c) 2009-2017 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief This is a "pickle" for expressions, CVC4-internal view
**
** This is the CVC4-internal view (private data structure) for a
** "pickle" for expressions. The public-facing view is a "Pickle",
** which just points to a PickleData. A pickle is a binary
** serialization of an expression that can be converted back into an
** expression in the same or another ExprManager.
**/
#include "cvc4_private.h"
#ifndef __CVC4__PICKLE_DATA_H
#define __CVC4__PICKLE_DATA_H
#include <sstream>
#include <deque>
#include <stack>
#include <exception>
#include "expr/expr.h"
#include "expr/node.h"
#include "expr/node_manager.h"
#include "expr/expr_manager.h"
#include "expr/variable_type_map.h"
#include "expr/kind.h"
#include "expr/metakind.h"
namespace CVC4 {
class NodeManager;
namespace expr {
namespace pickle {
const unsigned NBITS_BLOCK = 64;
const unsigned NBITS_KIND = __CVC4__EXPR__NODE_VALUE__NBITS__KIND;
const unsigned NBITS_NCHILDREN = __CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN;
const unsigned NBITS_CONSTBLOCKS = 32;
struct BlockHeader {
uint64_t d_kind : NBITS_KIND;
};/* struct BlockHeader */
struct BlockHeaderOperator {
uint64_t d_kind : NBITS_KIND;
uint64_t d_nchildren : NBITS_NCHILDREN;
uint64_t : NBITS_BLOCK - (NBITS_KIND + NBITS_NCHILDREN);
};/* struct BlockHeaderOperator */
struct BlockHeaderConstant {
uint64_t d_kind : NBITS_KIND;
uint64_t d_constblocks : NBITS_BLOCK - NBITS_KIND;
};/* struct BlockHeaderConstant */
struct BlockHeaderVariable {
uint64_t d_kind : NBITS_KIND;
uint64_t : NBITS_BLOCK - NBITS_KIND;
};/* struct BlockHeaderVariable */
struct BlockBody {
uint64_t d_data : NBITS_BLOCK;
};/* struct BlockBody */
union Block {
BlockHeader d_header;
BlockHeaderConstant d_headerConstant;
BlockHeaderOperator d_headerOperator;
BlockHeaderVariable d_headerVariable;
BlockBody d_body;
};/* union Block */
class PickleData {
typedef std::deque<Block> BlockDeque;
BlockDeque d_blocks;
public:
PickleData& operator<<(Block b) {
enqueue(b);
return (*this);
}
std::string toString() const;
void enqueue(Block b) {
d_blocks.push_back(b);
}
Block dequeue() {
Block b = d_blocks.front();
d_blocks.pop_front();
return b;
}
bool empty() const { return d_blocks.empty(); }
uint32_t size() const { return d_blocks.size(); }
void swap(PickleData& other){
d_blocks.swap(other.d_blocks);
}
void writeToStringStream(std::ostringstream& oss) const;
};/* class PickleData */
}/* CVC4::expr::pickle namespace */
}/* CVC4::expr namespace */
}/* CVC4 namespace */
#endif /* __CVC4__PICKLE_DATA_H */
|