syntex_syntax 0.4.3

Export of libsyntax for code generation
b0VIM 7.4#�OU�)��dericktErick-Tryzelaar-MBP.local~erickt/projects/rust/rust-syntex/syntex_syntax/src/codemap.rsutf-8	3210#"! Utp
smtp�UQ
`�+L/`y	_�
d8�`!{ad�s��]Z��R.-�
�
@
��W������yxji0/.�
�
�
�
�
�
j
h
g


�	�	�	c		����?%$
����oTS'��������ICA@#������X.(&%�����ed8������lfdc���\
��/// to the original source./// relative to FileMaps. Methods on the CodeMap can be used to relate spans back/// are *absolute* positions from the beginning of the codemap, not positions/// Spans represent a region of code, used for error reporting. Positions in spans//// Span, Spanned// _____________________________________________________________________________}    }        CharPos(self.to_usize() - rhs.to_usize())    fn sub(self, rhs: CharPos) -> CharPos {    type Output = CharPos;impl Sub for CharPos {}    }        CharPos(self.to_usize() + rhs.to_usize())    fn add(self, rhs: CharPos) -> CharPos {    type Output = CharPos;impl Add for CharPos {}    fn to_usize(&self) -> usize { let CharPos(n) = *self; n }    fn from_usize(n: usize) -> CharPos { CharPos(n) }impl Pos for CharPos {}    }        Ok(BytePos(try!{ d.read_u32() }))    fn decode<D: Decoder>(d: &mut D) -> Result<BytePos, D::Error> {impl Decodable for BytePos {}    }        s.emit_u32(self.0)    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {impl Encodable for BytePos {}    }        BytePos((self.to_usize() - rhs.to_usize()) as u32)    fn sub(self, rhs: BytePos) -> BytePos {    type Output = BytePos;impl Sub for BytePos {}    }        BytePos((self.to_usize() + rhs.to_usize()) as u32)    fn add(self, rhs: BytePos) -> BytePos {    type Output = BytePos;impl Add for BytePos {}    fn to_usize(&self) -> usize { let BytePos(n) = *self; n as usize }    fn from_usize(n: usize) -> BytePos { BytePos(n as u32) }impl Pos for BytePos {// have been unsuccessful// FIXME: Lots of boilerplate in these impls, but so far my attempts to fixpub struct CharPos(pub usize);#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Debug)]/// values to CharPos values as necessary./// is not equivalent to a character offset. The CodeMap will convert BytePos/// A character offset. Because of multibyte utf8 characters, a byte offsetpub struct BytePos(pub u32);#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Debug)]/// a lot of them./// A byte offset. Keep this small (currently 32-bits), as AST contains}    fn to_usize(&self) -> usize;    fn from_usize(n: usize) -> Self;pub trait Pos {//// Pos, BytePos, CharPos// _____________________________________________________________________________use serialize::{Encodable, Decodable, Encoder, Decoder};use std::fmt;use std::rc::Rc;use std::ops::{Add, Sub};use std::cell::RefCell;pub use self::MacroFormat::*;//! information, source code snippets, etc.//! within the CodeMap, which upon request can be converted to line and column//! `spans` and used pervasively in the compiler. They are absolute positions//! CodeMap and are represented by FileMaps. Byte positions are stored in//! or various bits of macro expansion) cover a continuous range of bytes in the//! of source parsed during crate parsing (typically files, in-memory strings,//! from integer byte positions to the original source code location. Each bit//! The CodeMap tracks all the source code used within a single crate, mapping// except according to those terms.// option. This file may not be copied, modified, or distributed// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or//// http://rust-lang.org/COPYRIGHT.// file at the top-level directory of this distribution and at// Copyright 2012 The Rust Project Developers. See the COPYRIGHTadS
�
!�gf��_�
�
~
x
w
k
]

��po3-, ��Y,+�
�
�
�
}    }        assert_eq!(sstr, "blork.rs:2:1: 2:12");        let sstr =  cm.span_to_string(span);        let span = Span {lo: BytePos(12), hi: BytePos(23), expn_id: NO_EXPANSION};        let cm = init_code_map();        // Test span_to_str for a span ending at the end of filemap    fn t9() {    #[test]    }        assert_eq!(snippet, Ok("second line".to_string()));        let snippet = cm.span_to_snippet(span);        let span = Span {lo: BytePos(12), hi: BytePos(23), expn_id: NO_EXPANSION};        let cm = init_code_map();        // Test span_to_snippet for a span ending at the end of filemap    fn t8() {    #[test]    }        assert_eq!(lines.lines, expected);            ];            LineInfo { line_index: 3, start_col: CharPos(0), end_col: CharPos(5) }            LineInfo { line_index: 2, start_col: CharPos(0), end_col: CharPos(3) },            LineInfo { line_index: 1, start_col: CharPos(4), end_col: CharPos(6) },        let expected = vec![        let lines = cm.span_to_lines(span).unwrap();        // check that span_to_lines gives us the complete result with the lines/cols we expected        assert_eq!(&cm.span_to_snippet(span).unwrap(), "BB\nCCC\nDDDDD");        // check that we are extracting the text we thought we were extractingad�
�+�����\A;987������qon_A/�
�
�
�
o
>

�����C�����~tX/�
�
n
m
E
)

�	�	u	>	2	1			����Y��{H�N!
����XW,������iM6��|poJI932����n821�    ///     /// Lookup source information about a BytePos    }                 pos.col.to_usize() + 1)).to_string()                 pos.line,                 pos.file.name,        (format!("<{}:{}:{}>",        let pos = self.lookup_char_pos(sp.lo);    pub fn mk_substr_filename(&self, sp: Span) -> String {    }        filemap        files.push(filemap.clone());        });            multibyte_chars: RefCell::new(file_local_multibyte_chars),            lines: RefCell::new(file_local_lines),            end_pos: end_pos,            start_pos: start_pos,            src: None,            name: filename,        let filemap = Rc::new(FileMap {        }            mbc.pos = mbc.pos + start_pos;        for mbc in &mut file_local_multibyte_chars {        }            *pos = *pos + start_pos;        for pos in &mut file_local_lines {        let start_pos = Pos::from_usize(start_pos);        let end_pos = Pos::from_usize(start_pos + source_len);        };            Some(last) => last.end_pos.to_usize(),            None => 0,        let start_pos = match files.last() {        let mut files = self.files.borrow_mut();                                -> Rc<FileMap> {                                mut file_local_multibyte_chars: Vec<MultiByteChar>)                                mut file_local_lines: Vec<BytePos>,                                source_len: usize,                                filename: FileName,    pub fn new_imported_filemap(&self,    /// information for things inlined from other crates.    /// but we still know enough to generate accurate debuginfo location    /// crate. The source code of such an "imported filemap" is not available,    /// Allocates a new FileMap representing a source file from an external    }        filemap        files.push(filemap.clone());        });            multibyte_chars: RefCell::new(Vec::new()),            lines: RefCell::new(Vec::new()),            end_pos: Pos::from_usize(end_pos),            start_pos: Pos::from_usize(start_pos),            src: Some(Rc::new(src)),            name: filename,        let filemap = Rc::new(FileMap {        let end_pos = start_pos + src.len();        }            src.push('\n');        if !src.is_empty() && !src.ends_with("\n") {        // results from CodeMap.span_to_*.        // of        };            String::from(&src        };            Stri        }            };            String::from(&src[..])        } else {            String::from(&src[3..])        let mut src = if src.starts_with("\u{feff}") {        // and reuse the allocation.        // FIXME #12884: no efficient/safe way to remove from the start of a string        // Remove utf-8 BOM if any.        };            Some(last) => last.end_pos.to_usize(),            None => 0,        let start_pos = match files.last() {        let mut files = self.files.borrow_mut();    pub fn new_filemap(&self, filename: FileName, src: String) -> Rc<FileMap> {    }        }            expansions: RefCell::new(Vec::new()),            files: RefCell::new(Vec::new()),        CodeMap {    pub fn new() -> CodeMap {impl CodeMap {}    expansions: RefCell<Vec<ExpnInfo>>    pub files: RefCell<Vec<Rc<FileMap>>>,pub struct CodeMap {//// CodeMap// _____________________________________________________________________________}    }        self.src.is_none()    pub fn is_imported(&self) -> bool {    }          self.name.ends_with(">"))        !(self.name.starts_with("<") &&    pub fn is_real_file(&self) -> bool {adp�L��}-��cYX+*�
�
�
_
2
��������e��l8�
m
<

�	�	�	�	�	I			�����YON&
����9-,�����fF+����    /// Lookup source information about a BytePos    }                 pos.col.to_usize() + 1)).to_string()                 pos.line,                 pos.file.name,        (format!("<{}:{}:{}>",        let pos = self.lookup_char_pos(sp.lo);    pub fn mk_substr_filename(&self, sp: Span) -> String {    }        filemap        files.push(filemap.clone());        });            multibyte_chars: RefCell::new(file_local_multibyte_chars),            lines: RefCell::new(file_local_lines),            end_pos: end_pos,            start_pos: start_pos,            src: None,            name: filename,        let filemap = Rc::new(FileMap {        }            mbc.pos = mbc.pos + start_pos;        for mbc in &mut file_local_multibyte_chars {        }            *pos = *pos + start_pos;        for pos in &mut file_local_lines {        let start_pos = Pos::from_usize(start_pos);        let end_pos = Pos::from_usize(start_pos + source_len);        };            Some(last) => last.end_pos.to_usize(),            None => 0,        let start_pos = match files.last() {        let mut files = self.files.borrow_mut();                                -> Rc<FileMap> {                                mut file_local_multibyte_chars: Vec<MultiByteChar>)                                mut file_local_lines: Vec<BytePos>,                                source_len: usize,                                filename: FileName,    pub fn new_imported_filemap(&self,    /// information for things inlined from other crates.    /// but we still know enough to generate accurate debuginfo location    /// crate. The source code of such an "imported filemap" is not available,    /// Allocates a new FileMap representing a source file from an external    }        filemap        files.push(filemap.clone());        });            multibyte_chars: RefCell::new(Vec::new()),            lines: RefCell::new(Vec::new()),            end_pos: Pos::from_usize(end_pos),            start_pos: Pos::from_usize(start_pos),            src: Some(Rc::new(src)),            name: filename,        let filemap = Rc::new(FileMap {        let end_pos = start_pos + src.len();        }            src.push('\n');        if !src.is_empty() && !src.ends_with("\n") {        // results from CodeMap.span_to_*.        // of span is also the last byte of filemap, which leads to incorrect        // accidentally overflowing into the next filemap in case the last byte        // This is a workaround to prevent CodeMap.lookup_filemap_idx from        // Append '\n' in case it's not already there.adAm����Z+��n5�
�
�
a
I
8
$
"
!

���SQP<;!��9
�
�
�
�
�
`
0

