Skip to content

Commit 1e3d11f

Browse files
committed
---
yaml --- r: 150687 b: refs/heads/try2 c: a00be50 h: refs/heads/master i: 150685: e907558 150683: 637fac2 150679: cb41521 150671: 0e69684 150655: eeff596 v: v3
1 parent 967eef9 commit 1e3d11f

File tree

12 files changed

+209
-349
lines changed

12 files changed

+209
-349
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7fbcb400f0697621ece9f9773b0f0bf1ec73e9c1
8+
refs/heads/try2: a00be50e00bc244569cb8d660f96abdde10dc6ef
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libglob/lib.rs

Lines changed: 10 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -43,7 +43,6 @@ use std::path::is_sep;
4343
pub struct Paths {
4444
root: Path,
4545
dir_patterns: Vec<Pattern>,
46-
require_dir: bool,
4746
options: MatchOptions,
4847
todo: Vec<(Path,uint)>,
4948
}
@@ -52,7 +51,7 @@ pub struct Paths {
5251
/// Return an iterator that produces all the Paths that match the given pattern,
5352
/// which may be absolute or relative to the current working directory.
5453
///
55-
/// This method uses the default match options and is equivalent to calling
54+
/// is method uses the default match options and is equivalent to calling
5655
/// `glob_with(pattern, MatchOptions::new())`. Use `glob_with` directly if you
5756
/// want to use non-default match options.
5857
///
@@ -107,7 +106,6 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
107106
return Paths {
108107
root: root,
109108
dir_patterns: Vec::new(),
110-
require_dir: false,
111109
options: options,
112110
todo: Vec::new(),
113111
};
@@ -119,21 +117,13 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
119117
let dir_patterns = pattern.slice_from(cmp::min(root_len, pattern.len()))
120118
.split_terminator(is_sep)
121119
.map(|s| Pattern::new(s))
122-
.collect::<Vec<Pattern>>();
123-
let require_dir = pattern.chars().next_back().map(is_sep) == Some(true);
120+
.collect();
124121

125-
let mut todo = Vec::new();
126-
if dir_patterns.len() > 0 {
127-
// Shouldn't happen, but we're using -1 as a special index.
128-
assert!(dir_patterns.len() < -1 as uint);
129-
130-
fill_todo(&mut todo, dir_patterns.as_slice(), 0, &root, options);
131-
}
122+
let todo = list_dir_sorted(&root).move_iter().map(|x|(x,0u)).collect();
132123

133124
Paths {
134125
root: root,
135126
dir_patterns: dir_patterns,
136-
require_dir: require_dir,
137127
options: options,
138128
todo: todo,
139129
}
@@ -148,12 +138,6 @@ impl Iterator<Path> for Paths {
148138
}
149139

150140
let (path,idx) = self.todo.pop().unwrap();
151-
// idx -1: was already checked by fill_todo, maybe path was '.' or
152-
// '..' that we can't match here because of normalization.
153-
if idx == -1 as uint {
154-
if self.require_dir && !path.is_dir() { continue; }
155-
return Some(path);
156-
}
157141
let ref pattern = *self.dir_patterns.get(idx);
158142

159143
if pattern.matches_with(match path.filename_str() {
@@ -168,27 +152,23 @@ impl Iterator<Path> for Paths {
168152
if idx == self.dir_patterns.len() - 1 {
169153
// it is not possible for a pattern to match a directory *AND* its children
170154
// so we don't need to check the children
171-
172-
if !self.require_dir || path.is_dir() {
173-
return Some(path);
174-
}
155+
return Some(path);
175156
} else {
176-
fill_todo(&mut self.todo, self.dir_patterns.as_slice(),
177-
idx + 1, &path, self.options);
157+
self.todo.extend(list_dir_sorted(&path).move_iter().map(|x|(x,idx+1)));
178158
}
179159
}
180160
}
181161
}
182162

183163
}
184164

