diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-25 15:53:45 -0700 |
|---|---|---|
| committer | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-25 16:00:47 -0700 |
| commit | c5e03e0e599e49f74303bbafc6d559f3138b5f72 (patch) | |
| tree | e2c87afbd28be1b40dcff23875465b7d61fed83d /src/comp/driver/driver.rs | |
| parent | 746fa279889b3ce2ed671aa06d34f15c4f34e902 (diff) | |
| download | rust-c5e03e0e599e49f74303bbafc6d559f3138b5f72.tar.gz rust-c5e03e0e599e49f74303bbafc6d559f3138b5f72.zip | |
Keep source file around after parsing.
Specifically box the string (to avoid unnecessary copies) and store it in codemap::filemap. Remove the hack in driver::diagnostic that rereads the source from the file and instead just get the source from the filemap. (This commit is also a prerequisite for issue #1612)
Diffstat (limited to 'src/comp/driver/driver.rs')
| -rw-r--r-- | src/comp/driver/driver.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/comp/driver/driver.rs b/src/comp/driver/driver.rs index f500936aa73..8840a7a59f8 100644 --- a/src/comp/driver/driver.rs +++ b/src/comp/driver/driver.rs @@ -77,7 +77,7 @@ fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg { fn input_is_stdin(filename: str) -> bool { filename == "-" } fn parse_input(sess: session, cfg: ast::crate_cfg, input: str) - -> {crate: @ast::crate, src: str} { + -> {crate: @ast::crate, src: @str} { let src = get_input_str(sess, input); let crate = if !input_is_stdin(input) { parser::parse_crate_from_file(input, cfg, sess.parse_sess) @@ -87,7 +87,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str) {crate: crate, src: src} } -fn get_input_str(sess: session, infile: str) -> str { +fn get_input_str(sess: session, infile: str) -> @str { let stream = if !input_is_stdin(infile) { alt io::file_reader(infile) { result::ok(reader) { reader } @@ -96,7 +96,7 @@ fn get_input_str(sess: session, infile: str) -> str { } } } else { io::stdin() }; - str::unsafe_from_bytes(stream.read_whole_stream()) + @str::unsafe_from_bytes(stream.read_whole_stream()) } fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T { @@ -141,7 +141,7 @@ enum compile_upto { fn compile_upto(sess: session, cfg: ast::crate_cfg, input: str, upto: compile_upto, outputs: option::t<output_filenames>) - -> {crate: @ast::crate, tcx: option::t<ty::ctxt>, src: str} { + -> {crate: @ast::crate, tcx: option::t<ty::ctxt>, src: @str} { let time_passes = sess.opts.time_passes; let {crate, src} = time(time_passes, "parsing", bind parse_input(sess, cfg, input)); @@ -300,7 +300,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str, ppm_expanded | ppm_normal {} } pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input, - io::string_reader(src), io::stdout(), ann); + io::string_reader(*src), io::stdout(), ann); } fn get_os(triple: str) -> option<session::os> { |
