1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! The data that we will serialize and deserialize.
13 use dep_graph::DepNode;
15 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
18 pub struct SerializedDepNodeIndex { .. }
21 /// Data for use when recompiling the **current crate**.
22 #[derive(Debug, RustcEncodable, RustcDecodable, Default)]
23 pub struct SerializedDepGraph {
24 /// The set of all DepNodes in the graph
25 pub nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
26 /// The set of all Fingerprints in the graph. Each Fingerprint corresponds to
27 /// the DepNode at the same index in the nodes vector.
28 pub fingerprints: IndexVec<SerializedDepNodeIndex, Fingerprint>,
29 /// For each DepNode, stores the list of edges originating from that
30 /// DepNode. Encoded as a [start, end) pair indexing into edge_list_data,
31 /// which holds the actual DepNodeIndices of the target nodes.
32 pub edge_list_indices: IndexVec<SerializedDepNodeIndex, (u32, u32)>,
33 /// A flattened list of all edge targets in the graph. Edge sources are
34 /// implicit in edge_list_indices.
35 pub edge_list_data: Vec<SerializedDepNodeIndex>,
38 impl SerializedDepGraph {
40 pub fn edge_targets_from(&self,
41 source: SerializedDepNodeIndex)
42 -> &[SerializedDepNodeIndex] {
43 let targets = self.edge_list_indices[source];
44 &self.edge_list_data[targets.0 as usize..targets.1 as usize]