Skip to content

Commit ee01fa3

Browse files
committed
---
yaml --- r: 128668 b: refs/heads/try c: a9b1a3b h: refs/heads/master v: v3
1 parent 74b54bc commit ee01fa3

File tree

2 files changed

+52
-25
lines changed

2 files changed

+52
-25
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: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 4c2ff0ab1790208e5a81abdcebd29d9e7d5c2ccf
5+
refs/heads/try: a9b1a3b40f29795d5f049e342ec4a494e83125e9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libsyntax/print/pprust.rs

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,35 +97,62 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
9797
out: Box<io::Writer>,
9898
ann: &'a PpAnn,
9999
is_expanded: bool) -> IoResult<()> {
100-
let (cmnts, lits) = comments::gather_comments_and_literals(
101-
span_diagnostic,
102-
filename,
103-
input
104-
);
105-
let mut s = State {
106-
s: pp::mk_printer(out, default_columns),
107-
cm: Some(cm),
108-
comments: Some(cmnts),
109-
// If the code is post expansion, don't use the table of
110-
// literals, since it doesn't correspond with the literals
111-
// in the AST anymore.
112-
literals: if is_expanded {
113-
None
114-
} else {
115-
Some(lits)
116-
},
117-
cur_cmnt_and_lit: CurrentCommentAndLiteral {
118-
cur_cmnt: 0,
119-
cur_lit: 0
120-
},
121-
boxes: Vec::new(),
122-
ann: ann
123-
};
100+
let mut s = State::new_from_input(cm,
101+
span_diagnostic,
102+
filename,
103+
input,
104+
out,
105+
ann,
106+
is_expanded);
124107
try!(s.print_mod(&krate.module, krate.attrs.as_slice()));
125108
try!(s.print_remaining_comments());
126109
eof(&mut s.s)
127110
}
128111

112+
impl<'a> State<'a> {
113+
pub fn new_from_input(cm: &'a CodeMap,
114+
span_diagnostic: &diagnostic::SpanHandler,
115+
filename: String,
116+
input: &mut io::Reader,
117+
out: Box<io::Writer>,
118+
ann: &'a PpAnn,
119+
is_expanded: bool) -> State<'a> {
120+
let (cmnts, lits) = comments::gather_comments_and_literals(
121+
span_diagnostic,
122+
filename,
123+
input);
124+
125+
State::new(
126+
cm,
127+
out,
128+
ann,
129+
Some(cmnts),
130+
// If the code is post expansion, don't use the table of
131+
// literals, since it doesn't correspond with the literals
132+
// in the AST anymore.
133+
if is_expanded { None } else { Some(lits) })
134+
}
135+
136+
pub fn new(cm: &'a CodeMap,
137+
out: Box<io::Writer>,
138+
ann: &'a PpAnn,
139+
comments: Option<Vec<comments::Comment>>,
140+
literals: Option<Vec<comments::Literal>>) -> State<'a> {
141+
State {
142+
s: pp::mk_printer(out, default_columns),
143+
cm: Some(cm),
144+
comments: comments,
145+
literals: literals,
146+
cur_cmnt_and_lit: CurrentCommentAndLiteral {
147+
cur_cmnt: 0,
148+
cur_lit: 0
149+
},
150+
boxes: Vec::new(),
151+
ann: ann
152+
}
153+
}
154+
}
155+
129156
pub fn to_string(f: |&mut State| -> IoResult<()>) -> String {
130157
let mut s = rust_printer(box MemWriter::new());
131158
f(&mut s).unwrap();

0 commit comments

Comments
 (0)