syntax: add a some docs/clarification to the fields of ExpnInfo.
This commit is contained in:
parent
2c7f3b850c
commit
85ff90c86c
1 changed files with 26 additions and 3 deletions
|
@ -88,6 +88,8 @@ to the original source.
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
lo: BytePos,
|
lo: BytePos,
|
||||||
hi: BytePos,
|
hi: BytePos,
|
||||||
|
/// Information about where the macro came from, if this piece of
|
||||||
|
/// code was created by a macro expansion.
|
||||||
expn_info: Option<@ExpnInfo>
|
expn_info: Option<@ExpnInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,26 +164,47 @@ pub struct LocWithOpt {
|
||||||
pub struct FileMapAndLine {fm: Rc<FileMap>, line: uint}
|
pub struct FileMapAndLine {fm: Rc<FileMap>, line: uint}
|
||||||
pub struct FileMapAndBytePos {fm: Rc<FileMap>, pos: BytePos}
|
pub struct FileMapAndBytePos {fm: Rc<FileMap>, pos: BytePos}
|
||||||
|
|
||||||
|
/// The syntax with which a macro was invoked.
|
||||||
#[deriving(Clone, Hash, Show)]
|
#[deriving(Clone, Hash, Show)]
|
||||||
pub enum MacroFormat {
|
pub enum MacroFormat {
|
||||||
// e.g. #[deriving(...)] <item>
|
/// e.g. #[deriving(...)] <item>
|
||||||
MacroAttribute,
|
MacroAttribute,
|
||||||
// e.g. `format!()`
|
/// e.g. `format!()`
|
||||||
MacroBang
|
MacroBang
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Hash, Show)]
|
#[deriving(Clone, Hash, Show)]
|
||||||
pub struct NameAndSpan {
|
pub struct NameAndSpan {
|
||||||
|
/// The name of the macro that was invoked to create the thing
|
||||||
|
/// with this Span.
|
||||||
name: ~str,
|
name: ~str,
|
||||||
// the format with which the macro was invoked.
|
/// The format with which the macro was invoked.
|
||||||
format: MacroFormat,
|
format: MacroFormat,
|
||||||
|
/// The span of the macro definition itself. The macro may not
|
||||||
|
/// have a sensible definition span (e.g. something defined
|
||||||
|
/// completely inside libsyntax) in which case this is None.
|
||||||
span: Option<Span>
|
span: Option<Span>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extra information for tracking macro expansion of spans
|
/// Extra information for tracking macro expansion of spans
|
||||||
#[deriving(Hash, Show)]
|
#[deriving(Hash, Show)]
|
||||||
pub struct ExpnInfo {
|
pub struct ExpnInfo {
|
||||||
|
/// The location of the actual macro invocation, e.g. `let x =
|
||||||
|
/// foo!();`
|
||||||
|
///
|
||||||
|
/// This may recursively refer to other macro invocations, e.g. if
|
||||||
|
/// `foo!()` invoked `bar!()` internally, and there was an
|
||||||
|
/// expression inside `bar!`; the call_site of the expression in
|
||||||
|
/// the expansion would point to the `bar!` invocation; that
|
||||||
|
/// call_site span would have its own ExpnInfo, with the call_site
|
||||||
|
/// pointing to the `foo!` invocation.
|
||||||
call_site: Span,
|
call_site: Span,
|
||||||
|
/// Information about the macro and its definition.
|
||||||
|
///
|
||||||
|
/// The `callee` of the inner expression in the `call_site`
|
||||||
|
/// example would point to the `macro_rules! bar { ... }` and that
|
||||||
|
/// of the `bar!()` invocation would point to the `macro_rules!
|
||||||
|
/// foo { ... }`.
|
||||||
callee: NameAndSpan
|
callee: NameAndSpan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue