Fix implicit leaks of imports throughout libraries
Also touch up use of 'pub' and move some tests around so the tested functions don't have to be 'pub'
This commit is contained in:
parent
f2837fa3f5
commit
2df07ddc25
@ -10,14 +10,12 @@
|
||||
|
||||
//! Sendable hash maps.
|
||||
|
||||
use container::{Container, Mutable, Map, Set};
|
||||
use cmp::Eq;
|
||||
use hash::Hash;
|
||||
use to_bytes::IterBytes;
|
||||
|
||||
/// Open addressing with linear probing.
|
||||
pub mod linear {
|
||||
use super::*;
|
||||
use container::{Container, Mutable, Map, Set};
|
||||
use cmp::Eq;
|
||||
use hash::Hash;
|
||||
use to_bytes::IterBytes;
|
||||
use iter::BaseIter;
|
||||
use hash::Hash;
|
||||
use iter;
|
||||
@ -752,7 +750,8 @@ mod test_map {
|
||||
|
||||
#[test]
|
||||
mod test_set {
|
||||
use super::*;
|
||||
use hashmap::linear;
|
||||
use container::{Container, Mutable, Map, Set};
|
||||
use vec;
|
||||
|
||||
#[test]
|
||||
|
@ -1021,10 +1021,10 @@ extern {
|
||||
pub mod consts {
|
||||
|
||||
#[cfg(unix)]
|
||||
use os::consts::unix::*;
|
||||
pub use os::consts::unix::*;
|
||||
|
||||
#[cfg(windows)]
|
||||
use os::consts::windows::*;
|
||||
pub use os::consts::windows::*;
|
||||
|
||||
pub mod unix {
|
||||
pub const FAMILY: &str = "unix";
|
||||
@ -1035,19 +1035,19 @@ pub mod consts {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use os::consts::macos::*;
|
||||
pub use os::consts::macos::*;
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
use os::consts::freebsd::*;
|
||||
pub use os::consts::freebsd::*;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use os::consts::linux::*;
|
||||
pub use os::consts::linux::*;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
use os::consts::android::*;
|
||||
pub use os::consts::android::*;
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
use os::consts::win32::*;
|
||||
pub use os::consts::win32::*;
|
||||
|
||||
pub mod macos {
|
||||
pub const SYSNAME: &str = "macos";
|
||||
@ -1086,13 +1086,13 @@ pub mod consts {
|
||||
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
use os::consts::x86::*;
|
||||
pub use os::consts::x86::*;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use os::consts::x86_64::*;
|
||||
pub use os::consts::x86_64::*;
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
use os::consts::arm::*;
|
||||
pub use os::consts::arm::*;
|
||||
|
||||
pub mod x86 {
|
||||
pub const ARCH: &str = "x86";
|
||||
|
@ -2375,6 +2375,7 @@ impl OwnedStr for ~str {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use char;
|
||||
use option::Some;
|
||||
use debug;
|
||||
use libc::c_char;
|
||||
use libc;
|
||||
|
@ -1444,7 +1444,7 @@ pub fn each2<U, T>(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) {
|
||||
* The total number of permutations produced is `len(v)!`. If `v` contains
|
||||
* repeated elements, then some permutations are repeated.
|
||||
*/
|
||||
pure fn each_permutation<T:Copy>(v: &[T], put: fn(ts: &[T]) -> bool) {
|
||||
pub pure fn each_permutation<T:Copy>(v: &[T], put: fn(ts: &[T]) -> bool) {
|
||||
let ln = len(v);
|
||||
if ln <= 1 {
|
||||
put(v);
|
||||
@ -2427,6 +2427,7 @@ impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] {
|
||||
mod tests {
|
||||
use option::{None, Option, Some};
|
||||
use option;
|
||||
use sys;
|
||||
use vec::*;
|
||||
|
||||
fn square(n: uint) -> uint { return n * n; }
|
||||
|
@ -230,6 +230,7 @@ use middle::liveness;
|
||||
use middle::mem_categorization::*;
|
||||
use middle::region;
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
use middle::moves;
|
||||
use util::common::{indenter, stmt_set};
|
||||
use util::ppaux::{expr_repr, note_and_explain_region};
|
||||
@ -239,6 +240,7 @@ use core::cmp;
|
||||
use core::dvec::DVec;
|
||||
use core::io;
|
||||
use core::result::{Result, Ok, Err};
|
||||
use core::to_bytes;
|
||||
use std::list::{List, Cons, Nil};
|
||||
use std::list;
|
||||
use std::oldmap::{HashMap, Set};
|
||||
|
@ -145,9 +145,10 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use back::abi;
|
||||
use lib::llvm::llvm;
|
||||
use lib::llvm::{ValueRef, BasicBlockRef};
|
||||
use lib;
|
||||
use lib::llvm::{llvm, ValueRef, BasicBlockRef};
|
||||
use middle::const_eval;
|
||||
use middle::borrowck::root_map_key;
|
||||
use middle::pat_util::*;
|
||||
use middle::resolve::DefMap;
|
||||
use middle::trans::base::*;
|
||||
@ -156,20 +157,26 @@ use middle::trans::callee;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::consts;
|
||||
use middle::trans::controlflow;
|
||||
use middle::trans::datum;
|
||||
use middle::trans::datum::*;
|
||||
use middle::trans::expr::Dest;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::tvec;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use util::common::indenter;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::dvec;
|
||||
use core::libc::c_ulonglong;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast::def_id;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::{dummy_sp, path_to_ident};
|
||||
use syntax::ast::ident;
|
||||
use syntax::ast_util::path_to_ident;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::span;
|
||||
use syntax::codemap::{span, dummy_sp};
|
||||
use syntax::print::pprust::pat_to_str;
|
||||
|
||||
// An option identifying a literal: either a unit-like struct or an
|
||||
|
@ -44,6 +44,7 @@ use middle::borrowck::RootInfo;
|
||||
use middle::pat_util::*;
|
||||
use middle::resolve;
|
||||
use middle::trans::_match;
|
||||
use middle::trans::base;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::callee;
|
||||
use middle::trans::common::*;
|
||||
@ -56,12 +57,15 @@ use middle::trans::foreign;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::inline;
|
||||
use middle::trans::machine;
|
||||
use middle::trans::machine::llsize_of;
|
||||
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 middle::trans::type_of::*;
|
||||
use middle::ty;
|
||||
use middle::ty::arg;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::{ty_to_str, ty_to_short_str};
|
||||
@ -77,6 +81,7 @@ use core::option;
|
||||
use core::uint;
|
||||
use std::oldmap::HashMap;
|
||||
use std::{oldmap, time, list};
|
||||
use syntax::ast::ident;
|
||||
use syntax::ast_map::{path, path_elt_to_str, path_mod, path_name};
|
||||
use syntax::ast_util::{def_id_of_def, local_def, path_to_ident};
|
||||
use syntax::attr;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
use codemap::span;
|
||||
use lib;
|
||||
use lib::llvm::llvm;
|
||||
use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering};
|
||||
use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False};
|
||||
@ -18,9 +19,12 @@ use libc::{c_uint, c_int, c_ulonglong};
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::machine::llsize_of_real;
|
||||
|
||||
use core::prelude::*;
|
||||
use core::cast::transmute;
|
||||
use core::cast;
|
||||
use core::libc;
|
||||
use core::option::Some;
|
||||
use core::ptr;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
use std::oldmap::HashMap;
|
||||
|
@ -13,6 +13,10 @@ use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::common::*;
|
||||
|
||||
use core::libc::c_uint;
|
||||
use core::option;
|
||||
use core::vec;
|
||||
|
||||
pub trait ABIInfo {
|
||||
fn compute_info(&self,
|
||||
atys: &[TypeRef],
|
||||
@ -28,7 +32,7 @@ pub struct LLVMType {
|
||||
pub struct FnType {
|
||||
arg_tys: ~[LLVMType],
|
||||
ret_ty: LLVMType,
|
||||
attrs: ~[Option<Attribute>],
|
||||
attrs: ~[option::Option<Attribute>],
|
||||
sret: bool
|
||||
}
|
||||
|
||||
@ -93,7 +97,7 @@ pub impl FnType {
|
||||
llargbundle: ValueRef, llretval: ValueRef) {
|
||||
for vec::eachi(self.attrs) |i, a| {
|
||||
match *a {
|
||||
Some(attr) => {
|
||||
option::Some(attr) => {
|
||||
unsafe {
|
||||
llvm::LLVMAddInstrAttribute(
|
||||
llretval, (i + 1u) as c_uint,
|
||||
|
@ -18,6 +18,14 @@ use lib::llvm::struct_tys;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::cabi::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::libc::c_uint;
|
||||
use core::option;
|
||||
use core::option::Option;
|
||||
use core::ptr;
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
|
||||
enum x86_64_reg_class {
|
||||
no_class,
|
||||
integer_class,
|
||||
|
@ -18,21 +18,33 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib::llvm::ValueRef;
|
||||
use middle::trans::base::{get_item_val, trans_external_path};
|
||||
use back::abi;
|
||||
use driver::session;
|
||||
use lib;
|
||||
use lib::llvm::{ValueRef, TypeRef};
|
||||
use lib::llvm::llvm;
|
||||
use metadata::csearch;
|
||||
use middle::trans::base;
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::callee;
|
||||
use middle::trans::closure;
|
||||
use middle::trans::common::{block, node_id_type_params};
|
||||
use middle::trans::common;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::datum::*;
|
||||
use middle::trans::datum::Datum;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::inline;
|
||||
use middle::trans::meth;
|
||||
use middle::trans::monomorphize;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
use util::common::indenter;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
use syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str};
|
||||
use syntax::visit;
|
||||
|
||||
|
@ -13,8 +13,7 @@ use core::prelude::*;
|
||||
use back::abi;
|
||||
use back::link::{mangle_internal_name_by_path_and_seq};
|
||||
use back::link::{mangle_internal_name_by_path};
|
||||
use lib::llvm::llvm;
|
||||
use lib::llvm::{ValueRef, TypeRef};
|
||||
use lib::llvm::{llvm, ValueRef, TypeRef};
|
||||
use middle::moves;
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
@ -25,6 +24,7 @@ use middle::trans::expr;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::machine;
|
||||
use middle::trans::type_of::*;
|
||||
use middle::ty;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::libc::c_uint;
|
||||
@ -33,6 +33,7 @@ use syntax::ast;
|
||||
use syntax::ast_map::{path, path_mod, path_name};
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::span;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::print::pprust::expr_to_str;
|
||||
|
||||
// ___Good to know (tm)__________________________________________________
|
||||
@ -185,7 +186,7 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
|
||||
}
|
||||
ast::BorrowedSigil => {
|
||||
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
|
||||
let llbox = base::alloc_ty(bcx, cbox_ty);
|
||||
let llbox = alloc_ty(bcx, cbox_ty);
|
||||
nuke_ref_count(bcx, llbox);
|
||||
rslt(bcx, llbox)
|
||||
}
|
||||
@ -342,7 +343,7 @@ pub fn load_environment(fcx: fn_ctxt,
|
||||
let bcx = raw_block(fcx, false, llloadenv);
|
||||
|
||||
// Load a pointer to the closure data, skipping over the box header:
|
||||
let llcdata = base::opaque_box_body(bcx, cdata_ty, fcx.llenv);
|
||||
let llcdata = opaque_box_body(bcx, cdata_ty, fcx.llenv);
|
||||
|
||||
// Populate the upvars from the environment.
|
||||
let mut i = 0u;
|
||||
|
@ -157,7 +157,7 @@ pub fn BuilderRef_res(B: BuilderRef) -> BuilderRef_res {
|
||||
}
|
||||
}
|
||||
|
||||
type ExternMap = HashMap<@str, ValueRef>;
|
||||
pub type ExternMap = HashMap<@str, ValueRef>;
|
||||
|
||||
// Crate context. Every crate we compile has one of these.
|
||||
pub struct CrateContext {
|
||||
|
@ -10,14 +10,18 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib::llvm::{llvm, ValueRef, True, TypeRef, False};
|
||||
use middle::const_eval;
|
||||
use middle::trans::base;
|
||||
use middle::trans::base::get_insn_ctxt;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::consts;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::machine;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
|
||||
use core::libc::c_uint;
|
||||
use syntax::{ast, ast_util, codemap, ast_map};
|
||||
|
||||
pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit)
|
||||
|
@ -10,13 +10,28 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib::llvm::ValueRef;
|
||||
use back::link;
|
||||
use lib;
|
||||
use lib::llvm::*;
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::callee;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::datum::*;
|
||||
use middle::trans::debuginfo;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::type_of::*;
|
||||
use middle::ty;
|
||||
use util::common::indenter;
|
||||
use util::ppaux;
|
||||
|
||||
use core::str;
|
||||
use syntax::ast;
|
||||
use syntax::ast::ident;
|
||||
use syntax::ast_map::path_mod;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::span;
|
||||
use syntax::print::pprust::expr_to_str;
|
||||
|
||||
pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
|
||||
let _icx = bcx.insn_ctxt("trans_block");
|
||||
|
@ -87,21 +87,29 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib;
|
||||
use lib::llvm::ValueRef;
|
||||
use middle::borrowck::{RootInfo, root_map_key};
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::callee;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::common;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::tvec;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::cmp;
|
||||
use core::option;
|
||||
use core::to_bytes;
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::special_idents;
|
||||
|
||||
#[deriving_eq]
|
||||
@ -326,7 +334,7 @@ pub impl Datum {
|
||||
Store(bcx, self.val, dst);
|
||||
}
|
||||
ByRef => {
|
||||
base::memcpy_ty(bcx, dst, self.val, self.ty);
|
||||
memcpy_ty(bcx, dst, self.val, self.ty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,7 +362,7 @@ pub impl Datum {
|
||||
|
||||
match self.mode {
|
||||
ByRef => {
|
||||
base::memcpy_ty(bcx, dst, self.val, self.ty);
|
||||
memcpy_ty(bcx, dst, self.val, self.ty);
|
||||
}
|
||||
ByValue => {
|
||||
Store(bcx, self.val, dst);
|
||||
@ -540,7 +548,7 @@ pub impl Datum {
|
||||
|
||||
let scratch = scratch_datum(bcx, self.ty, true);
|
||||
self.copy_to_datum(bcx, INIT, scratch);
|
||||
base::add_root_cleanup(bcx, root_info, scratch.val, scratch.ty);
|
||||
add_root_cleanup(bcx, root_info, scratch.val, scratch.ty);
|
||||
|
||||
// If we need to freeze the box, do that now.
|
||||
if root_info.freezes {
|
||||
|
@ -121,10 +121,15 @@ lvalues are *never* stored by value.
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib::llvm::ValueRef;
|
||||
use back::abi;
|
||||
use lib;
|
||||
use lib::llvm::{ValueRef, TypeRef, llvm, True};
|
||||
use middle::borrowck::root_map_key;
|
||||
use middle::resolve;
|
||||
use middle::trans::_match;
|
||||
use middle::trans::base;
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
|
||||
use middle::trans::callee;
|
||||
use middle::trans::closure;
|
||||
@ -132,16 +137,21 @@ use middle::trans::common::*;
|
||||
use middle::trans::consts;
|
||||
use middle::trans::controlflow;
|
||||
use middle::trans::datum::*;
|
||||
use middle::trans::debuginfo;
|
||||
use middle::trans::machine;
|
||||
use middle::trans::meth;
|
||||
use middle::trans::tvec;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use middle::ty::struct_mutable_fields;
|
||||
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn};
|
||||
use util::common::indenter;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::print::pprust::{expr_to_str};
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use syntax::codemap::spanned;
|
||||
|
||||
// Destinations
|
||||
@ -1128,7 +1138,7 @@ fn trans_rec_or_struct(bcx: block,
|
||||
let fields = ty::struct_mutable_fields(
|
||||
tcx, variant_id, substs);
|
||||
let field_lltys = do fields.map |field| {
|
||||
type_of(bcx.ccx(),
|
||||
type_of::type_of(bcx.ccx(),
|
||||
ty::subst_tps(
|
||||
tcx, substs.tps, None, field.mt.ty))
|
||||
};
|
||||
|
@ -11,6 +11,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use back::{link, abi};
|
||||
use driver::session;
|
||||
use driver::session::arch_x86_64;
|
||||
use driver::session::arch_arm;
|
||||
use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg};
|
||||
@ -27,11 +28,13 @@ use middle::trans::callee::*;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::datum::*;
|
||||
use middle::trans::expr::{Dest, Ignore};
|
||||
use middle::trans::machine::llsize_of;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::machine;
|
||||
use middle::trans::shape;
|
||||
use middle::trans::type_of::*;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use middle::ty::{FnSig, arg};
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
|
@ -14,19 +14,32 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib::llvm::{ValueRef, TypeRef};
|
||||
use back::abi;
|
||||
use back::link::*;
|
||||
use driver::session;
|
||||
use lib;
|
||||
use lib::llvm::{llvm, ValueRef, TypeRef, True};
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::callee;
|
||||
use middle::trans::closure;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::machine::*;
|
||||
use middle::trans::reflect;
|
||||
use middle::trans::tvec;
|
||||
use middle::trans::type_of::type_of;
|
||||
use middle::trans::type_of::{type_of, type_of_glue_fn};
|
||||
use middle::trans::uniq;
|
||||
use middle::ty;
|
||||
use util::ppaux;
|
||||
use util::ppaux::ty_to_short_str;
|
||||
|
||||
use core::io;
|
||||
use core::libc::c_uint;
|
||||
use core::str;
|
||||
use std::time;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::special_idents;
|
||||
|
||||
pub fn trans_free(cx: block, v: ValueRef) -> block {
|
||||
let _icx = cx.insn_ctxt("trans_free");
|
||||
@ -218,7 +231,7 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext,
|
||||
let _icx = ccx.insn_ctxt("lazily_emit_simplified_tydesc_glue");
|
||||
let simpl = simplified_glue_type(ccx.tcx, field, ti.ty);
|
||||
if simpl != ti.ty {
|
||||
let simpl_ti = base::get_tydesc(ccx, simpl);
|
||||
let simpl_ti = get_tydesc(ccx, simpl);
|
||||
lazily_emit_tydesc_glue(ccx, field, simpl_ti);
|
||||
if field == abi::tydesc_field_take_glue {
|
||||
ti.take_glue =
|
||||
@ -661,7 +674,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
|
||||
if ccx.sess.count_type_sizes() {
|
||||
io::println(fmt!("%u\t%s",
|
||||
llsize_of_real(ccx, llty),
|
||||
ty_to_str(ccx.tcx, t)));
|
||||
ppaux::ty_to_str(ccx.tcx, t)));
|
||||
}
|
||||
|
||||
let llsize = llsize_of(ccx, llty);
|
||||
@ -675,7 +688,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
|
||||
};
|
||||
// XXX: Bad copy.
|
||||
note_unique_llvm_symbol(ccx, copy name);
|
||||
log(debug, fmt!("+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name));
|
||||
debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), name);
|
||||
let gvar = str::as_c_str(name, |buf| {
|
||||
unsafe {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
|
||||
@ -709,7 +722,7 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
|
||||
} else {
|
||||
fn_nm = mangle_internal_name_by_seq(ccx, (~"glue_" + name));
|
||||
}
|
||||
debug!("%s is for type %s", fn_nm, ty_to_str(ccx.tcx, t));
|
||||
debug!("%s is for type %s", fn_nm, ppaux::ty_to_str(ccx.tcx, t));
|
||||
// XXX: Bad copy.
|
||||
note_unique_llvm_symbol(ccx, copy fn_nm);
|
||||
let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use metadata::csearch;
|
||||
use middle::astencode;
|
||||
use middle::trans::base::{get_insn_ctxt};
|
||||
use middle::trans::base::{impl_owned_self, impl_self, no_self};
|
||||
@ -18,6 +19,8 @@ use middle::trans::common::*;
|
||||
use middle::trans::common;
|
||||
use middle::trans::inline;
|
||||
use middle::trans::monomorphize;
|
||||
use middle::ty;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::vec;
|
||||
use syntax::ast;
|
||||
|
@ -11,6 +11,9 @@
|
||||
// Information concerning the machine representation of various types.
|
||||
|
||||
|
||||
use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef, BuilderRef};
|
||||
use lib::llvm::{True, False, Bool};
|
||||
use lib::llvm::llvm;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
@ -122,7 +125,7 @@ pub fn llalign_of_min(cx: @CrateContext, t: TypeRef) -> uint {
|
||||
pub fn llalign_of(cx: @CrateContext, t: TypeRef) -> ValueRef {
|
||||
unsafe {
|
||||
return llvm::LLVMConstIntCast(
|
||||
lib::llvm::llvm::LLVMAlignOf(t), cx.int_type, False);
|
||||
llvm::LLVMAlignOf(t), cx.int_type, False);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,14 +28,16 @@ use middle::trans::glue;
|
||||
use middle::trans::inline;
|
||||
use middle::trans::monomorphize;
|
||||
use middle::trans::type_of::*;
|
||||
use middle::ty;
|
||||
use middle::ty::arg;
|
||||
use middle::typeck;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::{ty_to_str, tys_to_str};
|
||||
|
||||
use core::libc::c_uint;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast_map::{path, path_mod, path_name, node_id_to_str};
|
||||
use syntax::ast_util::local_def;
|
||||
use syntax::ast_util;
|
||||
use syntax::print::pprust::expr_to_str;
|
||||
use syntax::{ast, ast_map};
|
||||
|
||||
@ -351,7 +353,7 @@ pub fn trans_static_method_callee(bcx: block,
|
||||
|
||||
pub fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
|
||||
-> Option<ast::def_id> {
|
||||
ms.find(|m| m.ident == name).map(|m| local_def(m.id))
|
||||
ms.find(|m| m.ident == name).map(|m| ast_util::local_def(m.id))
|
||||
}
|
||||
|
||||
pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
|
||||
@ -725,7 +727,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
|
||||
|
||||
// Load the function from the vtable and cast it to the expected type.
|
||||
debug!("(translating trait callee) loading method");
|
||||
let llcallee_ty = type_of::type_of_fn_from_ty(ccx, callee_ty);
|
||||
let llcallee_ty = type_of_fn_from_ty(ccx, callee_ty);
|
||||
let mptr = Load(bcx, GEPi(bcx, llvtable, [0u, n_method]));
|
||||
let mptr = PointerCast(bcx, mptr, T_ptr(llcallee_ty));
|
||||
|
||||
@ -885,8 +887,7 @@ pub fn trans_trait_cast(bcx: block,
|
||||
// Just store the pointer into the pair.
|
||||
llboxdest = PointerCast(bcx,
|
||||
llboxdest,
|
||||
T_ptr(type_of::type_of(bcx.ccx(),
|
||||
v_ty)));
|
||||
T_ptr(type_of(bcx.ccx(), v_ty)));
|
||||
bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
|
||||
}
|
||||
}
|
||||
@ -896,7 +897,7 @@ pub fn trans_trait_cast(bcx: block,
|
||||
let mut llvaldest = GEPi(bcx, lldest, [0, 1]);
|
||||
llvaldest = PointerCast(bcx,
|
||||
llvaldest,
|
||||
T_ptr(type_of::type_of(bcx.ccx(), v_ty)));
|
||||
T_ptr(type_of(bcx.ccx(), v_ty)));
|
||||
bcx = expr::trans_into(bcx, val, SaveIn(llvaldest));
|
||||
|
||||
// Get the type descriptor of the wrapped value and store it into
|
||||
|
@ -11,6 +11,8 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use back::link::mangle_exported_name;
|
||||
use driver::session;
|
||||
use lib::llvm::ValueRef;
|
||||
use middle::trans::base::{get_insn_ctxt};
|
||||
use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint};
|
||||
use middle::trans::base::{trans_enum_variant, trans_struct_dtor};
|
||||
@ -26,12 +28,15 @@ use middle::trans::shape;
|
||||
use middle::trans::type_of::type_of_fn_from_ty;
|
||||
use middle::trans::type_of;
|
||||
use middle::trans::type_use;
|
||||
use middle::ty;
|
||||
use middle::ty::{FnSig};
|
||||
use middle::typeck;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::option;
|
||||
use core::vec;
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
use syntax::ast_map::{path, path_mod, path_name};
|
||||
use syntax::ast_util::local_def;
|
||||
use syntax::parse::token::special_idents;
|
||||
|
@ -21,11 +21,13 @@ use middle::resolve;
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
|
||||
use core::vec;
|
||||
use core::prelude::*;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast;
|
||||
use syntax::ast::*;
|
||||
use syntax::ast_util::def_id_of_def;
|
||||
use syntax::attr;
|
||||
use syntax::codemap;
|
||||
use syntax::print::pprust::expr_to_str;
|
||||
use syntax::{visit, ast_util, ast_map};
|
||||
|
||||
|
@ -22,8 +22,11 @@ use middle::trans::glue;
|
||||
use middle::trans::machine;
|
||||
use middle::trans::meth;
|
||||
use middle::trans::type_of::*;
|
||||
use middle::ty;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::option::None;
|
||||
use core::vec;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast::def_id;
|
||||
use syntax::ast;
|
||||
@ -60,7 +63,7 @@ pub impl Reflector {
|
||||
}
|
||||
|
||||
fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] {
|
||||
let tr = type_of::type_of(self.bcx.ccx(), t);
|
||||
let tr = type_of(self.bcx.ccx(), t);
|
||||
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
|
||||
let a = machine::llalign_of_min(self.bcx.ccx(), tr);
|
||||
return ~[self.c_uint(s),
|
||||
@ -351,7 +354,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block,
|
||||
let final = sub_block(bcx, ~"final");
|
||||
assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc);
|
||||
let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc);
|
||||
let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty);
|
||||
let tydesc_ty = type_of(bcx.ccx(), tydesc_ty);
|
||||
let mut r = Reflector {
|
||||
visitor_val: visitor_val,
|
||||
visitor_methods: ty::trait_methods(bcx.tcx(), visitor_trait_id),
|
||||
|
@ -25,6 +25,7 @@ use util::ppaux::ty_to_str;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::option::is_some;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast;
|
||||
|
@ -10,20 +10,27 @@
|
||||
|
||||
|
||||
use back::abi;
|
||||
use lib::llvm::{ValueRef, TypeRef};
|
||||
use lib;
|
||||
use lib::llvm::{llvm, ValueRef, TypeRef};
|
||||
use middle::trans::base;
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::*;
|
||||
use middle::trans::callee;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::datum::*;
|
||||
use middle::trans::expr::{Dest, Ignore, SaveIn};
|
||||
use middle::trans::expr;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::shape::{llsize_of, nonzero_llsize_of};
|
||||
use middle::trans::machine::{llsize_of, nonzero_llsize_of};
|
||||
use middle::trans::type_of;
|
||||
use middle::ty;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use syntax::codemap::span;
|
||||
use syntax::print::pprust::{expr_to_str};
|
||||
|
||||
@ -81,7 +88,7 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t,
|
||||
let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty);
|
||||
let vecsize = Add(bcx, alloc, llsize_of(ccx, ccx.opaque_vec_type));
|
||||
|
||||
let MallocResult {bcx, box: bx, body} =
|
||||
let base::MallocResult {bcx, box: bx, body} =
|
||||
base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize);
|
||||
Store(bcx, fill, GEPi(bcx, body, [0u, abi::vec_elt_fill]));
|
||||
Store(bcx, alloc, GEPi(bcx, body, [0u, abi::vec_elt_alloc]));
|
||||
@ -91,7 +98,7 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t,
|
||||
|
||||
pub fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
|
||||
fill: ValueRef, alloc: ValueRef) -> Result {
|
||||
alloc_raw(bcx, unit_ty, fill, alloc, heap_for_unique(bcx, unit_ty))
|
||||
alloc_raw(bcx, unit_ty, fill, alloc, base::heap_for_unique(bcx, unit_ty))
|
||||
}
|
||||
|
||||
pub fn alloc_vec(bcx: block,
|
||||
@ -305,13 +312,13 @@ pub fn trans_uniq_or_managed_vstore(bcx: block,
|
||||
let llptrval = PointerCast(bcx, llptrval, T_ptr(T_i8()));
|
||||
let llsizeval = C_uint(bcx.ccx(), s.len());
|
||||
let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq);
|
||||
let lldestval = datum::scratch_datum(bcx, typ, false);
|
||||
let lldestval = scratch_datum(bcx, typ, false);
|
||||
let bcx = callee::trans_lang_call(
|
||||
bcx,
|
||||
bcx.tcx().lang_items.strdup_uniq_fn(),
|
||||
~[ llptrval, llsizeval ],
|
||||
expr::SaveIn(lldestval.to_ref_llval(bcx)));
|
||||
return datum::DatumBlock {
|
||||
return DatumBlock {
|
||||
bcx: bcx,
|
||||
datum: lldestval
|
||||
};
|
||||
@ -508,8 +515,8 @@ pub fn get_base_and_len(bcx: block,
|
||||
(base, len)
|
||||
}
|
||||
ty::vstore_uniq | ty::vstore_box => {
|
||||
let body = tvec::get_bodyptr(bcx, llval);
|
||||
(tvec::get_dataptr(bcx, body), tvec::get_fill(bcx, body))
|
||||
let body = get_bodyptr(bcx, llval);
|
||||
(get_dataptr(bcx, body), get_fill(bcx, body))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,16 @@
|
||||
|
||||
use lib::llvm::llvm;
|
||||
use lib::llvm::{TypeRef};
|
||||
use middle::trans::base;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::common;
|
||||
use middle::trans::expr;
|
||||
use middle::trans::machine;
|
||||
use middle::ty;
|
||||
use util::ppaux;
|
||||
|
||||
use core::option::None;
|
||||
use core::vec;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast;
|
||||
|
||||
@ -387,7 +391,7 @@ pub fn type_of_dtor(ccx: @CrateContext, self_ty: ty::t) -> TypeRef {
|
||||
pub fn type_of_rooted(ccx: @CrateContext, t: ty::t) -> TypeRef {
|
||||
let addrspace = base::get_tydesc(ccx, t).addrspace;
|
||||
debug!("type_of_rooted %s in addrspace %u",
|
||||
ty_to_str(ccx.tcx, t), addrspace as uint);
|
||||
ppaux::ty_to_str(ccx.tcx, t), addrspace as uint);
|
||||
return T_root(type_of(ccx, t), addrspace);
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,17 @@ use metadata::csearch;
|
||||
use middle::freevars;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::inline;
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
|
||||
use core::option;
|
||||
use core::option::{Some, None, Option};
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
use std::list::{List, Cons, Nil};
|
||||
use std::list;
|
||||
use std::oldmap::HashMap;
|
||||
use syntax::ast;
|
||||
use syntax::ast::*;
|
||||
use syntax::ast_map;
|
||||
use syntax::ast_util;
|
||||
|
@ -17,6 +17,7 @@ use middle::trans::common::*;
|
||||
use middle::trans::datum::immediate_rvalue;
|
||||
use middle::trans::datum;
|
||||
use middle::trans::glue;
|
||||
use middle::ty;
|
||||
|
||||
use syntax::ast;
|
||||
|
||||
|
@ -316,7 +316,7 @@ pub fn super_modes<C:Combine>(
|
||||
ty::unify_mode(tcx, expected_found(self, a, b))
|
||||
}
|
||||
|
||||
fn super_args<C:Combine>(
|
||||
pub fn super_args<C:Combine>(
|
||||
self: &C, a: ty::arg, b: ty::arg)
|
||||
-> cres<ty::arg> {
|
||||
|
||||
|
@ -18,9 +18,14 @@ use middle::typeck::infer::lattice::*;
|
||||
use middle::typeck::infer::lub::Lub;
|
||||
use middle::typeck::infer::sub::Sub;
|
||||
use middle::typeck::infer::to_str::InferStr;
|
||||
use middle::typeck::infer::{cres, InferCtxt};
|
||||
use middle::typeck::isr_alist;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl};
|
||||
use syntax::ast::{noreturn, pure_fn, ret_style, return_val, unsafe_fn};
|
||||
use syntax::ast::{Onceness, purity};
|
||||
use syntax::codemap::span;
|
||||
use util::common::{indent, indenter};
|
||||
use util::ppaux::mt_to_str;
|
||||
|
||||
use std::list;
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use middle::ty::{RegionVid, TyVar};
|
||||
use middle::ty::{RegionVid, TyVar, Vid};
|
||||
use middle::ty;
|
||||
use middle::typeck::isr_alist;
|
||||
use middle::typeck::infer::*;
|
||||
@ -46,6 +46,7 @@ use middle::typeck::infer::sub::Sub;
|
||||
use middle::typeck::infer::lub::Lub;
|
||||
use middle::typeck::infer::glb::Glb;
|
||||
use middle::typeck::infer::to_str::InferStr;
|
||||
use util::common::indenter;
|
||||
|
||||
use std::list;
|
||||
|
||||
|
@ -17,12 +17,17 @@ use middle::typeck::infer::glb::Glb;
|
||||
use middle::typeck::infer::lattice::*;
|
||||
use middle::typeck::infer::sub::Sub;
|
||||
use middle::typeck::infer::to_str::InferStr;
|
||||
use middle::typeck::infer::{cres, InferCtxt};
|
||||
use middle::typeck::isr_alist;
|
||||
use util::common::indent;
|
||||
use util::ppaux::mt_to_str;
|
||||
|
||||
use std::list;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Many, Once, extern_fn, m_const, impure_fn, noreturn};
|
||||
use syntax::ast::{pure_fn, ret_style, return_val, unsafe_fn};
|
||||
use syntax::ast::{Onceness, purity};
|
||||
use syntax::codemap::span;
|
||||
|
||||
pub enum Lub = CombineFields; // least-upper-bound: common supertype
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use middle::ty;
|
||||
use middle::ty::TyVar;
|
||||
use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig;
|
||||
use middle::typeck::infer::combine::*;
|
||||
use middle::typeck::infer::cres;
|
||||
@ -19,11 +20,14 @@ use middle::typeck::infer::InferCtxt;
|
||||
use middle::typeck::infer::lub::Lub;
|
||||
use middle::typeck::infer::to_str::InferStr;
|
||||
use middle::typeck::infer::unify::*;
|
||||
use util::common::{indent, indenter};
|
||||
use util::ppaux::bound_region_to_str;
|
||||
|
||||
use std::list::Nil;
|
||||
use std::list;
|
||||
use syntax::ast::{m_const, purity, ret_style};
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Onceness, m_const, purity, ret_style};
|
||||
use syntax::codemap::span;
|
||||
|
||||
|
||||
pub enum Sub = CombineFields; // "subtype", "subregion" etc
|
||||
|
@ -497,6 +497,7 @@ mod tests {
|
||||
use arc::*;
|
||||
use arc;
|
||||
|
||||
use core::cell::Cell;
|
||||
use core::option::{Some, None};
|
||||
use core::option;
|
||||
use core::pipes;
|
||||
|
@ -116,6 +116,9 @@ fn get<T>(elts: &r/[Option<T>], i: uint) -> &r/T {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use core::cmp::Eq;
|
||||
use core::kinds::{Durable, Copy};
|
||||
use core::prelude::debug;
|
||||
|
||||
#[test]
|
||||
fn test_simple() {
|
||||
|
@ -636,6 +636,7 @@ mod test {
|
||||
use DefaultEncoder = json::Encoder;
|
||||
use DefaultDecoder = json::Decoder;
|
||||
|
||||
use flatpipes::{Flattener, Unflattener};
|
||||
use flatpipes::flatteners::*;
|
||||
use flatpipes::bytepipes::*;
|
||||
use flatpipes::pod;
|
||||
@ -647,7 +648,7 @@ mod test {
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::int;
|
||||
use core::io::BytesReader;
|
||||
use core::io::{BytesReader, BytesWriter};
|
||||
use core::io;
|
||||
use core::prelude::*;
|
||||
use core::result;
|
||||
|
@ -150,7 +150,7 @@ pub mod test {
|
||||
|
||||
use future::*;
|
||||
|
||||
use core::comm::oneshot;
|
||||
use core::comm::{oneshot, send_one};
|
||||
use core::task;
|
||||
|
||||
#[test]
|
||||
|
@ -445,7 +445,7 @@ pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
|
||||
}
|
||||
|
||||
#[deriving_eq]
|
||||
enum FailType {
|
||||
pub enum FailType {
|
||||
ArgumentMissing_,
|
||||
UnrecognizedOption_,
|
||||
OptionMissing_,
|
||||
|
@ -1208,6 +1208,7 @@ mod tests {
|
||||
use core::prelude::*;
|
||||
|
||||
use json::*;
|
||||
use serialize;
|
||||
|
||||
use core::result;
|
||||
use core::hashmap::linear::LinearMap;
|
||||
|
@ -730,6 +730,91 @@ impl to_bytes::IterBytes for Url {
|
||||
}
|
||||
}
|
||||
|
||||
// Put a few tests outside of the 'test' module so they can test the internal
|
||||
// functions and those functions don't need 'pub'
|
||||
|
||||
#[test]
|
||||
fn test_split_char_first() {
|
||||
let (u,v) = split_char_first(~"hello, sweet world", ',');
|
||||
assert u == ~"hello";
|
||||
assert v == ~" sweet world";
|
||||
|
||||
let (u,v) = split_char_first(~"hello sweet world", ',');
|
||||
assert u == ~"hello sweet world";
|
||||
assert v == ~"";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_authority() {
|
||||
let (u, h, p, r) = get_authority(
|
||||
"//user:pass@rust-lang.org/something").unwrap();
|
||||
assert u == Some(UserInfo::new(~"user", Some(~"pass")));
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p.is_none();
|
||||
assert r == ~"/something";
|
||||
|
||||
let (u, h, p, r) = get_authority(
|
||||
"//rust-lang.org:8000?something").unwrap();
|
||||
assert u.is_none();
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p == Some(~"8000");
|
||||
assert r == ~"?something";
|
||||
|
||||
let (u, h, p, r) = get_authority(
|
||||
"//rust-lang.org#blah").unwrap();
|
||||
assert u.is_none();
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p.is_none();
|
||||
assert r == ~"#blah";
|
||||
|
||||
// ipv6 tests
|
||||
let (_, h, _, _) = get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap();
|
||||
assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334";
|
||||
|
||||
let (_, h, p, _) = get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap();
|
||||
assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334";
|
||||
assert p == Some(~"8000");
|
||||
|
||||
let (u, h, p, _) = get_authority(
|
||||
"//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah"
|
||||
).unwrap();
|
||||
assert u == Some(UserInfo::new(~"us", Some(~"p")));
|
||||
assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334";
|
||||
assert p == Some(~"8000");
|
||||
|
||||
// invalid authorities;
|
||||
assert get_authority("//user:pass@rust-lang:something").is_err();
|
||||
assert get_authority("//user@rust-lang:something:/path").is_err();
|
||||
assert get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err();
|
||||
assert get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err();
|
||||
|
||||
// these parse as empty, because they don't start with '//'
|
||||
let (_, h, _, _) = get_authority(~"user:pass@rust-lang").unwrap();
|
||||
assert h == ~"";
|
||||
let (_, h, _, _) = get_authority(~"rust-lang.org").unwrap();
|
||||
assert h == ~"";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_path() {
|
||||
let (p, r) = get_path("/something+%20orother", true).unwrap();
|
||||
assert p == ~"/something+ orother";
|
||||
assert r == ~"";
|
||||
let (p, r) = get_path("test@email.com#fragment", false).unwrap();
|
||||
assert p == ~"test@email.com";
|
||||
assert r == ~"#fragment";
|
||||
let (p, r) = get_path(~"/gen/:addr=?q=v", false).unwrap();
|
||||
assert p == ~"/gen/:addr=";
|
||||
assert r == ~"?q=v";
|
||||
|
||||
//failure cases
|
||||
assert get_path(~"something?q", true).is_err();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::prelude::*;
|
||||
@ -737,91 +822,10 @@ mod tests {
|
||||
use net_url::*;
|
||||
use net_url::UserInfo;
|
||||
|
||||
use core::hashmap::linear::LinearMap;
|
||||
use core::result;
|
||||
use core::str;
|
||||
|
||||
#[test]
|
||||
pub fn test_split_char_first() {
|
||||
let (u,v) = split_char_first(~"hello, sweet world", ',');
|
||||
assert u == ~"hello";
|
||||
assert v == ~" sweet world";
|
||||
|
||||
let (u,v) = split_char_first(~"hello sweet world", ',');
|
||||
assert u == ~"hello sweet world";
|
||||
assert v == ~"";
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_get_authority() {
|
||||
let (u, h, p, r) = get_authority(
|
||||
"//user:pass@rust-lang.org/something").unwrap();
|
||||
assert u == Some(UserInfo::new(~"user", Some(~"pass")));
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p.is_none();
|
||||
assert r == ~"/something";
|
||||
|
||||
let (u, h, p, r) = get_authority(
|
||||
"//rust-lang.org:8000?something").unwrap();
|
||||
assert u.is_none();
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p == Some(~"8000");
|
||||
assert r == ~"?something";
|
||||
|
||||
let (u, h, p, r) = get_authority(
|
||||
"//rust-lang.org#blah").unwrap();
|
||||
assert u.is_none();
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p.is_none();
|
||||
assert r == ~"#blah";
|
||||
|
||||
// ipv6 tests
|
||||
let (_, h, _, _) = get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334#blah").unwrap();
|
||||
assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334";
|
||||
|
||||
let (_, h, p, _) = get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah").unwrap();
|
||||
assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334";
|
||||
assert p == Some(~"8000");
|
||||
|
||||
let (u, h, p, _) = get_authority(
|
||||
"//us:p@2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000#blah"
|
||||
).unwrap();
|
||||
assert u == Some(UserInfo::new(~"us", Some(~"p")));
|
||||
assert h == ~"2001:0db8:85a3:0042:0000:8a2e:0370:7334";
|
||||
assert p == Some(~"8000");
|
||||
|
||||
// invalid authorities;
|
||||
assert get_authority("//user:pass@rust-lang:something").is_err();
|
||||
assert get_authority("//user@rust-lang:something:/path").is_err();
|
||||
assert get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334:800a").is_err();
|
||||
assert get_authority(
|
||||
"//2001:0db8:85a3:0042:0000:8a2e:0370:7334:8000:00").is_err();
|
||||
|
||||
// these parse as empty, because they don't start with '//'
|
||||
let (_, h, _, _) = get_authority(~"user:pass@rust-lang").unwrap();
|
||||
assert h == ~"";
|
||||
let (_, h, _, _) = get_authority(~"rust-lang.org").unwrap();
|
||||
assert h == ~"";
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_get_path() {
|
||||
let (p, r) = get_path("/something+%20orother", true).unwrap();
|
||||
assert p == ~"/something+ orother";
|
||||
assert r == ~"";
|
||||
let (p, r) = get_path("test@email.com#fragment", false).unwrap();
|
||||
assert p == ~"test@email.com";
|
||||
assert r == ~"#fragment";
|
||||
let (p, r) = get_path(~"/gen/:addr=?q=v", false).unwrap();
|
||||
assert p == ~"/gen/:addr=";
|
||||
assert r == ~"?q=v";
|
||||
|
||||
//failure cases
|
||||
assert get_path(~"something?q", true).is_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_url_parse() {
|
||||
let url = ~"http://user:pass@rust-lang.org/doc?s=v#something";
|
||||
|
@ -399,7 +399,7 @@ pub impl &Semaphore {
|
||||
* A task which fails while holding a mutex will unlock the mutex as it
|
||||
* unwinds.
|
||||
*/
|
||||
struct Mutex { priv sem: Sem<~[Waitqueue]> }
|
||||
pub struct Mutex { priv sem: Sem<~[Waitqueue]> }
|
||||
|
||||
/// Create a new mutex, with one associated condvar.
|
||||
pub fn Mutex() -> Mutex { mutex_with_condvars(1) }
|
||||
@ -447,7 +447,7 @@ struct RWlockInner {
|
||||
* A task which fails while holding an rwlock will unlock the rwlock as it
|
||||
* unwinds.
|
||||
*/
|
||||
struct RWlock {
|
||||
pub struct RWlock {
|
||||
priv order_lock: Semaphore,
|
||||
priv access_lock: Sem<~[Waitqueue]>,
|
||||
priv state: Exclusive<RWlockInner>
|
||||
@ -712,6 +712,7 @@ mod tests {
|
||||
use sync::*;
|
||||
|
||||
use core::cast;
|
||||
use core::cell::Cell;
|
||||
use core::option;
|
||||
use core::pipes;
|
||||
use core::ptr;
|
||||
|
@ -892,6 +892,7 @@ mod tests {
|
||||
use core::float;
|
||||
use core::os;
|
||||
use core::result;
|
||||
use core::result::{Err, Ok};
|
||||
use core::str;
|
||||
use core::u64;
|
||||
use core::uint;
|
||||
@ -902,15 +903,13 @@ mod tests {
|
||||
const some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
|
||||
|
||||
let tv1 = get_time();
|
||||
log(debug, ~"tv1=" + uint::to_str(tv1.sec as uint) + ~" sec + "
|
||||
+ uint::to_str(tv1.nsec as uint) + ~" nsec");
|
||||
debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint);
|
||||
|
||||
assert tv1.sec > some_recent_date;
|
||||
assert tv1.nsec < 1000000000i32;
|
||||
|
||||
let tv2 = get_time();
|
||||
log(debug, ~"tv2=" + uint::to_str(tv2.sec as uint) + ~" sec + "
|
||||
+ uint::to_str(tv2.nsec as uint) + ~" nsec");
|
||||
debug!("tv2=%? sec + %? nsec", tv2.sec as uint, tv2.nsec as uint);
|
||||
|
||||
assert tv2.sec >= tv1.sec;
|
||||
assert tv2.sec < some_future_date;
|
||||
@ -924,16 +923,16 @@ mod tests {
|
||||
let s0 = precise_time_s();
|
||||
let ns1 = precise_time_ns();
|
||||
|
||||
log(debug, ~"s0=" + float::to_str_digits(s0, 9u) + ~" sec");
|
||||
debug!("s0=%s sec", float::to_str_digits(s0, 9u));
|
||||
assert s0 > 0.;
|
||||
let ns0 = (s0 * 1000000000.) as u64;
|
||||
log(debug, ~"ns0=" + u64::to_str(ns0) + ~" ns");
|
||||
debug!("ns0=%? ns", ns0);
|
||||
|
||||
log(debug, ~"ns1=" + u64::to_str(ns1) + ~" ns");
|
||||
debug!("ns1=%? ns", ns0);
|
||||
assert ns1 >= ns0;
|
||||
|
||||
let ns2 = precise_time_ns();
|
||||
log(debug, ~"ns2=" + u64::to_str(ns2) + ~" ns");
|
||||
debug!("ns2=%? ns", ns0);
|
||||
assert ns2 >= ns1;
|
||||
}
|
||||
|
||||
|
@ -207,8 +207,8 @@ pub struct TreeMapIterator<K, V> {
|
||||
/// Advance the iterator to the next node (in order) and return a
|
||||
/// tuple with a reference to the key and value. If there are no
|
||||
/// more nodes, return `None`.
|
||||
fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>)
|
||||
-> Option<(&r/K, &r/V)> {
|
||||
pub fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>)
|
||||
-> Option<(&r/K, &r/V)> {
|
||||
while !iter.stack.is_empty() || iter.node.is_some() {
|
||||
match *iter.node {
|
||||
Some(ref x) => {
|
||||
@ -226,7 +226,7 @@ fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>)
|
||||
}
|
||||
|
||||
/// Advance the iterator through the map
|
||||
fn map_advance<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>,
|
||||
pub fn map_advance<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>,
|
||||
f: fn((&r/K, &r/V)) -> bool) {
|
||||
loop {
|
||||
match map_next(iter) {
|
||||
@ -683,7 +683,11 @@ fn remove<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
|
||||
#[cfg(test)]
|
||||
mod test_treemap {
|
||||
use super::*;
|
||||
use core::cmp::{Ord, Eq};
|
||||
use core::option::{Some, Option, None};
|
||||
use core::rand;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
#[test]
|
||||
fn find_empty() {
|
||||
|
@ -123,9 +123,11 @@ fn spawn_loop() -> IoTask {
|
||||
mod test {
|
||||
use core::prelude::*;
|
||||
|
||||
use get_gl = get;
|
||||
use uv::iotask;
|
||||
use uv::ll;
|
||||
use uv_global_loop::*;
|
||||
use uv_iotask::IoTask;
|
||||
|
||||
use core::iter;
|
||||
use core::libc;
|
||||
|
@ -202,124 +202,120 @@ extern fn tear_down_close_cb(handle: *ll::uv_async_t) {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use core::prelude::*;
|
||||
|
||||
use uv::ll;
|
||||
use uv_iotask::*;
|
||||
|
||||
use core::iter;
|
||||
use core::libc;
|
||||
use core::ptr;
|
||||
use core::task;
|
||||
use core::pipes::{stream, Chan, SharedChan, Port};
|
||||
|
||||
extern fn async_close_cb(handle: *ll::uv_async_t) {
|
||||
unsafe {
|
||||
log(debug, fmt!("async_close_cb handle %?", handle));
|
||||
let exit_ch = &(*(ll::get_data_for_uv_handle(handle)
|
||||
as *AhData)).exit_ch;
|
||||
let exit_ch = exit_ch.clone();
|
||||
exit_ch.send(());
|
||||
}
|
||||
}
|
||||
extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int) {
|
||||
unsafe {
|
||||
log(debug,
|
||||
fmt!("async_handle_cb handle %? status %?",handle,status));
|
||||
ll::close(handle, async_close_cb);
|
||||
}
|
||||
}
|
||||
struct AhData {
|
||||
iotask: IoTask,
|
||||
exit_ch: SharedChan<()>
|
||||
}
|
||||
fn impl_uv_iotask_async(iotask: &IoTask) {
|
||||
unsafe {
|
||||
let async_handle = ll::async_t();
|
||||
let ah_ptr = ptr::addr_of(&async_handle);
|
||||
let (exit_po, exit_ch) = stream::<()>();
|
||||
let ah_data = AhData {
|
||||
iotask: iotask.clone(),
|
||||
exit_ch: SharedChan(exit_ch)
|
||||
};
|
||||
let ah_data_ptr: *AhData = unsafe {
|
||||
ptr::to_unsafe_ptr(&ah_data)
|
||||
};
|
||||
debug!("about to interact");
|
||||
do interact(iotask) |loop_ptr| {
|
||||
unsafe {
|
||||
debug!("interacting");
|
||||
ll::async_init(loop_ptr, ah_ptr, async_handle_cb);
|
||||
ll::set_data_for_uv_handle(
|
||||
ah_ptr, ah_data_ptr as *libc::c_void);
|
||||
ll::async_send(ah_ptr);
|
||||
}
|
||||
};
|
||||
debug!("waiting for async close");
|
||||
exit_po.recv();
|
||||
}
|
||||
}
|
||||
|
||||
// this fn documents the bear minimum neccesary to roll your own
|
||||
// high_level_loop
|
||||
unsafe fn spawn_test_loop(exit_ch: ~Chan<()>) -> IoTask {
|
||||
let (iotask_port, iotask_ch) = stream::<IoTask>();
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
debug!("about to run a test loop");
|
||||
run_loop(&iotask_ch);
|
||||
exit_ch.send(());
|
||||
};
|
||||
return iotask_port.recv();
|
||||
}
|
||||
|
||||
extern fn lifetime_handle_close(handle: *libc::c_void) {
|
||||
unsafe {
|
||||
log(debug, fmt!("lifetime_handle_close ptr %?", handle));
|
||||
}
|
||||
}
|
||||
|
||||
extern fn lifetime_async_callback(handle: *libc::c_void,
|
||||
status: libc::c_int) {
|
||||
log(debug, fmt!("lifetime_handle_close ptr %? status %?",
|
||||
handle, status));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_uv_iotask_async() {
|
||||
unsafe {
|
||||
let (exit_po, exit_ch) = stream::<()>();
|
||||
let iotask = &spawn_test_loop(~exit_ch);
|
||||
|
||||
debug!("spawned iotask");
|
||||
|
||||
// using this handle to manage the lifetime of the
|
||||
// high_level_loop, as it will exit the first time one of
|
||||
// the impl_uv_hl_async() is cleaned up with no one ref'd
|
||||
// handles on the loop (Which can happen under
|
||||
// race-condition type situations.. this ensures that the
|
||||
// loop lives until, at least, all of the
|
||||
// impl_uv_hl_async() runs have been called, at least.
|
||||
let (work_exit_po, work_exit_ch) = stream::<()>();
|
||||
let work_exit_ch = SharedChan(work_exit_ch);
|
||||
for iter::repeat(7u) {
|
||||
let iotask_clone = iotask.clone();
|
||||
let work_exit_ch_clone = work_exit_ch.clone();
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
debug!("async");
|
||||
impl_uv_iotask_async(&iotask_clone);
|
||||
debug!("done async");
|
||||
work_exit_ch_clone.send(());
|
||||
};
|
||||
};
|
||||
for iter::repeat(7u) {
|
||||
debug!("waiting");
|
||||
work_exit_po.recv();
|
||||
};
|
||||
log(debug, ~"sending teardown_loop msg..");
|
||||
exit(iotask);
|
||||
exit_po.recv();
|
||||
log(debug, ~"after recv on exit_po.. exiting..");
|
||||
}
|
||||
extern fn async_close_cb(handle: *ll::uv_async_t) {
|
||||
unsafe {
|
||||
log(debug, fmt!("async_close_cb handle %?", handle));
|
||||
let exit_ch = &(*(ll::get_data_for_uv_handle(handle)
|
||||
as *AhData)).exit_ch;
|
||||
let exit_ch = exit_ch.clone();
|
||||
exit_ch.send(());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int) {
|
||||
unsafe {
|
||||
log(debug,
|
||||
fmt!("async_handle_cb handle %? status %?",handle,status));
|
||||
ll::close(handle, async_close_cb);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
struct AhData {
|
||||
iotask: IoTask,
|
||||
exit_ch: SharedChan<()>
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn impl_uv_iotask_async(iotask: &IoTask) {
|
||||
unsafe {
|
||||
let async_handle = ll::async_t();
|
||||
let ah_ptr = ptr::addr_of(&async_handle);
|
||||
let (exit_po, exit_ch) = stream::<()>();
|
||||
let ah_data = AhData {
|
||||
iotask: iotask.clone(),
|
||||
exit_ch: SharedChan(exit_ch)
|
||||
};
|
||||
let ah_data_ptr: *AhData = unsafe {
|
||||
ptr::to_unsafe_ptr(&ah_data)
|
||||
};
|
||||
debug!("about to interact");
|
||||
do interact(iotask) |loop_ptr| {
|
||||
unsafe {
|
||||
debug!("interacting");
|
||||
ll::async_init(loop_ptr, ah_ptr, async_handle_cb);
|
||||
ll::set_data_for_uv_handle(
|
||||
ah_ptr, ah_data_ptr as *libc::c_void);
|
||||
ll::async_send(ah_ptr);
|
||||
}
|
||||
};
|
||||
debug!("waiting for async close");
|
||||
exit_po.recv();
|
||||
}
|
||||
}
|
||||
|
||||
// this fn documents the bear minimum neccesary to roll your own
|
||||
// high_level_loop
|
||||
#[cfg(test)]
|
||||
unsafe fn spawn_test_loop(exit_ch: ~Chan<()>) -> IoTask {
|
||||
let (iotask_port, iotask_ch) = stream::<IoTask>();
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
debug!("about to run a test loop");
|
||||
run_loop(&iotask_ch);
|
||||
exit_ch.send(());
|
||||
};
|
||||
return iotask_port.recv();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
extern fn lifetime_handle_close(handle: *libc::c_void) {
|
||||
unsafe {
|
||||
log(debug, fmt!("lifetime_handle_close ptr %?", handle));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
extern fn lifetime_async_callback(handle: *libc::c_void,
|
||||
status: libc::c_int) {
|
||||
log(debug, fmt!("lifetime_handle_close ptr %? status %?",
|
||||
handle, status));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_uv_iotask_async() {
|
||||
unsafe {
|
||||
let (exit_po, exit_ch) = stream::<()>();
|
||||
let iotask = &spawn_test_loop(~exit_ch);
|
||||
|
||||
debug!("spawned iotask");
|
||||
|
||||
// using this handle to manage the lifetime of the
|
||||
// high_level_loop, as it will exit the first time one of
|
||||
// the impl_uv_hl_async() is cleaned up with no one ref'd
|
||||
// handles on the loop (Which can happen under
|
||||
// race-condition type situations.. this ensures that the
|
||||
// loop lives until, at least, all of the
|
||||
// impl_uv_hl_async() runs have been called, at least.
|
||||
let (work_exit_po, work_exit_ch) = stream::<()>();
|
||||
let work_exit_ch = SharedChan(work_exit_ch);
|
||||
for iter::repeat(7u) {
|
||||
let iotask_clone = iotask.clone();
|
||||
let work_exit_ch_clone = work_exit_ch.clone();
|
||||
do task::spawn_sched(task::ManualThreads(1u)) {
|
||||
debug!("async");
|
||||
impl_uv_iotask_async(&iotask_clone);
|
||||
debug!("done async");
|
||||
work_exit_ch_clone.send(());
|
||||
};
|
||||
};
|
||||
for iter::repeat(7u) {
|
||||
debug!("waiting");
|
||||
work_exit_po.recv();
|
||||
};
|
||||
log(debug, ~"sending teardown_loop msg..");
|
||||
exit(iotask);
|
||||
exit_po.recv();
|
||||
log(debug, ~"after recv on exit_po.. exiting..");
|
||||
}
|
||||
}
|
||||
|
@ -1199,6 +1199,7 @@ pub mod test {
|
||||
|
||||
use uv_ll::*;
|
||||
|
||||
use core::comm::{SharedChan, stream};
|
||||
use core::libc;
|
||||
use core::ptr;
|
||||
use core::str;
|
||||
@ -1687,7 +1688,7 @@ pub mod test {
|
||||
|
||||
// this is the impl for a test that is (maybe) ran on a
|
||||
// per-platform/arch basis below
|
||||
fn impl_uv_tcp_server_and_request() {
|
||||
pub fn impl_uv_tcp_server_and_request() {
|
||||
unsafe {
|
||||
let bind_ip = ~"0.0.0.0";
|
||||
let request_ip = ~"127.0.0.1";
|
||||
|
@ -16,6 +16,7 @@ use ast_util::{inlined_item_utils, path_to_ident, stmt_id};
|
||||
use ast_util;
|
||||
use attr;
|
||||
use codemap;
|
||||
use codemap::spanned;
|
||||
use diagnostic::span_handler;
|
||||
use parse::token::ident_interner;
|
||||
use print::pprust;
|
||||
|
@ -13,7 +13,7 @@ use core::prelude::*;
|
||||
use ast::*;
|
||||
use ast;
|
||||
use ast_util;
|
||||
use codemap::{span, BytePos, dummy_sp};
|
||||
use codemap::{span, BytePos, dummy_sp, spanned};
|
||||
use parse::token;
|
||||
use visit;
|
||||
use opt_vec;
|
||||
|
@ -93,6 +93,7 @@ use core::prelude::*;
|
||||
use ast;
|
||||
use ast_util;
|
||||
use attr;
|
||||
use codemap;
|
||||
use codemap::span;
|
||||
use ext::base::*;
|
||||
use parse;
|
||||
|
@ -82,7 +82,7 @@ pub enum SyntaxExtension {
|
||||
IdentTT(SyntaxExpanderTTItem),
|
||||
}
|
||||
|
||||
type SyntaxEnv = @mut MapChain<Name, Transformer>;
|
||||
pub type SyntaxEnv = @mut MapChain<Name, Transformer>;
|
||||
|
||||
// Name : the domain of SyntaxEnvs
|
||||
// want to change these to uints....
|
||||
@ -98,7 +98,7 @@ type Name = @~str;
|
||||
// toward a more uniform syntax syntax (sorry) where blocks are just
|
||||
// another kind of transformer.
|
||||
|
||||
enum Transformer {
|
||||
pub enum Transformer {
|
||||
// this identifier maps to a syntax extension or macro
|
||||
SE(SyntaxExtension),
|
||||
// should blocks occurring here limit macro scopes?
|
||||
@ -495,6 +495,7 @@ mod test {
|
||||
use super::*;
|
||||
use super::MapChain;
|
||||
use util::testing::check_equal;
|
||||
use core::hashmap::linear::LinearMap;
|
||||
|
||||
#[test] fn testenv () {
|
||||
let mut a = LinearMap::new();
|
||||
|
@ -10,8 +10,11 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use ast;
|
||||
use codemap::span;
|
||||
use ext::base::*;
|
||||
use ext::base;
|
||||
use parse::token;
|
||||
|
||||
pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
|
||||
-> base::MacResult {
|
||||
|
@ -15,6 +15,8 @@
|
||||
* interface.
|
||||
*/
|
||||
|
||||
use ast;
|
||||
use codemap::span;
|
||||
use ext::base::*;
|
||||
use ext::base;
|
||||
use ext::build::mk_uniq_str;
|
||||
|
@ -10,13 +10,16 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use ast::{blk_, attribute_, attr_outer, meta_word};
|
||||
use ast::{crate, expr_, expr_mac, mac_invoc_tt};
|
||||
use ast::{tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
|
||||
use ast;
|
||||
use attr;
|
||||
use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan};
|
||||
use codemap;
|
||||
use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned};
|
||||
use ext::base::*;
|
||||
use fold::*;
|
||||
use parse;
|
||||
use parse::{parser, parse_item_from_source_str, new_parser_from_tts};
|
||||
|
||||
use core::option;
|
||||
@ -175,7 +178,7 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
|
||||
}
|
||||
|
||||
// does this attribute list contain "macro_escape" ?
|
||||
fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{
|
||||
pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{
|
||||
let mut accum = false;
|
||||
do attrs.each |attr| {
|
||||
let mname = attr::get_attr_name(attr);
|
||||
@ -473,7 +476,13 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use ast;
|
||||
use ast::{attribute_, attr_outer, meta_word};
|
||||
use codemap;
|
||||
use codemap::spanned;
|
||||
use parse;
|
||||
use util::testing::check_equal;
|
||||
use core::option::{None, Some};
|
||||
|
||||
// make sure that fail! is present
|
||||
#[test] fn fail_exists_test () {
|
||||
|
@ -22,6 +22,7 @@ use ast;
|
||||
use codemap::span;
|
||||
use ext::base::*;
|
||||
use ext::base;
|
||||
use ext::build;
|
||||
use ext::build::*;
|
||||
use private::extfmt::ct::*;
|
||||
|
||||
|
@ -14,6 +14,7 @@ use ext::base::*;
|
||||
use ext::base;
|
||||
use print;
|
||||
|
||||
use core::io;
|
||||
use core::io::WriterUtil;
|
||||
use core::option;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use ast;
|
||||
use ast_util::{ident_to_path};
|
||||
use ast_util;
|
||||
use attr;
|
||||
use codemap::{span, respan, dummy_sp};
|
||||
use codemap::{span, respan, dummy_sp, spanned};
|
||||
use codemap;
|
||||
use ext::base::{ext_ctxt, mk_ctxt};
|
||||
use ext::quote::rt::*;
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
// Parsing pipes protocols from token trees.
|
||||
|
||||
use ast_util;
|
||||
use ext::pipes::pipec::*;
|
||||
use ext::pipes::proto::*;
|
||||
use parse::common::SeqSep;
|
||||
use parse::parser;
|
||||
use parse::token;
|
||||
|
@ -10,8 +10,9 @@
|
||||
|
||||
// A protocol compiler for Rust.
|
||||
|
||||
use ast;
|
||||
use ast::ident;
|
||||
use codemap::dummy_sp;
|
||||
use codemap::{dummy_sp, spanned};
|
||||
use ext::base::ext_ctxt;
|
||||
use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
|
||||
use ext::pipes::ast_builder::{path_global};
|
||||
|
@ -34,10 +34,12 @@ use core::str;
|
||||
|
||||
pub mod rt {
|
||||
use ast;
|
||||
use codemap;
|
||||
use ext::base::ext_ctxt;
|
||||
use parse;
|
||||
use print::pprust;
|
||||
|
||||
use core::prelude::*;
|
||||
use core::str;
|
||||
|
||||
pub use ast::*;
|
||||
@ -49,7 +51,7 @@ pub mod rt {
|
||||
use print::pprust;
|
||||
use print::pprust::{item_to_str, ty_to_str};
|
||||
|
||||
trait ToTokens {
|
||||
pub trait ToTokens {
|
||||
pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree];
|
||||
}
|
||||
|
||||
@ -73,7 +75,7 @@ pub mod rt {
|
||||
|
||||
*/
|
||||
|
||||
trait ToSource {
|
||||
pub trait ToSource {
|
||||
// Takes a thing and generates a string containing rust code for it.
|
||||
pub fn to_source(&self, cx: ext_ctxt) -> ~str;
|
||||
}
|
||||
@ -164,7 +166,7 @@ pub mod rt {
|
||||
}
|
||||
}
|
||||
|
||||
trait ExtParseUtils {
|
||||
pub trait ExtParseUtils {
|
||||
fn parse_item(s: ~str) -> @ast::item;
|
||||
fn parse_expr(s: ~str) -> @ast::expr;
|
||||
fn parse_stmt(s: ~str) -> @ast::stmt;
|
||||
|
@ -8,12 +8,14 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast;
|
||||
use codemap;
|
||||
use codemap::{FileMap, Loc, Pos, ExpandedFrom, span};
|
||||
use codemap::{CallInfo, NameAndSpan};
|
||||
use ext::base::*;
|
||||
use ext::base;
|
||||
use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str};
|
||||
use parse;
|
||||
use print::pprust;
|
||||
|
||||
use core::io;
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
// Earley-like parser for macros.
|
||||
use ast;
|
||||
use ast::{matcher, match_tok, match_seq, match_nonterminal, ident};
|
||||
use codemap::{BytePos, mk_sp};
|
||||
use codemap;
|
||||
@ -23,6 +24,7 @@ use core::dvec::DVec;
|
||||
use core::dvec;
|
||||
use core::io;
|
||||
use core::option;
|
||||
use core::option::{Option, Some, None};
|
||||
use core::str;
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
|
@ -12,7 +12,8 @@ use core::prelude::*;
|
||||
|
||||
use ast::*;
|
||||
use ast;
|
||||
use codemap::span;
|
||||
use codemap::{span, spanned};
|
||||
use opt_vec::OptVec;
|
||||
|
||||
use core::option;
|
||||
use core::vec;
|
||||
|
@ -15,6 +15,7 @@ use codemap::spanned;
|
||||
use codemap::BytePos;
|
||||
use parse::common::*; //resolve bug?
|
||||
use parse::token;
|
||||
use parse::parser::Parser;
|
||||
|
||||
use core::either::{Either, Left, Right};
|
||||
|
||||
|
@ -764,10 +764,14 @@ fn consume_whitespace(rdr: @mut StringReader) {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
|
||||
use super::*;
|
||||
use util::interner;
|
||||
|
||||
use ast;
|
||||
use codemap::{BytePos, CodeMap, span};
|
||||
use core::option::None;
|
||||
use diagnostic;
|
||||
use parse::token;
|
||||
use util::interner;
|
||||
use util::testing::{check_equal, check_equal_ptr};
|
||||
|
||||
// represents a testing reader (incl. both reader and interner)
|
||||
|
@ -234,6 +234,8 @@ mod test {
|
||||
use super::*;
|
||||
use std::serialize::Encodable;
|
||||
use std;
|
||||
use core::io;
|
||||
use core::option::None;
|
||||
use core::str;
|
||||
use util::testing::*;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast;
|
||||
use ast::*;
|
||||
use parse::token::*;
|
||||
use parse::token::Token;
|
||||
|
@ -2299,11 +2299,14 @@ pub fn print_onceness(s: @ps, o: ast::Onceness) {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use super::*;
|
||||
|
||||
use ast;
|
||||
use ast_util;
|
||||
use codemap;
|
||||
use core::cmp::Eq;
|
||||
use core::option::None;
|
||||
use parse;
|
||||
use super::*;
|
||||
//use util;
|
||||
use util::testing::check_equal;
|
||||
|
||||
fn string_check<T:Eq> (given : &T, expected: &T) {
|
||||
|
@ -16,6 +16,7 @@ use ast_util;
|
||||
use codemap::span;
|
||||
use parse;
|
||||
use opt_vec;
|
||||
use opt_vec::OptVec;
|
||||
|
||||
use core::option;
|
||||
use core::vec;
|
||||
|
Loading…
x
Reference in New Issue
Block a user