Skip to content

Commit

Permalink
save-analysis: tweak constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Jul 14, 2015
1 parent e6e6368 commit 41b0568
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/librustc_trans/save/dump_csv.rs
Expand Up @@ -35,7 +35,6 @@ use session::Session;
use middle::def;
use middle::ty::{self, Ty};

use std::cell::Cell;
use std::fs::File;
use std::path::Path;

Expand Down Expand Up @@ -76,14 +75,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
pub fn new(tcx: &'l ty::ctxt<'tcx>,
analysis: &'l ty::CrateAnalysis,
output_file: Box<File>) -> DumpCsvVisitor<'l, 'tcx> {
let span_utils = SpanUtils {
sess: &tcx.sess,
err_count: Cell::new(0)
};
let span_utils = SpanUtils::new(&tcx.sess);
DumpCsvVisitor {
sess: &tcx.sess,
tcx: tcx,
save_ctxt: SaveContext::new(tcx, span_utils.clone()),
save_ctxt: SaveContext::from_span_utils(tcx, span_utils.clone()),
analysis: analysis,
span: span_utils.clone(),
fmt: FmtStrs::new(box Recorder {
Expand Down
11 changes: 8 additions & 3 deletions src/librustc_trans/save/mod.rs
Expand Up @@ -163,9 +163,14 @@ pub struct MethodCallData {


impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
pub fn new(tcx: &'l ty::ctxt<'tcx>,
span_utils: SpanUtils<'l>)
-> SaveContext<'l, 'tcx> {
pub fn new(tcx: &'l ty::ctxt<'tcx>) -> SaveContext <'l, 'tcx> {
let span_utils = SpanUtils::new(&tcx.sess);
SaveContext::from_span_utils(tcx, span_utils)
}

pub fn from_span_utils(tcx: &'l ty::ctxt<'tcx>,
span_utils: SpanUtils<'l>)
-> SaveContext<'l, 'tcx> {
SaveContext {
tcx: tcx,
span_utils: span_utils,
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_trans/save/span_utils.rs
Expand Up @@ -28,6 +28,13 @@ pub struct SpanUtils<'a> {
}

impl<'a> SpanUtils<'a> {
pub fn new(sess: &'a Session) -> SpanUtils<'a> {
SpanUtils {
sess: sess,
err_count: Cell::new(0)
}
}

// Standard string for extents/location.
pub fn extent_str(&self, span: Span) -> String {
let lo_loc = self.sess.codemap().lookup_char_pos(span.lo);
Expand Down

0 comments on commit 41b0568

Please sign in to comment.