Impl CompilerCalls for CompileController instead of AdHocCompilerCalls
This commit is contained in:
parent
4f45b0611c
commit
4e0ee758b7
2 changed files with 57 additions and 24 deletions
|
|
@ -414,6 +414,63 @@ impl<'a> CompileController<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ::CompilerCalls<'a> for CompileController<'a> {
|
||||
fn early_callback(
|
||||
&mut self,
|
||||
matches: &::getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
descriptions: &::errors::registry::Registry,
|
||||
output: ::ErrorOutputType,
|
||||
) -> Compilation {
|
||||
::RustcDefaultCalls.early_callback(
|
||||
matches,
|
||||
sopts,
|
||||
cfg,
|
||||
descriptions,
|
||||
output,
|
||||
)
|
||||
}
|
||||
fn no_input(
|
||||
&mut self,
|
||||
matches: &::getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
descriptions: &::errors::registry::Registry,
|
||||
) -> Option<(Input, Option<PathBuf>)> {
|
||||
::RustcDefaultCalls.no_input(
|
||||
matches,
|
||||
sopts,
|
||||
cfg,
|
||||
odir,
|
||||
ofile,
|
||||
descriptions,
|
||||
)
|
||||
}
|
||||
fn late_callback(
|
||||
&mut self,
|
||||
codegen_backend: &::CodegenBackend,
|
||||
matches: &::getopts::Matches,
|
||||
sess: &Session,
|
||||
cstore: &::CrateStore,
|
||||
input: &Input,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
) -> Compilation {
|
||||
::RustcDefaultCalls
|
||||
.late_callback(codegen_backend, matches, sess, cstore, input, odir, ofile)
|
||||
}
|
||||
fn build_controller(
|
||||
self: Box<Self>,
|
||||
_: &Session,
|
||||
_: &::getopts::Matches
|
||||
) -> CompileController<'a> {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PhaseController<'a> {
|
||||
pub stop: Compilation,
|
||||
// If true then the compiler will try to run the callback even if the phase
|
||||
|
|
|
|||
|
|
@ -712,30 +712,6 @@ pub trait CompilerCalls<'a> {
|
|||
#[derive(Copy, Clone)]
|
||||
pub struct RustcDefaultCalls;
|
||||
|
||||
/// CompilerCalls instance for quick access to the result of one compile phase.
|
||||
pub enum AdHocCalls<'a> {
|
||||
AfterAnalysis(Compilation, Box<Fn(&mut ::driver::CompileState) + 'a>)
|
||||
}
|
||||
|
||||
impl<'a> CompilerCalls<'a> for AdHocCalls<'a> {
|
||||
fn build_controller(
|
||||
self: Box<Self>,
|
||||
_: &Session,
|
||||
_: &getopts::Matches
|
||||
) -> CompileController<'a> {
|
||||
let mut control = CompileController::basic();
|
||||
|
||||
match *self {
|
||||
AdHocCalls::AfterAnalysis(c, f) => {
|
||||
control.after_analysis.stop = c;
|
||||
control.after_analysis.callback = f;
|
||||
}
|
||||
}
|
||||
|
||||
control
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME remove these and use winapi 0.3 instead
|
||||
// Duplicates: bootstrap/compile.rs, librustc_errors/emitter.rs
|
||||
#[cfg(unix)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue