pub struct Context<'a> {
pub interner: &'a mut Interner,
pub sources: &'a mut SourceMap,
pub fs: &'a dyn FileSystem,
pub search: &'a SearchPath,
pub lex: Options,
pub max_include_depth: u32,
pub pedantic: bool,
}Expand description
Everything phase 4 needs from outside itself.
Grouped into one struct because #include needs all of it at once and threading five
references through every directive handler is how a parameter list becomes unreadable.
The lifetime is the compilation, and every field of it lives on the session.
Fields§
§interner: &'a mut InternerThe one interner.
sources: &'a mut SourceMapWhere an included file is added, and what a span is resolved against.
fs: &'a dyn FileSystemWhere a header is read from.
search: &'a SearchPathWhere a header is looked for.
lex: OptionsThe dialect knobs phase 1 cares about.
max_include_depth: u32How deep #include may nest before it is called a cycle.
A header that includes itself with no guard is the common way to reach this, and the alternative to a limit is a stack overflow with no diagnostic at all.
pedantic: boolWhether -Wpedantic is on, which is the only thing phase 4 asks it about today.
Here rather than on the preprocessor because it is a fact about the command line and the command line is what builds this. The parser keeps the same flag in the same place for the same reason.
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn new(
interner: &'a mut Interner,
sources: &'a mut SourceMap,
fs: &'a dyn FileSystem,
search: &'a SearchPath,
) -> Context<'a>
pub fn new( interner: &'a mut Interner, sources: &'a mut SourceMap, fs: &'a dyn FileSystem, search: &'a SearchPath, ) -> Context<'a>
A context with GCC’s include depth limit.