pub struct Expander { /* private fields */ }Expand description
Macro expansion state that outlives a single expansion.
Hide sets are interned for the whole translation unit, because the same set is produced over and over by the same nest of headers and re-interning it is free while re-allocating it is not.
Implementations§
Source§impl Expander
impl Expander
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Everything reported so far.
Sourcepub fn take_diagnostics(&mut self) -> Vec<Diagnostic>
pub fn take_diagnostics(&mut self) -> Vec<Diagnostic>
Takes the diagnostics, leaving the expander empty.
Sourcepub fn hide_sets(&self) -> usize
pub fn hide_sets(&self) -> usize
How many distinct hide sets have been interned, which is the number to watch when this starts costing memory.
Sourcepub fn expand(
&mut self,
tokens: &[PpToken],
macros: &MacroTable,
interner: &mut Interner,
sources: &SourceMap,
) -> Vec<Tok>
pub fn expand( &mut self, tokens: &[PpToken], macros: &MacroTable, interner: &mut Interner, sources: &SourceMap, ) -> Vec<Tok>
Expands a run of lexed tokens.
The input is a directive-free stretch of the file. An Eof token is ignored rather
than passed through, because the caller decides where the stream ends.
Sourcepub fn expand_toks(
&mut self,
tokens: Vec<Tok>,
macros: &MacroTable,
interner: &mut Interner,
sources: &SourceMap,
) -> Vec<Tok>
pub fn expand_toks( &mut self, tokens: Vec<Tok>, macros: &MacroTable, interner: &mut Interner, sources: &SourceMap, ) -> Vec<Tok>
Expands tokens that already carry hide sets, for a caller that is splicing streams together itself.
The source map is needed rather than merely useful: __FILE__ and __LINE__ are
answered from where the token turned out to be, and the map is the only thing that
knows that once a token has come out of three nested macros in two headers.