bootstrap/core/
compiler.rs1use std::hash::{Hash, Hasher};
2
3use crate::core::config::TargetSelection;
4use crate::core::session::Session;
5
6#[derive(Eq, PartialOrd, Ord, Clone, Copy, Debug)]
11pub struct Compiler {
12 pub(crate) stage: u32,
13 pub(crate) host: TargetSelection,
14 pub(crate) forced_compiler: bool,
18}
19
20impl Hash for Compiler {
21 fn hash<H: Hasher>(&self, state: &mut H) {
22 self.stage.hash(state);
23 self.host.hash(state);
24 }
25}
26
27impl PartialEq for Compiler {
28 fn eq(&self, other: &Self) -> bool {
29 self.stage == other.stage && self.host == other.host
30 }
31}
32
33impl Compiler {
34 pub(crate) fn new(stage: u32, host: TargetSelection) -> Self {
35 Self { stage, host, forced_compiler: false }
36 }
37
38 pub(crate) fn forced_compiler(&mut self, forced_compiler: bool) {
39 self.forced_compiler = forced_compiler;
40 }
41
42 pub(crate) fn is_snapshot(&self, sess: &Session) -> bool {
44 self.stage == 0 && self.host == sess.host_target
45 }
46
47 pub(crate) fn is_forced_compiler(&self) -> bool {
49 self.forced_compiler
50 }
51}