�	�	�	�	�	s	V	T	S	"			������T#! ��q(�vQ8�����B	����iG2����lD3������ve"#[derive(Debug)]pub struct FileMapAndLine { pub fm: Rc<FileMap>, pub line: usize }#[derive(Debug)]// used to be structural records. Better names, anyone?}    pub file: Option<Rc<FileMap>>,    pub col: CharPos,    pub line: usize,    pub filename: FileName,pub struct LocWithOpt {#[derive(Debug)]// perhaps they should just be removed.// Actually, *none* of the clients use the filename *or* file field;/// A source code location used as the result of lookup_char_pos_adj}    pub col: CharPos    /// The (0-based) column offset    pub line: usize,    /// The (1-based) line number    pub file: Rc<FileMap>,    /// Information about the original sourcepub struct Loc {#[derive(Debug)]/// A source code location used for error reporting//// Loc, LocWithOpt, FileMapAndLine, FileMapAndBytePos// _____________________________________________________________________________}    }        (Some(call_site1), _) => original_sp(cm, call_site1, enclosing_sp),        (Some(call_site1), Some(call_site2)) if call_site1 == call_site2 => sp,        (None, _) => sp,    match (call_site1, call_site2) {    let call_site2 = cm.with_expn_info(enclosing_sp.expn_id, |ei| ei.map(|ei| ei.call_site));    let call_site1 = cm.with_expn_info(sp.expn_id, |ei| ei.map(|ei| ei.call_site));pub fn original_sp(cm: &CodeMap, sp: Span, enclosing_sp: Span) -> Span {/// following the `expn_info` chain./// otherwise return the call site span up to the `enclosing_sp` by/// Return the span itself if it doesn't come from a macro expansion,}    Span {lo: lo, hi: hi, expn_id: NO_EXPANSION}pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {/* assuming that we're not in macro expansion */}    respan(DUMMY_SP, t)pub fn dummy_spanned<T>(t: T) -> Spanned<T> {}    Spanned {node: t, span: sp}pub fn respan<T>(sp: Span, t: T) -> Spanned<T> {}    respan(mk_sp(lo, hi), t)pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> Spanned<T> {}    }        Ok(mk_sp(lo, hi))        let hi = BytePos((lo_hi >> 32) as u32);        let lo = BytePos(lo_hi as u32);        let lo_hi: u64 = try! { d.read_u64() };    fn decode<D: Decoder>(d: &mut D) -> Result<Span, D::Error> {impl Decodable for Span {}    }        s.emit_u64( (self.lo.0 as u64) | ((self.hi.0 as u64) << 32) )        // altogether some time (FIXME #21482)        // added by the RBML metadata encoding. The should be solved differently        // Encode spans as a single u64 in order to cut down on tagging overhead    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {impl Encodable for Span {impl Eq for Span {}}    fn ne(&self, other: &Span) -> bool { !(*self).eq(other) }    }        return (*self).lo == (*other).lo && (*self).hi == (*other).hi;    fn eq(&self, other: &Span) -> bool {impl PartialEq for Span {}    pub span: Span,    pub node: T,pub struct Spanned<T> {#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]                                         expn_id: COMMAND_LINE_EXPN };                                         hi: BytePos(0),pub const COMMAND_LINE_SP: Span = Span { lo: BytePos(0),// Generic span to be used for code originating from the command linepub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };}    pub expn_id: ExpnId    /// code was created by a macro expansion.    /// Information about where the macro came from, if this piece of    pub hi: BytePos,    pub lo: BytePos,pub struct Span {#[derive(Clone, Copy, Debug, Hash)]ad,p���f854����zljiK2�
�
�
�
o
)
���h(�����v`�
~
9
�	�	�	m	5	-	��bL0.-����h65'���������X)&%	�����F*)������ywv6����bLJI&�xbJ)    pub src: Option<Rc<String>>,    /// The complete source code    pub name: FileName,    /// e.g. `<anon>`    /// originate from files has names between angle brackets by convention,    /// The name of the file that the source came from, source that doesn'tpub struct FileMap {/// A single source in the CodeMap}    pub bytes: usize,    /// The number of bytes, >=2    pub pos: BytePos,    /// The absolute offset of the character in the CodeMappub struct MultiByteChar {#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq)]/// Identifies an offset of a multi-byte character in a FileMap}    pub lines: Vec<LineInfo>    pub file: Rc<FileMap>,pub struct FileLines {}    pub end_col: CharPos,    /// Column in line where span ends, starting from 0, exclusive.    pub start_col: CharPos,    /// Column in line where span begins, starting from 0.    pub line_index: usize,    /// Index of line, starting from 0.pub struct LineInfo {#[derive(Copy, Clone, Debug, PartialEq, Eq)]pub type FileName = String;//// FileMap, MultiByteChar, FileName, FileLines// _____________________________________________________________________________}    }        self.0    pub fn into_u32(self) -> u32 {    }        ExpnId(id)    pub fn from_u32(id: u32) -> ExpnId {impl ExpnId {pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(!1);// For code appearing from the command linepub const NO_EXPANSION: ExpnId = ExpnId(!0);pub struct ExpnId(u32);#[derive(PartialEq, Eq, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Copy)]}    pub callee: NameAndSpan    /// foo { ... }`.    /// of the `bar!()` invocation would point to the `macro_rules!    /// example would point to the `macro_rules! bar { ... }` and that    /// The `callee` of the inner expression in the `call_site`    ///    /// Information about the macro and its definition.    pub call_site: Span,    /// pointing to the `foo!` invocation.    /// call_site span would have its own ExpnInfo, with the call_site    /// the expansion would point to the `bar!` invocation; that    /// expression inside `bar!`; the call_site of the expression in    /// `foo!()` invoked `bar!()` internally, and there was an    /// This may recursively refer to other macro invocations, e.g. if    ///    /// foo!();`    /// The location of the actual macro invocation, e.g. `let x =pub struct ExpnInfo {#[derive(Hash, Debug)]/// Extra information for tracking macro expansion of spans}    pub span: Option<Span>    /// completely inside libsyntax) in which case this is None.    /// have a sensible definition span (e.g. something defined    /// The span of the macro definition itself. The macro may not    pub allow_internal_unstable: bool,    /// to them.    /// features internally without forcing the whole crate to opt-in    /// Whether the macro is allowed to use #[unstable]/feature-gated    pub format: MacroFormat,    /// The format with which the macro was invoked.    pub name: String,    /// with this Span.    /// The name of the macro that was invoked to create the thingpub struct NameAndSpan {#[derive(Clone, Hash, Debug)]}    MacroBang    /// e.g. `format!()`    MacroAttribute,    /// e.g. #[derive(...)] <item>pub enum MacroFormat {#[derive(Clone, Copy, Hash, Debug)]/// The syntax with which a macro was invoked.//// MacroFormat, NameAndSpan, ExpnInfo, ExpnId// _____________________________________________________________________________pub struct FileMapAndBytePos { pub fm: Rc<FileMap>, pub pos: BytePos }ad,�U��tZ!�����g!�
�
Q
���g*)��\�
�
?
!

