Skip to content

Commit cf329fa

Browse files
committed
---
yaml --- r: 104362 b: refs/heads/try c: 0cc8ba0 h: refs/heads/master v: v3
1 parent 3b4c822 commit cf329fa

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
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: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
5-
refs/heads/try: 33923f47e3f90442ae3c604d8ea80992b71611f7
5+
refs/heads/try: 0cc8ba0c2030720750c6166ad898ca192c695ffc
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/driver/driver.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ use middle;
2727
use util::common::time;
2828
use util::ppaux;
2929

30+
use extra::json;
31+
use serialize::Encodable;
32+
3033
use std::cell::{Cell, RefCell};
3134
use std::hashmap::{HashMap,HashSet};
3235
use std::io;
@@ -154,7 +157,7 @@ pub enum Input {
154157

155158
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
156159
-> ast::Crate {
157-
time(sess.time_passes(), "parsing", (), |_| {
160+
let krate = time(sess.time_passes(), "parsing", (), |_| {
158161
match *input {
159162
FileInput(ref file) => {
160163
parse::parse_crate_from_file(&(*file), cfg.clone(), sess.parse_sess)
@@ -166,7 +169,15 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
166169
sess.parse_sess)
167170
}
168171
}
169-
})
172+
});
173+
174+
if sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0 {
175+
let mut stdout = io::stdout();
176+
let mut json = json::PrettyEncoder::new(&mut stdout);
177+
krate.encode(&mut json);
178+
}
179+
180+
krate
170181
}
171182

172183
// For continuing compilation after a parsed crate has been
@@ -220,8 +231,16 @@ pub fn phase_2_configure_and_expand(sess: Session,
220231
krate = time(time_passes, "prelude injection", krate, |krate|
221232
front::std_inject::maybe_inject_prelude(sess, krate));
222233

223-
time(time_passes, "assinging node ids and indexing ast", krate, |krate|
224-
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate))
234+
let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
235+
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
236+
237+
if sess.opts.debugging_opts & session::AST_JSON != 0 {
238+
let mut stdout = io::stdout();
239+
let mut json = json::PrettyEncoder::new(&mut stdout);
240+
krate.encode(&mut json);
241+
}
242+
243+
(krate, map)
225244
}
226245

227246
pub struct CrateAnalysis {
@@ -428,15 +447,15 @@ pub fn stop_after_phase_1(sess: Session) -> bool {
428447
debug!("invoked with --parse-only, returning early from compile_input");
429448
return true;
430449
}
431-
return false;
450+
return sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0;
432451
}
433452

434453
pub fn stop_after_phase_2(sess: Session) -> bool {
435454
if sess.opts.no_analysis {
436455
debug!("invoked with --no-analysis, returning early from compile_input");
437456
return true;
438457
}
439-
return false;
458+
return sess.opts.debugging_opts & session::AST_JSON != 0;
440459
}
441460

442461
pub fn stop_after_phase_5(sess: Session) -> bool {

branches/try/src/librustc/driver/session.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ debugging_opts!(
6565
GC,
6666
PRINT_LINK_ARGS,
6767
PRINT_LLVM_PASSES,
68-
LTO
68+
LTO,
69+
AST_JSON,
70+
AST_JSON_NOEXPAND
6971
]
7072
0
7173
)
@@ -97,6 +99,8 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] {
9799
"Prints the llvm optimization passes being run",
98100
PRINT_LLVM_PASSES),
99101
("lto", "Perform LLVM link-time optimizations", LTO),
102+
("ast-json", "Print the AST as JSON and halt", AST_JSON),
103+
("ast-json-noexpand", "Print the pre-expansion AST as JSON and halt", AST_JSON_NOEXPAND),
100104
]
101105
}
102106

branches/try/src/librustc/middle/trans/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use syntax::codemap::Span;
2020
use middle::trans::builder::Builder;
2121
use middle::trans::type_::Type;
2222

23-
use std::cast;
2423
use std::libc::{c_uint, c_ulonglong, c_char};
2524

2625
pub fn terminate(cx: &Block, _: &str) {
@@ -623,9 +622,7 @@ pub fn Phi(cx: &Block, Ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> Va
623622
pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
624623
unsafe {
625624
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
626-
let valptr = cast::transmute(&val);
627-
let bbptr = cast::transmute(&bb);
628-
llvm::LLVMAddIncoming(phi, valptr, bbptr, 1 as c_uint);
625+
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
629626
}
630627
}
631628

branches/try/src/librustc/middle/trans/builder.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use middle::trans::base;
1717
use middle::trans::common::*;
1818
use middle::trans::machine::llalign_of_pref;
1919
use middle::trans::type_::Type;
20-
use std::cast;
2120
use std::hashmap::HashMap;
2221
use std::libc::{c_uint, c_ulonglong, c_char};
2322
use syntax::codemap::Span;
@@ -30,10 +29,8 @@ pub struct Builder<'a> {
3029
// This is a really awful way to get a zero-length c-string, but better (and a
3130
// lot more efficient) than doing str::as_c_str("", ...) every time.
3231
pub fn noname() -> *c_char {
33-
unsafe {
34-
static cnull: uint = 0u;
35-
cast::transmute(&cnull)
36-
}
32+
static cnull: c_char = 0;
33+
&cnull as *c_char
3734
}
3835

3936
impl<'a> Builder<'a> {

branches/try/src/librustc/middle/trans/common.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ use util::ppaux::Repr;
3030

3131
use arena::TypedArena;
3232
use std::c_str::ToCStr;
33-
use std::cast::transmute;
34-
use std::cast;
3533
use std::cell::{Cell, RefCell};
3634
use std::hashmap::HashMap;
3735
use std::libc::{c_uint, c_longlong, c_ulonglong, c_char};
@@ -668,7 +666,7 @@ pub fn C_array(ty: Type, elts: &[ValueRef]) -> ValueRef {
668666

669667
pub fn C_bytes(bytes: &[u8]) -> ValueRef {
670668
unsafe {
671-
let ptr = cast::transmute(bytes.as_ptr());
669+
let ptr = bytes.as_ptr() as *c_char;
672670
return llvm::LLVMConstStringInContext(base::task_llcx(), ptr, bytes.len() as c_uint, True);
673671
}
674672
}

0 commit comments

Comments
 (0)