remove use of rbml and just use opaque encoder
This commit is contained in:
parent
e9ec282df8
commit
f2051212c2
@ -11,8 +11,8 @@
|
||||
//! Code to save/load the dep-graph from files.
|
||||
|
||||
use calculate_svh::SvhCalculate;
|
||||
use rbml::{self, Doc};
|
||||
use rbml::reader::{self, DecodeResult, Decoder};
|
||||
use rbml::Error;
|
||||
use rbml::opaque::Decoder;
|
||||
use rustc::dep_graph::DepNode;
|
||||
use rustc::middle::def_id::DefId;
|
||||
use rustc::ty;
|
||||
@ -66,7 +66,7 @@ pub fn load_dep_graph_if_exists<'tcx>(tcx: &ty::TyCtxt<'tcx>, path: &Path) {
|
||||
}
|
||||
}
|
||||
|
||||
match decode_dep_graph(tcx, Doc::new(&data)) {
|
||||
match decode_dep_graph(tcx, &data) {
|
||||
Ok(dirty) => dirty,
|
||||
Err(err) => {
|
||||
bug!("decoding error in dep-graph from `{}`: {}", path.display(), err);
|
||||
@ -74,34 +74,22 @@ pub fn load_dep_graph_if_exists<'tcx>(tcx: &ty::TyCtxt<'tcx>, path: &Path) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn decode_dep_graph<'tcx, 'doc>(tcx: &ty::TyCtxt<'tcx>, doc: rbml::Doc<'doc>)
|
||||
-> DecodeResult<()>
|
||||
pub fn decode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>, data: &[u8])
|
||||
-> Result<(), Error>
|
||||
{
|
||||
// First load the directory, which maps the def-ids found
|
||||
// elsewhere into `DefPath`. We can then refresh the `DefPath` to
|
||||
// obtain updated def-ids.
|
||||
let directory = {
|
||||
let directory_doc = reader::get_doc(doc, DIRECTORY_TAG);
|
||||
let mut decoder = Decoder::new(directory_doc);
|
||||
try!(DefIdDirectory::decode(&mut decoder))
|
||||
};
|
||||
// Deserialize the directory and dep-graph.
|
||||
let mut decoder = Decoder::new(data, 0);
|
||||
let directory = try!(DefIdDirectory::decode(&mut decoder));
|
||||
let serialized_dep_graph = try!(SerializedDepGraph::decode(&mut decoder));
|
||||
|
||||
debug!("decode_dep_graph: directory = {:#?}", directory);
|
||||
debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph);
|
||||
|
||||
// Retrace those paths to find their current location (if any).
|
||||
// Retrace the paths in the directory to find their current location (if any).
|
||||
let retraced = directory.retrace(tcx);
|
||||
|
||||
debug!("decode_dep_graph: retraced = {:#?}", retraced);
|
||||
|
||||
// Deserialize the dep-graph (which will include DefPathIndex entries)
|
||||
let serialized_dep_graph = {
|
||||
let dep_graph_doc = reader::get_doc(doc, DEP_GRAPH_TAG);
|
||||
let mut decoder = Decoder::new(dep_graph_doc);
|
||||
try!(SerializedDepGraph::decode(&mut decoder))
|
||||
};
|
||||
|
||||
debug!("decode_dep_graph: serialized_dep_graph = {:#?}", serialized_dep_graph);
|
||||
|
||||
// Compute the set of Hir nodes whose data has changed.
|
||||
let mut dirty_nodes =
|
||||
initial_dirty_nodes(tcx, &serialized_dep_graph.hashes, &retraced);
|
||||
|
@ -9,11 +9,11 @@
|
||||
// except according to those terms.
|
||||
|
||||
use calculate_svh::SvhCalculate;
|
||||
use rbml::writer::{EncodeResult, Encoder};
|
||||
use rbml::opaque::Encoder;
|
||||
use rustc::dep_graph::DepNode;
|
||||
use rustc::ty;
|
||||
use rustc_serialize::{Encodable as RustcEncodable};
|
||||
use std::io::{Cursor, Write};
|
||||
use std::io::{self, Cursor, Write};
|
||||
use std::fs::{self, File};
|
||||
|
||||
use super::data::*;
|
||||
@ -70,7 +70,7 @@ pub fn save_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>) {
|
||||
|
||||
pub fn encode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>,
|
||||
encoder: &mut Encoder)
|
||||
-> EncodeResult
|
||||
-> io::Result<()>
|
||||
{
|
||||
// Here we take advantage of how RBML allows us to skip around
|
||||
// and encode the depgraph as a two-part structure:
|
||||
@ -126,19 +126,10 @@ pub fn encode_dep_graph<'tcx>(tcx: &ty::TyCtxt<'tcx>,
|
||||
|
||||
debug!("graph = {:#?}", graph);
|
||||
|
||||
// Encode the graph data into RBML.
|
||||
try!(encoder.start_tag(DEP_GRAPH_TAG));
|
||||
try!(graph.encode(encoder));
|
||||
try!(encoder.end_tag());
|
||||
|
||||
// Now encode the directory.
|
||||
// Encode the directory and then the graph data.
|
||||
let directory = builder.into_directory();
|
||||
|
||||
debug!("directory = {:#?}", directory);
|
||||
|
||||
try!(encoder.start_tag(DIRECTORY_TAG));
|
||||
try!(directory.encode(encoder));
|
||||
try!(encoder.end_tag());
|
||||
try!(graph.encode(encoder));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -12,10 +12,6 @@ use rustc::ty;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const DEP_GRAPH_TAG: usize = 0x100;
|
||||
|
||||
pub const DIRECTORY_TAG: usize = DEP_GRAPH_TAG + 1;
|
||||
|
||||
pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
|
||||
// For now, just save/load dep-graph from
|
||||
// directory/dep_graph.rbml
|
||||
|
Loading…
x
Reference in New Issue
Block a user