�	�	b	:		���}J'���U ���b�O�����u:+ ����e
���Z����                d.read_struct_field("lines", 3, |d| {            let lines: Vec<BytePos> = try! {            };                d.read_struct_field("end_pos", 2, |d| Decodable::decode(d))            let end_pos: BytePos = try! {            };                d.read_struct_field("start_pos", 1, |d| Decodable::decode(d))            let start_pos: BytePos = try! {            };                d.read_struct_field("name", 0, |d| Decodable::decode(d))            let name: String = try! {        d.read_struct("FileMap", 5, |d| {    fn decode<D: Decoder>(d: &mut D) -> Result<FileMap, D::Error> {impl Decodable for FileMap {}    }        })            })                (*self.multibyte_chars.borrow()).encode(s)            s.emit_struct_field("multibyte_chars", 4, |s| {            };                })                    Ok(())                    }                        }                            _ => unreachable!()                            4 => for diff in diff_iter { try! { diff.0.encode(s) } },                            2 => for diff in diff_iter { try! { (diff.0 as u16).encode(s) } },                            1 => for diff in diff_iter { try! { (diff.0 as u8).encode(s) } },                        match bytes_per_diff {                                                    .map(|w| (w[1] - w[0]));                        let diff_iter = (&lines[..]).windows(2)                        try! { lines[0].encode(s) };                        // Encode the first element.                        try! { bytes_per_diff.encode(s) };                        // Encode the number of bytes used per diff.                        };                            _ => 4                            0x100 ... 0xFFFF => 2,                            0 ... 0xFF => 1,                        let bytes_per_diff: u8 = match max_line_length {                        };                                 .unwrap()                                 .max()                                 .map(|bp| bp.to_usize())                                 .map(|w| w[1] - w[0])                            lines.windows(2)                        } else {                            0                        let max_line_length = if lines.len() == 1 {                        // for the differences.                        // as a difference list, using as little space as possible                        // probably not that long. Because of that we can store lines                        // the lines list is sorted and individual lines are                        // In order to preserve some space, we exploit the fact that                    if !lines.is_empty() {                    try! { s.emit_u32(lines.len() as u32) };                    // store the length                    let lines = self.lines.borrow();            try! { s.emit_struct_field("lines", 3, |s| {            try! { s.emit_struct_field("end_pos", 2, |s| self.end_pos.encode(s)) };            try! { s.emit_struct_field("start_pos", 1, |s| self.start_pos.encode(s)) };            try! { s.emit_struct_field("name", 0, |s| self.name.encode(s)) };        s.emit_struct("FileMap", 5, |s| {    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {impl Encodable for FileMap {}    pub multibyte_chars: RefCell<Vec<MultiByteChar>>,    /// Locations of multi-byte characters in the source code    pub lines: RefCell<Vec<BytePos>>,    /// Locations of lines beginnings in the source code    pub end_pos: BytePos,    /// The end position of this source in the CodeMap    pub start_pos: BytePos,    /// The start position of this source in the CodeMapad�_��h��k/�
�
�
�
u
c
I

�����}|=����nhg�
�
a
7



