pub struct MacroDef {
pub name: Symbol,
pub function_like: bool,
pub params: Vec<Symbol>,
pub variadic: Option<Symbol>,
pub body: Vec<PpToken>,
pub span: Span,
pub builtin: Option<Builtin>,
}Expand description
A #define.
Fields§
§name: SymbolThe macro’s name.
function_like: boolWhether the macro takes arguments. A function-like macro with no parameters is not
the same thing as an object-like macro, so this cannot be inferred from params.
params: Vec<Symbol>The named parameters, in order, not including the variadic one.
variadic: Option<Symbol>The variadic parameter: __VA_ARGS__ for the standard ... spelling, or the given
name for the GNU args... form. None for a macro that is not variadic.
body: Vec<PpToken>The replacement list.
span: SpanThe #define line, for the note attached to a redefinition or an arity error.
builtin: Option<Builtin>Which question this macro asks, for the handful that ask one instead of having a body.
Implementations§
Source§impl MacroDef
impl MacroDef
Sourcepub fn is_variadic(&self) -> bool
pub fn is_variadic(&self) -> bool
Whether the macro takes a variable number of arguments.
Sourcepub fn param_index(&self, name: Symbol) -> Option<usize>
pub fn param_index(&self, name: Symbol) -> Option<usize>
The parameter position name refers to, with the variadic parameter counting as one
past the named ones.
Sourcepub fn is_variadic_param(&self, name: Symbol) -> bool
pub fn is_variadic_param(&self, name: Symbol) -> bool
Whether name is this macro’s variadic parameter.
Sourcepub fn same_definition_as(&self, other: &MacroDef) -> bool
pub fn same_definition_as(&self, other: &MacroDef) -> bool
Whether two definitions are the same one, which is what decides whether a redefinition is silently allowed.
The standard’s rule is spelling equivalence including whitespace separation, not just the same tokens, which is why the leading space flag is part of the comparison.