185-
fn list_dir_sorted(path: &Path) -> Option<Vec<Path>> {
165+
fn list_dir_sorted(path: &Path) -> Vec<Path> {
186166
match fs::readdir(path) {
187167
Ok(mut children) => {
188168
children.sort_by(|p1, p2| p2.filename().cmp(&p1.filename()));
189-
Some(children.move_iter().collect())
169+
children.move_iter().collect()
190170
}
191-
Err(..) => None
171+
Err(..) => Vec::new()
192172
}
193173
}
194174

@@ -455,72 +435,6 @@ impl Pattern {
455435

456436
}
457437

458-
// Fills `todo` with paths under `path` to be matched by `patterns[idx]`,
459-
// special-casing patterns to match `.` and `..`, and avoiding `readdir()`
460-
// calls when there are no metacharacters in the pattern.
461-
fn fill_todo(todo: &mut Vec<(Path, uint)>, patterns: &[Pattern], idx: uint, path: &Path,
462-
options: MatchOptions) {
463-
// convert a pattern that's just many Char(_) to a string
464-
fn pattern_as_str(pattern: &Pattern) -> Option<~str> {
465-
let mut s = ~"";
466-
for token in pattern.tokens.iter() {
467-
match *token {
468-
Char(c) => s.push_char(c),
469-
_ => return None
470-
}
471-
}
472-
return Some(s);
473-
}
474-
475-
let add = |todo: &mut Vec<_>, next_path: Path| {
476-
if idx + 1 == patterns.len() {
477-
// We know it's good, so don't make the iterator match this path
478-
// against the pattern again. In particular, it can't match
479-
// . or .. globs since these never show up as path components.
480-
todo.push((next_path, -1 as uint));
481-
} else {
482-
fill_todo(todo, patterns, idx + 1, &next_path, options);
483-
}
484-
};
485-
486-
let pattern = &patterns[idx];
487-
488-
match pattern_as_str(pattern) {
489-
Some(s) => {
490-
// This pattern component doesn't have any metacharacters, so we
491-
// don't need to read the current directory to know where to
492-
// continue. So instead of passing control back to the iterator,
493-
// we can just check for that one entry and potentially recurse
494-
// right away.
495-
let special = "." == s || ".." == s;
496-
let next_path = path.join(s);
497-
if (special && path.is_dir()) || (!special && next_path.exists()) {
498-
add(todo, next_path);
499-
}
500-
},
501-
None => {
502-
match list_dir_sorted(path) {
503-
Some(entries) => {
504-
todo.extend(entries.move_iter().map(|x|(x, idx)));
505-
506-
// Matching the special directory entries . and .. that refer to
507-
// the current and parent directory respectively requires that
508-
// the pattern has a leading dot, even if the `MatchOptions` field
509-
// `require_literal_leading_dot` is not set.
510-
if pattern.tokens.len() > 0 && pattern.tokens.get(0) == &Char('.') {
511-
for &special in [".", ".."].iter() {
512-
if pattern.matches_with(special, options) {
513-
add(todo, path.join(special));
514-
}
515-
}
516-
}
517-
}
518-
None => {}
519-
}
520-
}
521-
}
522-
}
523-
524438
fn parse_char_specifiers(s: &[char]) -> Vec<CharSpecifier> {
525439
let mut cs = Vec::new();
526440
let mut i = 0;
@@ -653,7 +567,7 @@ mod test {
653567
fn test_absolute_pattern() {
654568
// assume that the filesystem is not empty!
655569
assert!(glob("/*").next().is_some());
656-
assert!(glob("//").next().is_some());
570+
assert!(glob("//").next().is_none());
657571

658572
// check windows absolute paths with host/device components
659573
let root_with_device = os::getcwd().root_path().unwrap().join("*");

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,12 @@ pub fn opt_loan_path(cmt: mc::cmt) -> Option<@LoanPath> {
274274
match cmt.cat {
275275
mc::cat_rvalue(..) |
276276
mc::cat_static_item |
277-
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {
277+
mc::cat_copied_upvar(_) => {
278278
None
279279
}
280280

281281
mc::cat_local(id) |
282282
mc::cat_arg(id) |
283-
mc::cat_copied_upvar(mc::CopiedUpvar { upvar_id: id, .. }) |
284283
mc::cat_upvar(ty::UpvarId {var_id: id, ..}, _) => {
285284
Some(@LpVar(id))
286285
}

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef,
977977
X86 | Arm | Mips => "llvm.memcpy.p0i8.p0i8.i32",
978978
X86_64 => "llvm.memcpy.p0i8.p0i8.i64"
979979
};
980-
let memcpy = ccx.intrinsics.get_copy(&key);
980+
let memcpy = ccx.get_intrinsic(&key);
981981
let src_ptr = PointerCast(cx, src, Type::i8p(ccx));
982982
let dst_ptr = PointerCast(cx, dst, Type::i8p(ccx));
983983
let size = IntCast(cx, n_bytes, ccx.int_type);
@@ -1022,7 +1022,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
10221022
X86_64 => "llvm.memset.p0i8.i64"
10231023
};
10241024

1025-
let llintrinsicfn = ccx.intrinsics.get_copy(&intrinsic_key);
1025+
let llintrinsicfn = ccx.get_intrinsic(&intrinsic_key);
10261026
let llptr = b.pointercast(llptr, Type::i8(ccx).ptr_to());
10271027
let llzeroval = C_u8(ccx, 0);
10281028
let size = machine::llsize_of(ccx, ty);
@@ -2043,168 +2043,6 @@ pub fn p2i(ccx: &CrateContext, v: ValueRef) -> ValueRef {
20432043
}
20442044
}
20452045

2046-
2047-
pub fn declare_intrinsics(ccx: &mut CrateContext) {
2048-
macro_rules! ifn (
2049-
($name:expr fn() -> $ret:expr) => ({
2050-
let name = $name;
2051-
// HACK(eddyb) dummy output type, shouln't affect anything.
2052-
let f = decl_cdecl_fn(ccx.llmod, name, Type::func([], &$ret), ty::mk_nil());
2053-
ccx.intrinsics.insert(name, f);
2054-
});
2055-
($name:expr fn($($arg:expr),*) -> $ret:expr) => ({
2056-
let name = $name;
2057-
// HACK(eddyb) dummy output type, shouln't affect anything.
2058-
let f = decl_cdecl_fn(ccx.llmod, name,
2059-
Type::func([$($arg),*], &$ret), ty::mk_nil());
2060-
ccx.intrinsics.insert(name, f);
2061-
})
2062-
)
2063-
macro_rules! mk_struct (
2064-
($($field_ty:expr),*) => (Type::struct_(ccx, [$($field_ty),*], false))
2065-
)
2066-
2067-
let i8p = Type::i8p(ccx);
2068-
let void = Type::void(ccx);
2069-
let i1 = Type::i1(ccx);
2070-
let t_i8 = Type::i8(ccx);
2071-
let t_i16 = Type::i16(ccx);
2072-
let t_i32 = Type::i32(ccx);
2073-
let t_i64 = Type::i64(ccx);
2074-
let t_f32 = Type::f32(ccx);
2075-
let t_f64 = Type::f64(ccx);
2076-
2077-
ifn!("llvm.memcpy.p0i8.p0i8.i32" fn(i8p, i8p, t_i32, t_i32, i1) -> void);
2078-
ifn!("llvm.memcpy.p0i8.p0i8.i64" fn(i8p, i8p, t_i64, t_i32, i1) -> void);
2079-
ifn!("llvm.memmove.p0i8.p0i8.i32" fn(i8p, i8p, t_i32, t_i32, i1) -> void);
2080-
ifn!("llvm.memmove.p0i8.p0i8.i64" fn(i8p, i8p, t_i64, t_i32, i1) -> void);
2081-
ifn!("llvm.memset.p0i8.i32" fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
2082-
ifn!("llvm.memset.p0i8.i64" fn(i8p, t_i8, t_i64, t_i32, i1) -> void);
2083-
2084-
ifn!("llvm.trap" fn() -> void);
2085-
ifn!("llvm.debugtrap" fn() -> void);
2086-
ifn!("llvm.frameaddress" fn(t_i32) -> i8p);
2087-
2088-
ifn!("llvm.powi.f32" fn(t_f32, t_i32) -> t_f32);
2089-
ifn!("llvm.powi.f64" fn(t_f64, t_i32) -> t_f64);
2090-
ifn!("llvm.pow.f32" fn(t_f32, t_f32) -> t_f32);
2091-
ifn!("llvm.pow.f64" fn(t_f64, t_f64) -> t_f64);
2092-
2093-
ifn!("llvm.sqrt.f32" fn(t_f32) -> t_f32);
2094-
ifn!("llvm.sqrt.f64" fn(t_f64) -> t_f64);
2095-
ifn!("llvm.sin.f32" fn(t_f32) -> t_f32);
2096-
ifn!("llvm.sin.f64" fn(t_f64) -> t_f64);
2097-
ifn!("llvm.cos.f32" fn(t_f32) -> t_f32);
2098-
ifn!("llvm.cos.f64" fn(t_f64) -> t_f64);
2099-
ifn!("llvm.exp.f32" fn(t_f32) -> t_f32);
2100-
ifn!("llvm.exp.f64" fn(t_f64) -> t_f64);
2101-
ifn!("llvm.exp2.f32" fn(t_f32) -> t_f32);
2102-
ifn!("llvm.exp2.f64" fn(t_f64) -> t_f64);
2103-
ifn!("llvm.log.f32" fn(t_f32) -> t_f32);
2104-
ifn!("llvm.log.f64" fn(t_f64) -> t_f64);
2105-
ifn!("llvm.log10.f32" fn(t_f32) -> t_f32);
2106-
ifn!("llvm.log10.f64" fn(t_f64) -> t_f64);
2107-
ifn!("llvm.log2.f32" fn(t_f32) -> t_f32);
2108-
ifn!("llvm.log2.f64" fn(t_f64) -> t_f64);
2109-
2110-
ifn!("llvm.fma.f32" fn(t_f32, t_f32, t_f32) -> t_f32);
2111-
ifn!("llvm.fma.f64" fn(t_f64, t_f64, t_f64) -> t_f64);
2112-
2113-
ifn!("llvm.fabs.f32" fn(t_f32) -> t_f32);
2114-
ifn!("llvm.fabs.f64" fn(t_f64) -> t_f64);
2115-
2116-
ifn!("llvm.floor.f32" fn(t_f32) -> t_f32);
2117-
ifn!("llvm.floor.f64" fn(t_f64) -> t_f64);
2118-
ifn!("llvm.ceil.f32" fn(t_f32) -> t_f32);
2119-
ifn!("llvm.ceil.f64" fn(t_f64) -> t_f64);
2120-
ifn!("llvm.trunc.f32" fn(t_f32) -> t_f32);
2121-
ifn!("llvm.trunc.f64" fn(t_f64) -> t_f64);
2122-
2123-
ifn!("llvm.rint.f32" fn(t_f32) -> t_f32);
2124-
ifn!("llvm.rint.f64" fn(t_f64) -> t_f64);
2125-
ifn!("llvm.nearbyint.f32" fn(t_f32) -> t_f32);
2126-
ifn!("llvm.nearbyint.f64" fn(t_f64) -> t_f64);
2127-
2128-
ifn!("llvm.ctpop.i8" fn(t_i8) -> t_i8);
2129-
ifn!("llvm.ctpop.i16" fn(t_i16) -> t_i16);
2130-
ifn!("llvm.ctpop.i32" fn(t_i32) -> t_i32);
2131-
ifn!("llvm.ctpop.i64" fn(t_i64) -> t_i64);
2132-
2133-
ifn!("llvm.ctlz.i8" fn(t_i8 , i1) -> t_i8);
2134-
ifn!("llvm.ctlz.i16" fn(t_i16, i1) -> t_i16);
2135-
ifn!("llvm.ctlz.i32" fn(t_i32, i1) -> t_i32);
2136-
ifn!("llvm.ctlz.i64" fn(t_i64, i1) -> t_i64);
2137-
2138-
ifn!("llvm.cttz.i8" fn(t_i8 , i1) -> t_i8);
2139-
ifn!("llvm.cttz.i16" fn(t_i16, i1) -> t_i16);
2140-
ifn!("llvm.cttz.i32" fn(t_i32, i1) -> t_i32);
2141-
ifn!("llvm.cttz.i64" fn(t_i64, i1) -> t_i64);
2142-
2143-
ifn!("llvm.bswap.i16" fn(t_i16) -> t_i16);
2144-
ifn!("llvm.bswap.i32" fn(t_i32) -> t_i32);
2145-
ifn!("llvm.bswap.i64" fn(t_i64) -> t_i64);
2146-
2147-
ifn!("llvm.sadd.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
2148-
ifn!("llvm.sadd.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
2149-
ifn!("llvm.sadd.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
2150-
ifn!("llvm.sadd.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
2151-
2152-
ifn!("llvm.uadd.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
2153-
ifn!("llvm.uadd.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
2154-
ifn!("llvm.uadd.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
2155-
ifn!("llvm.uadd.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
2156-
2157-
ifn!("llvm.ssub.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
2158-
ifn!("llvm.ssub.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
2159-
ifn!("llvm.ssub.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
2160-
ifn!("llvm.ssub.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
2161-
2162-
ifn!("llvm.usub.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
2163-
ifn!("llvm.usub.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
2164-
ifn!("llvm.usub.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
2165-
ifn!("llvm.usub.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
2166-
2167-
ifn!("llvm.smul.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
2168-
ifn!("llvm.smul.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
2169-
ifn!("llvm.smul.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
2170-
ifn!("llvm.smul.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
2171-
2172-
ifn!("llvm.umul.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
2173-
ifn!("llvm.umul.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
2174-
ifn!("llvm.umul.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
2175-
ifn!("llvm.umul.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
2176-
2177-
ifn!("llvm.expect.i1" fn(i1, i1) -> i1);
2178-
2179-
// Some intrinsics were introduced in later versions of LLVM, but they have
2180-
// fallbacks in libc or libm and such. Currently, all of these intrinsics
2181-
// were introduced in LLVM 3.4, so we case on that.
2182-
macro_rules! compatible_ifn (
2183-
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => ({
2184-
let name = $name;
2185-
if unsafe { llvm::LLVMVersionMinor() >= 4 } {
2186-
ifn!(name fn($($arg),*) -> $ret);
2187-
} else {
2188-
let f = decl_cdecl_fn(ccx.llmod, stringify!($cname),
2189-
Type::func([$($arg),*], &$ret),
2190-
ty::mk_nil());
2191-
ccx.intrinsics.insert(name, f);
2192-
}
2193-
})
2194-
)
2195-
2196-
compatible_ifn!("llvm.copysign.f32", copysignf(t_f32, t_f32) -> t_f32);
2197-
compatible_ifn!("llvm.copysign.f64", copysign(t_f64, t_f64) -> t_f64);
2198-
compatible_ifn!("llvm.round.f32", roundf(t_f32) -> t_f32);
2199-
compatible_ifn!("llvm.round.f64", round(t_f64) -> t_f64);
2200-
2201-
2202-
if ccx.sess().opts.debuginfo != NoDebugInfo {
2203-
ifn!("llvm.dbg.declare" fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
2204-
ifn!("llvm.dbg.value" fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);
2205-
}
2206-
}
2207-
22082046
pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::EncodeInlinedItem<'r>)
22092047
-> encoder::EncodeParams<'r> {
22102048

0 commit comments

Comments
 (0)