rustc::driver: Capitalize structs and enums

driver::session::crate_metadata is unused; removed.
This commit is contained in:
klutzy 2014-01-14 01:31:05 +09:00
parent 80a3f453db
commit f30a9b3d5b
9 changed files with 55 additions and 60 deletions

View File

@ -1166,7 +1166,7 @@ fn add_local_native_libraries(args: &mut ~[~str], sess: Session) {
fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
dylib: bool, tmpdir: &Path) {
// Converts a library file-stem into a cc -l argument
fn unlib(config: @session::config, stem: &str) -> ~str {
fn unlib(config: @session::Config, stem: &str) -> ~str {
if stem.starts_with("lib") &&
config.os != abi::OsWin32 {
stem.slice(3, stem.len()).to_owned()

View File

@ -62,11 +62,11 @@ pub enum PpMode {
*/
pub fn anon_src() -> @str { @"<anon>" }
pub fn source_name(input: &input) -> @str {
pub fn source_name(input: &Input) -> @str {
match *input {
// FIXME (#9639): This needs to handle non-utf8 paths
file_input(ref ifile) => ifile.as_str().unwrap().to_managed(),
str_input(_) => anon_src()
FileInput(ref ifile) => ifile.as_str().unwrap().to_managed(),
StrInput(_) => anon_src()
}
}
@ -133,22 +133,22 @@ fn parse_cfgspecs(cfgspecs: ~[~str], demitter: @diagnostic::Emitter)
}).collect::<ast::CrateConfig>()
}
pub enum input {
pub enum Input {
/// Load source from file
file_input(Path),
FileInput(Path),
/// The string is the source
// FIXME (#2319): Don't really want to box the source string
str_input(@str)
StrInput(@str)
}
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &input)
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
-> ast::Crate {
time(sess.time_passes(), "parsing", (), |_| {
match *input {
file_input(ref file) => {
FileInput(ref file) => {
parse::parse_crate_from_file(&(*file), cfg.clone(), sess.parse_sess)
}
str_input(src) => {
StrInput(src) => {
parse::parse_crate_from_source_str(
anon_src(), src, cfg.clone(), sess.parse_sess)
}
@ -444,7 +444,7 @@ pub fn stop_after_phase_5(sess: Session) -> bool {
return false;
}
fn write_out_deps(sess: Session, input: &input, outputs: &OutputFilenames, crate: &ast::Crate)
fn write_out_deps(sess: Session, input: &Input, outputs: &OutputFilenames, crate: &ast::Crate)
{
let lm = link::build_link_meta(sess, crate.attrs, &outputs.obj_filename,
&mut ::util::sha2::Sha256::new());
@ -460,12 +460,12 @@ fn write_out_deps(sess: Session, input: &input, outputs: &OutputFilenames, crate
(true, Some(ref filename)) => filename.clone(),
// Use default filename: crate source filename with extension replaced by ".d"
(true, None) => match *input {
file_input(ref input_path) => {
FileInput(ref input_path) => {
let filestem = input_path.filestem().expect("input file must have stem");
let filename = out_filenames[0].dir_path().join(filestem).with_extension("d");
filename
},
str_input(..) => {
StrInput(..) => {
sess.warn("can not write --dep-info without a filename when compiling stdin.");
return;
},
@ -495,7 +495,7 @@ fn write_out_deps(sess: Session, input: &input, outputs: &OutputFilenames, crate
}
}
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
outdir: &Option<Path>, output: &Option<Path>) {
// We need nested scopes here, because the intermediate results can keep
// large chunks of memory alive and we want to free them as soon as
@ -587,7 +587,7 @@ impl pprust::PpAnn for TypedAnnotation {
pub fn pretty_print_input(sess: Session,
cfg: ast::CrateConfig,
input: &input,
input: &Input,
ppm: PpMode) {
let crate = phase_1_parse_input(sess, cfg.clone(), input);
@ -664,9 +664,9 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
("mips", abi::Mips)];
pub fn build_target_config(sopts: @session::options,
pub fn build_target_config(sopts: @session::Options,
demitter: @diagnostic::Emitter)
-> @session::config {
-> @session::Config {
let os = match get_os(sopts.target_triple) {
Some(os) => os,
None => early_error(demitter, "unknown operating system")
@ -689,7 +689,7 @@ pub fn build_target_config(sopts: @session::options,
abi::Arm => arm::get_target_strs(target_triple, os),
abi::Mips => mips::get_target_strs(target_triple, os)
};
let target_cfg = @session::config {
let target_cfg = @session::Config {
os: os,
arch: arch,
target_strs: target_strs,
@ -714,7 +714,7 @@ pub fn host_triple() -> ~str {
pub fn build_session_options(binary: ~str,
matches: &getopts::Matches,
demitter: @diagnostic::Emitter)
-> @session::options {
-> @session::Options {
let mut outputs = ~[];
if matches.opt_present("rlib") {
outputs.push(session::OutputRlib)
@ -862,7 +862,7 @@ pub fn build_session_options(binary: ~str,
matches.opt_present("crate-name"),
matches.opt_present("crate-file-name"));
let sopts = @session::options {
let sopts = @session::Options {
outputs: outputs,
gc: gc,
optimize: opt_level,
@ -895,7 +895,7 @@ pub fn build_session_options(binary: ~str,
return sopts;
}
pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
pub fn build_session(sopts: @session::Options, demitter: @diagnostic::Emitter)
-> Session {
let codemap = @codemap::CodeMap::new();
let diagnostic_handler =
@ -905,7 +905,7 @@ pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
build_session_(sopts, codemap, demitter, span_diagnostic_handler)
}
pub fn build_session_(sopts: @session::options,
pub fn build_session_(sopts: @session::Options,
cm: @codemap::CodeMap,
demitter: @diagnostic::Emitter,
span_diagnostic_handler: @diagnostic::SpanHandler)
@ -1046,7 +1046,7 @@ pub struct OutputFilenames {
obj_filename: Path
}
pub fn build_output_filenames(input: &input,
pub fn build_output_filenames(input: &Input,
odir: &Option<Path>,
ofile: &Option<Path>,
attrs: &[ast::Attribute],
@ -1074,15 +1074,15 @@ pub fn build_output_filenames(input: &input,
let dirpath = match *odir {
Some(ref d) => (*d).clone(),
None => match *input {
str_input(_) => os::getcwd(),
file_input(ref ifile) => (*ifile).dir_path()
StrInput(_) => os::getcwd(),
FileInput(ref ifile) => (*ifile).dir_path()
}
};
let mut stem = match *input {
// FIXME (#9639): This needs to handle non-utf8 paths
file_input(ref ifile) => (*ifile).filestem_str().unwrap().to_managed(),
str_input(_) => @"rust_out"
FileInput(ref ifile) => (*ifile).filestem_str().unwrap().to_managed(),
StrInput(_) => @"rust_out"
};
// If a crateid is present, we use it as the link name

View File

@ -31,7 +31,7 @@ use syntax;
use std::cell::{Cell, RefCell};
use std::hashmap::{HashMap,HashSet};
pub struct config {
pub struct Config {
os: abi::Os,
arch: abi::Architecture,
target_strs: target_strs::t,
@ -134,7 +134,7 @@ pub enum OptLevel {
}
#[deriving(Clone)]
pub struct options {
pub struct Options {
// The crate config requested for the session, which may be combined
// with additional crate configurations during the compile process
outputs: ~[OutputStyle],
@ -176,11 +176,6 @@ pub struct options {
print_metas: (bool, bool, bool),
}
pub struct crate_metadata {
name: ~str,
data: ~[u8]
}
// The type of entry function, so
// users can have their own entry
// functions that don't start a
@ -201,8 +196,8 @@ pub enum OutputStyle {
}
pub struct Session_ {
targ_cfg: @config,
opts: @options,
targ_cfg: @Config,
opts: @Options,
cstore: @metadata::cstore::CStore,
parse_sess: @ParseSess,
codemap: @codemap::CodeMap,
@ -375,8 +370,8 @@ impl Session_ {
}
/// Some reasonable defaults
pub fn basic_options() -> @options {
@options {
pub fn basic_options() -> @Options {
@Options {
outputs: ~[],
gc: false,
optimize: No,
@ -413,7 +408,7 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T {
diagnostic::expect(sess.diagnostic(), opt, msg)
}
pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
pub fn building_library(options: &Options, crate: &ast::Crate) -> bool {
if options.test { return false }
for output in options.outputs.iter() {
match *output {

View File

@ -255,9 +255,9 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
let ifile = matches.free[0].as_slice();
if "-" == ifile {
let src = str::from_utf8_owned(io::stdin().read_to_end());
d::str_input(src.to_managed())
d::StrInput(src.to_managed())
} else {
d::file_input(Path::new(ifile))
d::FileInput(Path::new(ifile))
}
}
_ => d::early_error(demitter, "multiple input filenames provided")
@ -281,12 +281,12 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
let ls = matches.opt_present("ls");
if ls {
match input {
d::file_input(ref ifile) => {
d::FileInput(ref ifile) => {
let mut stdout = io::stdout();
d::list_metadata(sess, &(*ifile),
&mut stdout as &mut io::Writer);
}
d::str_input(_) => {
d::StrInput(_) => {
d::early_error(demitter, "can not list metadata for stdin");
}
}
@ -332,12 +332,12 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
}
fn parse_crate_attrs(sess: session::Session,
input: &d::input) -> ~[ast::Attribute] {
input: &d::Input) -> ~[ast::Attribute] {
match *input {
d::file_input(ref ifile) => {
d::FileInput(ref ifile) => {
parse::parse_crate_attrs_from_file(ifile, ~[], sess.parse_sess)
}
d::str_input(src) => {
d::StrInput(src) => {
parse::parse_crate_attrs_from_source_str(
d::anon_src(), src, ~[], sess.parse_sess)
}

View File

@ -42,15 +42,15 @@ pub struct CrateAnalysis {
fn get_ast_and_resolve(cpath: &Path,
libs: HashSet<Path>, cfgs: ~[~str]) -> (DocContext, CrateAnalysis) {
use syntax::codemap::dummy_spanned;
use rustc::driver::driver::{file_input, build_configuration,
use rustc::driver::driver::{FileInput, build_configuration,
phase_1_parse_input,
phase_2_configure_and_expand,
phase_3_run_analysis_passes};
let parsesess = parse::new_parse_sess(None);
let input = file_input(cpath.clone());
let input = FileInput(cpath.clone());
let sessopts = @driver::session::options {
let sessopts = @driver::session::Options {
binary: ~"rustdoc",
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
addl_lib_search_paths: @RefCell::new(libs),

View File

@ -34,11 +34,11 @@ use visit_ast::RustdocVisitor;
pub fn run(input: &str, matches: &getopts::Matches) -> int {
let parsesess = parse::new_parse_sess(None);
let input = driver::file_input(Path::new(input));
let input = driver::FileInput(Path::new(input));
let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice()));
let libs = @RefCell::new(libs.move_iter().collect());
let sessopts = @session::options {
let sessopts = @session::Options {
binary: ~"rustdoc",
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
addl_lib_search_paths: libs,
@ -97,9 +97,9 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
let test = maketest(test, cratename);
let parsesess = parse::new_parse_sess(None);
let input = driver::str_input(test);
let input = driver::StrInput(test);
let sessopts = @session::options {
let sessopts = @session::Options {
binary: ~"rustdoctest",
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
addl_lib_search_paths: @RefCell::new(libs),

View File

@ -107,13 +107,13 @@ impl<'a> PkgScript<'a> {
// Build the rustc session data structures to pass
// to the compiler
debug!("pkgscript parse: {}", sysroot.display());
let options = @session::options {
let options = @session::Options {
binary: binary,
maybe_sysroot: Some(@sysroot),
outputs: ~[session::OutputExecutable],
.. (*session::basic_options()).clone()
};
let input = driver::file_input(script.clone());
let input = driver::FileInput(script.clone());
let sess = driver::build_session(options,
@diagnostic::DefaultEmitter as
@diagnostic::Emitter);
@ -146,7 +146,7 @@ impl<'a> PkgScript<'a> {
let (crate, ast_map) = self.crate_and_map.take_unwrap();
let crate = util::ready_crate(sess, crate);
debug!("Building output filenames with script name {}",
driver::source_name(&driver::file_input(self.input.clone())));
driver::source_name(&driver::FileInput(self.input.clone())));
let exe = self.build_dir.join("pkg" + util::exe_suffix());
util::compile_crate_from_input(&self.input,
exec,

View File

@ -171,7 +171,7 @@ pub fn compile_input(context: &BuildContext,
opt: session::OptLevel,
what: OutputType) -> Option<Path> {
assert!(in_file.components().nth(1).is_some());
let input = driver::file_input(in_file.clone());
let input = driver::FileInput(in_file.clone());
debug!("compile_input: {} / {:?}", in_file.display(), what);
// tjc: by default, use the package ID name as the link name
// not sure if we should support anything else
@ -228,7 +228,7 @@ pub fn compile_input(context: &BuildContext,
debug!("Output type = {:?}", output_type);
let options = @session::options {
let options = @session::Options {
optimize: opt,
test: what == Test || what == Bench,
maybe_sysroot: Some(sysroot_to_use),
@ -373,7 +373,7 @@ pub fn compile_crate_from_input(input: &Path,
// bad copy
debug!("out_dir = {}", out_dir.display());
let file_input = driver::file_input(input.clone());
let file_input = driver::FileInput(input.clone());
let mut outputs = driver::build_output_filenames(&file_input,
&Some(out_dir.clone()), &None,
crate.attrs, sess);

View File

@ -418,7 +418,7 @@ mod test {
#[test] fn string_to_tts_1 () {
let tts = string_to_tts(@"fn a (b : int) { b; }");
assert_eq!(to_json_str(@tts),
assert_eq!(to_json_str(&tts),
~"[\
{\
\"variant\":\"TTTok\",\