�	e	4		���vuA��l8���pYKA@����]4�����cL7 �g����hQC+����            }                      pos.to_usize());                panic!("position {} does not resolve to a source location",            if a == 0 {            }                break;            if !lines.is_empty() {            let lines = lines;            let lines = files[a].lines.borrow();        loop {        // rewind until we find a useful filemap.        // are length 0, they cannot contain what we are looking for). So,        // the previous filemap, but are not the filemaps we want (because they        // There can be filemaps with length 0. These have the same start_pos as        }            }                a = m;            } else {                b = m;            if files[m].start_pos > pos {            let m = (a + b) / 2;        while b - a > 1 {        let mut b = len;        let mut a = 0;        let len = files.len();        let files = &*files;        let files = self.files.borrow();    fn lookup_filemap_idx(&self, pos: BytePos) -> usize {    }        CharPos(bpos.to_usize() - map.start_pos.to_usize() - total_extra_bytes)        assert!(map.start_pos.to_usize() + total_extra_bytes <= bpos.to_usize());        }            }                break;            } else {                assert!(bpos.to_usize() >= mbc.pos.to_usize() + mbc.bytes);                // character                // We should never see a byte position in the middle of a                total_extra_bytes += mbc.bytes - 1;                // count the actual extra bytes.                // every character is at least one byte, so we only            if mbc.pos < bpos {            debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos);        for mbc in &*map.multibyte_chars.borrow() {        let mut total_extra_bytes = 0;        // The number of extra bytes due to multibyte chars in the FileMap        let map = &(*files)[idx];        let files = self.files.borrow();        let idx = self.lookup_filemap_idx(bpos);    pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos {    /// Converts an absolute BytePos to a CharPos relative to the filemap and above.    }        FileMapAndBytePos {fm: fm, pos: offset}        let offset = bpos - fm.start_pos;        let fm = (*self.files.borrow())[idx].clone();        let idx = self.lookup_filemap_idx(bpos);    pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {    /// For a global BytePos compute the local offset within the containing FileMap    }        panic!("asking for {} which we don't know about", filename);        }            }                return fm.clone();            if filename == fm.name {        for fm in &*self.files.borrow() {    pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> {    }        }            }                }                    });                        filename: local_begin.fm.name.clone()                    return Err(SpanSnippetError::SourceNotAvailable {                None => {                }                    return Ok((&src[start_index..end_index]).to_string())                    }                            }));                                end_pos: local_end.pos,                                begin_pos: local_begin.pos,                                source_len: source_len,                                name: local_begin.fm.name.clone(),                            MalformedCodemapPositions {                        return Err(SpanSnippetError::MalformedForCodemap(                    if start_index > end_index || end_index > source_len {                                      local_begin.fm.start_pos).to_usize();ad�d����bXWE?>����j`6�
�
�
�
v
N
H
G

��f7���X6	�
�
�
�
�
|
v
u
1
�	�	�	�	U	K	,	&	%	����d	��c&����J���~)���^#��[���eG1�����        }            }                break            if quit {            });                })                    }                        false                        expn_id = info.call_site.expn_id;                        // not the right place, keep looking                    } else {                        true                        // we've found the right place, stop looking                        allows_unstable = info.callee.allow_internal_unstable;                    if span_comes_from_this_expansion {                           info.callee.allow_internal_unstable);                           span_comes_from_this_expansion,                    debug!("span_allows_unstable: from this expansion? {}, allows unstable? {}",                        });                            mac_span.lo <= span.lo && span.hi <= mac_span.hi                        info.callee.span.map_or(span == info.call_site, |mac_span| {                    let span_comes_from_this_expansion =                expninfo.map_or(/* hit the top level */ true, |info| {                debug!("span_allows_unstable: expninfo = {:?}", expninfo);            let quit = self.with_expn_info(expn_id, |expninfo| {        loop {        let mut expn_id = span.expn_id;        let mut allows_unstable = false;        debug!("span_allows_unstable(span = {:?})", span);    pub fn span_allows_unstable(&self, span: Span) -> bool {    /// `#[allow_internal_unstable]`).    /// items can be used (that is, a macro marked with    /// Check if a span is "internal" to a macro in which #[unstable]    }        }            ExpnId(i) => f(Some(&(*self.expansions.borrow())[i as usize]))            NO_EXPANSION | COMMAND_LINE_EXPN => f(None),        match id {    {        F: FnOnce(Option<&ExpnInfo>) -> T,    pub fn with_expn_info<T, F>(&self, id: ExpnId, f: F) -> T where    }        ExpnId(len as u32 - 1)        }            panic!("too many ExpnInfo's!");        if len > u32::max_value() as usize {        let len = expansions.len();        expansions.push(expn_info);        let mut expansions = self.expansions.borrow_mut();    pub fn record_expansion(&self, expn_info: ExpnInfo) -> ExpnId {    }        }            col: chpos - linechpos            line: line,            file: f,        Loc {        assert!(chpos >= linechpos);        debug!("byte is on line: {}", line);               chpos, linechpos);        debug!("char pos {:?} is on the line at char pos {:?}",               pos, linebpos);        debug!("byte pos {:?} is on the line at byte pos {:?}",        let linechpos = self.bytepos_to_file_charpos(linebpos);        let linebpos = (*f.lines.borrow())[a];        let chpos = self.bytepos_to_file_charpos(pos);        let line = a + 1; // Line numbers start at 1        let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);    fn lookup_pos(&self, pos: BytePos) -> Loc {    }        FileMapAndLine {fm: f, line: a}        }            }                if (*lines)[m] > pos { b = m; } else { a = m; }                let m = (a + b) / 2;            while b - a > 1 {            let mut b = lines.len();            let lines = f.lines.borrow();        {        let mut a = 0;        let f = (*files)[idx].clone();        let files = self.files.borrow();        let idx = self.lookup_filemap_idx(pos);    fn lookup_line(&self, pos: BytePos) -> FileMapAndLine {    }        return a;        }                  pos.to_usize())            panic!("position {} does not resolve to a source location",        if a >= len {        }            a -= 1;ad!9�����Q�����}d><;�
�
�
�
Y
W
V
/

������v_G20/.����������tS�
�
w
S
0

�	�	�	�	�	�	r	)	������jI��[!����kG#"����wG���}|pb:���zUONB4����e:98        assert_eq!(loc1.col, CharPos(10));        assert_eq!(loc1.line, 2);        assert_eq!(loc1.file.name, "blork.rs");        let loc1 = cm.lookup_char_pos(BytePos(22));        let cm = init_code_map();        // Test zero-length filemaps.    fn t5() {    #[test]    }        assert_eq!(cp2, CharPos(0));        let cp2 = cm.bytepos_to_file_charpos(BytePos(24));        assert_eq!(cp1, CharPos(22));        let cp1 = cm.bytepos_to_file_charpos(BytePos(22));        let cm = init_code_map();        // Test bytepos_to_file_charpos    fn t4() {    #[test]    }        assert_eq!(fmabp2.pos, BytePos(0));        assert_eq!(fmabp2.fm.name, "blork2.rs");        let fmabp2 = cm.lookup_byte_offset(BytePos(24));        assert_eq!(fmabp1.pos, BytePos(22));        assert_eq!(fmabp1.fm.name, "blork.rs");        let fmabp1 = cm.lookup_byte_offset(BytePos(22));        let cm = init_code_map();        // Test lookup_byte_offset    fn t3() {    #[test]    }        cm        fm3.next_line(BytePos(34));        fm3.next_line(BytePos(24));        fm2.next_line(BytePos(24));        fm1.next_line(BytePos(12));        fm1.next_line(BytePos(0));                                 "first line.\nsecond line".to_string());        let fm3 = cm.new_filemap("blork2.rs".to_string(),                                 "".to_string());        let fm2 = cm.new_filemap("empty.rs".to_string(),                                 "first line.\nsecond line".to_string());        let fm1 = cm.new_filemap("blork.rs".to_string(),        let cm = CodeMap::new();    fn init_code_map() -> CodeMap {    }        fm.next_line(BytePos(2));        fm.next_line(BytePos(10));        fm.next_line(BytePos(0));        // TESTING *REALLY* BROKEN BEHAVIOR:                                "first line.\nsecond line".to_string());        let fm = cm.new_filemap("blork.rs".to_string(),        let cm = CodeMap::new();    fn t2 () {    #[should_panic]    #[test]    }        assert_eq!(fm.get_line(1), Some("."));        fm.next_line(BytePos(10));        // TESTING BROKEN BEHAVIOR:        assert_eq!(fm.get_line(0), Some("first line."));        fm.next_line(BytePos(0));                                "first line.\nsecond line".to_string());        let fm = cm.new_filemap("blork.rs".to_string(),        let cm = CodeMap::new();    fn t1 () {    #[test]    use std::rc::Rc;    use super::*;mod tests {#[cfg(test)]//// Tests// _____________________________________________________________________________}    end_pos: BytePos    begin_pos: BytePos,    source_len: usize,    name: String,pub struct MalformedCodemapPositions {#[derive(Clone, PartialEq, Eq, Debug)]}    end: (String, BytePos)    begin: (String, BytePos),pub struct DistinctSources {#[derive(Clone, PartialEq, Eq, Debug)]}    SourceNotAvailable { filename: String }    MalformedForCodemap(MalformedCodemapPositions),    DistinctSources(DistinctSources),    IllFormedSpan(Span),pub enum SpanSnippetError {#[derive(Clone, PartialEq, Eq, Debug)]}    DistinctSources(DistinctSources),    IllFormedSpan(Span),pub enum SpanLinesError {#[derive(Clone, PartialEq, Eq, Debug)]pub type FileLinesResult = Result<FileLines, SpanLinesError>;//// SpanLinesError, SpanSnippetError, DistinctSources, MalformedCodemapPositions// _____________________________________________________________________________}    }        allows_unstable        debug!("span_allows_unstable? {}", allows_unstable);ad�`��yOIH ����<�
�
�
f
B


���S ����{uthZ�
�
�
�
�
M
(
'
�	�	�	�	d	^	]	Q	C	���NM����l%��p>�b\[��qB�����9��g&����        let span = span_from_selection(inputtext, selection);        new_filemap_and_lines(&cm, "blork.rs", inputtext);        let selection = "     \n    ^~\n~~~\n~~~~~     \n   \n";        let inputtext = "aaaaa\nbbbbBB\nCCC\nDDDDDddddd\neee\n";        let cm = CodeMap::new();    fn span_to_snippet_and_lines_spanning_multiple_lines() {    #[test]    /// lines in the middle of a file.    /// Test span_to_snippet and span_to_lines for a span coverting 3    }        fm        }            byte_pos += line.len() as u32 + 1;            // update byte_pos to include this line and the \n at the end            fm.next_line(BytePos(byte_pos));            // register the start of this line        for line in input.lines() {        let mut byte_pos: u32 = 0;        let fm = cm.new_filemap(filename.to_string(), input.to_string());    fn new_filemap_and_lines(cm: &CodeMap, filename: &str, input: &str) -> Rc<FileMap> {    }        Span { lo: BytePos(left_index), hi: BytePos(right_index + 1), expn_id: NO_EXPANSION }        let right_index = selection.rfind('~').unwrap() as u32;        let left_index = selection.find('^').unwrap() as u32;        assert_eq!(input.len(), selection.len());    fn span_from_selection(input: &str, selection: &str) -> Span {    /// that this can span lines and so on.    /// length as the input, and we uncover the byte positions.  Note    /// coverting that range. The idea is that the string has the same    /// Given a string like " ^~~~~~~~~~~~ ", produces a span    }        assert_eq!(file_lines.lines[0].line_index, 1);        assert_eq!(file_lines.lines.len(), 1);        assert_eq!(file_lines.file.name, "blork.rs");        let file_lines = cm.span_to_lines(span).unwrap();        let span = Span {lo: BytePos(12), hi: BytePos(23), expn_id: NO_EXPANSION};        let cm = init_code_map();        // Test span_to_lines for a span ending at the end of filemap    fn t7() {    #[test]    }        assert_eq!(cp4, CharPos(15));        let cp4 = cm.bytepos_to_file_charpos(BytePos(61));        assert_eq!(cp3, CharPos(12));        let cp3 = cm.bytepos_to_file_charpos(BytePos(56));        assert_eq!(cp2, CharPos(4));        let cp2 = cm.bytepos_to_file_charpos(BytePos(6));        assert_eq!(cp1, CharPos(3));        let cp1 = cm.bytepos_to_file_charpos(BytePos(3));        let cm = init_code_map_mbc();        // Test bytepos_to_file_charpos in the presence of multi-byte chars    fn t6() {    #[test]    }        cm        fm2.record_multibyte_char(BytePos(58), 3);        fm2.record_multibyte_char(BytePos(53), 3);        fm2.record_multibyte_char(BytePos(50), 3);        fm1.record_multibyte_char(BytePos(18), 3);        fm1.record_multibyte_char(BytePos(15), 3);        fm1.record_multibyte_char(BytePos(12), 3);        fm1.record_multibyte_char(BytePos(9), 3);        fm1.record_multibyte_char(BytePos(3), 3);        fm2.next_line(BytePos(58));        fm2.next_line(BytePos(40));        fm1.next_line(BytePos(22));        fm1.next_line(BytePos(0));                                 "first line€€.\n€ second line".to_string());        let fm2 = cm.new_filemap("blork2.rs".to_string(),                           "fir€st €€€€ line.\nsecond line".to_string());            cm.new_filemap("blork.rs".to_string(),        let fm1 =        // € is a three byte utf8 char.        let cm = CodeMap::new();    fn init_code_map_mbc() -> CodeMap {    }        assert_eq!(loc2.col, CharPos(0));        assert_eq!(loc2.line, 1);        assert_eq!(loc2.file.name, "blork2.rs");        let loc2 = cm.lookup_char_pos(BytePos(24));ad&�`�lkD��}(�
�
�
�
G

��ut/.�������L�
�
�
�
�
l
Q
%
�	�	�	�	�	�	�	h	:	4	2	1	"	���:��R��M�����T/����P���R,������[9#	�����    }        self.multibyte_chars.borrow_mut().push(mbc);        };            bytes: bytes,            pos: pos,        let mbc = MultiByteChar {        assert!(bytes >=2 && bytes <= 4);    pub fn record_multibyte_char(&self, pos: BytePos, bytes: usize) {    }        }            None => None            }                })                    }                        None => slice                        Some(e) => &slice[..e],                    match slice.find('\n') {                    let slice = &src[begin..];                    let begin = begin.to_usize();                    let begin: BytePos = line - self.start_pos;                lines.get(line_number).map(|&line| {                let lines = self.lines.borrow();            Some(ref src) => {        match self.src {    pub fn get_line(&self, line_number: usize) -> Option<&str> {    /// line-number here is 0-based.    /// get a line from the list of pre-computed line-beginnings.    }        lines.push(pos);        assert!(line_len == 0 || ((*lines)[line_len - 1] < pos));        let line_len = lines.len();        let mut lines = self.lines.borrow_mut();        // the new charpos must be > the last one (or it's the first one).    pub fn next_line(&self, pos: BytePos) {    /// filemap.start_pos + newline_offset_relative_to_the_start_of_filemap.    /// so the safe way to call this is with value calculated as    /// and CodeMap will append a newline when adding a filemap without a newline at the end,    /// WARNING: pos param here is the offset relative to start of CodeMap,    /// about what ends a line between this file and parse.rs    /// order and must be in the right places; there is shared knowledge    /// UNCHECKED INVARIANT: these offsets must be added in the right    /// table of line-beginnings.    /// EFFECT: register a start-of-line offset in theimpl FileMap {}    }        write!(fmt, "FileMap({})", self.name)    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {impl fmt::Debug for FileMap {}    }        })            })                multibyte_chars: RefCell::new(multibyte_chars)                lines: RefCell::new(lines),                src: None,                end_pos: end_pos,                start_pos: start_pos,                name: name,            Ok(FileMap {            };                d.read_struct_field("multibyte_chars", 4, |d| Decodable::decode(d))            let multibyte_chars: Vec<MultiByteChar> = try! {            };                })                    Ok(lines)                    }                        }                            lines.push(line_start);                            line_start = line_start + BytePos(diff);                            };                                _ => unreachable!()                                4 => try! { d.read_u32() },                                2 => try! { d.read_u16() } as u32,                                1 => try! { d.read_u8() } as u32,                            let diff = match bytes_per_diff {                        for _ in 1..num_lines {                        lines.push(line_start);                        let mut line_start: BytePos = try! { Decodable::decode(d) };                        // Read the first element.                        let bytes_per_diff: u8 = try! { Decodable::decode(d) };                        // Read the number of bytes used per diff.                    if num_lines > 0 {                    let mut lines = Vec::with_capacity(num_lines as usize);                    let num_lines: u32 = try! { Decodable::decode(d) };ad�`����_2�������M�
�
�
�
r
G
"

��uon3�����]SR$�
�
�
x
6
�	�	�	�	�	r	q	6		���W��t:��{z3����a[Z����k32��r?����t2���                    let source_len = (local_begin.fm.end_pos -                    let end_index = local_end.pos.to_usize();                    let start_index = local_begin.pos.to_usize();                Some(ref src) => {            match local_begin.fm.src {        } else {            }));                      local_end.fm.start_pos)                end: (local_end.fm.name.clone(),                        local_begin.fm.start_pos),                begin: (local_begin.fm.name.clone(),            return Err(SpanSnippetError::DistinctSources(DistinctSources {        if local_begin.fm.start_pos != local_end.fm.start_pos {        let local_end = self.lookup_byte_offset(sp.hi);        let local_begin = self.lookup_byte_offset(sp.lo);        }            return Err(SpanSnippetError::IllFormedSpan(sp));        if sp.lo > sp.hi {    pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError> {    }        Ok(FileLines {file: lo.file, lines: lines})                              end_col: hi.col });                              start_col: start_col,        lines.push(LineInfo { line_index: hi.line - 1,        // For the last line, it extends from `start_col` to `hi.col`:        }            start_col = CharPos::from_usize(0);                                  end_col: CharPos::from_usize(line_len) });                                  start_col: start_col,            lines.push(LineInfo { line_index: line_index,            let line_len = lo.file.get_line(line_index).map(|s| s.len()).unwrap_or(0);        for line_index in lo.line-1 .. hi.line-1 {        // lines.        // numbers in Loc are 1-based, so we subtract 1 to get 0-based        // and to the end of the line. Be careful because the line        // For every line but the last, it extends from `start_col`        let mut start_col = lo.col;        // but after that it starts from offset 0.        // The span starts partway through the first line,        let mut lines = Vec::with_capacity(hi.line - lo.line + 1);        assert!(hi.line >= lo.line);        }            }));                end: (hi.file.name.clone(), hi.file.start_pos),                begin: (lo.file.name.clone(), lo.file.start_pos),            return Err(SpanLinesError::DistinctSources(DistinctSources {        if lo.file.start_pos != hi.file.start_pos {        let hi = self.lookup_char_pos(sp.hi);        let lo = self.lookup_char_pos(sp.lo);        }            return Err(SpanLinesError::IllFormedSpan(sp));        if sp.lo > sp.hi {    pub fn span_to_lines(&self, sp: Span) -> FileLinesResult {    }        self.lookup_char_pos(sp.lo).file.name.to_string()    pub fn span_to_filename(&self, sp: Span) -> FileName {    }                        hi.col.to_usize() + 1)).to_string()                        hi.line,                        lo.col.to_usize() + 1,                        lo.line,                        lo.filename,        return (format!("{}:{}:{}: {}:{}",        let hi = self.lookup_char_pos_adj(sp.hi);        let lo = self.lookup_char_pos_adj(sp.lo);        }            return "no-location".to_string();        if self.files.borrow().is_empty() && sp == DUMMY_SP {    pub fn span_to_string(&self, sp: Span) -> String {    }        }            file: Some(loc.file)            col: loc.col,            line: loc.line,            filename: loc.file.name.to_string(),        LocWithOpt {        let loc = self.lookup_char_pos(pos);    pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {    }        self.lookup_pos(pos)    pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {