Skip to content

Commit a94b3ab

Browse files
committed
---
yaml --- r: 210826 b: refs/heads/try c: cea73bf h: refs/heads/master v: v3
1 parent 225f14c commit a94b3ab

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: b248ee8746c4c016dd3001e59086f2c2f868f07e
5+
refs/heads/try: cea73bfb1596f1e5e1f3a6faa9863d2983a3ccea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc_trans/save/dump_csv.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use util::ppaux;
5555

5656

5757
pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
58-
save_ctxt: SaveContext<'l>,
58+
save_ctxt: SaveContext<'l, 'tcx>,
5959
sess: &'l Session,
6060
analysis: &'l ty::CrateAnalysis<'tcx>,
6161

@@ -74,7 +74,10 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
7474
output_file: Box<File>) -> DumpCsvVisitor<'l, 'tcx> {
7575
DumpCsvVisitor {
7676
sess: sess,
77-
save_ctxt: SaveContext { sess: sess },
77+
save_ctxt: SaveContext::new(sess, analysis, SpanUtils {
78+
sess: sess,
79+
err_count: Cell::new(0)
80+
}),
7881
analysis: analysis,
7982
collected_paths: vec![],
8083
collecting: false,

branches/try/src/librustc_trans/save/mod.rs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,50 @@ use std::env;
1515
use std::fs::{self, File};
1616
use std::path::{Path, PathBuf};
1717

18-
use syntax::{ast, attr, visit};
18+
use syntax::{attr, visit};
19+
use syntax::ast::{self, NodeId, DefId};
20+
use syntax::parse::token::keywords;
1921
use syntax::codemap::*;
2022

23+
use self::span_utils::SpanUtils;
24+
2125
mod span_utils;
2226
mod recorder;
2327

2428
mod dump_csv;
2529

26-
pub struct SaveContext<'l> {
30+
pub struct SaveContext<'l, 'tcx: 'l> {
2731
sess: &'l Session,
32+
analysis: &'l ty::CrateAnalysis<'tcx>,
33+
span_utils: SpanUtils<'l>,
2834
}
2935

3036
pub struct CrateData {
3137
pub name: String,
3238
pub number: u32,
3339
}
3440

35-
impl<'l> SaveContext<'l> {
36-
pub fn new<'ll>(sess: &'ll Session) -> SaveContext<'ll> {
41+
pub enum Data {
42+
FunctionData(FunctionData),
43+
}
44+
45+
pub struct FunctionData {
46+
pub id: NodeId,
47+
pub qualname: String,
48+
pub declaration: Option<DefId>,
49+
pub span: Span,
50+
pub scope: NodeId,
51+
}
52+
53+
impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
54+
pub fn new(sess: &'l Session,
55+
analysis: &'l ty::CrateAnalysis<'tcx>,
56+
span_utils: SpanUtils<'l>)
57+
-> SaveContext<'l, 'tcx> {
3758
SaveContext {
38-
sess: sess
59+
sess: sess,
60+
analysis: analysis,
61+
span_utils: span_utils,
3962
}
4063
}
4164

@@ -49,6 +72,30 @@ impl<'l> SaveContext<'l> {
4972

5073
result
5174
}
75+
76+
pub fn get_item_data(&self, item: &ast::Item) -> Data {
77+
match item.node {
78+
ast::Item_::ItemFn(..) => {
79+
let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id));
80+
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Fn);
81+
82+
Data::FunctionData(FunctionData {
83+
id: item.id,
84+
qualname: qualname,
85+
declaration: None,
86+
span: sub_span.unwrap(),
87+
scope: self.analysis.ty_cx.map.get_parent(item.id),
88+
})
89+
}
90+
_ => {
91+
unimplemented!();
92+
}
93+
}
94+
}
95+
96+
pub fn get_data_for_id(&self, id: &NodeId) -> Data {
97+
unimplemented!();
98+
}
5299
}
53100

54101
#[allow(deprecated)]

0 commit comments

Comments
 (0)