librustc: Terminate name searches at the nearest module scope for paths that contain at least two components. r=graydon

This commit is contained in:
Patrick Walton 2012-12-23 17:41:37 -05:00
parent 6b659392ea
commit 57c599914a
263 changed files with 2545 additions and 795 deletions

View File

@ -12,18 +12,18 @@
extern mod core(vers = "0.6");
#[cfg(cargo)]
extern mod self(name = "cargo", vers = "0.6");
extern mod this(name = "cargo", vers = "0.6");
#[cfg(fuzzer)]
extern mod self(name = "fuzzer", vers = "0.6");
extern mod this(name = "fuzzer", vers = "0.6");
#[cfg(rustdoc)]
extern mod self(name = "rustdoc", vers = "0.6");
extern mod this(name = "rustdoc", vers = "0.6");
#[cfg(rusti)]
extern mod self(name = "rusti", vers = "0.6");
extern mod this(name = "rusti", vers = "0.6");
#[cfg(rustc)]
extern mod self(name = "rustc", vers = "0.6");
extern mod this(name = "rustc", vers = "0.6");
fn main() { self::main() }
fn main() { this::main() }

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::os;
use core::run;
fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {
return run::program_output(~"gpgv", args);
}

View File

@ -15,13 +15,18 @@
#[forbid(deprecated_pattern)];
use cast::transmute;
use iter;
use libc;
use ptr::addr_of;
use sys;
use uint;
use vec;
/// Code for dealing with @-vectors. This is pretty incomplete, and
/// contains a bunch of duplication from the code for ~-vectors.
#[abi = "cdecl"]
extern mod rustrt {
pub extern mod rustrt {
#[legacy_exports];
fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
++v: **vec::raw::VecRepr,
@ -29,7 +34,7 @@ extern mod rustrt {
}
#[abi = "rust-intrinsic"]
extern mod rusti {
pub extern mod rusti {
#[legacy_exports];
fn move_val_init<T>(dst: &mut T, -src: T);
}
@ -157,6 +162,13 @@ pub mod traits {
pub mod traits {}
pub mod raw {
use at_vec::{rusti, rustrt};
use libc;
use ptr;
use sys;
use uint;
use vec;
pub type VecRepr = vec::raw::VecRepr;
pub type SliceRepr = vec::raw::SliceRepr;

View File

@ -16,6 +16,7 @@
//! Boolean logic
use cmp;
use cmp::Eq;
/// Negation / inverse

View File

@ -15,6 +15,10 @@
#[forbid(deprecated_pattern)];
use cmp::Eq;
use str;
use u32;
use uint;
use unicode;
/*
Lu Uppercase_Letter an uppercase letter

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use task;
// helper for transmutation, shown below.
type RustClosure = (int,int);
pub struct Handler<T, U> {

View File

@ -235,7 +235,7 @@ mod stackwalk;
// 'core' so that macro-expanded references to core::error and such
// can be resolved within libcore.
#[doc(hidden)] // FIXME #3538
mod core {
pub mod core {
pub const error : u32 = 1_u32;
pub const warn : u32 = 2_u32;
pub const info : u32 = 3_u32;

View File

@ -22,6 +22,10 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use managed;
use option;
use vec;
type DListLink<T> = Option<DListNode<T>>;
enum DListNode<T> = @{

View File

@ -23,8 +23,10 @@ Note that recursive use is not permitted.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use cast;
use cast::reinterpret_cast;
use ptr::null;
use vec;
/**
* A growable, modifiable vector type that accumulates elements into a

View File

@ -14,8 +14,11 @@
//! A type that represents one of two alternatives
use cmp;
use cmp::Eq;
use result;
use result::Result;
use vec;
/// The either type
#[deriving_eq]

View File

@ -82,7 +82,7 @@ debug!("hello, %s!", "world");
use cmp::Eq;
use option::{Some, None};
use str;
/*
* We have a 'ct' (compile-time) module that parses format strings into a
@ -98,6 +98,10 @@ use option::{Some, None};
// Functions used by the fmt extension at compile time
#[doc(hidden)]
pub mod ct {
use char;
use str;
use vec;
pub enum Signedness { Signed, Unsigned, }
pub enum Caseness { CaseUpper, CaseLower, }
pub enum Ty {
@ -332,6 +336,12 @@ pub mod ct {
// implement it 0this way, I think.
#[doc(hidden)]
pub mod rt {
use float;
use str;
use sys;
use uint;
use vec;
pub const flag_none : u32 = 0u32;
pub const flag_left_justify : u32 = 0b00000000000001u32;
pub const flag_left_zero_pad : u32 = 0b00000000000010u32;

View File

@ -14,6 +14,9 @@
//! Operations and constants for `f32`
use cmp;
use num;
pub use cmath::c_float_utils::*;
pub use cmath::c_float_targ_consts::*;

View File

@ -14,6 +14,11 @@
//! Operations and constants for `f64`
use cmath;
use cmp;
use libc;
use num;
pub use cmath::c_double_utils::*;
pub use cmath::c_double_targ_consts::*;

View File

@ -18,7 +18,10 @@ Simple compression
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use libc;
use libc::{c_void, size_t, c_int};
use ptr;
use vec;
extern mod rustrt {
fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,

View File

@ -26,6 +26,13 @@
use m_float = f64;
use cmp::{Eq, Ord};
use f64;
use num;
use num::Num::from_int;
use str;
use uint;
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
pub use f64::logarithm;
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
@ -35,8 +42,6 @@ pub use f64::{lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix};
pub use f64::{modf, pow, round, sinh, tanh, tgamma, trunc};
pub use f64::signbit;
pub use f64::{j0, j1, jn, y0, y1, yn};
use cmp::{Eq, Ord};
use num::Num::from_int;
pub const NaN: float = 0.0/0.0;

View File

@ -39,10 +39,15 @@ with destructors.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
pub use stackwalk::Word;
use libc::size_t;
use libc::uintptr_t;
use cast;
use io;
use libc::{size_t, uintptr_t};
use ptr;
use send_map::linear::LinearMap;
use stackwalk;
use sys;
pub use stackwalk::Word;
// Mirrors rust_stack.h stk_seg
struct StackSegment {

View File

@ -23,9 +23,12 @@
* CPRNG like rand::rng.
*/
use io::Writer;
use io::WriterUtil;
use io;
use io::{Writer, WriterUtil};
use os;
use to_bytes::IterBytes;
use uint;
use vec;
/**
* Types that can meaningfully be hashed should implement this.

View File

@ -14,9 +14,15 @@
use T = self::inst::T;
use char;
use cmp::{Eq, Ord};
use from_str::FromStr;
use iter;
use num;
use num::Num::from_int;
use str;
use uint;
use vec;
pub const bits : uint = inst::bits;
pub const bytes : uint = (inst::bits / 8);

View File

@ -12,5 +12,5 @@
mod inst {
pub type T = i16;
pub const bits: uint = u16::bits;
}
pub const bits: uint = ::u16::bits;
}

View File

@ -12,5 +12,5 @@
mod inst {
pub type T = i32;
pub const bits: uint = u32::bits;
pub const bits: uint = ::u32::bits;
}

View File

@ -12,5 +12,5 @@
mod inst {
pub type T = i64;
pub const bits: uint = u64::bits;
}
pub const bits: uint = ::u64::bits;
}

View File

@ -12,5 +12,5 @@
mod inst {
pub type T = i8;
pub const bits: uint = u8::bits;
}
pub const bits: uint = ::u8::bits;
}

View File

@ -14,7 +14,7 @@ pub use self::inst::pow;
mod inst {
pub type T = int;
pub const bits: uint = uint::bits;
pub const bits: uint = ::uint::bits;
/// Returns `base` raised to the power of `exponent`
pub pure fn pow(base: int, exponent: uint) -> int {

View File

@ -21,9 +21,18 @@ use result::Result;
use cmp::Eq;
use dvec::DVec;
use int;
use libc;
use libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
use libc::consts::os::posix88::*;
use libc::consts::os::extra::*;
use option;
use os;
use ptr;
use result;
use str;
use uint;
use vec;
#[allow(non_camel_case_types)] // not sure what to do about this
type fd_t = c_int;
@ -1019,6 +1028,9 @@ pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> {
// fsync related
pub mod fsync {
use libc;
use option;
use os;
pub enum Level {
// whatever fsync does on that platform

View File

@ -16,6 +16,7 @@
#[forbid(deprecated_pattern)];
use cmp::{Eq, Ord};
use iter;
use self::inst::{IMPL_T, EACH, SIZE_HINT};

View File

@ -9,6 +9,10 @@
// except according to those terms.
mod inst {
use dlist;
use managed;
use option;
#[allow(non_camel_case_types)]
pub type IMPL_T<A> = dlist::DList<A>;
@ -45,4 +49,4 @@ mod inst {
pub pure fn SIZE_HINT<A>(self: &IMPL_T<A>) -> Option<uint> {
Some(self.len())
}
}
}

View File

@ -9,6 +9,8 @@
// except according to those terms.
mod inst {
use dvec;
#[allow(non_camel_case_types)]
pub type IMPL_T<A> = dvec::DVec<A>;
@ -29,4 +31,4 @@ mod inst {
pub pure fn SIZE_HINT<A>(self: &IMPL_T<A>) -> Option<uint> {
Some(self.len())
}
}
}

View File

@ -18,6 +18,7 @@ The iteration traits and common implementation
#[forbid(deprecated_pattern)];
use cmp::{Eq, Ord};
use vec;
/// A function used to initialize the elements of a sequence
pub type InitOp<T> = &fn(uint) -> T;

View File

@ -15,6 +15,10 @@
#[forbid(deprecated_pattern)];
use cast::transmute;
use io;
use libc;
use repr;
use vec;
#[nolink]
extern mod rustrt {

View File

@ -16,6 +16,7 @@
use cmp::{Eq, Ord};
use intrinsic::TyDesc;
use ptr;
pub mod raw {
pub struct BoxHeaderRepr {

View File

@ -46,8 +46,15 @@ will once again be the preferred module for intertask communication.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use cast;
use either;
use either::Either;
use libc;
use libc::size_t;
use ptr;
use sys;
use task;
use vec;
// After snapshot, change p2::addr_of => addr_of
/**

View File

@ -45,6 +45,8 @@ let unwrapped_msg = match move msg {
#[forbid(deprecated_pattern)];
use cmp::Eq;
use option;
use util;
/// The option type
#[deriving_eq]

View File

@ -30,14 +30,24 @@
* to write OS-ignorant code by default.
*/
use libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t,
mode_t, pid_t, FILE};
pub use libc::{close, fclose};
use cast;
use either;
use io;
use libc;
use libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t};
use libc::{mode_t, pid_t, FILE};
use option;
use option::{Some, None};
pub use os::consts::*;
use private;
use ptr;
use str;
use task;
use task::TaskBuilder;
use uint;
use vec;
pub use libc::{close, fclose};
pub use os::consts::*;
// FIXME: move these to str perhaps? #2620
@ -127,6 +137,12 @@ pub fn env() -> ~[(~str,~str)] {
mod global_env {
//! Internal module for serializing access to getenv/setenv
use either;
use libc;
use oldcomm;
use private;
use str;
use task;
extern mod rustrt {
fn rust_global_env_chan_ptr() -> *libc::uintptr_t;
@ -142,7 +158,7 @@ mod global_env {
let env_ch = get_global_env_chan();
let po = oldcomm::Port();
oldcomm::send(env_ch, MsgGetEnv(str::from_slice(n),
oldcomm::Chan(&po)));
oldcomm::Chan(&po)));
oldcomm::recv(po)
}
@ -150,8 +166,8 @@ mod global_env {
let env_ch = get_global_env_chan();
let po = oldcomm::Port();
oldcomm::send(env_ch, MsgSetEnv(str::from_slice(n),
str::from_slice(v),
oldcomm::Chan(&po)));
str::from_slice(v),
oldcomm::Chan(&po)));
oldcomm::recv(po)
}
@ -195,6 +211,13 @@ mod global_env {
}
mod impl_ {
use cast;
use libc;
use option;
use ptr;
use str;
use vec;
extern mod rustrt {
fn rust_env_pairs() -> ~[~str];
}

View File

@ -19,6 +19,9 @@ Cross-platform file path handling
#[forbid(deprecated_pattern)];
use cmp::Eq;
use libc;
use ptr;
use str;
#[deriving_eq]
pub struct WindowsPath {
@ -87,6 +90,8 @@ pub pure fn Path(s: &str) -> Path {
mod stat {
#[cfg(target_arch = "x86")]
pub mod arch {
use libc;
pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
@ -115,6 +120,8 @@ mod stat {
#[cfg(target_arch = "x86_64")]
pub mod arch {
use libc;
pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
@ -144,6 +151,8 @@ mod stat {
mod stat {
#[cfg(target_arch = "x86_64")]
pub mod arch {
use libc;
pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
@ -176,6 +185,8 @@ mod stat {
#[cfg(target_os = "macos")]
mod stat {
pub mod arch {
use libc;
pub fn default_stat() -> libc::stat {
libc::stat {
st_dev: 0,
@ -738,6 +749,8 @@ pub pure fn normalize(components: &[~str]) -> ~[~str] {
// Various windows helpers, and tests for the impl.
mod windows {
use libc;
#[inline(always)]
pub pure fn is_sep(u: u8) -> bool {
u == '/' as u8 || u == '\\' as u8

View File

@ -90,7 +90,14 @@ bounded and unbounded protocols allows for less code duplication.
use cmp::Eq;
use cast::{forget, reinterpret_cast, transmute};
use either::{Either, Left, Right};
use libc;
use option;
use option::unwrap;
use pipes;
use ptr;
use private;
use task;
use vec;
#[doc(hidden)]
const SPIN_COUNT: uint = 0;

View File

@ -15,8 +15,14 @@
#[doc(hidden)];
use task::TaskBuilder;
use task::atomically;
use cast;
use libc;
use oldcomm;
use option;
use pipes;
use ptr;
use task;
use task::{TaskBuilder, atomically};
extern mod rustrt {
#[legacy_exports];

View File

@ -13,8 +13,11 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use cast;
use cmp::{Eq, Ord};
use libc;
use libc::{c_void, size_t};
use sys;
#[nolink]
#[abi = "cdecl"]

View File

@ -14,6 +14,14 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use int;
use str;
use task;
use u32;
use uint;
use util;
use vec;
#[allow(non_camel_case_types)] // runtime type
enum rctx {}

View File

@ -19,6 +19,8 @@ Runtime type reflection
use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor};
use libc::c_void;
use sys;
use vec;
/**
* Trait for visitor that wishes to reflect on data. To use this, create a

View File

@ -17,16 +17,31 @@ More runtime type reflection
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use cast::transmute;
use cast;
use char;
use dvec::DVec;
use intrinsic;
use intrinsic::{TyDesc, TyVisitor, visit_tydesc};
use io;
use io::{Writer, WriterUtil};
use libc::c_void;
use to_str::ToStr;
use cast::transmute;
use intrinsic::{TyDesc, TyVisitor, visit_tydesc};
use managed;
use managed::raw::BoxHeaderRepr;
use ptr;
use reflect;
use reflect::{MovePtr, MovePtrAdaptor, align};
use repr;
use str;
use sys;
use sys::TypeDesc;
use to_str::ToStr;
use uint;
use vec::UnboxedVecRepr;
use vec::raw::{VecRepr, SliceRepr};
use vec;
pub use managed::raw::BoxRepr;
use dvec::DVec;
/// Helpers

View File

@ -15,8 +15,11 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use cmp;
use cmp::Eq;
use either;
use either::Either;
use vec;
/// The result type
#[deriving_eq]

View File

@ -15,10 +15,9 @@
#[forbid(deprecated_pattern)];
//! Runtime calls emitted by the compiler.
use libc::c_char;
use libc::c_void;
use libc::size_t;
use libc::uintptr_t;
use libc::{c_char, c_void, size_t, uintptr_t};
use str;
use sys;
use gc::{cleanup_stack_for_failure, gc, Word};

View File

@ -13,9 +13,18 @@
#[forbid(deprecated_pattern)];
//! Process spawning
use option::{Some, None};
use libc::{pid_t, c_void, c_int};
use io;
use io::ReaderUtil;
use libc;
use libc::{pid_t, c_void, c_int};
use oldcomm;
use option::{Some, None};
use os;
use ptr;
use run;
use str;
use task;
use vec;
#[abi = "cdecl"]
extern mod rustrt {

View File

@ -45,6 +45,12 @@ pub trait SendMap<K:Eq Hash, V: Copy> {
/// Open addressing with linear probing.
pub mod linear {
use cmp;
use option;
use rand;
use uint;
use vec;
const INITIAL_CAPACITY: uint = 32u; // 2^5
struct Bucket<K:Eq Hash,V> {

View File

@ -20,10 +20,19 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use at_vec;
use cast;
use char;
use cmp::{Eq, Ord};
use libc;
use libc::size_t;
use io::WriterUtil;
use ptr;
use str;
use to_str::ToStr;
use u8;
use uint;
use vec;
/*
Section: Creating a string
@ -1936,6 +1945,11 @@ pub pure fn escape_unicode(s: &str) -> ~str {
/// Unsafe operations
pub mod raw {
use cast;
use libc;
use ptr;
use str::raw;
use vec;
/// Create a Rust string from a null-terminated *u8 buffer
pub unsafe fn from_buf(buf: *u8) -> ~str {

View File

@ -14,8 +14,16 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use cast;
use cmp::{Eq, Ord};
use gc;
use io;
use libc;
use libc::{c_void, c_char, size_t};
use ptr;
use repr;
use str;
use vec;
pub type FreeGlue = fn(*TypeDesc, *c_void);

View File

@ -26,12 +26,8 @@ magic.
*/
use task::local_data_priv::{
local_pop,
local_get,
local_set,
local_modify
};
use rt;
use task::local_data_priv::{local_get, local_pop, local_modify, local_set};
/**
* Indexes a task-local data slot. The function's code pointer is used for

View File

@ -10,6 +10,11 @@
#[doc(hidden)]; // FIXME #3538
use cast;
use dvec;
use libc;
use option;
use task::rt;
use task::local_data::LocalDataKey;
#[cfg(notest)]

View File

@ -38,11 +38,16 @@
* ~~~
*/
use cmp;
use cmp::Eq;
use oldcomm;
use option;
use result::Result;
use pipes::{stream, Chan, Port};
use result;
use task::local_data_priv::{local_get, local_set};
use task::rt::{task_id, rust_task};
use util;
use util::replace;
mod local_data_priv;

View File

@ -16,6 +16,8 @@ The task interface to the runtime
#[doc(hidden)]; // FIXME #3538
use libc;
#[allow(non_camel_case_types)] // runtime type
pub type sched_id = int;
#[allow(non_camel_case_types)] // runtime type

View File

@ -73,8 +73,16 @@
#[doc(hidden)]; // FIXME #3538
#[warn(deprecated_mode)];
use cast;
use option;
use private;
use ptr;
use send_map;
use task::rt;
use task::rt::rust_task;
use task::rt::rust_closure;
use uint;
use util;
macro_rules! move_it (
{ $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )

View File

@ -18,7 +18,9 @@ The `ToBytes` and `IterBytes` traits
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use io;
use io::Writer;
use str;
pub type Cb = fn(buf: &[const u8]) -> bool;

View File

@ -18,49 +18,52 @@ The `ToStr` trait for converting to strings
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
use str;
use vec;
pub trait ToStr { pub pure fn to_str() -> ~str; }
impl int: ToStr {
pure fn to_str() -> ~str { int::str(self) }
pure fn to_str() -> ~str { ::int::str(self) }
}
impl i8: ToStr {
pure fn to_str() -> ~str { i8::str(self) }
pure fn to_str() -> ~str { ::i8::str(self) }
}
impl i16: ToStr {
pure fn to_str() -> ~str { i16::str(self) }
pure fn to_str() -> ~str { ::i16::str(self) }
}
impl i32: ToStr {
pure fn to_str() -> ~str { i32::str(self) }
pure fn to_str() -> ~str { ::i32::str(self) }
}
impl i64: ToStr {
pure fn to_str() -> ~str { i64::str(self) }
pure fn to_str() -> ~str { ::i64::str(self) }
}
impl uint: ToStr {
pure fn to_str() -> ~str { uint::str(self) }
pure fn to_str() -> ~str { ::uint::str(self) }
}
impl u8: ToStr {
pure fn to_str() -> ~str { u8::str(self) }
pure fn to_str() -> ~str { ::u8::str(self) }
}
impl u16: ToStr {
pure fn to_str() -> ~str { u16::str(self) }
pure fn to_str() -> ~str { ::u16::str(self) }
}
impl u32: ToStr {
pure fn to_str() -> ~str { u32::str(self) }
pure fn to_str() -> ~str { ::u32::str(self) }
}
impl u64: ToStr {
pure fn to_str() -> ~str { u64::str(self) }
pure fn to_str() -> ~str { ::u64::str(self) }
}
impl float: ToStr {
pure fn to_str() -> ~str { float::to_str(self, 4u) }
pure fn to_str() -> ~str { ::float::to_str(self, 4u) }
}
impl f32: ToStr {
pure fn to_str() -> ~str { float::to_str(self as float, 4u) }
pure fn to_str() -> ~str { ::float::to_str(self as float, 4u) }
}
impl f64: ToStr {
pure fn to_str() -> ~str { float::to_str(self as float, 4u) }
pure fn to_str() -> ~str { ::float::to_str(self as float, 4u) }
}
impl bool: ToStr {
pure fn to_str() -> ~str { bool::to_str(self) }
pure fn to_str() -> ~str { ::bool::to_str(self) }
}
impl (): ToStr {
pure fn to_str() -> ~str { ~"()" }
@ -69,10 +72,10 @@ impl ~str: ToStr {
pure fn to_str() -> ~str { copy self }
}
impl &str: ToStr {
pure fn to_str() -> ~str { str::from_slice(self) }
pure fn to_str() -> ~str { ::str::from_slice(self) }
}
impl @str: ToStr {
pure fn to_str() -> ~str { str::from_slice(self) }
pure fn to_str() -> ~str { ::str::from_slice(self) }
}
impl<A: ToStr Copy, B: ToStr Copy> (A, B): ToStr {

View File

@ -15,6 +15,7 @@
//! Operations on tuples
use cmp::{Eq, Ord};
use vec;
pub trait CopyableTuple<T, U> {
pure fn first() -> T;

View File

@ -14,8 +14,13 @@
use T = self::inst::T;
use char;
use cmp::{Eq, Ord};
use from_str::FromStr;
use iter;
use num;
use str;
use vec;
pub const bits : uint = inst::bits;
pub const bytes : uint = (inst::bits / 8);

View File

@ -16,6 +16,8 @@ pub use self::inst::{
};
mod inst {
use sys;
pub type T = uint;
#[cfg(target_arch = "x86")]

View File

@ -14,20 +14,27 @@
#[forbid(deprecated_pattern)];
#[warn(non_camel_case_types)];
use cast;
use cmp::{Eq, Ord};
use option::{Some, None};
use ptr::addr_of;
use iter;
use libc;
use libc::size_t;
use option::{Some, None};
use ptr;
use ptr::addr_of;
use sys;
use uint;
use vec;
#[abi = "cdecl"]
extern mod rustrt {
pub extern mod rustrt {
fn vec_reserve_shared(++t: *sys::TypeDesc,
++v: **raw::VecRepr,
++n: libc::size_t);
}
#[abi = "rust-intrinsic"]
extern mod rusti {
pub extern mod rusti {
fn move_val_init<T>(dst: &mut T, -src: T);
fn init<T>() -> T;
}
@ -1799,6 +1806,11 @@ pub struct UnboxedVecRepr {
/// Unsafe operations
pub mod raw {
use managed;
use option;
use ptr;
use sys;
use vec::rusti;
/// The internal representation of a (boxed) vector
pub struct VecRepr {
@ -1939,6 +1951,10 @@ pub mod raw {
/// Operations on `[u8]`
pub mod bytes {
use libc;
use uint;
use vec;
use vec::raw;
/// Bytewise string comparison
pub pure fn cmp(a: &~[u8], b: &~[u8]) -> int {

View File

@ -8,24 +8,37 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use libc::{c_int, c_uint, c_char};
use back::rpath;
use driver::session;
use session::Session;
use lib::llvm::llvm;
use syntax::attr;
use middle::ty;
use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False};
use lib::llvm::{PassManagerRef, FileType};
use lib;
use metadata::common::link_meta;
use metadata::filesearch;
use metadata::{encoder, cstore};
use middle::trans::common::crate_ctxt;
use metadata::common::link_meta;
use middle::ty;
use session::Session;
use session;
use util::ppaux;
use core::char;
use core::cmp;
use core::hash;
use core::io::{Writer, WriterUtil};
use core::libc::{c_int, c_uint, c_char};
use core::os;
use core::ptr;
use core::run;
use core::str;
use core::vec;
use std::map::HashMap;
use std::sha1::sha1;
use syntax::ast;
use syntax::print::pprust;
use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False,
PassManagerRef, FileType};
use metadata::filesearch;
use syntax::ast_map::{path, path_mod, path_name};
use io::{Writer, WriterUtil};
use syntax::attr;
use syntax::print::pprust;
enum output_type {
output_type_none,
@ -65,8 +78,16 @@ fn WriteOutputFile(sess: Session,
}
}
mod jit {
pub mod jit {
#[legacy_exports];
use lib::llvm::llvm;
use metadata::cstore;
use core::cast;
use core::ptr;
use core::str;
#[nolink]
#[abi = "rust-intrinsic"]
extern mod rusti {
@ -133,6 +154,16 @@ mod jit {
mod write {
#[legacy_exports];
use back::link::jit;
use driver::session;
use lib::llvm::llvm;
use lib;
use core::char;
use core::str;
use core::vec;
fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
if ot == output_type_assembly || ot == output_type_object ||
ot == output_type_exe {
@ -609,7 +640,7 @@ fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str {
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
t: ty::t, name: ~str) ->
~str {
let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
let s = ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
return mangle(ccx.sess,
~[path_name(ccx.sess.ident_of(name)),

View File

@ -8,12 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::map;
use std::map::HashMap;
use metadata::cstore;
use driver::session;
use metadata::cstore;
use metadata::filesearch;
use core::os;
use core::uint;
use core::util;
use core::vec;
use std::map::HashMap;
use std::map;
export get_rpath_flags;
pure fn not_win32(os: session::os) -> bool {
@ -116,7 +121,7 @@ fn get_rpath_relative_to_output(os: session::os,
let prefix = match os {
session::os_linux | session::os_freebsd => "$ORIGIN",
session::os_macos => "@executable_path",
session::os_win32 => core::util::unreachable()
session::os_win32 => util::unreachable()
};
Path(prefix).push_rel(&get_relative_to(&os::make_absolute(output),

View File

@ -8,9 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use back::target_strs;
use driver::session;
use session::sess_os_to_meta_os;
use metadata::loader::meta_section_name;
use session::sess_os_to_meta_os;
fn get_target_strs(target_os: session::os) -> target_strs::t {
return {

View File

@ -8,9 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use back::target_strs;
use driver::session;
use session::sess_os_to_meta_os;
use metadata::loader::meta_section_name;
use session::sess_os_to_meta_os;
fn get_target_strs(target_os: session::os) -> target_strs::t {
return {

View File

@ -9,27 +9,49 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use metadata::{creader, cstore, filesearch};
use session::{Session, Session_, OptLevel, No, Less, Default, Aggressive};
use syntax::parse;
use syntax::{ast, codemap};
use syntax::attr;
use middle::{trans, freevars, kind, ty, typeck, lint};
use syntax::print::{pp, pprust};
use util::ppaux;
use back::link;
use result::{Ok, Err};
use std::getopts;
use std::getopts::{opt_present};
use std::getopts::groups;
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
use io::WriterUtil;
use back::{x86, x86_64};
use std::map::HashMap;
use front;
use lib::llvm::llvm;
use metadata::{creader, cstore, filesearch};
use metadata;
use middle::{trans, freevars, kind, ty, typeck, lint};
use middle;
use session::{Session, Session_, OptLevel, No, Less, Default, Aggressive};
use session;
use util::ppaux;
enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified,
ppm_expanded_identified }
use core::cmp;
use core::int;
use core::io::WriterUtil;
use core::io;
use core::option;
use core::os;
use core::result::{Ok, Err};
use core::str;
use core::vec;
use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
use std::getopts::groups;
use std::getopts::{opt_present};
use std::getopts;
use std::map::HashMap;
use std;
use syntax::ast;
use syntax::ast_map;
use syntax::attr;
use syntax::codemap;
use syntax::diagnostic;
use syntax::parse;
use syntax::print::{pp, pprust};
use syntax;
enum pp_mode {
ppm_normal,
ppm_expanded,
ppm_typed,
ppm_identified,
ppm_expanded_identified
}
/**
* The name used for source code that doesn't originate in a file

View File

@ -11,15 +11,22 @@
use back::link;
use back::target_strs;
use back;
use driver;
use driver::session;
use metadata::filesearch;
use metadata;
use middle::lint;
use core::cmp;
use core::option;
use syntax::ast::node_id;
use syntax::ast::{int_ty, uint_ty, float_ty};
use syntax::codemap::span;
use syntax::diagnostic;
use syntax::parse::parse_sess;
use syntax::{ast, codemap};
use syntax;
enum os { os_win32, os_macos, os_linux, os_freebsd, }

View File

@ -10,6 +10,9 @@
use syntax::{ast, fold, attr};
use core::option;
use core::vec;
export strip_unconfigured_items;
export metas_in_cfg;
export strip_items;

View File

@ -9,13 +9,18 @@
// except according to those terms.
use driver::session::Session;
use syntax::codemap;
use core::vec;
use syntax::ast;
use syntax::ast_util::*;
use syntax::attr;
use syntax::codemap;
use syntax::fold;
export maybe_inject_libcore_ref;
const CORE_VERSION: &static/str = "0.6";
fn maybe_inject_libcore_ref(sess: Session,
crate: @ast::crate) -> @ast::crate {
if use_core(crate) {
@ -31,29 +36,56 @@ fn use_core(crate: @ast::crate) -> bool {
fn inject_libcore_ref(sess: Session,
crate: @ast::crate) -> @ast::crate {
fn spanned<T: Copy>(x: T) -> @ast::spanned<T> {
return @{node: x,
span: dummy_sp()};
fn spanned<T: Copy>(x: T) -> ast::spanned<T> {
return {node: x, span: dummy_sp()};
}
let n1 = sess.next_node_id();
let n2 = sess.next_node_id();
let precursor = @{
fold_crate: |crate, span, fld| {
let n1 = sess.next_node_id();
let vi1 = @{node: ast::view_item_use(sess.ident_of(~"core"),
~[],
n1),
attrs: ~[
spanned({
style: ast::attr_inner,
value: spanned(ast::meta_name_value(
~"vers",
spanned(ast::lit_str(
@CORE_VERSION.to_str()))
)),
is_sugared_doc: false
})
],
vis: ast::private,
span: dummy_sp()};
let vi1 = @{node: ast::view_item_use(sess.ident_of(~"core"), ~[], n1),
attrs: ~[],
vis: ast::private,
span: dummy_sp()};
let vp = spanned(ast::view_path_glob(
ident_to_path(dummy_sp(), sess.ident_of(~"core")),
n2));
let vi2 = @{node: ast::view_item_import(~[vp]),
attrs: ~[],
vis: ast::private,
span: dummy_sp()};
let vis = vec::append(~[vi1], crate.module.view_items);
let mut new_module = { view_items: vis, ..crate.module };
new_module = fld.fold_mod(new_module);
let vis = vec::append(~[vi1, vi2], crate.node.module.view_items);
let new_crate = { module: new_module, ..crate };
(new_crate, span)
},
fold_mod: |module, fld| {
let n2 = sess.next_node_id();
return @{node: {module: { view_items: vis,.. crate.node.module },
.. crate.node},.. *crate }
let vp = @spanned(
ast::view_path_glob(ident_to_path(dummy_sp(),
sess.ident_of(~"core")),
n2));
let vi2 = @{node: ast::view_item_import(~[vp]),
attrs: ~[],
vis: ast::private,
span: dummy_sp()};
let vis = vec::append(~[vi2], module.view_items);
let new_module = { view_items: vis, ..module };
fold::noop_fold_mod(new_module, fld)
},
..*fold::default_ast_fold()
};
let fold = fold::make_fold(precursor);
@fold.fold_crate(*crate)
}

View File

@ -12,11 +12,11 @@ use driver::session::Session;
use syntax::parse;
use syntax::ast;
use core::vec;
export inject_intrinsic;
fn inject_intrinsic(sess: Session,
crate: @ast::crate) -> @ast::crate {
fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate {
let intrinsic_module = @(include_str!("intrinsic.rs").to_owned());
let item = parse::parse_item_from_source_str(~"<intrinsic>",

View File

@ -10,16 +10,19 @@
// Code that generates a test runner to run all the tests in a crate
use syntax::{ast, ast_util};
use driver::session;
use front::config;
use session::Session;
use core::dvec::DVec;
use core::option;
use core::vec;
use syntax::ast_util::*;
//import syntax::ast_util::dummy_sp;
use syntax::attr;
use syntax::codemap::span;
use syntax::fold;
use syntax::print::pprust;
use syntax::codemap::span;
use driver::session;
use session::Session;
use syntax::attr;
use dvec::DVec;
use syntax::{ast, ast_util};
export modify_for_testing;

View File

@ -8,12 +8,21 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::cast;
use core::cmp;
use core::int;
use core::io;
use core::libc::{c_char, c_int, c_uint, c_longlong, c_ulonglong};
use core::option;
use core::ptr;
use core::str;
use core::uint;
use core::vec;
use std::map::HashMap;
use libc::{c_char, c_int, c_uint, c_longlong, c_ulonglong};
type Opcode = u32;
type Bool = c_uint;
const True: Bool = 1 as Bool;
const False: Bool = 0 as Bool;
@ -1058,8 +1067,8 @@ fn SetLinkage(Global: ValueRef, Link: Linkage) {
/* Memory-managed object interface to type handles. */
type type_names = @{type_names: std::map::HashMap<TypeRef, ~str>,
named_types: std::map::HashMap<~str, TypeRef>};
type type_names = @{type_names: HashMap<TypeRef, ~str>,
named_types: HashMap<~str, TypeRef>};
fn associate_type(tn: type_names, s: ~str, t: TypeRef) {
assert tn.type_names.insert(t, s);
@ -1075,8 +1084,8 @@ fn name_has_type(tn: type_names, s: ~str) -> Option<TypeRef> {
}
fn mk_type_names() -> type_names {
@{type_names: std::map::HashMap(),
named_types: std::map::HashMap()}
@{type_names: HashMap(),
named_types: HashMap()}
}
fn type_to_str(names: type_names, ty: TypeRef) -> ~str {

View File

@ -10,25 +10,36 @@
//! Validates all used crates and extern libraries and loads their metadata
use syntax::diagnostic::span_handler;
use syntax::{ast, ast_util};
use syntax::attr;
use syntax::visit;
use syntax::codemap::span;
use std::map::HashMap;
use syntax::print::pprust;
use metadata::filesearch::FileSearch;
use metadata::cstore;
use metadata::common::*;
use dvec::DVec;
use metadata::decoder;
use metadata::filesearch::FileSearch;
use metadata::loader;
use core::dvec::DVec;
use core::either;
use core::option;
use core::vec;
use syntax::attr;
use syntax::codemap::span;
use syntax::diagnostic::span_handler;
use syntax::parse::token::ident_interner;
use syntax::print::pprust;
use syntax::visit;
use syntax::{ast, ast_util};
use std::map::HashMap;
export read_crates;
// Traverses an AST, reading all the information about use'd crates and extern
// libraries necessary for later resolving, typechecking, linking, etc.
fn read_crates(diag: span_handler, crate: ast::crate,
cstore: cstore::CStore, filesearch: FileSearch,
os: loader::os, static: bool, intr: @ident_interner) {
fn read_crates(diag: span_handler,
crate: ast::crate,
cstore: cstore::CStore,
filesearch: FileSearch,
os: loader::os,
static: bool,
intr: @ident_interner) {
let e = @{diag: diag,
filesearch: filesearch,
cstore: cstore,

View File

@ -11,10 +11,13 @@
// Searching for information from the cstore
use metadata::common::*;
use metadata::cstore;
use metadata::decoder;
use metadata;
use middle::ty;
use core::dvec::DVec;
use core::option::{Some, None};
use core::vec;
use reader = std::ebml::reader;
use std::ebml;
use std::map::HashMap;

View File

@ -11,8 +11,16 @@
// The crate store - a central repo for information collected about external
// crates and libraries
use std::map;
use metadata::creader;
use metadata::cstore;
use metadata::decoder;
use core::option;
use core::str;
use core::vec;
use std::map::HashMap;
use std::map;
use std;
use syntax::{ast, attr};
use syntax::parse::token::ident_interner;

View File

@ -16,12 +16,22 @@ use hash::{Hash, HashUtil};
use io::WriterUtil;
use metadata::common::*;
use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
use metadata::csearch;
use metadata::cstore;
use metadata::decoder;
use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data};
use metadata::tydecode::{parse_ident};
use middle::ty;
use util::ppaux::ty_to_str;
use reader = std::ebml::reader;
use core::cmp;
use core::dvec;
use core::int;
use core::io;
use core::option;
use core::str;
use core::vec;
use std::ebml::reader;
use std::ebml;
use std::map::HashMap;
use std::map;

View File

@ -10,28 +10,42 @@
// Metadata encoding
use metadata::common::*;
use metadata::csearch;
use metadata::cstore;
use metadata::decoder;
use metadata::tyencode;
use middle::resolve;
use middle::ty::node_id_to_type;
use middle::ty;
use middle;
use util::ppaux::ty_to_str;
use std::{ebml, map};
use core::dvec;
use core::flate;
use core::float;
use core::hash::{Hash, HashUtil};
use core::int;
use core::io::WriterUtil;
use core::io;
use core::str::to_bytes;
use core::str;
use core::to_bytes::IterBytes;
use core::uint;
use core::vec;
use std::map::HashMap;
use io::WriterUtil;
use writer = std::ebml::writer;
use std::{ebml, map};
use std;
use syntax::ast::*;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::*;
use syntax::attr;
use syntax::diagnostic::span_handler;
use syntax::print::pprust;
use syntax::{ast_util, visit};
use syntax::ast_util::*;
use metadata::common::*;
use middle::ty;
use middle::ty::node_id_to_type;
use middle::resolve;
use syntax::ast_map;
use syntax::attr;
use str::to_bytes;
use syntax::ast;
use syntax::diagnostic::span_handler;
use hash::{Hash, HashUtil};
use to_bytes::IterBytes;
use syntax;
use writer = std::ebml::writer;
export encode_parms;
export encode_metadata;
@ -458,7 +472,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: writer::Encoder,
let its_ty = node_id_to_type(ecx.tcx, id);
debug!("fn name = %s ty = %s its node id = %d",
ecx.tcx.sess.str_of(ident),
util::ppaux::ty_to_str(ecx.tcx, its_ty), id);
ty_to_str(ecx.tcx, its_ty), id);
encode_type(ecx, ebml_w, its_ty);
encode_path(ecx, ebml_w, path, ast_map::path_name(ident));
match item {

View File

@ -12,7 +12,12 @@
// FIXME (#2658): I'm not happy how this module turned out. Should
// probably just be folded into cstore.
use result::Result;
use core::option;
use core::os;
use core::result::Result;
use core::result;
use core::str;
export FileSearch;
export mk_filesearch;
export pick;

View File

@ -10,14 +10,26 @@
//! Finds crate binaries and loads their metadata
use syntax::diagnostic::span_handler;
use syntax::{ast, attr};
use syntax::print::pprust;
use syntax::codemap::span;
use lib::llvm::{False, llvm, mk_object_file, mk_section_iter};
use metadata::decoder;
use metadata::encoder;
use metadata::filesearch::FileSearch;
use io::WriterUtil;
use metadata::filesearch;
use syntax::codemap::span;
use syntax::diagnostic::span_handler;
use syntax::parse::token::ident_interner;
use syntax::print::pprust;
use syntax::{ast, attr};
use core::cast;
use core::flate;
use core::io::WriterUtil;
use core::io;
use core::option;
use core::ptr;
use core::str;
use core::uint;
use core::vec;
export os;
export os_macos, os_win32, os_linux, os_freebsd;

View File

@ -16,6 +16,10 @@
use middle::ty;
use middle::ty::{FnTyBase, FnMeta, FnSig};
use core::io;
use core::str;
use core::uint;
use core::vec;
use syntax::ast;
use syntax::ast::*;
use syntax::ast_util;

View File

@ -10,12 +10,16 @@
// Type encoding
use io::WriterUtil;
use middle::ty;
use middle::ty::vid;
use core::io::WriterUtil;
use core::io;
use core::uint;
use core::vec;
use std::map::HashMap;
use syntax::ast::*;
use syntax::diagnostic::span_handler;
use middle::ty;
use middle::ty::vid;
use syntax::print::pprust::*;
export ctxt;

View File

@ -20,10 +20,12 @@ use middle::freevars::freevar_entry;
use middle::typeck::{method_origin, method_map_entry, vtable_res};
use middle::typeck::{vtable_origin};
use middle::{ty, typeck};
use middle;
use util::ppaux::ty_to_str;
use reader = std::ebml::reader;
use core::{dvec, option, vec};
use std::ebml::reader::get_doc;
use std::ebml::reader;
use std::ebml::writer::Encoder;
use std::ebml;
use std::map::HashMap;
@ -41,6 +43,7 @@ use syntax::fold;
use syntax::parse;
use syntax::print::pprust;
use syntax::visit;
use syntax;
use writer = std::ebml::writer;
export maps;

View File

@ -18,8 +18,16 @@
// 4. moves to dnot affect things loaned out in any way
use middle::ty::{CopyValue, MoveValue, ReadValue};
use middle::ty;
use dvec::DVec;
use core::cmp;
use core::dvec::DVec;
use core::uint;
use core::vec;
use syntax::ast;
use syntax::ast_util;
use syntax::print::pprust;
use syntax::visit;
export check_loans;

View File

@ -16,11 +16,18 @@
// their associated scopes. In phase two, checking loans, we will then make
// sure that all of these loans are honored.
use middle::mem_categorization::{mem_categorization_ctxt, opt_deref_kind};
use middle::borrowck::preserve::{preserve_condition, pc_ok, pc_if_pure};
use middle::mem_categorization::{mem_categorization_ctxt, opt_deref_kind};
use middle::pat_util;
use middle::ty::{ty_region};
use middle::ty;
use core::dvec;
use core::send_map::linear::LinearMap;
use core::vec;
use syntax::ast;
use syntax::print::pprust;
use syntax::visit;
export gather_loans;

View File

@ -12,8 +12,12 @@
// Loan(Ex, M, S) = Ls holds if ToAddr(Ex) will remain valid for the entirety
// of the scope S, presuming that the returned set of loans `Ls` are honored.
use middle::ty;
use core::result::{Result, Ok, Err};
use syntax::ast;
export public_methods;
use result::{Result, Ok, Err};
impl borrowck_ctxt {
fn loan(cmt: cmt,

View File

@ -226,13 +226,18 @@ Borrowck results in two maps.
#[legacy_exports];
use middle::liveness;
use middle::mem_categorization::*;
use middle::region;
use middle::ty::to_str;
use middle::ty;
use util::common::indenter;
use util::ppaux::{expr_repr, note_and_explain_region};
use util::ppaux::{ty_to_str, region_to_str, explain_region};
use core::cmp;
use core::dvec::DVec;
use core::io;
use core::result::{Result, Ok, Err};
use std::list::{List, Cons, Nil};
use std::list;
@ -333,7 +338,7 @@ type root_map_key = {id: ast::node_id, derefs: uint};
// set of ids of local vars / formal arguments that are modified / moved.
// this is used in trans for optimization purposes.
type mutbl_map = std::map::HashMap<ast::node_id, ()>;
type mutbl_map = HashMap<ast::node_id, ()>;
// Errors that can occur"]
enum bckerr_code {

View File

@ -13,6 +13,10 @@
// the scope S.
//
use middle::ty;
use syntax::ast;
export public_methods, preserve_condition, pc_ok, pc_if_pure;
enum preserve_condition {

View File

@ -8,10 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use syntax::{ast, ast_util};
use syntax::codemap::span;
use std::map;
use middle::freevars;
use middle::ty;
use core::option;
use core::vec;
use std::map::HashMap;
use std::map;
use syntax::codemap::span;
use syntax::{ast, ast_util};
export capture_mode;
export capture_var;

View File

@ -16,13 +16,18 @@ use middle::ty;
use middle::typeck::method_map;
use util::ppaux::ty_to_str;
use core::cmp;
use core::option;
use core::uint;
use core::vec;
use std::map::HashMap;
use std::sort;
use syntax::ast::*;
use syntax::ast_util::{variant_def_ids, dummy_sp, unguarded_pat, walk_pat};
use syntax::ast_util;
use syntax::codemap::span;
use syntax::print::pprust::pat_to_str;
use syntax::visit;
use std::sort;
struct AltCheckCtxt {
tcx: ty::ctxt,
@ -470,7 +475,7 @@ fn ctor_arity(cx: @AltCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
}
fn wild() -> @pat {
@{id: 0, node: pat_wild, span: syntax::ast_util::dummy_sp()}
@{id: 0, node: pat_wild, span: ast_util::dummy_sp()}
}
fn specialize(cx: @AltCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint,

View File

@ -8,11 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use driver::session::Session;
use middle::resolve;
use middle::ty;
use middle::typeck;
use util::ppaux;
use core::dvec::DVec;
use core::option;
use std::map::HashMap;
use syntax::ast::*;
use syntax::{visit, ast_util, ast_map};
use driver::session::Session;
use std::map::HashMap;
use dvec::DVec;
fn check_crate(sess: Session, crate: @crate, ast_map: ast_map::map,
def_map: resolve::DefMap,
@ -88,7 +94,7 @@ fn check_expr(sess: Session, def_map: resolve::DefMap,
let ety = ty::expr_ty(tcx, e);
if !ty::type_is_numeric(ety) {
sess.span_err(e.span, ~"can not cast to `" +
util::ppaux::ty_to_str(tcx, ety) +
ppaux::ty_to_str(tcx, ety) +
~"` in a constant expression");
}
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use middle::ty;
use syntax::ast::*;
use syntax::visit;

View File

@ -8,6 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use middle::resolve;
use middle::ty;
use middle;
use core::cmp;
use core::float;
use core::vec;
use syntax::{ast, ast_map, ast_util, visit};
use syntax::ast::*;

View File

@ -11,11 +11,16 @@
// A pass that annotates for each loops and functions with the free
// variables that they contain.
use syntax::print::pprust::path_to_str;
use middle::resolve;
use middle::ty;
use core::int;
use core::option::*;
use core::vec;
use std::map::*;
use option::*;
use syntax::{ast, ast_util, visit};
use syntax::codemap::span;
use syntax::print::pprust::path_to_str;
use syntax::{ast, ast_util, visit};
export annotate_freevars;
export freevar_map;

View File

@ -9,11 +9,20 @@
// except according to those terms.
use middle::freevars::freevar_entry;
use middle::freevars;
use middle::lint::{non_implicitly_copyable_typarams, implicit_copies};
use middle::liveness;
use middle::pat_util;
use middle::ty::{CopyValue, MoveValue, ReadValue};
use middle::ty::{Kind, kind_copyable, kind_noncopyable, kind_const};
use middle::ty;
use middle::typeck;
use middle;
use util::ppaux::{ty_to_str, tys_to_str};
use core::option;
use core::str;
use core::vec;
use std::map::HashMap;
use syntax::ast::*;
use syntax::codemap::span;
@ -71,7 +80,7 @@ fn kind_to_str(k: Kind) -> ~str {
str::connect(kinds, ~" ")
}
type rval_map = std::map::HashMap<node_id, ()>;
type rval_map = HashMap<node_id, ()>;
type ctx = {tcx: ty::ctxt,
method_map: typeck::method_map,

View File

@ -29,6 +29,7 @@ use syntax::ast_util::{local_def};
use syntax::visit::{default_simple_visitor, mk_simple_visitor};
use syntax::visit::{visit_crate, visit_item};
use core::ptr;
use std::map::HashMap;
use str_eq = str::eq;

View File

@ -8,19 +8,38 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use driver::session;
use driver::session::Session;
use driver::session;
use middle::pat_util::{pat_bindings};
use middle::ty;
use syntax::{ast, ast_util, visit};
use util::ppaux::{ty_to_str};
use core::char;
use core::cmp;
use core::either;
use core::i8;
use core::i16;
use core::i32;
use core::i64;
use core::int;
use core::io::WriterUtil;
use core::str;
use core::u8;
use core::u16;
use core::u32;
use core::u64;
use core::uint;
use core::vec;
use std::map::{Map, HashMap};
use std::map;
use std::smallintmap::{Map, SmallIntMap};
use std::smallintmap;
use syntax::ast_util::{path_to_ident};
use syntax::attr;
use syntax::codemap::span;
use std::map::{Map,HashMap};
use std::smallintmap::{Map,SmallIntMap};
use io::WriterUtil;
use util::ppaux::{ty_to_str};
use middle::pat_util::{pat_bindings};
use syntax::ast_util::{path_to_ident};
use syntax::print::pprust::{expr_to_str, mode_to_str, pat_to_str};
use syntax::{ast, ast_util, visit};
export lint, ctypes, unused_imports, while_true, path_statement, old_vecs;
export unrecognized_lint, non_implicitly_copyable_typarams;
export vecs_implicitly_copyable, implicit_copies, legacy_modes;
@ -226,7 +245,7 @@ fn get_lint_dict() -> lint_dict {
default: warn}),
*/
];
std::map::hash_from_vec(v)
map::hash_from_vec(v)
}
// This is a highly not-optimal set of data structure decisions.
@ -242,7 +261,7 @@ type lint_settings = {
};
fn mk_lint_settings() -> lint_settings {
{default_settings: std::smallintmap::mk(),
{default_settings: smallintmap::mk(),
settings_map: HashMap()}
}
@ -266,7 +285,7 @@ fn get_lint_settings_level(settings: lint_settings,
// This is kind of unfortunate. It should be somewhere else, or we should use
// a persistent data structure...
fn clone_lint_modes(modes: lint_modes) -> lint_modes {
std::smallintmap::SmallIntMap_(@{v: copy modes.v})
smallintmap::SmallIntMap_(@{v: copy modes.v})
}
type ctxt_ = {dict: lint_dict,
@ -386,7 +405,7 @@ fn build_settings_item(i: @ast::item, &&cx: ctxt, v: visit::vt<ctxt>) {
fn build_settings_crate(sess: session::Session, crate: @ast::crate) {
let cx = ctxt_({dict: get_lint_dict(),
curr: std::smallintmap::mk(),
curr: smallintmap::mk(),
is_default: true,
sess: sess});

View File

@ -103,10 +103,20 @@
*/
use middle::capture::{cap_move, cap_drop, cap_copy, cap_ref};
use middle::capture;
use middle::pat_util;
use middle::ty::MoveValue;
use middle::ty;
use middle::typeck;
use core::cmp;
use core::dvec::DVec;
use core::io::WriterUtil;
use core::io;
use core::ptr;
use core::to_str;
use core::uint;
use core::vec;
use std::map::HashMap;
use syntax::ast::*;
use syntax::codemap::span;
@ -414,7 +424,7 @@ impl IrMaps {
fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
sp: span, id: node_id, &&self: @IrMaps, v: vt<@IrMaps>) {
debug!("visit_fn: id=%d", id);
let _i = util::common::indenter();
let _i = ::util::common::indenter();
// swap in a new set of IR maps for this function body:
let fn_maps = @IrMaps(self.tcx, self.method_map,

View File

@ -46,13 +46,19 @@
* then an index to jump forward to the relevant item.
*/
use syntax::ast;
use syntax::ast::{m_imm, m_const, m_mutbl};
use syntax::codemap::span;
use syntax::print::pprust;
use middle::ty;
use middle::typeck;
use util::ppaux::{ty_to_str, region_to_str};
use util::common::indenter;
use core::cmp;
use core::to_bytes;
use core::uint;
use syntax::ast::{m_imm, m_const, m_mutbl};
use syntax::ast;
use syntax::codemap::span;
use syntax::print::pprust;
enum categorization {
cat_rvalue, // result of eval'ing some misc expr
cat_special(special_kind), //

View File

@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use middle::resolve;
use middle::ty::{CopyValue, MoveValue, ReadValue};
use middle::ty;
use syntax::ast::*;
use syntax::ast_util;
@ -23,12 +25,12 @@ export pat_is_variant_or_struct, pat_is_binding, pat_is_binding_or_wild;
export pat_is_const;
export arms_have_by_move_bindings;
type PatIdMap = std::map::HashMap<ident, node_id>;
type PatIdMap = HashMap<ident, node_id>;
// This is used because same-named variables in alternative patterns need to
// use the node_id of their namesake in the first pattern.
fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap {
let map = std::map::HashMap();
let map = HashMap();
do pat_bindings(dm, pat) |_bm, p_id, _s, n| {
map.insert(path_to_ident(n), p_id);
};

View File

@ -12,21 +12,22 @@
// outside their scopes.
use middle::ty::{ty_struct, ty_enum};
use middle::ty;
use middle::typeck::{method_map, method_origin, method_param, method_self};
use middle::typeck::{method_static, method_trait};
use /*mod*/ syntax::ast;
use /*mod*/ syntax::visit;
use syntax::ast_map;
use core::dvec::DVec;
use core::util::ignore;
use syntax::ast::{def_variant, expr_field, expr_method_call, expr_struct};
use syntax::ast::{expr_unary, ident, item_struct, item_enum, item_impl};
use syntax::ast::{item_trait, local_crate, node_id, pat_struct, private};
use syntax::ast::{provided, required};
use syntax::ast;
use syntax::ast_map::{node_item, node_method};
use syntax::ast_map;
use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local};
use syntax::ast_util::{visibility_to_privacy};
use core::util::ignore;
use dvec::DVec;
use syntax::visit;
fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
let privileged_items = @DVec();

View File

@ -19,11 +19,14 @@ region parameterized.
use driver::session::Session;
use metadata::csearch;
use middle::resolve;
use middle::ty::{region_variance, rv_covariant, rv_invariant};
use middle::ty::{rv_contravariant};
use middle::ty;
use core::cmp;
use core::dvec::DVec;
use core::vec;
use std::list;
use std::list::list;
use std::map::HashMap;
@ -564,7 +567,7 @@ impl determine_rp_ctxt {
self.item_id = item_id;
self.anon_implies_rp = anon_implies_rp;
debug!("with_item_id(%d, %b)", item_id, anon_implies_rp);
let _i = util::common::indenter();
let _i = ::util::common::indenter();
f();
self.item_id = old_item_id;
self.anon_implies_rp = old_anon_implies_rp;

View File

@ -16,6 +16,10 @@ use metadata::decoder::{def_like, dl_def, dl_field, dl_impl};
use middle::lang_items::LanguageItems;
use middle::lint::{deny, allow, forbid, level, unused_imports, warn};
use middle::pat_util::{pat_bindings};
use core::cmp;
use core::str;
use core::vec;
use syntax::ast::{_mod, add, arm, binding_mode, bitand, bitor, bitxor, blk};
use syntax::ast::{capture_clause};
use syntax::ast::{crate, crate_num, decl_item, def, def_arg, def_binding};
@ -35,16 +39,16 @@ use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge};
use syntax::ast::{gt, ident, impure_fn, inherited, item, item_struct};
use syntax::ast::{item_const, item_enum, item_fn, item_foreign_mod};
use syntax::ast::{item_impl, item_mac, item_mod, item_trait, item_ty, le};
use syntax::ast::{local, local_crate, lt, method, mode, module_ns, mul, ne};
use syntax::ast::{neg, node_id, pat, pat_enum, pat_ident, path, prim_ty};
use syntax::ast::{pat_box, pat_lit, pat_range, pat_rec, pat_struct};
use syntax::ast::{pat_tup, pat_uniq, pat_wild, private, provided, public};
use syntax::ast::{required, rem, self_ty_, shl, shr, stmt_decl, struct_dtor};
use syntax::ast::{struct_field, struct_variant_kind, sty_by_ref, sty_static};
use syntax::ast::{subtract, trait_ref, tuple_variant_kind, Ty, ty_bool};
use syntax::ast::{ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i, ty_i16};
use syntax::ast::{ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path, ty_str};
use syntax::ast::{ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint};
use syntax::ast::{local, local_crate, lt, method, mode, module_ns, mul};
use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
use syntax::ast::{path, pat_box, pat_lit, pat_range, pat_rec, pat_struct};
use syntax::ast::{pat_tup, pat_uniq, pat_wild, prim_ty, private, provided};
use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl};
use syntax::ast::{struct_dtor, struct_field, struct_variant_kind, sty_by_ref};
use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path};
use syntax::ast::{ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint};
use syntax::ast::{type_value_ns, ty_param_bound, unnamed_field};
use syntax::ast::{variant, view_item, view_item_export, view_item_import};
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
@ -54,6 +58,8 @@ use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
use syntax::ast_util::{Privacy, Public, Private, visibility_to_privacy};
use syntax::ast_util::has_legacy_export_attr;
use syntax::attr::{attr_metas, contains_name};
use syntax::parse::token::ident_interner;
use syntax::parse::token::special_idents;
use syntax::print::pprust::{pat_to_str, path_to_str};
use syntax::codemap::span;
use syntax::visit::{default_visitor, fk_method, mk_vt, visit_block};
@ -66,7 +72,6 @@ use dvec::DVec;
use option::{Some, get, is_some, is_none};
use str::{connect, split_str};
use vec::pop;
use syntax::parse::token::ident_interner;
use std::list::{Cons, List, Nil};
use std::map::HashMap;
@ -317,9 +322,14 @@ enum UseLexicalScopeFlag {
UseLexicalScope
}
struct ModulePrefixResult {
result: ResolveResult<@Module>,
prefix_len: uint
enum SearchThroughModulesFlag {
DontSearchThroughModules,
SearchThroughModules
}
enum ModulePrefixResult {
NoPrefixFound,
PrefixFound(@Module, uint)
}
impl XrayFlag : cmp::Eq {
@ -475,10 +485,19 @@ enum ParentLink {
BlockParentLink(@Module, node_id)
}
/// The type of module this is.
enum ModuleKind {
NormalModuleKind,
ExternModuleKind,
TraitModuleKind,
AnonymousModuleKind,
}
/// One node in the tree of modules.
struct Module {
parent_link: ParentLink,
mut def_id: Option<def_id>,
kind: ModuleKind,
children: HashMap<ident,@NameBindings>,
imports: DVec<@ImportDirective>,
@ -527,10 +546,12 @@ struct Module {
fn Module(parent_link: ParentLink,
def_id: Option<def_id>,
kind: ModuleKind,
legacy_exports: bool) -> Module {
Module {
parent_link: parent_link,
def_id: def_id,
kind: kind,
children: HashMap(),
imports: DVec(),
anonymous_children: HashMap(),
@ -589,10 +610,11 @@ impl NameBindings {
fn define_module(privacy: Privacy,
parent_link: ParentLink,
def_id: Option<def_id>,
kind: ModuleKind,
legacy_exports: bool,
sp: span) {
// Merges the module with the existing type def or creates a new one.
let module_ = @Module(parent_link, def_id, legacy_exports);
let module_ = @Module(parent_link, def_id, kind, legacy_exports);
match self.type_def {
None => {
self.type_def = Some(TypeNsDef {
@ -794,6 +816,7 @@ fn Resolver(session: Session, lang_items: LanguageItems,
(*graph_root).define_module(Public,
NoParentLink,
Some({ crate: 0, node: 0 }),
NormalModuleKind,
has_legacy_export_attr(crate.node.attrs),
crate.span);
@ -824,7 +847,7 @@ fn Resolver(session: Session, lang_items: LanguageItems,
xray_context: NoXray,
current_trait_refs: None,
self_ident: syntax::parse::token::special_idents::self_,
self_ident: special_idents::self_,
primitive_type_table: @PrimitiveTypeTable(session.
parse_sess.interner),
@ -1111,8 +1134,12 @@ impl Resolver {
let parent_link = self.get_parent_link(new_parent, ident);
let def_id = { crate: 0, node: item.id };
(*name_bindings).define_module(privacy, parent_link,
Some(def_id), legacy, sp);
(*name_bindings).define_module(privacy,
parent_link,
Some(def_id),
NormalModuleKind,
legacy,
sp);
let new_parent =
ModuleReducedGraphParent((*name_bindings).get_module());
@ -1134,6 +1161,7 @@ impl Resolver {
(*name_bindings).define_module(privacy,
parent_link,
Some(def_id),
ExternModuleKind,
legacy,
sp);
@ -1251,8 +1279,12 @@ impl Resolver {
let parent_link = self.get_parent_link(new_parent,
ident);
let def_id = local_def(item.id);
name_bindings.define_module(privacy, parent_link,
Some(def_id), false, sp);
name_bindings.define_module(privacy,
parent_link,
Some(def_id),
TraitModuleKind,
false,
sp);
let new_parent = ModuleReducedGraphParent(
name_bindings.get_module());
@ -1313,6 +1345,7 @@ impl Resolver {
name_bindings.define_module(privacy,
parent_link,
Some(local_def(item.id)),
TraitModuleKind,
false,
sp);
module_parent_opt = Some(ModuleReducedGraphParent(
@ -1568,6 +1601,7 @@ impl Resolver {
(*child_name_bindings).define_module(privacy,
parent_link,
Some(def_id),
NormalModuleKind,
false,
view_item.span);
self.build_reduced_graph_for_external_crate
@ -1626,7 +1660,9 @@ impl Resolver {
let parent_module = self.get_module_from_parent(parent);
let new_module = @Module(BlockParentLink(parent_module, block_id),
None, false);
None,
AnonymousModuleKind,
false);
parent_module.anonymous_children.insert(block_id, new_module);
new_parent = ModuleReducedGraphParent(new_module);
} else {
@ -1660,6 +1696,7 @@ impl Resolver {
child_name_bindings.define_module(Public,
parent_link,
Some(def_id),
NormalModuleKind,
false,
dummy_sp());
modules.insert(def_id,
@ -1791,6 +1828,7 @@ impl Resolver {
(*child_name_bindings).define_module(Public,
parent_link,
None,
NormalModuleKind,
false,
dummy_sp());
}
@ -1804,6 +1842,7 @@ impl Resolver {
(*child_name_bindings).define_module(Public,
parent_link,
None,
NormalModuleKind,
false,
dummy_sp());
}
@ -1874,6 +1913,7 @@ impl Resolver {
Public,
parent_link,
Some(def),
NormalModuleKind,
false,
dummy_sp());
type_module =
@ -2722,23 +2762,13 @@ impl Resolver {
self.idents_to_str((*module_path).get()),
self.module_to_str(module_));
// The first element of the module path must be in the current scope
// chain.
let resolve_result = match use_lexical_scope {
DontUseLexicalScope => {
self.resolve_module_prefix(module_, module_path)
}
UseLexicalScope => {
let result = self.resolve_module_in_lexical_scope(
module_,
module_path.get_elt(0));
ModulePrefixResult { result: result, prefix_len: 1 }
}
};
// Resolve the module prefix, if any.
let module_prefix_result = self.resolve_module_prefix(module_,
module_path);
let mut search_module;
match resolve_result.result {
let mut start_index;
match module_prefix_result {
Failed => {
self.session.span_err(span, ~"unresolved name");
return Failed;
@ -2748,21 +2778,61 @@ impl Resolver {
bailing");
return Indeterminate;
}
Success(resulting_module) => {
search_module = resulting_module;
Success(NoPrefixFound) => {
// There was no prefix, so we're considering the first element
// of the path. How we handle this depends on whether we were
// instructed to use lexical scope or not.
match use_lexical_scope {
DontUseLexicalScope => {
// This is a crate-relative path. We will start the
// resolution process at index zero.
search_module = self.graph_root.get_module();
start_index = 0;
}
UseLexicalScope => {
// This is not a crate-relative path. We resolve the
// first component of the path in the current lexical
// scope and then proceed to resolve below that.
let result = self.resolve_module_in_lexical_scope(
module_,
module_path.get_elt(0));
match result {
Failed => {
self.session.span_err(span,
~"unresolved name");
return Failed;
}
Indeterminate => {
debug!("(resolving module path for import) \
indeterminate; bailing");
return Indeterminate;
}
Success(containing_module) => {
search_module = containing_module;
start_index = 1;
}
}
}
}
}
Success(PrefixFound(containing_module, index)) => {
search_module = containing_module;
start_index = index;
}
}
return self.resolve_module_path_from_root(search_module,
module_path,
resolve_result.prefix_len,
start_index,
xray,
span);
}
fn resolve_item_in_lexical_scope(module_: @Module,
name: ident,
namespace: Namespace)
namespace: Namespace,
search_through_modules:
SearchThroughModulesFlag)
-> ResolveResult<Target> {
debug!("(resolving item in lexical scope) resolving `%s` in \
@ -2818,7 +2888,30 @@ impl Resolver {
module");
return Failed;
}
ModuleParentLink(parent_module_node, _) |
ModuleParentLink(parent_module_node, _) => {
match search_through_modules {
DontSearchThroughModules => {
match search_module.kind {
NormalModuleKind => {
// We stop the search here.
debug!("(resolving item in lexical \
scope) unresolved module: not \
searching through module \
parents");
return Failed;
}
ExternModuleKind |
TraitModuleKind |
AnonymousModuleKind => {
search_module = parent_module_node;
}
}
}
SearchThroughModules => {
search_module = parent_module_node;
}
}
}
BlockParentLink(parent_module_node, _) => {
search_module = parent_module_node;
}
@ -2854,9 +2947,8 @@ impl Resolver {
-> ResolveResult<@Module> {
// If this module is an anonymous module, resolve the item in the
// lexical scope. Otherwise, resolve the item from the crate root.
let resolve_result = self.resolve_item_in_lexical_scope(module_,
name,
TypeNS);
let resolve_result = self.resolve_item_in_lexical_scope(
module_, name, TypeNS, DontSearchThroughModules);
match resolve_result {
Success(target) => {
match target.bindings.type_def {
@ -2894,46 +2986,102 @@ impl Resolver {
}
/**
* Resolves a "module prefix". A module prefix is one of (a) the name of a
* module; (b) "self::"; (c) some chain of "super::".
* Returns the nearest normal module parent of the given module.
*/
fn get_nearest_normal_module_parent(module_: @Module) -> Option<@Module> {
let mut module_ = module_;
loop {
match module_.parent_link {
NoParentLink => return None,
ModuleParentLink(new_module, _) |
BlockParentLink(new_module, _) => {
match new_module.kind {
NormalModuleKind => return Some(new_module),
ExternModuleKind |
TraitModuleKind |
AnonymousModuleKind => module_ = new_module,
}
}
}
}
}
/**
* Returns the nearest normal module parent of the given module, or the
* module itself if it is a normal module.
*/
fn get_nearest_normal_module_parent_or_self(module_: @Module) -> @Module {
match module_.kind {
NormalModuleKind => return module_,
ExternModuleKind | TraitModuleKind | AnonymousModuleKind => {
match self.get_nearest_normal_module_parent(module_) {
None => module_,
Some(new_module) => new_module
}
}
}
}
/**
* Resolves a "module prefix". A module prefix is one of (a) `self::`;
* (b) some chain of `super::`.
*/
fn resolve_module_prefix(module_: @Module,
module_path: @DVec<ident>)
-> ModulePrefixResult {
-> ResolveResult<ModulePrefixResult> {
let interner = self.session.parse_sess.interner;
let mut containing_module = self.graph_root.get_module();
let mut i = 0;
loop {
if *interner.get(module_path.get_elt(i)) == ~"self" {
containing_module = module_;
i += 1;
break;
}
if *interner.get(module_path.get_elt(i)) == ~"super" {
match containing_module.parent_link {
NoParentLink => {
return ModulePrefixResult {
result: Failed,
prefix_len: i
};
}
BlockParentLink(new_module, _) |
ModuleParentLink(new_module, _) => {
containing_module = new_module;
}
// Start at the current module if we see `self` or `super`, or at the
// top of the crate otherwise.
let mut containing_module;
let mut i;
if *interner.get(module_path.get_elt(0)) == ~"self" {
containing_module =
self.get_nearest_normal_module_parent_or_self(module_);
i = 1;
} else if *interner.get(module_path.get_elt(0)) == ~"super" {
containing_module =
self.get_nearest_normal_module_parent_or_self(module_);
i = 0; // We'll handle `super` below.
} else {
return Success(NoPrefixFound);
}
// Now loop through all the `super`s we find.
while i < module_path.len() &&
*interner.get(module_path.get_elt(i)) == ~"super" {
debug!("(resolving module prefix) resolving `super` at %s",
self.module_to_str(containing_module));
match self.get_nearest_normal_module_parent(containing_module) {
None => return Failed,
Some(new_module) => {
containing_module = new_module;
i += 1;
}
i += 1;
} else {
break;
}
}
debug!("(resolving module prefix) finished resolving prefix at %s",
self.module_to_str(containing_module));
return Success(PrefixFound(containing_module, i));
/*
// If we reached the end, return the containing module.
if i == module_path.len() {
return ModulePrefixResult {
result: Success(containing_module),
prefix_len: i
};
}
// Is the containing module the current module? If so, we allow
// globs to be unresolved.
let allow_globs = core::managed::ptr_eq(containing_module, module_);
let name = module_path.get_elt(i);
i += 1;
let resolve_result = self.resolve_name_in_module(containing_module,
name,
TypeNS,
@ -2950,13 +3098,13 @@ impl Resolver {
module!");
return ModulePrefixResult {
result: Failed,
prefix_len: i + 1
prefix_len: i
};
}
Some(module_def) => {
return ModulePrefixResult {
result: Success(module_def),
prefix_len: i + 1
prefix_len: i
};
}
}
@ -2966,7 +3114,7 @@ impl Resolver {
wasn't actually a module!");
return ModulePrefixResult {
result: Failed,
prefix_len: i + 1
prefix_len: i
};
}
}
@ -2976,17 +3124,18 @@ impl Resolver {
bailing");
return ModulePrefixResult {
result: Indeterminate,
prefix_len: i + 1
prefix_len: i
};
}
Failed => {
debug!("(resolving crate-relative module) failed to resolve");
return ModulePrefixResult {
result: Failed,
prefix_len: i + 1
prefix_len: i
};
}
}
*/
}
fn name_is_exported(module_: @Module, name: ident) -> bool {
@ -3109,7 +3258,8 @@ impl Resolver {
debug!("(resolving one-level naming result) searching for module");
match self.resolve_item_in_lexical_scope(module_,
source_name,
TypeNS) {
TypeNS,
SearchThroughModules) {
Failed => {
debug!("(resolving one-level renaming import) didn't find \
module result");
@ -3135,8 +3285,9 @@ impl Resolver {
} else {
debug!("(resolving one-level naming result) searching for value");
match self.resolve_item_in_lexical_scope(module_,
source_name,
ValueNS) {
source_name,
ValueNS,
SearchThroughModules) {
Failed => {
debug!("(resolving one-level renaming import) didn't \
@ -3157,8 +3308,9 @@ impl Resolver {
debug!("(resolving one-level naming result) searching for type");
match self.resolve_item_in_lexical_scope(module_,
source_name,
TypeNS) {
source_name,
TypeNS,
SearchThroughModules) {
Failed => {
debug!("(resolving one-level renaming import) didn't \
@ -3831,7 +3983,7 @@ impl Resolver {
if !self.session.building_library &&
is_none(&self.session.main_fn) &&
item.ident == syntax::parse::token::special_idents::main {
item.ident == special_idents::main {
self.session.main_fn = Some((item.id, item.span));
}
@ -4571,7 +4723,8 @@ impl Resolver {
-> BareIdentifierPatternResolution {
match self.resolve_item_in_lexical_scope(self.current_module,
name,
ValueNS) {
ValueNS,
SearchThroughModules) {
Success(target) => {
match target.bindings.value_def {
None => {
@ -4608,10 +4761,11 @@ impl Resolver {
* If `check_ribs` is true, checks the local definitions first; i.e.
* doesn't skip straight to the containing module.
*/
fn resolve_path(path: @path, namespace: Namespace, check_ribs: bool,
fn resolve_path(path: @path,
namespace: Namespace,
check_ribs: bool,
visitor: ResolveVisitor)
-> Option<def> {
// First, resolve the types.
for path.types.each |ty| {
self.resolve_type(*ty, visitor);
@ -4625,8 +4779,8 @@ impl Resolver {
if path.idents.len() > 1 {
return self.resolve_module_relative_path(path,
self.xray_context,
namespace);
self.xray_context,
namespace);
}
return self.resolve_identifier(path.idents.last(),
@ -4797,10 +4951,10 @@ impl Resolver {
let mut containing_module;
match self.resolve_module_path_from_root(root_module,
module_path_idents,
0,
xray,
path.span) {
module_path_idents,
0,
xray,
path.span) {
Failed => {
self.session.span_err(path.span,
@ -4821,9 +4975,9 @@ impl Resolver {
let name = path.idents.last();
match self.resolve_definition_of_name_in_module(containing_module,
name,
namespace,
xray) {
name,
namespace,
xray) {
NoNameDefinition => {
// We failed to resolve the name. Report an error.
return None;
@ -4870,8 +5024,9 @@ impl Resolver {
-> Option<def> {
// Check the items.
match self.resolve_item_in_lexical_scope(self.current_module,
ident,
namespace) {
ident,
namespace,
SearchThroughModules) {
Success(target) => {
match (*target.bindings).def_for_namespace(namespace) {
None => {
@ -4909,10 +5064,8 @@ impl Resolver {
item_struct(class_def, _) => {
for vec::each(class_def.fields) |field| {
match field.node.kind {
syntax::ast::unnamed_field
=> {},
syntax::ast::named_field(ident, _, _)
=> {
unnamed_field => {},
named_field(ident, _, _) => {
if str::eq_slice(self.session.str_of(ident),
name) {
return true
@ -5352,7 +5505,7 @@ impl Resolver {
current_module = module_;
}
BlockParentLink(module_, _) => {
idents.push(syntax::parse::token::special_idents::opaque);
idents.push(special_idents::opaque);
current_module = module_;
}
}

View File

@ -145,17 +145,24 @@
use back::abi;
use lib::llvm::llvm;
use lib::llvm::{ValueRef, BasicBlockRef};
use middle::const_eval;
use middle::pat_util::*;
use middle::resolve::DefMap;
use middle::trans::base::*;
use middle::trans::build::*;
use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::controlflow;
use middle::trans::datum::*;
use middle::trans::expr::Dest;
use middle::trans::expr;
use middle::trans::glue;
use middle::ty::{CopyValue, MoveValue, ReadValue};
use util::common::indenter;
use core::dvec::DVec;
use core::dvec;
use std::map::HashMap;
use syntax::ast::def_id;
use syntax::ast;
@ -279,7 +286,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt {
return var(v.disr_val, {enm: enum_id, var: var_id});
}
}
core::util::unreachable();
::core::util::unreachable();
}
ast::def_struct(_) => {
return lit(UnitLikeStructLit(pat_id));
@ -1543,7 +1550,7 @@ fn trans_alt_inner(scope_cx: block,
// to an alloca() that will be the value for that local variable.
// Note that we use the names because each binding will have many ids
// from the various alternatives.
let bindings_map = std::map::HashMap();
let bindings_map = HashMap();
do pat_bindings(tcx.def_map, arm.pats[0]) |bm, p_id, s, path| {
let ident = path_to_ident(path);
let variable_ty = node_id_type(bcx, p_id);

View File

@ -34,20 +34,43 @@ use driver::session::Session;
use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef};
use lib::llvm::{True, False};
use lib::llvm::{llvm, mk_target_data, mk_type_names};
use lib;
use metadata::common::link_meta;
use metadata::{csearch, cstore, decoder, encoder};
use middle::astencode;
use middle::pat_util::*;
use middle::resolve;
use middle::trans::alt;
use middle::trans::build::*;
use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::controlflow;
use middle::trans::datum;
use middle::trans::debuginfo;
use middle::trans::expr;
use middle::trans::foreign;
use middle::trans::glue;
use middle::trans::inline;
use middle::trans::meth;
use middle::trans::monomorphize;
use middle::trans::reachable;
use middle::trans::shape::*;
use middle::trans::tvec;
use middle::trans::type_of::*;
use util::common::indenter;
use util::common::is_main_name;
use util::ppaux::{ty_to_str, ty_to_short_str};
use util::ppaux;
use core::either;
use core::hash;
use core::int;
use core::io;
use core::libc::{c_uint, c_ulonglong};
use core::option::{is_none, is_some};
use core::option;
use core::uint;
use std::map::HashMap;
use std::smallintmap;
use std::{map, time, list};

Some files were not shown because too many files have changed in this diff Show More