]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #7997 : omasanori/rust/cleanup, r=cmr
authorbors <bors@rust-lang.org>
Wed, 24 Jul 2013 18:16:33 +0000 (11:16 -0700)
committerbors <bors@rust-lang.org>
Wed, 24 Jul 2013 18:16:33 +0000 (11:16 -0700)
Just an minor cleanup.

140 files changed:
doc/tutorial-container.md
doc/tutorial.md
src/compiletest/runtest.rs
src/etc/emacs/README.md
src/libextra/base64.rs
src/libextra/future.rs
src/libextra/getopts.rs
src/libextra/json.rs
src/libextra/rc.rs
src/libextra/task_pool.rs
src/libextra/test.rs
src/libextra/treemap.rs
src/libextra/workcache.rs
src/librust/rust.rs
src/librustc/back/passes.rs
src/librustc/metadata/encoder.rs
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/asm.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/build.rs
src/librustc/middle/trans/cabi.rs
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/closure.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/controlflow.rs
src/librustc/middle/trans/datum.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/foreign.rs
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/meth.rs
src/librustc/middle/trans/reflect.rs
src/librustc/middle/trans/tvec.rs
src/librustc/middle/trans/uniq.rs
src/librustc/middle/trans/write_guard.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/rustc.rs
src/librustc/util/common.rs
src/librustdoc/config.rs
src/librustdoc/rustdoc.rs
src/librusti/rusti.rs
src/librustpkg/path_util.rs
src/librustpkg/testsuite/pass/src/fancy-lib/pkg.rs
src/libstd/iterator.rs
src/libstd/num/strconv.rs
src/libstd/num/uint_macros.rs
src/libstd/ops.rs
src/libstd/rand.rs
src/libstd/rand/distributions.rs
src/libstd/rt/args.rs
src/libstd/rt/global_heap.rs
src/libstd/rt/local_heap.rs
src/libstd/std.rs
src/libstd/str.rs
src/libstd/to_str.rs
src/libstd/unstable/atomics.rs
src/libstd/util.rs
src/libstd/vec.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/bytes.rs
src/libsyntax/ext/fmt.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/parse/token.rs
src/rt/rust_crate_map.h
src/test/auxiliary/issue_5844_aux.rs [new file with mode: 0644]
src/test/bench/core-map.rs
src/test/bench/core-std.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/msgsend-ring-pipes.rs
src/test/bench/msgsend-ring-rw-arcs.rs
src/test/bench/pingpong.rs
src/test/bench/shootout-ackermann.rs
src/test/bench/shootout-binarytrees.rs
src/test/bench/shootout-fannkuch-redux.rs
src/test/bench/shootout-fibo.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-spectralnorm.rs
src/test/bench/shootout-threadring.rs
src/test/compile-fail/borrowck-auto-mut-ref-to-immut-var.rs
src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs
src/test/compile-fail/issue-3820.rs
src/test/compile-fail/issue-4335.rs
src/test/compile-fail/issue-5844.rs [new file with mode: 0644]
src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs
src/test/compile-fail/rcmut-not-const-and-not-owned.rs
src/test/compile-fail/tuple-struct-nonexhaustive.rs
src/test/run-fail/borrowck-wg-one-mut-one-imm-slice-method.rs
src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs
src/test/run-fail/borrowck-wg-one-mut-one-imm.rs
src/test/run-fail/borrowck-wg-two-array-indices.rs
src/test/run-fail/bug-2470-bounds-check-overflow-2.rs
src/test/run-fail/bug-2470-bounds-check-overflow-3.rs
src/test/run-fail/too-much-recursion-unwinding.rs
src/test/run-fail/unwind-misc-1.rs
src/test/run-pass/auto-ref.rs
src/test/run-pass/borrowck-wg-two-imm-borrows.rs
src/test/run-pass/cci_impl_exe.rs
src/test/run-pass/cci_iter_exe.rs
src/test/run-pass/cci_no_inline_exe.rs
src/test/run-pass/const-fields-and-indexing.rs
src/test/run-pass/const-rec-and-tup.rs
src/test/run-pass/const-region-ptrs.rs
src/test/run-pass/const-struct.rs
src/test/run-pass/const-vecs-and-slices.rs
src/test/run-pass/functional-struct-update.rs
src/test/run-pass/issue-2185.rs
src/test/run-pass/issue-2989.rs
src/test/run-pass/issue-3211.rs
src/test/run-pass/issue-3743.rs
src/test/run-pass/issue-3753.rs
src/test/run-pass/issue-3794.rs
src/test/run-pass/issue-3904.rs
src/test/run-pass/issue-4241.rs
src/test/run-pass/issue-4401.rs
src/test/run-pass/link-section.rs [new file with mode: 0644]
src/test/run-pass/max-min-classes.rs
src/test/run-pass/new-style-constants.rs
src/test/run-pass/new-style-fixed-length-vec.rs
src/test/run-pass/newtype.rs
src/test/run-pass/num-range-rev.rs
src/test/run-pass/num-range.rs
src/test/run-pass/placement-new-arena.rs
src/test/run-pass/recursion.rs
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/reflect-visit-type.rs
src/test/run-pass/struct-pattern-matching.rs
src/test/run-pass/trait-inheritance-num2.rs
src/test/run-pass/trait-inheritance-num3.rs
src/test/run-pass/transmute-non-immediate-to-immediate.rs [new file with mode: 0644]
src/test/run-pass/tuple-struct-construct.rs
src/test/run-pass/tuple-struct-destructuring.rs
src/test/run-pass/tuple-struct-matching.rs
src/test/run-pass/vec-fixed-length.rs
src/test/run-pass/vec-matching-legal-tail-element-borrow.rs

index 2146b76a4afbd13ee3d1801318db28c181e3afc4..1b195e99979895b05a9d22fe951fa335b2db9565 100644 (file)
@@ -192,7 +192,7 @@ let mut it = xs.iter().zip(ys.iter());
 
 // print out the pairs of elements up to (&3, &"baz")
 for it.advance |(x, y)| {
-    println(fmt!("%d %s", *x, *y));
+    printfln!("%d %s", *x, *y);
 
     if *x == 3 {
         break;
@@ -200,7 +200,7 @@ for it.advance |(x, y)| {
 }
 
 // yield and print the last pair from the iterator
-println(fmt!("last: %?", it.next()));
+printfln!("last: %?", it.next());
 
 // the iterator is now fully consumed
 assert!(it.next().is_none());
@@ -294,15 +294,59 @@ another `DoubleEndedIterator` with `next` and `next_back` exchanged.
 ~~~
 let xs = [1, 2, 3, 4, 5, 6];
 let mut it = xs.iter();
-println(fmt!("%?", it.next())); // prints `Some(&1)`
-println(fmt!("%?", it.next())); // prints `Some(&2)`
-println(fmt!("%?", it.next_back())); // prints `Some(&6)`
+printfln!("%?", it.next()); // prints `Some(&1)`
+printfln!("%?", it.next()); // prints `Some(&2)`
+printfln!("%?", it.next_back()); // prints `Some(&6)`
 
 // prints `5`, `4` and `3`
 for it.invert().advance |&x| {
-    println(fmt!("%?", x))
+    printfln!("%?", x)
 }
 ~~~
 
 The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted
 version of the standard immutable and mutable vector iterators.
+
+The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are
+`DoubleEndedIterator` implementations if the underlying iterators are.
+
+~~~
+let xs = [1, 2, 3, 4];
+let ys = [5, 6, 7, 8];
+let mut it = xs.iter().chain_(ys.iter()).transform(|&x| x * 2);
+
+printfln!("%?", it.next()); // prints `Some(2)`
+
+// prints `16`, `14`, `12`, `10`, `8`, `6`, `4`
+for it.invert().advance |x| {
+    printfln!("%?", x);
+}
+~~~
+
+## Random-access iterators
+
+The `RandomAccessIterator` trait represents an iterator offering random access
+to the whole range. The `indexable` method retrieves the number of elements
+accessible with the `idx` method.
+
+The `chain_` adaptor is an implementation of `RandomAccessIterator` if the
+underlying iterators are.
+
+~~~
+let xs = [1, 2, 3, 4, 5];
+let ys = ~[7, 9, 11];
+let mut it = xs.iter().chain_(ys.iter());
+printfln!("%?", it.idx(0)); // prints `Some(&1)`
+printfln!("%?", it.idx(5)); // prints `Some(&7)`
+printfln!("%?", it.idx(7)); // prints `Some(&11)`
+printfln!("%?", it.idx(8)); // prints `None`
+
+// yield two elements from the beginning, and one from the end
+it.next();
+it.next();
+it.next_back();
+
+printfln!("%?", it.idx(0)); // prints `Some(&3)`
+printfln!("%?", it.idx(4)); // prints `Some(&9)`
+printfln!("%?", it.idx(6)); // prints `None`
+~~~
index 898811dc3a6cd2f60266b974c9886a3ea78eb501..d0b375b0b5846c7fa669bd71fdf596030bfae4b3 100644 (file)
@@ -499,8 +499,8 @@ types.
 > items.
 
 ~~~~
-use std::float;
-use std::num::atan;
+use std::float;
+use std::num::atan;
 fn angle(vector: (float, float)) -> float {
     let pi = float::consts::pi;
     match vector {
@@ -555,7 +555,7 @@ while cake_amount > 0 {
 `loop` denotes an infinite loop, and is the preferred way of writing `while true`:
 
 ~~~~
-use std::int;
+use std::int;
 let mut x = 5;
 loop {
     x += x - 3;
@@ -701,7 +701,7 @@ get at their contents. All variant constructors can be used as
 patterns, as in this definition of `area`:
 
 ~~~~
-use std::float;
+use std::float;
 # struct Point {x: float, y: float}
 # enum Shape { Circle(Point, float), Rectangle(Point, Point) }
 fn area(sh: Shape) -> float {
@@ -733,7 +733,7 @@ fn point_from_direction(dir: Direction) -> Point {
 Enum variants may also be structs. For example:
 
 ~~~~
-use std::float;
+use std::float;
 # struct Point { x: float, y: float }
 # fn square(x: float) -> float { x * x }
 enum Shape {
@@ -1599,7 +1599,8 @@ lists back to back. Since that is so unsightly, empty argument lists
 may be omitted from `do` expressions.
 
 ~~~~
-# use std::task::spawn;
+use std::task::spawn;
+
 do spawn {
    debug!("Kablam!");
 }
@@ -1728,7 +1729,7 @@ impl Circle {
 To call such a method, just prefix it with the type name and a double colon:
 
 ~~~~
-use std::float::consts::pi;
+use std::float::consts::pi;
 struct Circle { radius: float }
 impl Circle {
     fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
@@ -1774,7 +1775,7 @@ illegal to copy and pass by value.
 Generic `type`, `struct`, and `enum` declarations follow the same pattern:
 
 ~~~~
-use std::hashmap::HashMap;
+use std::hashmap::HashMap;
 type Set<T> = HashMap<T, ()>;
 
 struct Stack<T> {
@@ -2000,7 +2001,7 @@ name and a double colon.  The compiler uses type inference to decide which
 implementation to use.
 
 ~~~~
-use std::float::consts::pi;
+use std::float::consts::pi;
 trait Shape { fn new(area: float) -> Self; }
 struct Circle { radius: float }
 struct Square { length: float }
@@ -2156,7 +2157,7 @@ trait Circle : Shape { fn radius(&self) -> float; }
 Now, we can implement `Circle` on a type only if we also implement `Shape`.
 
 ~~~~
-use std::float::consts::pi;
+use std::float::consts::pi;
 # trait Shape { fn area(&self) -> float; }
 # trait Circle : Shape { fn radius(&self) -> float; }
 # struct Point { x: float, y: float }
@@ -2191,7 +2192,7 @@ fn radius_times_area<T: Circle>(c: T) -> float {
 Likewise, supertrait methods may also be called on trait objects.
 
 ~~~ {.xfail-test}
-use std::float::consts::pi;
+use std::float::consts::pi;
 # trait Shape { fn area(&self) -> float; }
 # trait Circle : Shape { fn radius(&self) -> float; }
 # struct Point { x: float, y: float }
index a2f36c104a0a27d1cb7a1b40f2867530dc222f84..7cd73c82530815788842bceac46330e1d87e970f 100644 (file)
@@ -292,7 +292,7 @@ fn debugger() -> ~str { ~"gdb" }
             }
         }
         if i != num_check_lines {
-            fatal_ProcRes(fmt!("line not found in debugger output: %s"
+            fatal_ProcRes(fmt!("line not found in debugger output: %s",
                                check_lines[i]), &ProcRes);
         }
     }
index 006dd6654cdecda2c4ec91b116c56d3784048d54..02c2c248d3625eb9c946868b1d7d9193e59e4bea 100644 (file)
@@ -98,3 +98,8 @@ marking, press x, and ELPA will install the packages for you (under
 ~/.emacs.d/elpa/).
 
 * or using <kbd>M-x package-install rust-mode
+
+### Known bugs
+
+* Combining `global-whitespace-mode` and `rust-mode` is generally glitchy.
+  See [Issue #3994](https://github.com/mozilla/rust/issues/3994).
index 3c549d4291710d48fddf7010261bda886fe9a545..37d95d622c0830094888d0f98be02478e4d648ff 100644 (file)
@@ -75,7 +75,7 @@ impl<'self> ToBase64 for &'self [u8] {
      *
      * fn main () {
      *     let str = [52,32].to_base64(standard);
-     *     println(fmt!("%s", str));
+     *     printfln!("%s", str);
      * }
      * ~~~
      */
@@ -164,7 +164,7 @@ impl<'self> ToBase64 for &'self str {
      *
      * fn main () {
      *     let str = "Hello, World".to_base64(standard);
-     *     println(fmt!("%s",str));
+     *     printfln!("%s", str);
      * }
      * ~~~
      *
@@ -194,9 +194,9 @@ impl<'self> FromBase64 for &'self [u8] {
      *
      * fn main () {
      *     let str = [52,32].to_base64(standard);
-     *     println(fmt!("%s", str));
+     *     printfln!("%s", str);
      *     let bytes = str.from_base64();
-     *     println(fmt!("%?",bytes));
+     *     printfln!("%?", bytes);
      * }
      * ~~~
      */
@@ -271,11 +271,11 @@ impl<'self> FromBase64 for &'self str {
      *
      * fn main () {
      *     let hello_str = "Hello, World".to_base64(standard);
-     *     println(fmt!("%s",hello_str));
+     *     printfln!("%s", hello_str);
      *     let bytes = hello_str.from_base64();
-     *     println(fmt!("%?",bytes));
+     *     printfln!("%?", bytes);
      *     let result_str = str::from_bytes(bytes);
-     *     println(fmt!("%s",result_str));
+     *     printfln!("%s", result_str);
      * }
      * ~~~
      */
index d8f21b460138e941e3ce2863b5a6c9cabcb53347..5e37efa647ad695225c7b8315fdc761879e208e1 100644 (file)
@@ -19,7 +19,7 @@
  * # fn make_a_sandwich() {};
  * let mut delayed_fib = extra::future::spawn (|| fib(5000) );
  * make_a_sandwich();
- * println(fmt!("fib(5000) = %?", delayed_fib.get()))
+ * printfln!("fib(5000) = %?", delayed_fib.get())
  * ~~~
  */
 
index 07a1c6744040e5dc6589d31d99217f5d3ee99f7f..ad452125239de6404b5e2c55a14c3c4f6a4d7d6a 100644 (file)
@@ -44,7 +44,7 @@
  *    }
  *
  *    fn print_usage(program: &str, _opts: &[Opt]) {
- *        println(fmt!("Usage: %s [options]", program));
+ *        printfln!("Usage: %s [options]", program);
  *        println("-o\t\tOutput");
  *        println("-h --help\tUsage");
  *    }
index 5602964245f37a357b7b88eff6a781105c098b0c..6a7f0607dd66aa3240f999534240302839ec4ca0 100644 (file)
@@ -41,7 +41,7 @@ pub enum Json {
 }
 
 pub type List = ~[Json];
-pub type Object = HashMap<~str, Json>;
+pub type Object = TreeMap<~str, Json>;
 
 #[deriving(Eq)]
 /// If an error occurs while parsing some JSON, this is the structure which is
@@ -809,7 +809,7 @@ fn parse_object(&mut self) -> Result<Json, Error> {
         self.bump();
         self.parse_whitespace();
 
-        let mut values = ~HashMap::new();
+        let mut values = ~TreeMap::new();
 
         if self.ch == '}' {
           self.bump();
@@ -1087,7 +1087,7 @@ fn read_map<T>(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T {
         let len = match self.stack.pop() {
             Object(obj) => {
                 let len = obj.len();
-                for obj.consume().advance |(key, value)| {
+                for obj.consume_iter().advance |(key, value)| {
                     self.stack.push(value);
                     self.stack.push(String(key));
                 }
@@ -1294,9 +1294,9 @@ impl<A:ToJson> ToJson for ~[A] {
     fn to_json(&self) -> Json { List(self.map(|elt| elt.to_json())) }
 }
 
-impl<A:ToJson> ToJson for HashMap<~str, A> {
+impl<A:ToJson> ToJson for TreeMap<~str, A> {
     fn to_json(&self) -> Json {
-        let mut d = HashMap::new();
+        let mut d = TreeMap::new();
         for self.iter().advance |(key, value)| {
             d.insert((*key).clone(), value.to_json());
         }
@@ -1304,9 +1304,9 @@ fn to_json(&self) -> Json {
     }
 }
 
-impl<A:ToJson> ToJson for TreeMap<~str, A> {
+impl<A:ToJson> ToJson for HashMap<~str, A> {
     fn to_json(&self) -> Json {
-        let mut d = HashMap::new();
+        let mut d = TreeMap::new();
         for self.iter().advance |(key, value)| {
             d.insert((*key).clone(), value.to_json());
         }
@@ -1338,11 +1338,11 @@ mod tests {
 
     use super::*;
 
-    use std::hashmap::HashMap;
     use std::io;
     use std::result;
 
-    use extra::serialize::Decodable;
+    use serialize::Decodable;
+    use treemap::TreeMap;
 
     #[deriving(Eq, Encodable, Decodable)]
     enum Animal {
@@ -1363,7 +1363,7 @@ struct Outer {
     }
 
     fn mk_object(items: &[(~str, Json)]) -> Json {
-        let mut d = ~HashMap::new();
+        let mut d = ~TreeMap::new();
 
         for items.iter().advance |item| {
             match *item {
@@ -1954,7 +1954,7 @@ fn test_decode_enum() {
     fn test_decode_map() {
         let s = ~"{\"a\": \"Dog\", \"b\": [\"Frog\", \"Henry\", 349]}";
         let mut decoder = Decoder(from_str(s).unwrap());
-        let mut map: HashMap<~str, Animal> = Decodable::decode(&mut decoder);
+        let mut map: TreeMap<~str, Animal> = Decodable::decode(&mut decoder);
 
         assert_eq!(map.pop(&~"a"), Some(Dog));
         assert_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349)));
index 8d6b146e1426436c47124e4b1d53d00948af6a07..04d6b8ebca5fe38a8a637d01c504ddbfbd3f6562 100644 (file)
 
 
 use std::cast;
-use std::libc::{c_void, size_t, malloc, free};
 use std::ptr;
-use std::sys;
 use std::unstable::intrinsics;
 
+// Convert ~T into *mut T without dropping it
+#[inline]
+unsafe fn owned_to_raw<T>(mut box: ~T) -> *mut T {
+    let ptr = ptr::to_mut_unsafe_ptr(box);
+    intrinsics::forget(box);
+    ptr
+}
+
 struct RcBox<T> {
     value: T,
     count: uint
@@ -42,21 +48,20 @@ pub struct Rc<T> {
 
 impl<T> Rc<T> {
     unsafe fn new(value: T) -> Rc<T> {
-        let ptr = malloc(sys::size_of::<RcBox<T>>() as size_t) as *mut RcBox<T>;
-        assert!(!ptr::is_null(ptr));
-        intrinsics::move_val_init(&mut *ptr, RcBox{value: value, count: 1});
-        Rc{ptr: ptr}
+        Rc{ptr: owned_to_raw(~RcBox{value: value, count: 1})}
     }
 }
 
-// FIXME: #6516: should be a static method
-pub fn rc_from_owned<T: Send>(value: T) -> Rc<T> {
-    unsafe { Rc::new(value) }
+impl<T: Send> Rc<T> {
+    pub fn from_owned(value: T) -> Rc<T> {
+        unsafe { Rc::new(value) }
+    }
 }
 
-// FIXME: #6516: should be a static method
-pub fn rc_from_const<T: Freeze>(value: T) -> Rc<T> {
-    unsafe { Rc::new(value) }
+impl<T: Freeze> Rc<T> {
+    pub fn from_const(value: T) -> Rc<T> {
+        unsafe { Rc::new(value) }
+    }
 }
 
 impl<T> Rc<T> {
@@ -73,8 +78,7 @@ fn drop(&self) {
             if self.ptr.is_not_null() {
                 (*self.ptr).count -= 1;
                 if (*self.ptr).count == 0 {
-                    ptr::read_ptr(self.ptr);
-                    free(self.ptr as *c_void)
+                    let _: ~T = cast::transmute(self.ptr);
                 }
             }
         }
@@ -107,7 +111,7 @@ mod test_rc {
 
     #[test]
     fn test_clone() {
-        let x = rc_from_owned(Cell::new(5));
+        let x = Rc::from_owned(Cell::new(5));
         let y = x.clone();
         do x.borrow().with_mut_ref |inner| {
             *inner = 20;
@@ -117,7 +121,7 @@ fn test_clone() {
 
     #[test]
     fn test_deep_clone() {
-        let x = rc_from_owned(Cell::new(5));
+        let x = Rc::from_owned(Cell::new(5));
         let y = x.deep_clone();
         do x.borrow().with_mut_ref |inner| {
             *inner = 20;
@@ -127,13 +131,13 @@ fn test_deep_clone() {
 
     #[test]
     fn test_simple() {
-        let x = rc_from_const(5);
+        let x = Rc::from_const(5);
         assert_eq!(*x.borrow(), 5);
     }
 
     #[test]
     fn test_simple_clone() {
-        let x = rc_from_const(5);
+        let x = Rc::from_const(5);
         let y = x.clone();
         assert_eq!(*x.borrow(), 5);
         assert_eq!(*y.borrow(), 5);
@@ -141,17 +145,11 @@ fn test_simple_clone() {
 
     #[test]
     fn test_destructor() {
-        let x = rc_from_owned(~5);
+        let x = Rc::from_owned(~5);
         assert_eq!(**x.borrow(), 5);
     }
 }
 
-#[abi = "rust-intrinsic"]
-extern "rust-intrinsic" {
-    fn init<T>() -> T;
-    fn uninit<T>() -> T;
-}
-
 #[deriving(Eq)]
 enum Borrow {
     Mutable,
@@ -175,21 +173,20 @@ pub struct RcMut<T> {
 
 impl<T> RcMut<T> {
     unsafe fn new(value: T) -> RcMut<T> {
-        let ptr = malloc(sys::size_of::<RcMutBox<T>>() as size_t) as *mut RcMutBox<T>;
-        assert!(!ptr::is_null(ptr));
-        intrinsics::move_val_init(&mut *ptr, RcMutBox{value: value, count: 1, borrow: Nothing});
-        RcMut{ptr: ptr}
+        RcMut{ptr: owned_to_raw(~RcMutBox{value: value, count: 1, borrow: Nothing})}
     }
 }
 
-// FIXME: #6516: should be a static method
-pub fn rc_mut_from_owned<T: Send>(value: T) -> RcMut<T> {
-    unsafe { RcMut::new(value) }
+impl<T: Send> RcMut<T> {
+    pub fn from_owned(value: T) -> RcMut<T> {
+        unsafe { RcMut::new(value) }
+    }
 }
 
-// FIXME: #6516: should be a static method
-pub fn rc_mut_from_const<T: Freeze>(value: T) -> RcMut<T> {
-    unsafe { RcMut::new(value) }
+impl<T: Freeze> RcMut<T> {
+    pub fn from_const(value: T) -> RcMut<T> {
+        unsafe { RcMut::new(value) }
+    }
 }
 
 impl<T> RcMut<T> {
@@ -226,8 +223,7 @@ fn drop(&self) {
             if self.ptr.is_not_null() {
                 (*self.ptr).count -= 1;
                 if (*self.ptr).count == 0 {
-                    ptr::replace_ptr(self.ptr, uninit());
-                    free(self.ptr as *c_void)
+                    let _: ~T = cast::transmute(self.ptr);
                 }
             }
         }
@@ -262,7 +258,7 @@ mod test_rc_mut {
 
     #[test]
     fn test_clone() {
-        let x = rc_mut_from_owned(5);
+        let x = RcMut::from_owned(5);
         let y = x.clone();
         do x.with_mut_borrow |value| {
             *value = 20;
@@ -274,7 +270,7 @@ fn test_clone() {
 
     #[test]
     fn test_deep_clone() {
-        let x = rc_mut_from_const(5);
+        let x = RcMut::from_const(5);
         let y = x.deep_clone();
         do x.with_mut_borrow |value| {
             *value = 20;
@@ -286,7 +282,7 @@ fn test_deep_clone() {
 
     #[test]
     fn borrow_many() {
-        let x = rc_mut_from_owned(5);
+        let x = RcMut::from_owned(5);
         let y = x.clone();
 
         do x.with_borrow |a| {
@@ -302,7 +298,7 @@ fn borrow_many() {
 
     #[test]
     fn modify() {
-        let x = rc_mut_from_const(5);
+        let x = RcMut::from_const(5);
         let y = x.clone();
 
         do y.with_mut_borrow |a| {
@@ -317,14 +313,14 @@ fn modify() {
 
     #[test]
     fn release_immutable() {
-        let x = rc_mut_from_owned(5);
+        let x = RcMut::from_owned(5);
         do x.with_borrow |_| {}
         do x.with_mut_borrow |_| {}
     }
 
     #[test]
     fn release_mutable() {
-        let x = rc_mut_from_const(5);
+        let x = RcMut::from_const(5);
         do x.with_mut_borrow |_| {}
         do x.with_borrow |_| {}
     }
@@ -332,7 +328,7 @@ fn release_mutable() {
     #[test]
     #[should_fail]
     fn frozen() {
-        let x = rc_mut_from_owned(5);
+        let x = RcMut::from_owned(5);
         let y = x.clone();
 
         do x.with_borrow |_| {
@@ -344,7 +340,7 @@ fn frozen() {
     #[test]
     #[should_fail]
     fn mutable_dupe() {
-        let x = rc_mut_from_const(5);
+        let x = RcMut::from_const(5);
         let y = x.clone();
 
         do x.with_mut_borrow |_| {
@@ -356,7 +352,7 @@ fn mutable_dupe() {
     #[test]
     #[should_fail]
     fn mutable_freeze() {
-        let x = rc_mut_from_owned(5);
+        let x = RcMut::from_owned(5);
         let y = x.clone();
 
         do x.with_mut_borrow |_| {
@@ -368,7 +364,7 @@ fn mutable_freeze() {
     #[test]
     #[should_fail]
     fn restore_freeze() {
-        let x = rc_mut_from_const(5);
+        let x = RcMut::from_const(5);
         let y = x.clone();
 
         do x.with_borrow |_| {
index 49d5dd93869535506e0b24a75343ade58e38a14d..edd16fe88f425196b0ad96201caf98858d90ffc3 100644 (file)
@@ -103,6 +103,6 @@ fn test_task_pool() {
     };
     let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
     for 8.times {
-        pool.execute(|i| println(fmt!("Hello from thread %u!", *i)));
+        pool.execute(|i| printfln!("Hello from thread %u!", *i));
     }
 }
index 910c95eb8f9ae7a237d58be5214cc362a8e1734b..a5705d08b72bed1ef28c903c8a1c181cd9136e7d 100644 (file)
@@ -38,7 +38,6 @@
 use std::to_str::ToStr;
 use std::u64;
 use std::f64;
-use std::hashmap::HashMap;
 use std::os;
 
 
@@ -852,7 +851,7 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult {
 
 impl ToJson for Metric {
     fn to_json(&self) -> json::Json {
-        let mut map = ~HashMap::new();
+        let mut map = ~TreeMap::new();
         map.insert(~"value", json::Number(self.value as float));
         map.insert(~"noise", json::Number(self.noise as float));
         json::Object(map)
index f9b2c8429cff7a2f4f811c6851bfdedf8bcdf2d6..303ae6a6d1de147552c936844354f3ac8039e4c9 100644 (file)
@@ -204,6 +204,19 @@ pub fn each_value_reverse(&self, f: &fn(&V) -> bool) -> bool {
     pub fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
         TreeMapIterator{stack: ~[], node: &self.root, remaining: self.length}
     }
+
+    /// Get a lazy iterator that consumes the treemap.
+    pub fn consume_iter(self) -> TreeMapConsumeIterator<K, V> {
+        let TreeMap { root: root, length: length } = self;
+        let stk = match root {
+            None => ~[],
+            Some(~tn) => ~[tn]
+        };
+        TreeMapConsumeIterator {
+            stack: stk,
+            remaining: length
+        }
+    }
 }
 
 /// Lazy forward iterator over a map
@@ -241,6 +254,56 @@ fn size_hint(&self) -> (uint, Option<uint>) {
     }
 }
 
+/// Lazy forward iterator over a map that consumes the map while iterating
+pub struct TreeMapConsumeIterator<K, V> {
+    priv stack: ~[TreeNode<K, V>],
+    priv remaining: uint
+}
+
+impl<K, V> Iterator<(K, V)> for TreeMapConsumeIterator<K,V> {
+    #[inline]
+    fn next(&mut self) -> Option<(K, V)> {
+        while !self.stack.is_empty() {
+            let TreeNode {
+                key: key,
+                value: value,
+                left: left,
+                right: right,
+                level: level
+            } = self.stack.pop();
+
+            match left {
+                Some(~left) => {
+                    let n = TreeNode {
+                        key: key,
+                        value: value,
+                        left: None,
+                        right: right,
+                        level: level
+                    };
+                    self.stack.push(n);
+                    self.stack.push(left);
+                }
+                None => {
+                    match right {
+                        Some(~right) => self.stack.push(right),
+                        None => ()
+                    }
+                    self.remaining -= 1;
+                    return Some((key, value))
+                }
+            }
+        }
+        None
+    }
+
+    #[inline]
+    fn size_hint(&self) -> (uint, Option<uint>) {
+        (self.remaining, Some(self.remaining))
+    }
+
+}
+
 impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> {
     /// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
     #[inline]
@@ -1200,7 +1263,7 @@ fn test_iterator() {
 
         let mut n = 0;
         for m.iter().advance |x| {
-            println(fmt!("%?", x));
+            printfln!(x);
             assert_eq!(*x, n);
             n += 1
         }
index ea13f33199912183d7ea39a31ac2257a76c765d8..42210d0cd895c392ce8237492f6b1a7e2c527b02 100644 (file)
 use json;
 use sha1::Sha1;
 use serialize::{Encoder, Encodable, Decoder, Decodable};
-use sort;
+use arc::{ARC,RWARC};
+use treemap::TreeMap;
 
 use std::cell::Cell;
-use std::cmp;
 use std::comm::{PortOne, oneshot, send_one, recv_one};
 use std::either::{Either, Left, Right};
-use std::hashmap::HashMap;
 use std::io;
 use std::result;
 use std::run;
 use std::task;
-use std::to_bytes;
 
 /**
 *
 *
 */
 
-#[deriving(Clone, Eq, Encodable, Decodable)]
+#[deriving(Clone, Eq, Encodable, Decodable, TotalOrd, TotalEq)]
 struct WorkKey {
     kind: ~str,
     name: ~str
 }
 
-impl to_bytes::IterBytes for WorkKey {
-    #[inline]
-    fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
-        self.kind.iter_bytes(lsb0, |b| f(b)) && self.name.iter_bytes(lsb0, |b| f(b))
-    }
-}
-
-impl cmp::Ord for WorkKey {
-    fn lt(&self, other: &WorkKey) -> bool {
-        self.kind < other.kind ||
-            (self.kind == other.kind &&
-             self.name < other.name)
-    }
-    fn le(&self, other: &WorkKey) -> bool {
-        self.lt(other) || self.eq(other)
-    }
-    fn ge(&self, other: &WorkKey) -> bool {
-        self.gt(other) || self.eq(other)
-    }
-    fn gt(&self, other: &WorkKey) -> bool {
-        ! self.le(other)
-    }
-}
-
 impl WorkKey {
     pub fn new(kind: &str, name: &str) -> WorkKey {
         WorkKey {
@@ -135,48 +109,30 @@ pub fn new(kind: &str, name: &str) -> WorkKey {
     }
 }
 
-struct WorkMap(HashMap<WorkKey, ~str>);
-
-impl Clone for WorkMap {
-    fn clone(&self) -> WorkMap {
-        WorkMap((**self).clone())
-    }
-}
+#[deriving(Clone, Eq, Encodable, Decodable)]
+struct WorkMap(TreeMap<WorkKey, ~str>);
 
 impl WorkMap {
-    fn new() -> WorkMap { WorkMap(HashMap::new()) }
-}
-
-impl<S:Encoder> Encodable<S> for WorkMap {
-    fn encode(&self, s: &mut S) {
-        let mut d = ~[];
-        for self.iter().advance |(k, v)| {
-            d.push(((*k).clone(), (*v).clone()))
-        }
-        sort::tim_sort(d);
-        d.encode(s)
-    }
-}
-
-impl<D:Decoder> Decodable<D> for WorkMap {
-    fn decode(d: &mut D) -> WorkMap {
-        let v : ~[(WorkKey,~str)] = Decodable::decode(d);
-        let mut w = WorkMap::new();
-        for v.iter().advance |pair| {
-            w.insert(pair.first(), pair.second());
-        }
-        w
-    }
+    fn new() -> WorkMap { WorkMap(TreeMap::new()) }
 }
 
 struct Database {
     db_filename: Path,
-    db_cache: HashMap<~str, ~str>,
+    db_cache: TreeMap<~str, ~str>,
     db_dirty: bool
 }
 
 impl Database {
-    pub fn prepare(&mut self,
+
+    pub fn new(p: Path) -> Database {
+        Database {
+            db_filename: p,
+            db_cache: TreeMap::new(),
+            db_dirty: false
+        }
+    }
+
+    pub fn prepare(&self,
                    fn_name: &str,
                    declared_inputs: &WorkMap)
                    -> Option<(WorkMap, WorkMap, ~str)> {
@@ -208,22 +164,27 @@ struct Logger {
 }
 
 impl Logger {
+
+    pub fn new() -> Logger {
+        Logger { a: () }
+    }
+
     pub fn info(&self, i: &str) {
         io::println(~"workcache: " + i);
     }
 }
 
+#[deriving(Clone)]
 struct Context {
-    db: @mut Database,
-    logger: @mut Logger,
-    cfg: @json::Object,
-    freshness: HashMap<~str,@fn(&str,&str)->bool>
+    db: RWARC<Database>,
+    logger: RWARC<Logger>,
+    cfg: ARC<json::Object>,
+    freshness: ARC<TreeMap<~str,extern fn(&str,&str)->bool>>
 }
 
-#[deriving(Clone)]
-struct Prep {
-    ctxt: @Context,
-    fn_name: ~str,
+struct Prep<'self> {
+    ctxt: &'self Context,
+    fn_name: &'self str,
     declared_inputs: WorkMap,
 }
 
@@ -232,8 +193,8 @@ struct Exec {
     discovered_outputs: WorkMap
 }
 
-struct Work<T> {
-    prep: @mut Prep,
+struct Work<'self, T> {
+    prep: &'self Prep<'self>,
     res: Option<Either<T,PortOne<(Exec,T)>>>
 }
 
@@ -267,43 +228,40 @@ fn digest_file(path: &Path) -> ~str {
 }
 
 impl Context {
-    pub fn new(db: @mut Database, lg: @mut Logger, cfg: @json::Object)
-               -> Context {
+
+    pub fn new(db: RWARC<Database>,
+               lg: RWARC<Logger>,
+               cfg: ARC<json::Object>) -> Context {
         Context {
             db: db,
             logger: lg,
             cfg: cfg,
-            freshness: HashMap::new()
+            freshness: ARC(TreeMap::new())
         }
     }
 
-    pub fn prep<T:Send +
-                  Encodable<json::Encoder> +
-                  Decodable<json::Decoder>>(@self, // FIXME(#5121)
-                                            fn_name:&str,
-                                            blk: &fn(@mut Prep)->Work<T>)
-                                            -> Work<T> {
-        let p = @mut Prep {
-            ctxt: self,
-            fn_name: fn_name.to_owned(),
-            declared_inputs: WorkMap::new()
-        };
-        blk(p)
+    pub fn prep<'a>(&'a self, fn_name: &'a str) -> Prep<'a> {
+        Prep::new(self, fn_name)
     }
-}
 
+    pub fn with_prep<'a, T>(&'a self, fn_name: &'a str, blk: &fn(p: &mut Prep) -> T) -> T {
+        let mut p = self.prep(fn_name);
+        blk(&mut p)
+    }
 
-trait TPrep {
-    fn declare_input(&mut self, kind:&str, name:&str, val:&str);
-    fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool;
-    fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool;
-    fn exec<T:Send +
-              Encodable<json::Encoder> +
-              Decodable<json::Decoder>>( // FIXME(#5121)
-        &self, blk: ~fn(&Exec) -> T) -> Work<T>;
 }
 
-impl TPrep for Prep {
+impl<'self> Prep<'self> {
+    fn new(ctxt: &'self Context, fn_name: &'self str) -> Prep<'self> {
+        Prep {
+            ctxt: ctxt,
+            fn_name: fn_name,
+            declared_inputs: WorkMap::new()
+        }
+    }
+}
+
+impl<'self> Prep<'self> {
     fn declare_input(&mut self, kind:&str, name:&str, val:&str) {
         self.declared_inputs.insert(WorkKey::new(kind, name),
                                  val.to_owned());
@@ -312,16 +270,21 @@ fn declare_input(&mut self, kind:&str, name:&str, val:&str) {
     fn is_fresh(&self, cat: &str, kind: &str,
                 name: &str, val: &str) -> bool {
         let k = kind.to_owned();
-        let f = (*self.ctxt.freshness.get(&k))(name, val);
-        let lg = self.ctxt.logger;
-            if f {
+        let f = self.ctxt.freshness.get().find(&k);
+        let fresh = match f {
+            None => fail!("missing freshness-function for '%s'", kind),
+            Some(f) => (*f)(name, val)
+        };
+        do self.ctxt.logger.write |lg| {
+            if fresh {
                 lg.info(fmt!("%s %s:%s is fresh",
                              cat, kind, name));
             } else {
                 lg.info(fmt!("%s %s:%s is not fresh",
                              cat, kind, name))
             }
-        f
+        };
+        fresh
     }
 
     fn all_fresh(&self, cat: &str, map: &WorkMap) -> bool {
@@ -334,20 +297,28 @@ fn all_fresh(&self, cat: &str, map: &WorkMap) -> bool {
     }
 
     fn exec<T:Send +
-              Encodable<json::Encoder> +
-              Decodable<json::Decoder>>( // FIXME(#5121)
-            &self, blk: ~fn(&Exec) -> T) -> Work<T> {
+        Encodable<json::Encoder> +
+        Decodable<json::Decoder>>(
+            &'self self, blk: ~fn(&Exec) -> T) -> T {
+        self.exec_work(blk).unwrap()
+    }
+
+    fn exec_work<T:Send +
+        Encodable<json::Encoder> +
+        Decodable<json::Decoder>>( // FIXME(#5121)
+            &'self self, blk: ~fn(&Exec) -> T) -> Work<'self, T> {
         let mut bo = Some(blk);
 
-        let cached = self.ctxt.db.prepare(self.fn_name, &self.declared_inputs);
+        let cached = do self.ctxt.db.read |db| {
+            db.prepare(self.fn_name, &self.declared_inputs)
+        };
 
-        match cached {
+        let res = match cached {
             Some((ref disc_in, ref disc_out, ref res))
-            if self.all_fresh("declared input",
-                              &self.declared_inputs) &&
-            self.all_fresh("discovered input", disc_in) &&
-            self.all_fresh("discovered output", disc_out) => {
-                Work::new(@mut (*self).clone(), Left(json_decode(*res)))
+            if self.all_fresh("declared input",&self.declared_inputs) &&
+               self.all_fresh("discovered input", disc_in) &&
+               self.all_fresh("discovered output", disc_out) => {
+                Left(json_decode(*res))
             }
 
             _ => {
@@ -364,72 +335,72 @@ fn exec<T:Send +
                     let v = blk(&exe);
                     send_one(chan, (exe, v));
                 }
-                Work::new(@mut (*self).clone(), Right(port))
+                Right(port)
             }
-        }
+        };
+        Work::new(self, res)
     }
 }
 
-impl<T:Send +
+impl<'self, T:Send +
        Encodable<json::Encoder> +
-       Decodable<json::Decoder>> Work<T> { // FIXME(#5121)
-    pub fn new(p: @mut Prep, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
+       Decodable<json::Decoder>>
+    Work<'self, T> { // FIXME(#5121)
+
+    pub fn new(p: &'self Prep<'self>, e: Either<T,PortOne<(Exec,T)>>) -> Work<'self, T> {
         Work { prep: p, res: Some(e) }
     }
-}
 
-// FIXME (#3724): movable self. This should be in impl Work.
-fn unwrap<T:Send +
-            Encodable<json::Encoder> +
-            Decodable<json::Decoder>>( // FIXME(#5121)
-        w: Work<T>) -> T {
-    let mut ww = w;
-    let s = ww.res.take();
-
-    match s {
-        None => fail!(),
-        Some(Left(v)) => v,
-        Some(Right(port)) => {
-            let (exe, v) = recv_one(port);
-
-            let s = json_encode(&v);
-
-            let p = &*ww.prep;
-            let db = p.ctxt.db;
-            db.cache(p.fn_name,
-                 &p.declared_inputs,
-                 &exe.discovered_inputs,
-                 &exe.discovered_outputs,
-                 s);
-            v
+    pub fn unwrap(self) -> T {
+        let Work { prep, res } = self;
+        match res {
+            None => fail!(),
+            Some(Left(v)) => v,
+            Some(Right(port)) => {
+                let (exe, v) = recv_one(port);
+                let s = json_encode(&v);
+                do prep.ctxt.db.write |db| {
+                    db.cache(prep.fn_name,
+                             &prep.declared_inputs,
+                             &exe.discovered_inputs,
+                             &exe.discovered_outputs,
+                             s);
+                }
+                v
+            }
         }
     }
 }
 
+
 //#[test]
 fn test() {
     use std::io::WriterUtil;
 
-    let db = @mut Database { db_filename: Path("db.json"),
-                             db_cache: HashMap::new(),
-                             db_dirty: false };
-    let lg = @mut Logger { a: () };
-    let cfg = @HashMap::new();
-    let cx = @Context::new(db, lg, cfg);
-    let w:Work<~str> = do cx.prep("test1") |prep| {
-        let pth = Path("foo.c");
-        {
-            let file = io::file_writer(&pth, [io::Create]).unwrap();
-            file.write_str("int main() { return 0; }");
-        }
+    let pth = Path("foo.c");
+    {
+        let r = io::file_writer(&pth, [io::Create]);
+        r.get_ref().write_str("int main() { return 0; }");
+    }
+
+    let cx = Context::new(RWARC(Database::new(Path("db.json"))),
+                          RWARC(Logger::new()),
+                          ARC(TreeMap::new()));
+
+    let s = do cx.with_prep("test1") |prep| {
+
+        let subcx = cx.clone();
 
         prep.declare_input("file", pth.to_str(), digest_file(&pth));
         do prep.exec |_exe| {
             let out = Path("foo.o");
             run::process_status("gcc", [~"foo.c", ~"-o", out.to_str()]);
+
+            let _proof_of_concept = subcx.prep("subfn");
+            // Could run sub-rules inside here.
+
             out.to_str()
         }
     };
-    let s = unwrap(w);
     io::println(s);
 }
index bc97ef0e8ca4d9541334773323127dfc25f1f05c..c47c573d16fbe3bbae89eef2f3649f9b1a026554 100644 (file)
@@ -132,13 +132,13 @@ fn print_usage(command_string: ~str) -> ValidUsage {
         match find_cmd(command_string) {
             Some(command) => {
                 match command.action {
-                    CallMain(prog, _) => io::println(fmt!(
+                    CallMain(prog, _) => printfln!(
                         "The %s command is an alias for the %s program.",
-                        command.cmd, prog)),
+                        command.cmd, prog),
                     _       => ()
                 }
                 match command.usage_full {
-                    UsgStr(msg) => io::println(fmt!("%s\n", msg)),
+                    UsgStr(msg) => printfln!("%s\n", msg),
                     UsgCall(f)  => f(),
                 }
                 Valid(0)
@@ -211,8 +211,7 @@ fn usage() {
 
     for COMMANDS.iter().advance |command| {
         let padding = " ".repeat(INDENT - command.cmd.len());
-        io::println(fmt!("    %s%s%s",
-                         command.cmd, padding, command.usage_line));
+        printfln!("    %s%s%s", command.cmd, padding, command.usage_line);
     }
 
     io::print(
index f9dc88074d3b15044ec670bd2a9c32c82faa592f..48a685058bbd5ce96e2cce4fbffa725ad87a2770 100644 (file)
@@ -191,15 +191,15 @@ pub fn list_passes() {
 
     io::println("\nAnalysis Passes:");
     for analysis_passes.iter().advance |&(name, desc)| {
-        io::println(fmt!("    %-30s -- %s", name, desc));
+        printfln!("    %-30s -- %s", name, desc);
     }
     io::println("\nTransformation Passes:");
     for transform_passes.iter().advance |&(name, desc)| {
-        io::println(fmt!("    %-30s -- %s", name, desc));
+        printfln!("    %-30s -- %s", name, desc);
     }
     io::println("\nUtility Passes:");
     for utility_passes.iter().advance |&(name, desc)| {
-        io::println(fmt!("    %-30s -- %s", name, desc));
+        printfln!("    %-30s -- %s", name, desc);
     }
 }
 
@@ -344,7 +344,7 @@ fn passes_exist() {
     if failed.len() > 0 {
         io::println("Some passes don't exist:");
         for failed.iter().advance |&n| {
-            io::println(fmt!("    %s", n));
+            printfln!("    %s", n);
         }
         fail!();
     }
index 3c02609def11e9e930305e2f1286d714bf9026df..78e1a579d741b1cf28f2cbb0edbb6b763acc9e7e 100644 (file)
@@ -1624,16 +1624,16 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
         }
 
         io::println("metadata stats:");
-        io::println(fmt!("    inline bytes: %u", ecx.stats.inline_bytes));
-        io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes));
-        io::println(fmt!("       dep bytes: %u", ecx.stats.dep_bytes));
-        io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes));
-        io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes));
-        io::println(fmt!("      misc bytes: %u", ecx.stats.misc_bytes));
-        io::println(fmt!("      item bytes: %u", ecx.stats.item_bytes));
-        io::println(fmt!("     index bytes: %u", ecx.stats.index_bytes));
-        io::println(fmt!("      zero bytes: %u", ecx.stats.zero_bytes));
-        io::println(fmt!("     total bytes: %u", ecx.stats.total_bytes));
+        printfln!("    inline bytes: %u", ecx.stats.inline_bytes);
+        printfln!(" attribute bytes: %u", ecx.stats.attr_bytes);
+        printfln!("       dep bytes: %u", ecx.stats.dep_bytes);
+        printfln!(" lang item bytes: %u", ecx.stats.lang_item_bytes);
+        printfln!(" link args bytes: %u", ecx.stats.link_args_bytes);
+        printfln!("      misc bytes: %u", ecx.stats.misc_bytes);
+        printfln!("      item bytes: %u", ecx.stats.item_bytes);
+        printfln!("     index bytes: %u", ecx.stats.index_bytes);
+        printfln!("      zero bytes: %u", ecx.stats.zero_bytes);
+        printfln!("     total bytes: %u", ecx.stats.total_bytes);
     }
 
     // Pad this, since something (LLVM, presumably) is cutting off the
index 31fb1765e43bcded52d6dc492f52157f547c259d..fc34e873ef95eb2942d177f038ece87d28cbe0a3 100644 (file)
@@ -232,7 +232,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                     self.bccx.span_err(
                         new_loan.span,
                         fmt!("cannot borrow `%s` as %s because \
-                              it is also borrowed as %s"
+                              it is also borrowed as %s",
                              self.bccx.loan_path_to_str(new_loan.loan_path),
                              self.bccx.mut_to_str(new_loan.mutbl),
                              self.bccx.mut_to_str(old_loan.mutbl)));
@@ -320,7 +320,7 @@ pub fn check_assignment(&self, expr: @ast::expr) {
         // Otherwise, just a plain error.
         self.bccx.span_err(
             expr.span,
-            fmt!("cannot assign to %s %s"
+            fmt!("cannot assign to %s %s",
                  cmt.mutbl.to_user_str(),
                  self.bccx.cmt_to_str(cmt)));
         return;
index b307280729ed47f4789866bad76faa81e3274368..bf9b4fcaedfa6665a5da2d94456a5b8438385578 100644 (file)
@@ -93,16 +93,16 @@ pub fn check_crate(
 
     if tcx.sess.borrowck_stats() {
         io::println("--- borrowck stats ---");
-        io::println(fmt!("paths requiring guarantees: %u",
-                        bccx.stats.guaranteed_paths));
-        io::println(fmt!("paths requiring loans     : %s",
-                         make_stat(bccx, bccx.stats.loaned_paths_same)));
-        io::println(fmt!("paths requiring imm loans : %s",
-                         make_stat(bccx, bccx.stats.loaned_paths_imm)));
-        io::println(fmt!("stable paths              : %s",
-                         make_stat(bccx, bccx.stats.stable_paths)));
-        io::println(fmt!("paths requiring purity    : %s",
-                         make_stat(bccx, bccx.stats.req_pure_paths)));
+        printfln!("paths requiring guarantees: %u",
+                  bccx.stats.guaranteed_paths);
+        printfln!("paths requiring loans     : %s",
+                  make_stat(bccx, bccx.stats.loaned_paths_same));
+        printfln!("paths requiring imm loans : %s",
+                  make_stat(bccx, bccx.stats.loaned_paths_imm));
+        printfln!("stable paths              : %s",
+                  make_stat(bccx, bccx.stats.stable_paths));
+        printfln!("paths requiring purity    : %s",
+                  make_stat(bccx, bccx.stats.req_pure_paths));
     }
 
     return (bccx.root_map, bccx.write_guard_map);
index bffc8532af5d86df130f0d4b56036a8c2aa4d3e6..843aa2b749cfa58d944299ce5c896e00f2386069 100644 (file)
@@ -258,7 +258,7 @@ pub enum opt_result {
     lower_bound(Result),
     range_result(Result, Result),
 }
-pub fn trans_opt(bcx: block, o: &Opt) -> opt_result {
+pub fn trans_opt(bcx: @mut Block, o: &Opt) -> opt_result {
     let _icx = push_ctxt("match::trans_opt");
     let ccx = bcx.ccx();
     let bcx = bcx;
@@ -292,7 +292,7 @@ pub fn trans_opt(bcx: block, o: &Opt) -> opt_result {
     }
 }
 
-pub fn variant_opt(bcx: block, pat_id: ast::node_id)
+pub fn variant_opt(bcx: @mut Block, pat_id: ast::node_id)
     -> Opt {
     let ccx = bcx.ccx();
     match ccx.tcx.def_map.get_copy(&pat_id) {
@@ -342,7 +342,7 @@ pub struct BindingInfo {
 
 #[deriving(Clone)]
 pub struct ArmData<'self> {
-    bodycx: block,
+    bodycx: @mut Block,
     arm: &'self ast::arm,
     bindings_map: @BindingsMap
 }
@@ -353,7 +353,7 @@ pub struct Match<'self> {
     data: ArmData<'self>
 }
 
-pub fn match_to_str(bcx: block, m: &Match) -> ~str {
+pub fn match_to_str(bcx: @mut Block, m: &Match) -> ~str {
     if bcx.sess().verbose() {
         // for many programs, this just take too long to serialize
         fmt!("%?", m.pats.map(|p| pat_to_str(*p, bcx.sess().intr())))
@@ -362,7 +362,7 @@ pub fn match_to_str(bcx: block, m: &Match) -> ~str {
     }
 }
 
-pub fn matches_to_str(bcx: block, m: &[Match]) -> ~str {
+pub fn matches_to_str(bcx: @mut Block, m: &[Match]) -> ~str {
     fmt!("%?", m.map(|n| match_to_str(bcx, n)))
 }
 
@@ -376,7 +376,7 @@ pub fn has_nested_bindings(m: &[Match], col: uint) -> bool {
     return false;
 }
 
-pub fn expand_nested_bindings<'r>(bcx: block,
+pub fn expand_nested_bindings<'r>(bcx: @mut Block,
                                   m: &[Match<'r>],
                                   col: uint,
                                   val: ValueRef)
@@ -411,7 +411,7 @@ pub fn expand_nested_bindings<'r>(bcx: block,
     }
 }
 
-pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
+pub fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) {
     if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
         bcx.sess().span_bug(
             p.span,
@@ -422,7 +422,7 @@ pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
 
 pub type enter_pat<'self> = &'self fn(@ast::pat) -> Option<~[@ast::pat]>;
 
-pub fn enter_match<'r>(bcx: block,
+pub fn enter_match<'r>(bcx: @mut Block,
                        dm: DefMap,
                        m: &[Match<'r>],
                        col: uint,
@@ -472,7 +472,7 @@ pub fn enter_match<'r>(bcx: block,
     return result;
 }
 
-pub fn enter_default<'r>(bcx: block,
+pub fn enter_default<'r>(bcx: @mut Block,
                          dm: DefMap,
                          m: &[Match<'r>],
                          col: uint,
@@ -518,7 +518,7 @@ pub fn enter_default<'r>(bcx: block,
 // <nmatsakis> so all patterns must either be records (resp. tuples) or
 //             wildcards
 
-pub fn enter_opt<'r>(bcx: block,
+pub fn enter_opt<'r>(bcx: @mut Block,
                      m: &[Match<'r>],
                      opt: &Opt,
                      col: uint,
@@ -630,7 +630,7 @@ pub fn enter_opt<'r>(bcx: block,
     }
 }
 
-pub fn enter_rec_or_struct<'r>(bcx: block,
+pub fn enter_rec_or_struct<'r>(bcx: @mut Block,
                                dm: DefMap,
                                m: &[Match<'r>],
                                col: uint,
@@ -665,7 +665,7 @@ pub fn enter_rec_or_struct<'r>(bcx: block,
     }
 }
 
-pub fn enter_tup<'r>(bcx: block,
+pub fn enter_tup<'r>(bcx: @mut Block,
                      dm: DefMap,
                      m: &[Match<'r>],
                      col: uint,
@@ -691,7 +691,7 @@ pub fn enter_tup<'r>(bcx: block,
     }
 }
 
-pub fn enter_tuple_struct<'r>(bcx: block,
+pub fn enter_tuple_struct<'r>(bcx: @mut Block,
                               dm: DefMap,
                               m: &[Match<'r>],
                               col: uint,
@@ -717,7 +717,7 @@ pub fn enter_tuple_struct<'r>(bcx: block,
     }
 }
 
-pub fn enter_box<'r>(bcx: block,
+pub fn enter_box<'r>(bcx: @mut Block,
                      dm: DefMap,
                      m: &[Match<'r>],
                      col: uint,
@@ -744,7 +744,7 @@ pub fn enter_box<'r>(bcx: block,
     }
 }
 
-pub fn enter_uniq<'r>(bcx: block,
+pub fn enter_uniq<'r>(bcx: @mut Block,
                       dm: DefMap,
                       m: &[Match<'r>],
                       col: uint,
@@ -771,7 +771,7 @@ pub fn enter_uniq<'r>(bcx: block,
     }
 }
 
-pub fn enter_region<'r>(bcx: block,
+pub fn enter_region<'r>(bcx: @mut Block,
                         dm: DefMap,
                         m: &[Match<'r>],
                         col: uint,
@@ -801,7 +801,7 @@ pub fn enter_region<'r>(bcx: block,
 // Returns the options in one column of matches. An option is something that
 // needs to be conditionally matched at runtime; for example, the discriminant
 // on a set of enum variants or a literal.
-pub fn get_options(bcx: block, m: &[Match], col: uint) -> ~[Opt] {
+pub fn get_options(bcx: @mut Block, m: &[Match], col: uint) -> ~[Opt] {
     let ccx = bcx.ccx();
     fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], val: Opt) {
         if set.iter().any(|l| opt_eq(tcx, l, &val)) {return;}
@@ -869,10 +869,10 @@ fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], val: Opt) {
 
 pub struct ExtractedBlock {
     vals: ~[ValueRef],
-    bcx: block
+    bcx: @mut Block
 }
 
-pub fn extract_variant_args(bcx: block,
+pub fn extract_variant_args(bcx: @mut Block,
                             repr: &adt::Repr,
                             disr_val: int,
                             val: ValueRef)
@@ -885,7 +885,7 @@ pub fn extract_variant_args(bcx: block,
     ExtractedBlock { vals: args, bcx: bcx }
 }
 
-fn match_datum(bcx: block, val: ValueRef, pat_id: ast::node_id) -> Datum {
+fn match_datum(bcx: @mut Block, val: ValueRef, pat_id: ast::node_id) -> Datum {
     //! Helper for converting from the ValueRef that we pass around in
     //! the match code, which is always by ref, into a Datum. Eventually
     //! we should just pass around a Datum and be done with it.
@@ -895,7 +895,7 @@ fn match_datum(bcx: block, val: ValueRef, pat_id: ast::node_id) -> Datum {
 }
 
 
-pub fn extract_vec_elems(bcx: block,
+pub fn extract_vec_elems(bcx: @mut Block,
                          pat_span: span,
                          pat_id: ast::node_id,
                          elem_count: uint,
@@ -950,7 +950,7 @@ pub fn extract_vec_elems(bcx: block,
 }
 
 // NB: This function does not collect fields from struct-like enum variants.
-pub fn collect_record_or_struct_fields(bcx: block,
+pub fn collect_record_or_struct_fields(bcx: @mut Block,
                                        m: &[Match],
                                        col: uint)
                                     -> ~[ast::ident] {
@@ -978,7 +978,7 @@ fn extend(idents: &mut ~[ast::ident], field_pats: &[ast::field_pat]) {
     }
 }
 
-pub fn pats_require_rooting(bcx: block,
+pub fn pats_require_rooting(bcx: @mut Block,
                             m: &[Match],
                             col: uint)
                          -> bool {
@@ -989,11 +989,11 @@ pub fn pats_require_rooting(bcx: block,
     }
 }
 
-pub fn root_pats_as_necessary(mut bcx: block,
+pub fn root_pats_as_necessary(mut bcx: @mut Block,
                               m: &[Match],
                               col: uint,
                               val: ValueRef)
-                           -> block {
+                           -> @mut Block {
     for m.iter().advance |br| {
         let pat_id = br.pats[col].id;
         if pat_id != 0 {
@@ -1036,7 +1036,7 @@ pub fn any_tup_pat(m: &[Match], col: uint) -> bool {
     any_pat!(m, ast::pat_tup(_))
 }
 
-pub fn any_tuple_struct_pat(bcx: block, m: &[Match], col: uint) -> bool {
+pub fn any_tuple_struct_pat(bcx: @mut Block, m: &[Match], col: uint) -> bool {
     do m.iter().any |br| {
         let pat = br.pats[col];
         match pat.node {
@@ -1090,7 +1090,7 @@ pub enum branch_kind { no_branch, single, switch, compare, compare_vec_len, }
 // Compiles a comparison between two things.
 //
 // NB: This must produce an i1, not a Rust bool (i8).
-pub fn compare_values(cx: block,
+pub fn compare_values(cx: @mut Block,
                       lhs: ValueRef,
                       rhs: ValueRef,
                       rhs_t: ty::t)
@@ -1133,10 +1133,10 @@ pub fn compare_values(cx: block,
     }
 }
 
-fn store_non_ref_bindings(bcx: block,
+fn store_non_ref_bindings(bcx: @mut Block,
                           bindings_map: &BindingsMap,
                           mut opt_temp_cleanups: Option<&mut ~[ValueRef]>)
-                          -> block
+                          -> @mut Block
 {
     /*!
      *
@@ -1167,10 +1167,10 @@ fn store_non_ref_bindings(bcx: block,
     return bcx;
 }
 
-fn insert_lllocals(bcx: block,
+fn insert_lllocals(bcx: @mut Block,
                    bindings_map: &BindingsMap,
                    binding_mode: IrrefutablePatternBindingMode,
-                   add_cleans: bool) -> block {
+                   add_cleans: bool) -> @mut Block {
     /*!
      * For each binding in `data.bindings_map`, adds an appropriate entry into
      * the `fcx.lllocals` map.  If add_cleans is true, then adds cleanups for
@@ -1206,13 +1206,13 @@ fn insert_lllocals(bcx: block,
     return bcx;
 }
 
-pub fn compile_guard(bcx: block,
+pub fn compile_guard(bcx: @mut Block,
                      guard_expr: @ast::expr,
                      data: &ArmData,
                      m: &[Match],
                      vals: &[ValueRef],
                      chk: Option<mk_fail>)
-                  -> block {
+                  -> @mut Block {
     debug!("compile_guard(bcx=%s, guard_expr=%s, m=%s, vals=%?)",
            bcx.to_str(),
            bcx.expr_to_str(guard_expr),
@@ -1248,7 +1248,7 @@ pub fn compile_guard(bcx: block,
         bcx
     };
 
-    fn drop_bindings(bcx: block, data: &ArmData) -> block {
+    fn drop_bindings(bcx: @mut Block, data: &ArmData) -> @mut Block {
         let mut bcx = bcx;
         for data.bindings_map.each_value |&binding_info| {
             match binding_info.trmode {
@@ -1263,7 +1263,7 @@ fn drop_bindings(bcx: block, data: &ArmData) -> block {
     }
 }
 
-pub fn compile_submatch(bcx: block,
+pub fn compile_submatch(bcx: @mut Block,
                         m: &[Match],
                         vals: &[ValueRef],
                         chk: Option<mk_fail>) {
@@ -1311,7 +1311,7 @@ pub fn compile_submatch(bcx: block,
     }
 }
 
-fn compile_submatch_continue(mut bcx: block,
+fn compile_submatch_continue(mut bcx: @mut Block,
                              m: &[Match],
                              vals: &[ValueRef],
                              chk: Option<mk_fail>,
@@ -1623,18 +1623,18 @@ fn compile_submatch_continue(mut bcx: block,
     }
 }
 
-pub fn trans_match(bcx: block,
+pub fn trans_match(bcx: @mut Block,
                    match_expr: &ast::expr,
                    discr_expr: @ast::expr,
                    arms: &[ast::arm],
-                   dest: Dest) -> block {
+                   dest: Dest) -> @mut Block {
     let _icx = push_ctxt("match::trans_match");
     do with_scope(bcx, match_expr.info(), "match") |bcx| {
         trans_match_inner(bcx, discr_expr, arms, dest)
     }
 }
 
-fn create_bindings_map(bcx: block, pat: @ast::pat) -> BindingsMap {
+fn create_bindings_map(bcx: @mut Block, pat: @ast::pat) -> BindingsMap {
     // Create the bindings map, which is a mapping from each binding name
     // 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
@@ -1671,10 +1671,10 @@ fn create_bindings_map(bcx: block, pat: @ast::pat) -> BindingsMap {
     return bindings_map;
 }
 
-pub fn trans_match_inner(scope_cx: block,
+pub fn trans_match_inner(scope_cx: @mut Block,
                          discr_expr: @ast::expr,
                          arms: &[ast::arm],
-                         dest: Dest) -> block {
+                         dest: Dest) -> @mut Block {
     let _icx = push_ctxt("match::trans_match_inner");
     let mut bcx = scope_cx;
     let tcx = bcx.tcx();
@@ -1743,7 +1743,7 @@ pub fn trans_match_inner(scope_cx: block,
     bcx = controlflow::join_blocks(scope_cx, arm_cxs);
     return bcx;
 
-    fn mk_fail(bcx: block, sp: span, msg: @str,
+    fn mk_fail(bcx: @mut Block, sp: span, msg: @str,
                finished: @mut Option<BasicBlockRef>) -> BasicBlockRef {
         match *finished { Some(bb) => return bb, _ => () }
         let fail_cx = sub_block(bcx, "case_fallthrough");
@@ -1760,10 +1760,10 @@ pub enum IrrefutablePatternBindingMode {
     BindArgument
 }
 
-pub fn store_local(bcx: block,
+pub fn store_local(bcx: @mut Block,
                    pat: @ast::pat,
                    opt_init_expr: Option<@ast::expr>)
-                               -> block {
+                               -> @mut Block {
     /*!
      * Generates code for a local variable declaration like
      * `let <pat>;` or `let <pat> = <opt_init_expr>`.
@@ -1814,7 +1814,7 @@ pub fn store_local(bcx: block,
         }
     };
 
-    fn create_dummy_locals(mut bcx: block, pat: @ast::pat) -> block {
+    fn create_dummy_locals(mut bcx: @mut Block, pat: @ast::pat) -> @mut Block {
         // create dummy memory for the variables if we have no
         // value to store into them immediately
         let tcx = bcx.tcx();
@@ -1827,10 +1827,10 @@ fn create_dummy_locals(mut bcx: block, pat: @ast::pat) -> block {
     }
 }
 
-pub fn store_arg(mut bcx: block,
+pub fn store_arg(mut bcx: @mut Block,
                  pat: @ast::pat,
                  llval: ValueRef)
-                 -> block {
+                 -> @mut Block {
     /*!
      * Generates code for argument patterns like `fn foo(<pat>: T)`.
      * Creates entries in the `llargs` map for each of the bindings
@@ -1870,11 +1870,11 @@ pub fn store_arg(mut bcx: block,
     return bcx;
 }
 
-fn mk_binding_alloca(mut bcx: block,
+fn mk_binding_alloca(mut bcx: @mut Block,
                      p_id: ast::node_id,
                      path: &ast::Path,
                      binding_mode: IrrefutablePatternBindingMode,
-                     populate: &fn(block, ty::t, ValueRef) -> block) -> block {
+                     populate: &fn(@mut Block, ty::t, ValueRef) -> @mut Block) -> @mut Block {
     let var_ty = node_id_type(bcx, p_id);
     let ident = ast_util::path_to_ident(path);
     let llval = alloc_ty(bcx, var_ty, bcx.ident(ident));
@@ -1888,11 +1888,11 @@ fn mk_binding_alloca(mut bcx: block,
     return bcx;
 }
 
-fn bind_irrefutable_pat(bcx: block,
+fn bind_irrefutable_pat(bcx: @mut Block,
                         pat: @ast::pat,
                         val: ValueRef,
                         binding_mode: IrrefutablePatternBindingMode)
-                        -> block {
+                        -> @mut Block {
     /*!
      * A simple version of the pattern matching code that only handles
      * irrefutable patterns. This is used in let/argument patterns,
index fd38ec39bb1bba0d312cb5949fca12765c5184e4..ee53bfdcbda78ca417776fad9ed37e5ddaffaa0c 100644 (file)
@@ -106,7 +106,7 @@ pub struct Struct {
  * these, for places in trans where the `ty::t` isn't directly
  * available.
  */
-pub fn represent_node(bcx: block, node: ast::node_id) -> @Repr {
+pub fn represent_node(bcx: @mut Block, node: ast::node_id) -> @Repr {
     represent_type(bcx.ccx(), node_id_type(bcx, node))
 }
 
@@ -283,7 +283,7 @@ fn struct_llfields(cx: &mut CrateContext, st: &Struct, sizing: bool) -> ~[Type]
  *
  * This should ideally be less tightly tied to `_match`.
  */
-pub fn trans_switch(bcx: block, r: &Repr, scrutinee: ValueRef)
+pub fn trans_switch(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
     -> (_match::branch_kind, Option<ValueRef>) {
     match *r {
         CEnum(*) | General(*) => {
@@ -301,7 +301,7 @@ pub fn trans_switch(bcx: block, r: &Repr, scrutinee: ValueRef)
 
 
 /// Obtain the actual discriminant of a value.
-pub fn trans_get_discr(bcx: block, r: &Repr, scrutinee: ValueRef)
+pub fn trans_get_discr(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
     -> ValueRef {
     match *r {
         CEnum(min, max) => load_discr(bcx, scrutinee, min, max),
@@ -315,7 +315,7 @@ pub fn trans_get_discr(bcx: block, r: &Repr, scrutinee: ValueRef)
     }
 }
 
-fn nullable_bitdiscr(bcx: block, nonnull: &Struct, nndiscr: int, ptrfield: uint,
+fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: int, ptrfield: uint,
                      scrutinee: ValueRef) -> ValueRef {
     let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
     let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
@@ -324,7 +324,7 @@ fn nullable_bitdiscr(bcx: block, nonnull: &Struct, nndiscr: int, ptrfield: uint,
 }
 
 /// Helper for cases where the discriminant is simply loaded.
-fn load_discr(bcx: block, scrutinee: ValueRef, min: int, max: int)
+fn load_discr(bcx: @mut Block, scrutinee: ValueRef, min: int, max: int)
     -> ValueRef {
     let ptr = GEPi(bcx, scrutinee, [0, 0]);
     if max + 1 == min {
@@ -348,7 +348,7 @@ fn load_discr(bcx: block, scrutinee: ValueRef, min: int, max: int)
  *
  * This should ideally be less tightly tied to `_match`.
  */
-pub fn trans_case(bcx: block, r: &Repr, discr: int) -> _match::opt_result {
+pub fn trans_case(bcx: @mut Block, r: &Repr, discr: int) -> _match::opt_result {
     match *r {
         CEnum(*) => {
             _match::single_result(rslt(bcx, C_int(bcx.ccx(), discr)))
@@ -371,7 +371,7 @@ pub fn trans_case(bcx: block, r: &Repr, discr: int) -> _match::opt_result {
  * representation.  The fields, if any, should then be initialized via
  * `trans_field_ptr`.
  */
-pub fn trans_start_init(bcx: block, r: &Repr, val: ValueRef, discr: int) {
+pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: int) {
     match *r {
         CEnum(min, max) => {
             assert!(min <= discr && discr <= max);
@@ -417,7 +417,7 @@ pub fn num_args(r: &Repr, discr: int) -> uint {
 }
 
 /// Access a field, at a point when the value's case is known.
-pub fn trans_field_ptr(bcx: block, r: &Repr, val: ValueRef, discr: int,
+pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: int,
                        ix: uint) -> ValueRef {
     // Note: if this ever needs to generate conditionals (e.g., if we
     // decide to do some kind of cdr-coding-like non-unique repr
@@ -449,7 +449,7 @@ pub fn trans_field_ptr(bcx: block, r: &Repr, val: ValueRef, discr: int,
     }
 }
 
-fn struct_field_ptr(bcx: block, st: &Struct, val: ValueRef, ix: uint,
+fn struct_field_ptr(bcx: @mut Block, st: &Struct, val: ValueRef, ix: uint,
               needs_cast: bool) -> ValueRef {
     let ccx = bcx.ccx();
 
@@ -467,7 +467,7 @@ fn struct_field_ptr(bcx: block, st: &Struct, val: ValueRef, ix: uint,
 }
 
 /// Access the struct drop flag, if present.
-pub fn trans_drop_flag_ptr(bcx: block, r: &Repr, val: ValueRef) -> ValueRef {
+pub fn trans_drop_flag_ptr(bcx: @mut Block, r: &Repr, val: ValueRef) -> ValueRef {
     match *r {
         Univariant(ref st, true) => GEPi(bcx, val, [0, st.fields.len() - 1]),
         _ => bcx.ccx().sess.bug("tried to get drop flag of non-droppable type")
index fadeab0f1f7708bdac1bd52a70889d07c414c0c7..b76b76ff603d58066c9645ce2428f2de82f8ce96 100644 (file)
@@ -25,7 +25,7 @@
 use syntax::ast;
 
 // Take an inline assembly expression and splat it out via LLVM
-pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
+pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
 
     let mut bcx = bcx;
     let mut constraints = ~[];
index 32a5ebe0c39cb100bd884a200a6c5ed4ca9e37c0..fba67d57994e4d1b5fae91976dbc3008ce428021 100644 (file)
@@ -131,7 +131,7 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
     _InsnCtxt { _x: () }
 }
 
-fn fcx_has_nonzero_span(fcx: fn_ctxt) -> bool {
+fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
     match fcx.span {
         None => true,
         Some(span) => *span.lo != 0 || *span.hi != 0
@@ -228,13 +228,13 @@ pub fn get_extern_const(externs: &mut ExternMap, llmod: ModuleRef,
         return c;
     }
 }
-pub fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
+pub fn umax(cx: @mut Block, a: ValueRef, b: ValueRef) -> ValueRef {
     let _icx = push_ctxt("umax");
     let cond = ICmp(cx, lib::llvm::IntULT, a, b);
     return Select(cx, cond, b, a);
 }
 
-pub fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
+pub fn umin(cx: @mut Block, a: ValueRef, b: ValueRef) -> ValueRef {
     let _icx = push_ctxt("umin");
     let cond = ICmp(cx, lib::llvm::IntULT, a, b);
     return Select(cx, cond, a, b);
@@ -243,7 +243,7 @@ pub fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
 // Given a pointer p, returns a pointer sz(p) (i.e., inc'd by sz bytes).
 // The type of the returned pointer is always i8*.  If you care about the
 // return type, use bump_ptr().
-pub fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef {
+pub fn ptr_offs(bcx: @mut Block, base: ValueRef, sz: ValueRef) -> ValueRef {
     let _icx = push_ctxt("ptr_offs");
     let raw = PointerCast(bcx, base, Type::i8p());
     InBoundsGEP(bcx, raw, [sz])
@@ -251,7 +251,7 @@ pub fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef {
 
 // Increment a pointer by a given amount and then cast it to be a pointer
 // to a given type.
-pub fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) ->
+pub fn bump_ptr(bcx: @mut Block, t: ty::t, base: ValueRef, sz: ValueRef) ->
    ValueRef {
     let _icx = push_ctxt("bump_ptr");
     let ccx = bcx.ccx();
@@ -265,7 +265,7 @@ pub fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) ->
 // known.
 //
 // The runtime equivalent is box_body() in "rust_internal.h".
-pub fn opaque_box_body(bcx: block,
+pub fn opaque_box_body(bcx: @mut Block,
                        body_t: ty::t,
                        boxptr: ValueRef) -> ValueRef {
     let _icx = push_ctxt("opaque_box_body");
@@ -278,14 +278,14 @@ pub fn opaque_box_body(bcx: block,
 
 // malloc_raw_dyn: allocates a box to contain a given type, but with a
 // potentially dynamic size.
-pub fn malloc_raw_dyn(bcx: block,
+pub fn malloc_raw_dyn(bcx: @mut Block,
                       t: ty::t,
                       heap: heap,
                       size: ValueRef) -> Result {
     let _icx = push_ctxt("malloc_raw");
     let ccx = bcx.ccx();
 
-    fn require_alloc_fn(bcx: block, t: ty::t, it: LangItem) -> ast::def_id {
+    fn require_alloc_fn(bcx: @mut Block, t: ty::t, it: LangItem) -> ast::def_id {
         let li = &bcx.tcx().lang_items;
         match li.require(it) {
             Ok(id) => id,
@@ -345,21 +345,21 @@ fn require_alloc_fn(bcx: block, t: ty::t, it: LangItem) -> ast::def_id {
 // malloc_raw: expects an unboxed type and returns a pointer to
 // enough space for a box of that type.  This includes a rust_opaque_box
 // header.
-pub fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> Result {
+pub fn malloc_raw(bcx: @mut Block, t: ty::t, heap: heap) -> Result {
     let ty = type_of(bcx.ccx(), t);
     let size = llsize_of(bcx.ccx(), ty);
     malloc_raw_dyn(bcx, t, heap, size)
 }
 
 pub struct MallocResult {
-    bcx: block,
+    bcx: @mut Block,
     box: ValueRef,
     body: ValueRef
 }
 
 // malloc_general_dyn: usefully wraps malloc_raw_dyn; allocates a box,
 // and pulls out the body
-pub fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef)
+pub fn malloc_general_dyn(bcx: @mut Block, t: ty::t, heap: heap, size: ValueRef)
     -> MallocResult {
     assert!(heap != heap_exchange);
     let _icx = push_ctxt("malloc_general");
@@ -369,17 +369,17 @@ pub fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef)
     MallocResult { bcx: bcx, box: llbox, body: body }
 }
 
-pub fn malloc_general(bcx: block, t: ty::t, heap: heap) -> MallocResult {
+pub fn malloc_general(bcx: @mut Block, t: ty::t, heap: heap) -> MallocResult {
     let ty = type_of(bcx.ccx(), t);
     assert!(heap != heap_exchange);
     malloc_general_dyn(bcx, t, heap, llsize_of(bcx.ccx(), ty))
 }
-pub fn malloc_boxed(bcx: block, t: ty::t)
+pub fn malloc_boxed(bcx: @mut Block, t: ty::t)
     -> MallocResult {
     malloc_general(bcx, t, heap_managed)
 }
 
-pub fn heap_for_unique(bcx: block, t: ty::t) -> heap {
+pub fn heap_for_unique(bcx: @mut Block, t: ty::t) -> heap {
     if ty::type_contents(bcx.tcx(), t).contains_managed() {
         heap_managed_unique
     } else {
@@ -387,7 +387,7 @@ pub fn heap_for_unique(bcx: block, t: ty::t) -> heap {
     }
 }
 
-pub fn maybe_set_managed_unique_rc(bcx: block, bx: ValueRef, heap: heap) {
+pub fn maybe_set_managed_unique_rc(bcx: @mut Block, bx: ValueRef, heap: heap) {
     assert!(heap != heap_exchange);
     if heap == heap_managed_unique {
         // In cases where we are looking at a unique-typed allocation in the
@@ -562,7 +562,7 @@ pub fn maybe_name_value(cx: &CrateContext, v: ValueRef, s: &str) {
 pub enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
 
 // NB: This produces an i1, not a Rust bool (i8).
-pub fn compare_scalar_types(cx: block,
+pub fn compare_scalar_types(cx: @mut Block,
                             lhs: ValueRef,
                             rhs: ValueRef,
                             t: ty::t,
@@ -593,14 +593,14 @@ pub fn compare_scalar_types(cx: block,
 
 
 // A helper function to do the actual comparison of scalar values.
-pub fn compare_scalar_values(cx: block,
+pub fn compare_scalar_values(cx: @mut Block,
                              lhs: ValueRef,
                              rhs: ValueRef,
                              nt: scalar_type,
                              op: ast::binop)
                           -> ValueRef {
     let _icx = push_ctxt("compare_scalar_values");
-    fn die(cx: block) -> ! {
+    fn die(cx: @mut Block) -> ! {
         cx.tcx().sess.bug("compare_scalar_values: must be a\
                            comparison operator");
     }
@@ -654,24 +654,24 @@ fn die(cx: block) -> ! {
     }
 }
 
-pub type val_and_ty_fn<'self> = &'self fn(block, ValueRef, ty::t) -> block;
+pub type val_and_ty_fn<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
 
-pub fn load_inbounds(cx: block, p: ValueRef, idxs: &[uint]) -> ValueRef {
+pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
     return Load(cx, GEPi(cx, p, idxs));
 }
 
-pub fn store_inbounds(cx: block, v: ValueRef, p: ValueRef, idxs: &[uint]) {
+pub fn store_inbounds(cx: @mut Block, v: ValueRef, p: ValueRef, idxs: &[uint]) {
     Store(cx, v, GEPi(cx, p, idxs));
 }
 
 // Iterates through the elements of a structural type.
-pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
-                          f: val_and_ty_fn) -> block {
+pub fn iter_structural_ty(cx: @mut Block, av: ValueRef, t: ty::t,
+                          f: val_and_ty_fn) -> @mut Block {
     let _icx = push_ctxt("iter_structural_ty");
 
-    fn iter_variant(cx: block, repr: &adt::Repr, av: ValueRef,
+    fn iter_variant(cx: @mut Block, repr: &adt::Repr, av: ValueRef,
                     variant: @ty::VariantInfo,
-                    tps: &[ty::t], f: val_and_ty_fn) -> block {
+                    tps: &[ty::t], f: val_and_ty_fn) -> @mut Block {
         let _icx = push_ctxt("iter_variant");
         let tcx = cx.tcx();
         let mut cx = cx;
@@ -757,7 +757,7 @@ fn iter_variant(cx: block, repr: &adt::Repr, av: ValueRef,
     return cx;
 }
 
-pub fn cast_shift_expr_rhs(cx: block, op: ast::binop,
+pub fn cast_shift_expr_rhs(cx: @mut Block, op: ast::binop,
                            lhs: ValueRef, rhs: ValueRef) -> ValueRef {
     cast_shift_rhs(op, lhs, rhs,
                    |a,b| Trunc(cx, a, b),
@@ -798,8 +798,8 @@ pub fn cast_shift_rhs(op: ast::binop,
     }
 }
 
-pub fn fail_if_zero(cx: block, span: span, divrem: ast::binop,
-                    rhs: ValueRef, rhs_t: ty::t) -> block {
+pub fn fail_if_zero(cx: @mut Block, span: span, divrem: ast::binop,
+                    rhs: ValueRef, rhs_t: ty::t) -> @mut Block {
     let text = if divrem == ast::div {
         @"attempted to divide by zero"
     } else {
@@ -824,7 +824,7 @@ pub fn fail_if_zero(cx: block, span: span, divrem: ast::binop,
     }
 }
 
-pub fn null_env_ptr(bcx: block) -> ValueRef {
+pub fn null_env_ptr(bcx: @mut Block) -> ValueRef {
     C_null(Type::opaque_box(bcx.ccx()).ptr_to())
 }
 
@@ -844,8 +844,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::def_id, t: ty::t)
     };
 }
 
-pub fn invoke(bcx: block, llfn: ValueRef, llargs: ~[ValueRef])
-           -> (ValueRef, block) {
+pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef])
+           -> (ValueRef, @mut Block) {
     let _icx = push_ctxt("invoke_");
     if bcx.unreachable {
         return (C_null(Type::i8()), bcx);
@@ -889,7 +889,7 @@ pub fn invoke(bcx: block, llfn: ValueRef, llargs: ~[ValueRef])
     }
 }
 
-pub fn need_invoke(bcx: block) -> bool {
+pub fn need_invoke(bcx: @mut Block) -> bool {
     if (bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0) {
         return false;
     }
@@ -931,7 +931,7 @@ pub fn need_invoke(bcx: block) -> bool {
     }
 }
 
-pub fn have_cached_lpad(bcx: block) -> bool {
+pub fn have_cached_lpad(bcx: @mut Block) -> bool {
     let mut res = false;
     do in_lpad_scope_cx(bcx) |inf| {
         match inf.landing_pad {
@@ -942,7 +942,7 @@ pub fn have_cached_lpad(bcx: block) -> bool {
     return res;
 }
 
-pub fn in_lpad_scope_cx(bcx: block, f: &fn(si: &mut scope_info)) {
+pub fn in_lpad_scope_cx(bcx: @mut Block, f: &fn(si: &mut ScopeInfo)) {
     let mut bcx = bcx;
     let mut cur_scope = bcx.scope;
     loop {
@@ -962,7 +962,7 @@ pub fn in_lpad_scope_cx(bcx: block, f: &fn(si: &mut scope_info)) {
     }
 }
 
-pub fn get_landing_pad(bcx: block) -> BasicBlockRef {
+pub fn get_landing_pad(bcx: @mut Block) -> BasicBlockRef {
     let _icx = push_ctxt("get_landing_pad");
 
     let mut cached = None;
@@ -1013,7 +1013,7 @@ pub fn get_landing_pad(bcx: block) -> BasicBlockRef {
     return pad_bcx.llbb;
 }
 
-pub fn find_bcx_for_scope(bcx: block, scope_id: ast::node_id) -> block {
+pub fn find_bcx_for_scope(bcx: @mut Block, scope_id: ast::node_id) -> @mut Block {
     let mut bcx_sid = bcx;
     let mut cur_scope = bcx_sid.scope;
     loop {
@@ -1042,7 +1042,7 @@ pub fn find_bcx_for_scope(bcx: block, scope_id: ast::node_id) -> block {
 }
 
 
-pub fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef {
+pub fn do_spill(bcx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
     if ty::type_is_bot(t) {
         return C_null(Type::i8p());
     }
@@ -1053,25 +1053,25 @@ pub fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef {
 
 // Since this function does *not* root, it is the caller's responsibility to
 // ensure that the referent is pointed to by a root.
-pub fn do_spill_noroot(cx: block, v: ValueRef) -> ValueRef {
+pub fn do_spill_noroot(cx: @mut Block, v: ValueRef) -> ValueRef {
     let llptr = alloca(cx, val_ty(v), "");
     Store(cx, v, llptr);
     return llptr;
 }
 
-pub fn spill_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef {
+pub fn spill_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
     let _icx = push_ctxt("spill_if_immediate");
     if ty::type_is_immediate(cx.tcx(), t) { return do_spill(cx, v, t); }
     return v;
 }
 
-pub fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef {
+pub fn load_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
     let _icx = push_ctxt("load_if_immediate");
     if ty::type_is_immediate(cx.tcx(), t) { return Load(cx, v); }
     return v;
 }
 
-pub fn trans_trace(bcx: block, sp_opt: Option<span>, trace_str: @str) {
+pub fn trans_trace(bcx: @mut Block, sp_opt: Option<span>, trace_str: @str) {
     if !bcx.sess().trace() { return; }
     let _icx = push_ctxt("trans_trace");
     add_comment(bcx, trace_str);
@@ -1093,13 +1093,13 @@ pub fn trans_trace(bcx: block, sp_opt: Option<span>, trace_str: @str) {
     Call(bcx, ccx.upcalls.trace, args);
 }
 
-pub fn ignore_lhs(_bcx: block, local: &ast::Local) -> bool {
+pub fn ignore_lhs(_bcx: @mut Block, local: &ast::Local) -> bool {
     match local.pat.node {
         ast::pat_wild => true, _ => false
     }
 }
 
-pub fn init_local(bcx: block, local: &ast::Local) -> block {
+pub fn init_local(bcx: @mut Block, local: &ast::Local) -> @mut Block {
 
     debug!("init_local(bcx=%s, local.id=%?)",
            bcx.to_str(), local.id);
@@ -1120,7 +1120,7 @@ pub fn init_local(bcx: block, local: &ast::Local) -> block {
     _match::store_local(bcx, local.pat, local.init)
 }
 
-pub fn trans_stmt(cx: block, s: &ast::stmt) -> block {
+pub fn trans_stmt(cx: @mut Block, s: &ast::stmt) -> @mut Block {
     let _icx = push_ctxt("trans_stmt");
     debug!("trans_stmt(%s)", stmt_to_str(s, cx.tcx().sess.intr()));
 
@@ -1155,19 +1155,22 @@ pub fn trans_stmt(cx: block, s: &ast::stmt) -> block {
 
 // You probably don't want to use this one. See the
 // next three functions instead.
-pub fn new_block(cx: fn_ctxt, parent: Option<block>, scope: Option<@mut scope_info>,
-                 is_lpad: bool, name: &str, opt_node_info: Option<NodeInfo>)
-    -> block {
-
+pub fn new_block(cx: @mut FunctionContext,
+                 parent: Option<@mut Block>,
+                 scope: Option<@mut ScopeInfo>,
+                 is_lpad: bool,
+                 name: &str,
+                 opt_node_info: Option<NodeInfo>)
+              -> @mut Block {
     unsafe {
         let llbb = do name.as_c_str |buf| {
             llvm::LLVMAppendBasicBlockInContext(cx.ccx.llcx, cx.llfn, buf)
         };
-        let bcx = mk_block(llbb,
-                           parent,
-                           is_lpad,
-                           opt_node_info,
-                           cx);
+        let bcx = @mut Block::new(llbb,
+                                  parent,
+                                  is_lpad,
+                                  opt_node_info,
+                                  cx);
         bcx.scope = scope;
         for parent.iter().advance |cx| {
             if cx.unreachable {
@@ -1179,9 +1182,9 @@ pub fn new_block(cx: fn_ctxt, parent: Option<block>, scope: Option<@mut scope_in
     }
 }
 
-pub fn simple_block_scope(parent: Option<@mut scope_info>,
-                          node_info: Option<NodeInfo>) -> @mut scope_info {
-    @mut scope_info {
+pub fn simple_block_scope(parent: Option<@mut ScopeInfo>,
+                          node_info: Option<NodeInfo>) -> @mut ScopeInfo {
+    @mut ScopeInfo {
         parent: parent,
         loop_break: None,
         loop_label: None,
@@ -1193,25 +1196,25 @@ pub fn simple_block_scope(parent: Option<@mut scope_info>,
 }
 
 // Use this when you're at the top block of a function or the like.
-pub fn top_scope_block(fcx: fn_ctxt, opt_node_info: Option<NodeInfo>)
-                    -> block {
+pub fn top_scope_block(fcx: @mut FunctionContext, opt_node_info: Option<NodeInfo>)
+                    -> @mut Block {
     return new_block(fcx, None, Some(simple_block_scope(None, opt_node_info)), false,
                   "function top level", opt_node_info);
 }
 
-pub fn scope_block(bcx: block,
+pub fn scope_block(bcx: @mut Block,
                    opt_node_info: Option<NodeInfo>,
-                   n: &str) -> block {
+                   n: &str) -> @mut Block {
     return new_block(bcx.fcx, Some(bcx), Some(simple_block_scope(None, opt_node_info)), bcx.is_lpad,
                   n, opt_node_info);
 }
 
-pub fn loop_scope_block(bcx: block,
-                        loop_break: block,
+pub fn loop_scope_block(bcx: @mut Block,
+                        loop_break: @mut Block,
                         loop_label: Option<ident>,
                         n: &str,
-                        opt_node_info: Option<NodeInfo>) -> block {
-    return new_block(bcx.fcx, Some(bcx), Some(@mut scope_info {
+                        opt_node_info: Option<NodeInfo>) -> @mut Block {
+    return new_block(bcx.fcx, Some(bcx), Some(@mut ScopeInfo {
         parent: None,
         loop_break: Some(loop_break),
         loop_label: loop_label,
@@ -1223,17 +1226,17 @@ pub fn loop_scope_block(bcx: block,
 }
 
 // Use this when creating a block for the inside of a landing pad.
-pub fn lpad_block(bcx: block, n: &str) -> block {
+pub fn lpad_block(bcx: @mut Block, n: &str) -> @mut Block {
     new_block(bcx.fcx, Some(bcx), None, true, n, None)
 }
 
 // Use this when you're making a general CFG BB within a scope.
-pub fn sub_block(bcx: block, n: &str) -> block {
+pub fn sub_block(bcx: @mut Block, n: &str) -> @mut Block {
     new_block(bcx.fcx, Some(bcx), None, bcx.is_lpad, n, None)
 }
 
-pub fn raw_block(fcx: fn_ctxt, is_lpad: bool, llbb: BasicBlockRef) -> block {
-    mk_block(llbb, None, is_lpad, None, fcx)
+pub fn raw_block(fcx: @mut FunctionContext, is_lpad: bool, llbb: BasicBlockRef) -> @mut Block {
+    @mut Block::new(llbb, None, is_lpad, None, fcx)
 }
 
 
@@ -1244,14 +1247,14 @@ pub fn raw_block(fcx: fn_ctxt, is_lpad: bool, llbb: BasicBlockRef) -> block {
 // need to make sure those variables go out of scope when the block ends.  We
 // do that by running a 'cleanup' function for each variable.
 // trans_block_cleanups runs all the cleanup functions for the block.
-pub fn trans_block_cleanups(bcx: block, cleanups: ~[cleanup]) -> block {
+pub fn trans_block_cleanups(bcx: @mut Block, cleanups: ~[cleanup]) -> @mut Block {
     trans_block_cleanups_(bcx, cleanups, false)
 }
 
-pub fn trans_block_cleanups_(bcx: block,
+pub fn trans_block_cleanups_(bcx: @mut Block,
                              cleanups: &[cleanup],
                              /* cleanup_cx: block, */
-                             is_lpad: bool) -> block {
+                             is_lpad: bool) -> @mut Block {
     let _icx = push_ctxt("trans_block_cleanups");
     // NB: Don't short-circuit even if this block is unreachable because
     // GC-based cleanup needs to the see that the roots are live.
@@ -1276,7 +1279,7 @@ pub fn trans_block_cleanups_(bcx: block,
 // In the last argument, Some(block) mean jump to this block, and none means
 // this is a landing pad and leaving should be accomplished with a resume
 // instruction.
-pub fn cleanup_and_leave(bcx: block,
+pub fn cleanup_and_leave(bcx: @mut Block,
                          upto: Option<BasicBlockRef>,
                          leave: Option<BasicBlockRef>) {
     let _icx = push_ctxt("cleanup_and_leave");
@@ -1350,7 +1353,7 @@ pub fn cleanup_and_leave(bcx: block,
     }
 }
 
-pub fn cleanup_block(bcx: block, upto: Option<BasicBlockRef>) -> block{
+pub fn cleanup_block(bcx: @mut Block, upto: Option<BasicBlockRef>) -> @mut Block{
     let _icx = push_ctxt("cleanup_block");
     let mut cur = bcx;
     let mut bcx = bcx;
@@ -1386,12 +1389,12 @@ pub fn cleanup_block(bcx: block, upto: Option<BasicBlockRef>) -> block{
     bcx
 }
 
-pub fn cleanup_and_Br(bcx: block, upto: block, target: BasicBlockRef) {
+pub fn cleanup_and_Br(bcx: @mut Block, upto: @mut Block, target: BasicBlockRef) {
     let _icx = push_ctxt("cleanup_and_Br");
     cleanup_and_leave(bcx, Some(upto.llbb), Some(target));
 }
 
-pub fn leave_block(bcx: block, out_of: block) -> block {
+pub fn leave_block(bcx: @mut Block, out_of: @mut Block) -> @mut Block {
     let _icx = push_ctxt("leave_block");
     let next_cx = sub_block(block_parent(out_of), "next");
     if bcx.unreachable { Unreachable(next_cx); }
@@ -1399,10 +1402,10 @@ pub fn leave_block(bcx: block, out_of: block) -> block {
     next_cx
 }
 
-pub fn with_scope(bcx: block,
+pub fn with_scope(bcx: @mut Block,
                   opt_node_info: Option<NodeInfo>,
                   name: &str,
-                  f: &fn(block) -> block) -> block {
+                  f: &fn(@mut Block) -> @mut Block) -> @mut Block {
     let _icx = push_ctxt("with_scope");
 
     debug!("with_scope(bcx=%s, opt_node_info=%?, name=%s)",
@@ -1417,10 +1420,10 @@ pub fn with_scope(bcx: block,
     ret
 }
 
-pub fn with_scope_result(bcx: block,
+pub fn with_scope_result(bcx: @mut Block,
                          opt_node_info: Option<NodeInfo>,
                          _name: &str,
-                         f: &fn(block) -> Result) -> Result {
+                         f: &fn(@mut Block) -> Result) -> Result {
     let _icx = push_ctxt("with_scope_result");
 
     let scope = simple_block_scope(bcx.scope, opt_node_info);
@@ -1434,8 +1437,8 @@ pub fn with_scope_result(bcx: block,
     rslt(out_bcx, val)
 }
 
-pub fn with_scope_datumblock(bcx: block, opt_node_info: Option<NodeInfo>,
-                             name: &str, f: &fn(block) -> datum::DatumBlock)
+pub fn with_scope_datumblock(bcx: @mut Block, opt_node_info: Option<NodeInfo>,
+                             name: &str, f: &fn(@mut Block) -> datum::DatumBlock)
                           -> datum::DatumBlock {
     use middle::trans::datum::DatumBlock;
 
@@ -1460,7 +1463,7 @@ pub fn block_locals(b: &ast::Block, it: &fn(@ast::Local)) {
     }
 }
 
-pub fn with_cond(bcx: block, val: ValueRef, f: &fn(block) -> block) -> block {
+pub fn with_cond(bcx: @mut Block, val: ValueRef, f: &fn(@mut Block) -> @mut Block) -> @mut Block {
     let _icx = push_ctxt("with_cond");
     let next_cx = base::sub_block(bcx, "next");
     let cond_cx = base::sub_block(bcx, "cond");
@@ -1470,7 +1473,7 @@ pub fn with_cond(bcx: block, val: ValueRef, f: &fn(block) -> block) -> block {
     next_cx
 }
 
-pub fn call_memcpy(cx: block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
+pub fn call_memcpy(cx: @mut Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
     let _icx = push_ctxt("call_memcpy");
     let ccx = cx.ccx();
     let key = match ccx.sess.targ_cfg.arch {
@@ -1486,7 +1489,7 @@ pub fn call_memcpy(cx: block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, a
     Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile]);
 }
 
-pub fn memcpy_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) {
+pub fn memcpy_ty(bcx: @mut Block, dst: ValueRef, src: ValueRef, t: ty::t) {
     let _icx = push_ctxt("memcpy_ty");
     let ccx = bcx.ccx();
     if ty::type_is_structural(t) {
@@ -1499,7 +1502,7 @@ pub fn memcpy_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) {
     }
 }
 
-pub fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) {
+pub fn zero_mem(cx: @mut Block, llptr: ValueRef, t: ty::t) {
     if cx.unreachable { return; }
     let _icx = push_ctxt("zero_mem");
     let bcx = cx;
@@ -1531,7 +1534,7 @@ pub fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
     b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile]);
 }
 
-pub fn alloc_ty(bcx: block, t: ty::t, name: &str) -> ValueRef {
+pub fn alloc_ty(bcx: @mut Block, t: ty::t, name: &str) -> ValueRef {
     let _icx = push_ctxt("alloc_ty");
     let ccx = bcx.ccx();
     let ty = type_of::type_of(ccx, t);
@@ -1540,11 +1543,11 @@ pub fn alloc_ty(bcx: block, t: ty::t, name: &str) -> ValueRef {
     return val;
 }
 
-pub fn alloca(cx: block, ty: Type, name: &str) -> ValueRef {
+pub fn alloca(cx: @mut Block, ty: Type, name: &str) -> ValueRef {
     alloca_maybe_zeroed(cx, ty, name, false)
 }
 
-pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> ValueRef {
+pub fn alloca_maybe_zeroed(cx: @mut Block, ty: Type, name: &str, zero: bool) -> ValueRef {
     let _icx = push_ctxt("alloca");
     if cx.unreachable {
         unsafe {
@@ -1560,7 +1563,7 @@ pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> Value
     p
 }
 
-pub fn arrayalloca(cx: block, ty: Type, v: ValueRef) -> ValueRef {
+pub fn arrayalloca(cx: @mut Block, ty: Type, v: ValueRef) -> ValueRef {
     let _icx = push_ctxt("arrayalloca");
     if cx.unreachable {
         unsafe {
@@ -1592,7 +1595,7 @@ pub fn mk_return_basic_block(llfn: ValueRef) -> BasicBlockRef {
 
 // Creates and returns space for, or returns the argument representing, the
 // slot where the return value of the function must go.
-pub fn make_return_pointer(fcx: fn_ctxt, output_type: ty::t) -> ValueRef {
+pub fn make_return_pointer(fcx: @mut FunctionContext, output_type: ty::t) -> ValueRef {
     unsafe {
         if !ty::type_is_immediate(fcx.ccx.tcx, output_type) {
             llvm::LLVMGetParam(fcx.llfn, 0)
@@ -1619,7 +1622,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
                         param_substs: Option<@param_substs>,
                         opt_node_info: Option<NodeInfo>,
                         sp: Option<span>)
-                     -> fn_ctxt {
+                     -> @mut FunctionContext {
     for param_substs.iter().advance |p| { p.validate(); }
 
     debug!("new_fn_ctxt_w_id(path=%s, id=%?, \
@@ -1635,7 +1638,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
         }
     };
     let is_immediate = ty::type_is_immediate(ccx.tcx, substd_output_type);
-    let fcx = @mut fn_ctxt_ {
+    let fcx = @mut FunctionContext {
           llfn: llfndecl,
           llenv: unsafe {
               llvm::LLVMGetUndef(Type::i8p().to_ref())
@@ -1680,7 +1683,7 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
                    llfndecl: ValueRef,
                    output_type: ty::t,
                    sp: Option<span>)
-                -> fn_ctxt {
+                -> @mut FunctionContext {
     new_fn_ctxt_w_id(ccx, path, llfndecl, -1, output_type, false, None, None, sp)
 }
 
@@ -1698,7 +1701,7 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
 // spaces that have been created for them (by code in the llallocas field of
 // the function's fn_ctxt).  create_llargs_for_fn_args populates the llargs
 // field of the fn_ctxt with
-pub fn create_llargs_for_fn_args(cx: fn_ctxt,
+pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
                                  self_arg: self_arg,
                                  args: &[ast::arg])
                               -> ~[ValueRef] {
@@ -1739,11 +1742,11 @@ pub fn create_llargs_for_fn_args(cx: fn_ctxt,
     })
 }
 
-pub fn copy_args_to_allocas(fcx: fn_ctxt,
-                            bcx: block,
+pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
+                            bcx: @mut Block,
                             args: &[ast::arg],
                             raw_llargs: &[ValueRef],
-                            arg_tys: &[ty::t]) -> block {
+                            arg_tys: &[ty::t]) -> @mut Block {
     let _icx = push_ctxt("copy_args_to_allocas");
     let mut bcx = bcx;
 
@@ -1796,7 +1799,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
 
 // Ties up the llstaticallocas -> llloadenv -> lltop edges,
 // and builds the return block.
-pub fn finish_fn(fcx: fn_ctxt, last_bcx: block) {
+pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @mut Block) {
     let _icx = push_ctxt("finish_fn");
 
     let ret_cx = match fcx.llreturn {
@@ -1813,7 +1816,7 @@ pub fn finish_fn(fcx: fn_ctxt, last_bcx: block) {
 }
 
 // Builds the return block for a function.
-pub fn build_return_block(fcx: fn_ctxt, ret_cx: block) {
+pub fn build_return_block(fcx: &FunctionContext, ret_cx: @mut Block) {
     // Return the value if this function immediate; otherwise, return void.
     if fcx.llretptr.is_some() && fcx.has_immediate_return_value {
         Ret(ret_cx, Load(ret_cx, fcx.llretptr.get()))
@@ -1837,8 +1840,8 @@ pub fn trans_closure(ccx: @mut CrateContext,
                      id: ast::node_id,
                      attributes: &[ast::Attribute],
                      output_type: ty::t,
-                     maybe_load_env: &fn(fn_ctxt),
-                     finish: &fn(block)) {
+                     maybe_load_env: &fn(@mut FunctionContext),
+                     finish: &fn(@mut Block)) {
     ccx.stats.n_closures += 1;
     let _icx = push_ctxt("trans_closure");
     set_uwtable(llfndecl);
@@ -1944,7 +1947,7 @@ pub fn trans_fn(ccx: @mut CrateContext,
                   |_bcx| { });
 }
 
-fn insert_synthetic_type_entries(bcx: block,
+fn insert_synthetic_type_entries(bcx: @mut Block,
                                  fn_args: &[ast::arg],
                                  arg_tys: &[ty::t])
 {
@@ -2416,7 +2419,7 @@ fn create_entry_fn(ccx: @mut CrateContext,
     }
 }
 
-pub fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef,
+pub fn fill_fn_pair(bcx: @mut Block, pair: ValueRef, llfn: ValueRef,
                     llenvptr: ValueRef) {
     let ccx = bcx.ccx();
     let code_cell = GEPi(bcx, pair, [0u, abi::fn_field_code]);
@@ -2446,7 +2449,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::node_id) -> ValueRef {
         let val = match item {
           ast_map::node_item(i, pth) => {
             let my_path = vec::append((*pth).clone(), [path_name(i.ident)]);
-            match i.node {
+            let v = match i.node {
               ast::item_static(_, m, expr) => {
                 let typ = ty::node_id_to_type(ccx.tcx, i.id);
                 let s = mangle_exported_name(ccx, my_path, typ);
@@ -2478,7 +2481,16 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::node_id) -> ValueRef {
                 llfn
               }
               _ => fail!("get_item_val: weird result in table")
+            };
+            match (attr::first_attr_value_str_by_name(i.attrs, "link_section")) {
+                Some(sect) => unsafe {
+                    do sect.as_c_str |buf| {
+                        llvm::LLVMSetSection(v, buf);
+                    }
+                },
+                None => ()
             }
+            v
           }
           ast_map::node_trait_method(trait_method, _, pth) => {
             debug!("get_item_val(): processing a node_trait_method");
@@ -2637,7 +2649,7 @@ pub fn trans_constants(ccx: @mut CrateContext, crate: &ast::Crate) {
         })));
 }
 
-pub fn vp2i(cx: block, v: ValueRef) -> ValueRef {
+pub fn vp2i(cx: @mut Block, v: ValueRef) -> ValueRef {
     let ccx = cx.ccx();
     return PtrToInt(cx, v, ccx.int_type);
 }
@@ -2737,7 +2749,7 @@ pub fn declare_dbg_intrinsics(llmod: ModuleRef, intrinsics: &mut HashMap<&'stati
     ifn!("llvm.dbg.value",   [Type::metadata(), Type::i64(), Type::metadata()], Type::void());
 }
 
-pub fn trap(bcx: block) {
+pub fn trap(bcx: @mut Block) {
     match bcx.ccx().intrinsics.find_equiv(& &"llvm.trap") {
       Some(&x) => { Call(bcx, x, []); },
       _ => bcx.sess().bug("unbound llvm.trap in trap")
@@ -2999,17 +3011,15 @@ pub fn trans_crate(sess: session::Session,
     write_metadata(ccx, crate);
     if ccx.sess.trans_stats() {
         io::println("--- trans stats ---");
-        io::println(fmt!("n_static_tydescs: %u",
-                         ccx.stats.n_static_tydescs));
-        io::println(fmt!("n_glues_created: %u",
-                         ccx.stats.n_glues_created));
-        io::println(fmt!("n_null_glues: %u", ccx.stats.n_null_glues));
-        io::println(fmt!("n_real_glues: %u", ccx.stats.n_real_glues));
-
-        io::println(fmt!("n_fns: %u", ccx.stats.n_fns));
-        io::println(fmt!("n_monos: %u", ccx.stats.n_monos));
-        io::println(fmt!("n_inlines: %u", ccx.stats.n_inlines));
-        io::println(fmt!("n_closures: %u", ccx.stats.n_closures));
+        printfln!("n_static_tydescs: %u", ccx.stats.n_static_tydescs);
+        printfln!("n_glues_created: %u", ccx.stats.n_glues_created);
+        printfln!("n_null_glues: %u", ccx.stats.n_null_glues);
+        printfln!("n_real_glues: %u", ccx.stats.n_real_glues);
+
+        printfln!("n_fns: %u", ccx.stats.n_fns);
+        printfln!("n_monos: %u", ccx.stats.n_monos);
+        printfln!("n_inlines: %u", ccx.stats.n_inlines);
+        printfln!("n_closures: %u", ccx.stats.n_closures);
         io::println("fn stats:");
         do sort::quick_sort(ccx.stats.fn_stats) |&(_, _, insns_a), &(_, _, insns_b)| {
             insns_a > insns_b
@@ -3017,14 +3027,14 @@ pub fn trans_crate(sess: session::Session,
         for ccx.stats.fn_stats.iter().advance |tuple| {
             match *tuple {
                 (ref name, ms, insns) => {
-                    io::println(fmt!("%u insns, %u ms, %s", insns, ms, *name));
+                    printfln!("%u insns, %u ms, %s", insns, ms, *name);
                 }
             }
         }
     }
     if ccx.sess.count_llvm_insns() {
         for ccx.stats.llvm_insns.iter().advance |(k, v)| {
-            io::println(fmt!("%-7u %s", *v, *k));
+            printfln!("%-7u %s", *v, *k);
         }
     }
 
index a8c7efb2ad43de193024b6f08bbb4ce91b16696a..9c34d2a3526b6b32aff30b6854c7381ea638e92d 100644 (file)
 use std::cast;
 use std::libc::{c_uint, c_ulonglong, c_char};
 
-pub fn terminate(cx: block, _: &str) {
+pub fn terminate(cx: @mut Block, _: &str) {
     cx.terminated = true;
 }
 
-pub fn check_not_terminated(cx: block) {
+pub fn check_not_terminated(cx: @mut Block) {
     if cx.terminated {
         fail!("already terminated!");
     }
 }
 
-pub fn B(cx: block) -> Builder {
+pub fn B(cx: @mut Block) -> Builder {
     let b = cx.fcx.ccx.builder();
     b.position_at_end(cx.llbb);
     b
@@ -47,35 +47,35 @@ pub fn B(cx: block) -> Builder {
 // for (fail/break/return statements, call to diverging functions, etc), and
 // further instructions to the block should simply be ignored.
 
-pub fn RetVoid(cx: block) {
+pub fn RetVoid(cx: @mut Block) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
     terminate(cx, "RetVoid");
     B(cx).ret_void();
 }
 
-pub fn Ret(cx: block, V: ValueRef) {
+pub fn Ret(cx: @mut Block, V: ValueRef) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
     terminate(cx, "Ret");
     B(cx).ret(V);
 }
 
-pub fn AggregateRet(cx: block, RetVals: &[ValueRef]) {
+pub fn AggregateRet(cx: @mut Block, RetVals: &[ValueRef]) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
     terminate(cx, "AggregateRet");
     B(cx).aggregate_ret(RetVals);
 }
 
-pub fn Br(cx: block, Dest: BasicBlockRef) {
+pub fn Br(cx: @mut Block, Dest: BasicBlockRef) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
     terminate(cx, "Br");
     B(cx).br(Dest);
 }
 
-pub fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
+pub fn CondBr(cx: @mut Block, If: ValueRef, Then: BasicBlockRef,
               Else: BasicBlockRef) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
@@ -83,7 +83,7 @@ pub fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
     B(cx).cond_br(If, Then, Else);
 }
 
-pub fn Switch(cx: block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
+pub fn Switch(cx: @mut Block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
     -> ValueRef {
     if cx.unreachable { return _Undef(V); }
     check_not_terminated(cx);
@@ -98,14 +98,14 @@ pub fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) {
     }
 }
 
-pub fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
+pub fn IndirectBr(cx: @mut Block, Addr: ValueRef, NumDests: uint) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
     terminate(cx, "IndirectBr");
     B(cx).indirect_br(Addr, NumDests);
 }
 
-pub fn Invoke(cx: block,
+pub fn Invoke(cx: @mut Block,
               Fn: ValueRef,
               Args: &[ValueRef],
               Then: BasicBlockRef,
@@ -122,7 +122,7 @@ pub fn Invoke(cx: block,
     B(cx).invoke(Fn, Args, Then, Catch)
 }
 
-pub fn FastInvoke(cx: block, Fn: ValueRef, Args: &[ValueRef],
+pub fn FastInvoke(cx: @mut Block, Fn: ValueRef, Args: &[ValueRef],
                   Then: BasicBlockRef, Catch: BasicBlockRef) {
     if cx.unreachable { return; }
     check_not_terminated(cx);
@@ -130,7 +130,7 @@ pub fn FastInvoke(cx: block, Fn: ValueRef, Args: &[ValueRef],
     B(cx).fast_invoke(Fn, Args, Then, Catch);
 }
 
-pub fn Unreachable(cx: block) {
+pub fn Unreachable(cx: @mut Block) {
     if cx.unreachable { return; }
     cx.unreachable = true;
     if !cx.terminated {
@@ -145,177 +145,177 @@ pub fn _Undef(val: ValueRef) -> ValueRef {
 }
 
 /* Arithmetic */
-pub fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn Add(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).add(LHS, RHS)
 }
 
-pub fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn NSWAdd(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).nswadd(LHS, RHS)
 }
 
-pub fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn NUWAdd(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).nuwadd(LHS, RHS)
 }
 
-pub fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn FAdd(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).fadd(LHS, RHS)
 }
 
-pub fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn Sub(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).sub(LHS, RHS)
 }
 
-pub fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn NSWSub(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).nswsub(LHS, RHS)
 }
 
-pub fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn NUWSub(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).nuwsub(LHS, RHS)
 }
 
-pub fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn FSub(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).fsub(LHS, RHS)
 }
 
-pub fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn Mul(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).mul(LHS, RHS)
 }
 
-pub fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn NSWMul(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).nswmul(LHS, RHS)
 }
 
-pub fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn NUWMul(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).nuwmul(LHS, RHS)
 }
 
-pub fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn FMul(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).fmul(LHS, RHS)
 }
 
-pub fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn UDiv(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).udiv(LHS, RHS)
 }
 
-pub fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn SDiv(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).sdiv(LHS, RHS)
 }
 
-pub fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn ExactSDiv(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).exactsdiv(LHS, RHS)
 }
 
-pub fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn FDiv(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).fdiv(LHS, RHS)
 }
 
-pub fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn URem(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).urem(LHS, RHS)
 }
 
-pub fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn SRem(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).srem(LHS, RHS)
 }
 
-pub fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn FRem(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).frem(LHS, RHS)
 }
 
-pub fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn Shl(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).shl(LHS, RHS)
 }
 
-pub fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn LShr(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).lshr(LHS, RHS)
 }
 
-pub fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn AShr(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).ashr(LHS, RHS)
 }
 
-pub fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn And(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).and(LHS, RHS)
 }
 
-pub fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn Or(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).or(LHS, RHS)
 }
 
-pub fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn Xor(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).xor(LHS, RHS)
 }
 
-pub fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef)
+pub fn BinOp(cx: @mut Block, Op: Opcode, LHS: ValueRef, RHS: ValueRef)
           -> ValueRef {
     if cx.unreachable { return _Undef(LHS); }
     B(cx).binop(Op, LHS, RHS)
 }
 
-pub fn Neg(cx: block, V: ValueRef) -> ValueRef {
+pub fn Neg(cx: @mut Block, V: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(V); }
     B(cx).neg(V)
 }
 
-pub fn NSWNeg(cx: block, V: ValueRef) -> ValueRef {
+pub fn NSWNeg(cx: @mut Block, V: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(V); }
     B(cx).nswneg(V)
 }
 
-pub fn NUWNeg(cx: block, V: ValueRef) -> ValueRef {
+pub fn NUWNeg(cx: @mut Block, V: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(V); }
     B(cx).nuwneg(V)
 }
-pub fn FNeg(cx: block, V: ValueRef) -> ValueRef {
+pub fn FNeg(cx: @mut Block, V: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(V); }
     B(cx).fneg(V)
 }
 
-pub fn Not(cx: block, V: ValueRef) -> ValueRef {
+pub fn Not(cx: @mut Block, V: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(V); }
     B(cx).not(V)
 }
 
 /* Memory */
-pub fn Malloc(cx: block, Ty: Type) -> ValueRef {
+pub fn Malloc(cx: @mut Block, Ty: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
         B(cx).malloc(Ty)
     }
 }
 
-pub fn ArrayMalloc(cx: block, Ty: Type, Val: ValueRef) -> ValueRef {
+pub fn ArrayMalloc(cx: @mut Block, Ty: Type, Val: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
         B(cx).array_malloc(Ty, Val)
     }
 }
 
-pub fn Alloca(cx: block, Ty: Type, name: &str) -> ValueRef {
+pub fn Alloca(cx: @mut Block, Ty: Type, name: &str) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
         let b = cx.fcx.ccx.builder();
@@ -324,7 +324,7 @@ pub fn Alloca(cx: block, Ty: Type, name: &str) -> ValueRef {
     }
 }
 
-pub fn ArrayAlloca(cx: block, Ty: Type, Val: ValueRef) -> ValueRef {
+pub fn ArrayAlloca(cx: @mut Block, Ty: Type, Val: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
         let b = cx.fcx.ccx.builder();
@@ -333,12 +333,12 @@ pub fn ArrayAlloca(cx: block, Ty: Type, Val: ValueRef) -> ValueRef {
     }
 }
 
-pub fn Free(cx: block, PointerVal: ValueRef) {
+pub fn Free(cx: @mut Block, PointerVal: ValueRef) {
     if cx.unreachable { return; }
     B(cx).free(PointerVal)
 }
 
-pub fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
+pub fn Load(cx: @mut Block, PointerVal: ValueRef) -> ValueRef {
     unsafe {
         let ccx = cx.fcx.ccx;
         if cx.unreachable {
@@ -354,7 +354,7 @@ pub fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
     }
 }
 
-pub fn AtomicLoad(cx: block, PointerVal: ValueRef, order: AtomicOrdering) -> ValueRef {
+pub fn AtomicLoad(cx: @mut Block, PointerVal: ValueRef, order: AtomicOrdering) -> ValueRef {
     unsafe {
         let ccx = cx.fcx.ccx;
         if cx.unreachable {
@@ -365,7 +365,7 @@ pub fn AtomicLoad(cx: block, PointerVal: ValueRef, order: AtomicOrdering) -> Val
 }
 
 
-pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
+pub fn LoadRangeAssert(cx: @mut Block, PointerVal: ValueRef, lo: c_ulonglong,
                        hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
     if cx.unreachable {
         let ccx = cx.fcx.ccx;
@@ -383,17 +383,17 @@ pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
     }
 }
 
-pub fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
+pub fn Store(cx: @mut Block, Val: ValueRef, Ptr: ValueRef) {
     if cx.unreachable { return; }
     B(cx).store(Val, Ptr)
 }
 
-pub fn AtomicStore(cx: block, Val: ValueRef, Ptr: ValueRef, order: AtomicOrdering) {
+pub fn AtomicStore(cx: @mut Block, Val: ValueRef, Ptr: ValueRef, order: AtomicOrdering) {
     if cx.unreachable { return; }
     B(cx).atomic_store(Val, Ptr, order)
 }
 
-pub fn GEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
+pub fn GEP(cx: @mut Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
         B(cx).gep(Pointer, Indices)
@@ -403,35 +403,35 @@ pub fn GEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
 // Simple wrapper around GEP that takes an array of ints and wraps them
 // in C_i32()
 #[inline]
-pub fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
+pub fn GEPi(cx: @mut Block, base: ValueRef, ixs: &[uint]) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
         B(cx).gepi(base, ixs)
     }
 }
 
-pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
+pub fn InBoundsGEP(cx: @mut Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
         B(cx).inbounds_gep(Pointer, Indices)
     }
 }
 
-pub fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef {
+pub fn StructGEP(cx: @mut Block, Pointer: ValueRef, Idx: uint) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
         B(cx).struct_gep(Pointer, Idx)
     }
 }
 
-pub fn GlobalString(cx: block, _Str: *c_char) -> ValueRef {
+pub fn GlobalString(cx: @mut Block, _Str: *c_char) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
         B(cx).global_string(_Str)
     }
 }
 
-pub fn GlobalStringPtr(cx: block, _Str: *c_char) -> ValueRef {
+pub fn GlobalStringPtr(cx: @mut Block, _Str: *c_char) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
         B(cx).global_string_ptr(_Str)
@@ -439,112 +439,112 @@ pub fn GlobalStringPtr(cx: block, _Str: *c_char) -> ValueRef {
 }
 
 /* Casts */
-pub fn Trunc(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn Trunc(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).trunc(Val, DestTy)
     }
 }
 
-pub fn ZExt(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn ZExt(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).zext(Val, DestTy)
     }
 }
 
-pub fn SExt(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn SExt(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).sext(Val, DestTy)
     }
 }
 
-pub fn FPToUI(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn FPToUI(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).fptoui(Val, DestTy)
     }
 }
 
-pub fn FPToSI(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn FPToSI(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).fptosi(Val, DestTy)
     }
 }
 
-pub fn UIToFP(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn UIToFP(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).uitofp(Val, DestTy)
     }
 }
 
-pub fn SIToFP(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn SIToFP(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).sitofp(Val, DestTy)
     }
 }
 
-pub fn FPTrunc(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn FPTrunc(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).fptrunc(Val, DestTy)
     }
 }
 
-pub fn FPExt(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn FPExt(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).fpext(Val, DestTy)
     }
 }
 
-pub fn PtrToInt(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn PtrToInt(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).ptrtoint(Val, DestTy)
     }
 }
 
-pub fn IntToPtr(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn IntToPtr(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).inttoptr(Val, DestTy)
     }
 }
 
-pub fn BitCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn BitCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).bitcast(Val, DestTy)
     }
 }
 
-pub fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn ZExtOrBitCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).zext_or_bitcast(Val, DestTy)
     }
 }
 
-pub fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn SExtOrBitCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).sext_or_bitcast(Val, DestTy)
     }
 }
 
-pub fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn TruncOrBitCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).trunc_or_bitcast(Val, DestTy)
     }
 }
 
-pub fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: Type, _: *u8)
+pub fn Cast(cx: @mut Block, Op: Opcode, Val: ValueRef, DestTy: Type, _: *u8)
      -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
@@ -552,21 +552,21 @@ pub fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: Type, _: *u8)
     }
 }
 
-pub fn PointerCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn PointerCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).pointercast(Val, DestTy)
     }
 }
 
-pub fn IntCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn IntCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).intcast(Val, DestTy)
     }
 }
 
-pub fn FPCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
+pub fn FPCast(cx: @mut Block, Val: ValueRef, DestTy: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
         B(cx).fpcast(Val, DestTy)
@@ -575,7 +575,7 @@ pub fn FPCast(cx: block, Val: ValueRef, DestTy: Type) -> ValueRef {
 
 
 /* Comparisons */
-pub fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
+pub fn ICmp(cx: @mut Block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
      -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
@@ -583,7 +583,7 @@ pub fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
     }
 }
 
-pub fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
+pub fn FCmp(cx: @mut Block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
      -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
@@ -592,14 +592,14 @@ pub fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
 }
 
 /* Miscellaneous instructions */
-pub fn EmptyPhi(cx: block, Ty: Type) -> ValueRef {
+pub fn EmptyPhi(cx: @mut Block, Ty: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Ty.to_ref()); }
         B(cx).empty_phi(Ty)
     }
 }
 
-pub fn Phi(cx: block, Ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef {
+pub fn Phi(cx: @mut Block, Ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Ty.to_ref()); }
         B(cx).phi(Ty, vals, bbs)
@@ -615,7 +615,7 @@ pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
     }
 }
 
-pub fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
+pub fn _UndefReturn(cx: @mut Block, Fn: ValueRef) -> ValueRef {
     unsafe {
         let ccx = cx.fcx.ccx;
         let ty = val_ty(Fn);
@@ -629,57 +629,57 @@ pub fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
     }
 }
 
-pub fn add_span_comment(cx: block, sp: span, text: &str) {
+pub fn add_span_comment(cx: @mut Block, sp: span, text: &str) {
     B(cx).add_span_comment(sp, text)
 }
 
-pub fn add_comment(cx: block, text: &str) {
+pub fn add_comment(cx: @mut Block, text: &str) {
     B(cx).add_comment(text)
 }
 
-pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,
+pub fn InlineAsmCall(cx: @mut Block, asm: *c_char, cons: *c_char,
                      inputs: &[ValueRef], output: Type,
                      volatile: bool, alignstack: bool,
                      dia: AsmDialect) -> ValueRef {
     B(cx).inline_asm_call(asm, cons, inputs, output, volatile, alignstack, dia)
 }
 
-pub fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
+pub fn Call(cx: @mut Block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
     if cx.unreachable { return _UndefReturn(cx, Fn); }
     B(cx).call(Fn, Args)
 }
 
-pub fn FastCall(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
+pub fn FastCall(cx: @mut Block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
     if cx.unreachable { return _UndefReturn(cx, Fn); }
     B(cx).call(Fn, Args)
 }
 
-pub fn CallWithConv(cx: block, Fn: ValueRef, Args: &[ValueRef],
+pub fn CallWithConv(cx: @mut Block, Fn: ValueRef, Args: &[ValueRef],
                     Conv: CallConv) -> ValueRef {
     if cx.unreachable { return _UndefReturn(cx, Fn); }
     B(cx).call_with_conv(Fn, Args, Conv)
 }
 
-pub fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef {
+pub fn Select(cx: @mut Block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef {
     if cx.unreachable { return _Undef(Then); }
     B(cx).select(If, Then, Else)
 }
 
-pub fn VAArg(cx: block, list: ValueRef, Ty: Type) -> ValueRef {
+pub fn VAArg(cx: @mut Block, list: ValueRef, Ty: Type) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Ty.to_ref()); }
         B(cx).va_arg(list, Ty)
     }
 }
 
-pub fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) -> ValueRef {
+pub fn ExtractElement(cx: @mut Block, VecVal: ValueRef, Index: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
         B(cx).extract_element(VecVal, Index)
     }
 }
 
-pub fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
+pub fn InsertElement(cx: @mut Block, VecVal: ValueRef, EltVal: ValueRef,
                      Index: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
@@ -687,7 +687,7 @@ pub fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
     }
 }
 
-pub fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
+pub fn ShuffleVector(cx: @mut Block, V1: ValueRef, V2: ValueRef,
                      Mask: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
@@ -695,40 +695,40 @@ pub fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
     }
 }
 
-pub fn VectorSplat(cx: block, NumElts: uint, EltVal: ValueRef) -> ValueRef {
+pub fn VectorSplat(cx: @mut Block, NumElts: uint, EltVal: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
         B(cx).vector_splat(NumElts, EltVal)
     }
 }
 
-pub fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
+pub fn ExtractValue(cx: @mut Block, AggVal: ValueRef, Index: uint) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
         B(cx).extract_value(AggVal, Index)
     }
 }
 
-pub fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) {
+pub fn InsertValue(cx: @mut Block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) {
     if cx.unreachable { return; }
     B(cx).insert_value(AggVal, EltVal, Index)
 }
 
-pub fn IsNull(cx: block, Val: ValueRef) -> ValueRef {
+pub fn IsNull(cx: @mut Block, Val: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
         B(cx).is_null(Val)
     }
 }
 
-pub fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef {
+pub fn IsNotNull(cx: @mut Block, Val: ValueRef) -> ValueRef {
     unsafe {
         if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
         B(cx).is_not_null(Val)
     }
 }
 
-pub fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
+pub fn PtrDiff(cx: @mut Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     unsafe {
         let ccx = cx.fcx.ccx;
         if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type.to_ref()); }
@@ -736,35 +736,35 @@ pub fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
     }
 }
 
-pub fn Trap(cx: block) {
+pub fn Trap(cx: @mut Block) {
     if cx.unreachable { return; }
     B(cx).trap();
 }
 
-pub fn LandingPad(cx: block, Ty: Type, PersFn: ValueRef,
+pub fn LandingPad(cx: @mut Block, Ty: Type, PersFn: ValueRef,
                   NumClauses: uint) -> ValueRef {
     check_not_terminated(cx);
     assert!(!cx.unreachable);
     B(cx).landing_pad(Ty, PersFn, NumClauses)
 }
 
-pub fn SetCleanup(cx: block, LandingPad: ValueRef) {
+pub fn SetCleanup(cx: @mut Block, LandingPad: ValueRef) {
     B(cx).set_cleanup(LandingPad)
 }
 
-pub fn Resume(cx: block, Exn: ValueRef) -> ValueRef {
+pub fn Resume(cx: @mut Block, Exn: ValueRef) -> ValueRef {
     check_not_terminated(cx);
     terminate(cx, "Resume");
     B(cx).resume(Exn)
 }
 
 // Atomic Operations
-pub fn AtomicCmpXchg(cx: block, dst: ValueRef,
+pub fn AtomicCmpXchg(cx: @mut Block, dst: ValueRef,
                      cmp: ValueRef, src: ValueRef,
                      order: AtomicOrdering) -> ValueRef {
     B(cx).atomic_cmpxchg(dst, cmp, src, order)
 }
-pub fn AtomicRMW(cx: block, op: AtomicBinOp,
+pub fn AtomicRMW(cx: @mut Block, op: AtomicBinOp,
                  dst: ValueRef, src: ValueRef,
                  order: AtomicOrdering) -> ValueRef {
     B(cx).atomic_rmw(op, dst, src, order)
index b7e157bc7e25423fdc442a6c4ecaff064002cbe3..d6215cd60af32be1824212aa4cdda952fa1c4ca0 100644 (file)
@@ -56,7 +56,7 @@ pub fn decl_fn(&self, decl: &fn(fnty: Type) -> ValueRef) -> ValueRef {
         return llfn;
     }
 
-    pub fn build_shim_args(&self, bcx: block, arg_tys: &[Type], llargbundle: ValueRef)
+    pub fn build_shim_args(&self, bcx: @mut Block, arg_tys: &[Type], llargbundle: ValueRef)
                            -> ~[ValueRef] {
         let mut atys: &[LLVMType] = self.arg_tys;
         let mut attrs: &[option::Option<Attribute>] = self.attrs;
@@ -90,7 +90,7 @@ pub fn build_shim_args(&self, bcx: block, arg_tys: &[Type], llargbundle: ValueRe
         return llargvals;
     }
 
-    pub fn build_shim_ret(&self, bcx: block, arg_tys: &[Type], ret_def: bool,
+    pub fn build_shim_ret(&self, bcx: @mut Block, arg_tys: &[Type], ret_def: bool,
                           llargbundle: ValueRef, llretval: ValueRef) {
         for self.attrs.iter().enumerate().advance |(i, a)| {
             match *a {
@@ -120,7 +120,7 @@ pub fn build_shim_ret(&self, bcx: block, arg_tys: &[Type], ret_def: bool,
         };
     }
 
-    pub fn build_wrap_args(&self, bcx: block, ret_ty: Type,
+    pub fn build_wrap_args(&self, bcx: @mut Block, ret_ty: Type,
                            llwrapfn: ValueRef, llargbundle: ValueRef) {
         let mut atys: &[LLVMType] = self.arg_tys;
         let mut attrs: &[option::Option<Attribute>] = self.attrs;
@@ -156,7 +156,7 @@ pub fn build_wrap_args(&self, bcx: block, ret_ty: Type,
         store_inbounds(bcx, llretptr, llargbundle, [0u, n]);
     }
 
-    pub fn build_wrap_ret(&self, bcx: block, arg_tys: &[Type], llargbundle: ValueRef) {
+    pub fn build_wrap_ret(&self, bcx: @mut Block, arg_tys: &[Type], llargbundle: ValueRef) {
         if self.ret_ty.ty.kind() == Void {
             return;
         }
index 73adcec71e46227b8ff8b9df2053ef34247e749b..d64615e5dc7b3507909544804eb363dbc0abaa35 100644 (file)
@@ -72,11 +72,11 @@ pub enum CalleeData {
 }
 
 pub struct Callee {
-    bcx: block,
+    bcx: @mut Block,
     data: CalleeData
 }
 
-pub fn trans(bcx: block, expr: @ast::expr) -> Callee {
+pub fn trans(bcx: @mut Block, expr: @ast::expr) -> Callee {
     let _icx = push_ctxt("trans_callee");
     debug!("callee::trans(expr=%s)", expr.repr(bcx.tcx()));
 
@@ -91,7 +91,7 @@ pub fn trans(bcx: block, expr: @ast::expr) -> Callee {
     // any other expressions are closures:
     return datum_callee(bcx, expr);
 
-    fn datum_callee(bcx: block, expr: @ast::expr) -> Callee {
+    fn datum_callee(bcx: @mut Block, expr: @ast::expr) -> Callee {
         let DatumBlock {bcx, datum} = expr::trans_to_datum(bcx, expr);
         match ty::get(datum.ty).sty {
             ty::ty_bare_fn(*) => {
@@ -110,11 +110,11 @@ fn datum_callee(bcx: block, expr: @ast::expr) -> Callee {
         }
     }
 
-    fn fn_callee(bcx: block, fd: FnData) -> Callee {
+    fn fn_callee(bcx: @mut Block, fd: FnData) -> Callee {
         return Callee {bcx: bcx, data: Fn(fd)};
     }
 
-    fn trans_def(bcx: block, def: ast::def, ref_expr: @ast::expr) -> Callee {
+    fn trans_def(bcx: @mut Block, def: ast::def, ref_expr: @ast::expr) -> Callee {
         match def {
             ast::def_fn(did, _) | ast::def_static_method(did, None, _) => {
                 fn_callee(bcx, trans_fn_ref(bcx, did, ref_expr.id))
@@ -155,14 +155,14 @@ fn trans_def(bcx: block, def: ast::def, ref_expr: @ast::expr) -> Callee {
     }
 }
 
-pub fn trans_fn_ref_to_callee(bcx: block,
+pub fn trans_fn_ref_to_callee(bcx: @mut Block,
                               def_id: ast::def_id,
                               ref_id: ast::node_id) -> Callee {
     Callee {bcx: bcx,
             data: Fn(trans_fn_ref(bcx, def_id, ref_id))}
 }
 
-pub fn trans_fn_ref(bcx: block,
+pub fn trans_fn_ref(bcx: @mut Block,
                     def_id: ast::def_id,
                     ref_id: ast::node_id) -> FnData {
     /*!
@@ -182,7 +182,7 @@ pub fn trans_fn_ref(bcx: block,
 }
 
 pub fn trans_fn_ref_with_vtables_to_callee(
-        bcx: block,
+        bcx: @mut Block,
         def_id: ast::def_id,
         ref_id: ast::node_id,
         type_params: &[ty::t],
@@ -193,7 +193,7 @@ pub fn trans_fn_ref_with_vtables_to_callee(
                                                type_params, vtables))}
 }
 
-fn get_impl_resolutions(bcx: block,
+fn get_impl_resolutions(bcx: @mut Block,
                         impl_id: ast::def_id)
                          -> typeck::vtable_res {
     if impl_id.crate == ast::local_crate {
@@ -208,7 +208,7 @@ fn get_impl_resolutions(bcx: block,
     }
 }
 
-fn resolve_default_method_vtables(bcx: block,
+fn resolve_default_method_vtables(bcx: @mut Block,
                                   impl_id: ast::def_id,
                                   method: &ty::Method,
                                   substs: &ty::substs,
@@ -246,7 +246,7 @@ fn resolve_default_method_vtables(bcx: block,
 
 
 pub fn trans_fn_ref_with_vtables(
-        bcx: block,            //
+        bcx: @mut Block,       //
         def_id: ast::def_id,   // def id of fn
         ref_id: ast::node_id,  // node id of use of fn; may be zero if N/A
         type_params: &[ty::t], // values for fn's ty params
@@ -431,13 +431,13 @@ pub fn trans_fn_ref_with_vtables(
 // ______________________________________________________________________
 // Translating calls
 
-pub fn trans_call(in_cx: block,
+pub fn trans_call(in_cx: @mut Block,
                   call_ex: @ast::expr,
                   f: @ast::expr,
                   args: CallArgs,
                   id: ast::node_id,
                   dest: expr::Dest)
-                  -> block {
+                  -> @mut Block {
     let _icx = push_ctxt("trans_call");
     trans_call_inner(in_cx,
                      call_ex.info(),
@@ -449,13 +449,13 @@ pub fn trans_call(in_cx: block,
                      DontAutorefArg).bcx
 }
 
-pub fn trans_method_call(in_cx: block,
+pub fn trans_method_call(in_cx: @mut Block,
                          call_ex: @ast::expr,
                          callee_id: ast::node_id,
                          rcvr: @ast::expr,
                          args: CallArgs,
                          dest: expr::Dest)
-                         -> block {
+                         -> @mut Block {
     let _icx = push_ctxt("trans_method_call");
     debug!("trans_method_call(call_ex=%s, rcvr=%s)",
            call_ex.repr(in_cx.tcx()),
@@ -487,7 +487,7 @@ pub fn trans_method_call(in_cx: block,
         DontAutorefArg).bcx
 }
 
-pub fn trans_lang_call(bcx: block,
+pub fn trans_lang_call(bcx: @mut Block,
                        did: ast::def_id,
                        args: &[ValueRef],
                        dest: Option<expr::Dest>)
@@ -514,12 +514,12 @@ pub fn trans_lang_call(bcx: block,
                              DontAutorefArg)
 }
 
-pub fn trans_lang_call_with_type_params(bcx: block,
+pub fn trans_lang_call_with_type_params(bcx: @mut Block,
                                         did: ast::def_id,
                                         args: &[ValueRef],
                                         type_params: &[ty::t],
                                         dest: expr::Dest)
-    -> block {
+    -> @mut Block {
     let fty;
     if did.crate == ast::local_crate {
         fty = ty::node_id_to_type(bcx.tcx(), did.node);
@@ -572,11 +572,11 @@ pub fn body_contains_ret(body: &ast::Block) -> bool {
 }
 
 // See [Note-arg-mode]
-pub fn trans_call_inner(in_cx: block,
+pub fn trans_call_inner(in_cx: @mut Block,
                         call_info: Option<NodeInfo>,
                         fn_expr_ty: ty::t,
                         ret_ty: ty::t,
-                        get_callee: &fn(block) -> Callee,
+                        get_callee: &fn(@mut Block) -> Callee,
                         args: CallArgs,
                         dest: Option<expr::Dest>,
                         autoref_arg: AutorefArg)
@@ -654,9 +654,9 @@ pub fn trans_call_inner(in_cx: block,
 
         // Uncomment this to debug calls.
         /*
-        io::println(fmt!("calling: %s", bcx.val_to_str(llfn)));
+        printfln!("calling: %s", bcx.val_to_str(llfn));
         for llargs.iter().advance |llarg| {
-            io::println(fmt!("arg: %s", bcx.val_to_str(*llarg)));
+            printfln!("arg: %s", bcx.val_to_str(*llarg));
         }
         io::println("---");
         */
@@ -718,7 +718,7 @@ pub enum CallArgs<'self> {
     ArgVals(&'self [ValueRef])
 }
 
-pub fn trans_ret_slot(bcx: block, fn_ty: ty::t, dest: Option<expr::Dest>)
+pub fn trans_ret_slot(bcx: @mut Block, fn_ty: ty::t, dest: Option<expr::Dest>)
                       -> ValueRef {
     let retty = ty::ty_fn_ret(fn_ty);
 
@@ -736,12 +736,12 @@ pub fn trans_ret_slot(bcx: block, fn_ty: ty::t, dest: Option<expr::Dest>)
     }
 }
 
-pub fn trans_args(cx: block,
+pub fn trans_args(cx: @mut Block,
                   args: CallArgs,
                   fn_ty: ty::t,
                   ret_flag: Option<ValueRef>,
                   autoref_arg: AutorefArg,
-                  llargs: &mut ~[ValueRef]) -> block
+                  llargs: &mut ~[ValueRef]) -> @mut Block
 {
     let _icx = push_ctxt("trans_args");
     let mut temp_cleanups = ~[];
@@ -790,7 +790,7 @@ pub enum AutorefArg {
 
 // temp_cleanups: cleanups that should run only if failure occurs before the
 // call takes place:
-pub fn trans_arg_expr(bcx: block,
+pub fn trans_arg_expr(bcx: @mut Block,
                       formal_arg_ty: ty::t,
                       self_mode: ty::SelfMode,
                       arg_expr: @ast::expr,
index 5723e24e421b8cb61975a4bfd4c127003366619c..6e0f0eeee87717839ca7be938dc5994a8d2dcfb0 100644 (file)
@@ -156,7 +156,7 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
     return cdata_ty;
 }
 
-fn heap_for_unique_closure(bcx: block, t: ty::t) -> heap {
+fn heap_for_unique_closure(bcx: @mut Block, t: ty::t) -> heap {
     if ty::type_contents(bcx.tcx(), t).contains_managed() {
         heap_managed_unique
     } else {
@@ -164,7 +164,7 @@ fn heap_for_unique_closure(bcx: block, t: ty::t) -> heap {
     }
 }
 
-pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
+pub fn allocate_cbox(bcx: @mut Block, sigil: ast::Sigil, cdata_ty: ty::t)
                   -> Result {
     let _icx = push_ctxt("closure::allocate_cbox");
     let ccx = bcx.ccx();
@@ -189,14 +189,14 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
 pub struct ClosureResult {
     llbox: ValueRef, // llvalue of ptr to closure
     cdata_ty: ty::t, // type of the closure data
-    bcx: block       // final bcx
+    bcx: @mut Block       // final bcx
 }
 
 // Given a block context and a list of tydescs and values to bind
 // construct a closure out of them. If copying is true, it is a
 // heap allocated closure that copies the upvars into environment.
 // Otherwise, it is stack allocated and copies pointers to the upvars.
-pub fn store_environment(bcx: block,
+pub fn store_environment(bcx: @mut Block,
                          bound_values: ~[EnvValue],
                          sigil: ast::Sigil) -> ClosureResult {
     let _icx = push_ctxt("closure::store_environment");
@@ -257,7 +257,7 @@ pub fn store_environment(bcx: block,
 
 // Given a context and a list of upvars, build a closure. This just
 // collects the upvars and packages them up for store_environment.
-pub fn build_closure(bcx0: block,
+pub fn build_closure(bcx0: @mut Block,
                      cap_vars: &[moves::CaptureVar],
                      sigil: ast::Sigil,
                      include_ret_handle: Option<ValueRef>) -> ClosureResult {
@@ -318,7 +318,7 @@ pub fn build_closure(bcx0: block,
 // Given an enclosing block context, a new function context, a closure type,
 // and a list of upvars, generate code to load and populate the environment
 // with the upvars and type descriptors.
-pub fn load_environment(fcx: fn_ctxt,
+pub fn load_environment(fcx: @mut FunctionContext,
                         cdata_ty: ty::t,
                         cap_vars: &[moves::CaptureVar],
                         load_ret_handle: bool,
@@ -355,14 +355,14 @@ pub fn load_environment(fcx: fn_ctxt,
     }
 }
 
-pub fn trans_expr_fn(bcx: block,
+pub fn trans_expr_fn(bcx: @mut Block,
                      sigil: ast::Sigil,
                      decl: &ast::fn_decl,
                      body: &ast::Block,
                      outer_id: ast::node_id,
                      user_id: ast::node_id,
                      is_loop_body: Option<Option<ValueRef>>,
-                     dest: expr::Dest) -> block {
+                     dest: expr::Dest) -> @mut Block {
     /*!
      *
      * Translates the body of a closure expression.
@@ -455,10 +455,10 @@ pub fn trans_expr_fn(bcx: block,
 }
 
 pub fn make_closure_glue(
-        cx: block,
+        cx: @mut Block,
         v: ValueRef,
         t: ty::t,
-        glue_fn: &fn(block, v: ValueRef, t: ty::t) -> block) -> block {
+        glue_fn: &fn(@mut Block, v: ValueRef, t: ty::t) -> @mut Block) -> @mut Block {
     let _icx = push_ctxt("closure::make_closure_glue");
     let bcx = cx;
     let tcx = cx.tcx();
@@ -478,10 +478,10 @@ pub fn make_closure_glue(
 }
 
 pub fn make_opaque_cbox_take_glue(
-    bcx: block,
+    bcx: @mut Block,
     sigil: ast::Sigil,
     cboxptr: ValueRef)     // ptr to ptr to the opaque closure
-    -> block {
+    -> @mut Block {
     // Easy cases:
     let _icx = push_ctxt("closure::make_opaque_cbox_take_glue");
     match sigil {
@@ -499,10 +499,10 @@ pub fn make_opaque_cbox_take_glue(
 }
 
 pub fn make_opaque_cbox_drop_glue(
-    bcx: block,
+    bcx: @mut Block,
     sigil: ast::Sigil,
     cboxptr: ValueRef)     // ptr to the opaque closure
-    -> block {
+    -> @mut Block {
     let _icx = push_ctxt("closure::make_opaque_cbox_drop_glue");
     match sigil {
         ast::BorrowedSigil => bcx,
@@ -520,10 +520,10 @@ pub fn make_opaque_cbox_drop_glue(
 }
 
 pub fn make_opaque_cbox_free_glue(
-    bcx: block,
+    bcx: @mut Block,
     sigil: ast::Sigil,
     cbox: ValueRef)     // ptr to ptr to the opaque closure
-    -> block {
+    -> @mut Block {
     let _icx = push_ctxt("closure::make_opaque_cbox_free_glue");
     match sigil {
         ast::BorrowedSigil => {
index 995cda92d9b8ce6bb5bec456793b1b50d5f1a88b..fef6607bbed8e925eeda2f00c3c9ac6ad69089d1 100644 (file)
@@ -157,7 +157,7 @@ fn repr(&self, tcx: ty::ctxt) -> ~str {
 
 // Function context.  Every LLVM function we create will have one of
 // these.
-pub struct fn_ctxt_ {
+pub struct FunctionContext {
     // The ValueRef returned from a call to llvm::LLVMAddFunction; the
     // address of the first instruction in the sequence of
     // instructions for this function that will go in the .text
@@ -174,7 +174,7 @@ pub struct fn_ctxt_ {
     // always be Some.
     llretptr: Option<ValueRef>,
 
-    entry_bcx: Option<block>,
+    entry_bcx: Option<@mut Block>,
 
     // These elements: "hoisted basic blocks" containing
     // administrative activities that have to happen in only one place in
@@ -227,7 +227,7 @@ pub struct fn_ctxt_ {
     ccx: @mut CrateContext
 }
 
-impl fn_ctxt_ {
+impl FunctionContext {
     pub fn arg_pos(&self, arg: uint) -> uint {
         if self.has_immediate_return_value {
             arg + 1u
@@ -266,8 +266,6 @@ pub fn get_llreturn(&mut self) -> BasicBlockRef {
     }
 }
 
-pub type fn_ctxt = @mut fn_ctxt_;
-
 pub fn warn_not_to_commit(ccx: &mut CrateContext, msg: &str) {
     if !ccx.do_not_commit_warning_issued {
         ccx.do_not_commit_warning_issued = true;
@@ -291,8 +289,8 @@ pub enum cleantype {
 }
 
 pub enum cleanup {
-    clean(@fn(block) -> block, cleantype),
-    clean_temp(ValueRef, @fn(block) -> block, cleantype),
+    clean(@fn(@mut Block) -> @mut Block, cleantype),
+    clean_temp(ValueRef, @fn(@mut Block) -> @mut Block, cleantype),
 }
 
 // Can't use deriving(Clone) because of the managed closure.
@@ -314,13 +312,13 @@ pub struct cleanup_path {
     dest: BasicBlockRef
 }
 
-pub fn shrink_scope_clean(scope_info: &mut scope_info, size: uint) {
+pub fn shrink_scope_clean(scope_info: &mut ScopeInfo, size: uint) {
     scope_info.landing_pad = None;
     scope_info.cleanup_paths = scope_info.cleanup_paths.iter()
             .take_while(|&cu| cu.size <= size).transform(|&x|x).collect();
 }
 
-pub fn grow_scope_clean(scope_info: &mut scope_info) {
+pub fn grow_scope_clean(scope_info: &mut ScopeInfo) {
     scope_info.landing_pad = None;
 }
 
@@ -332,7 +330,7 @@ pub fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype {
     }
 }
 
-pub fn add_clean(bcx: block, val: ValueRef, t: ty::t) {
+pub fn add_clean(bcx: @mut Block, val: ValueRef, t: ty::t) {
     if !ty::type_needs_drop(bcx.tcx(), t) { return; }
 
     debug!("add_clean(%s, %s, %s)", bcx.to_str(), bcx.val_to_str(val), t.repr(bcx.tcx()));
@@ -344,7 +342,7 @@ pub fn add_clean(bcx: block, val: ValueRef, t: ty::t) {
     }
 }
 
-pub fn add_clean_temp_immediate(cx: block, val: ValueRef, ty: ty::t) {
+pub fn add_clean_temp_immediate(cx: @mut Block, val: ValueRef, ty: ty::t) {
     if !ty::type_needs_drop(cx.tcx(), ty) { return; }
     debug!("add_clean_temp_immediate(%s, %s, %s)",
            cx.to_str(), cx.val_to_str(val),
@@ -358,15 +356,18 @@ pub fn add_clean_temp_immediate(cx: block, val: ValueRef, ty: ty::t) {
     }
 }
 
-pub fn add_clean_temp_mem(bcx: block, val: ValueRef, t: ty::t) {
+pub fn add_clean_temp_mem(bcx: @mut Block, val: ValueRef, t: ty::t) {
     add_clean_temp_mem_in_scope_(bcx, None, val, t);
 }
 
-pub fn add_clean_temp_mem_in_scope(bcx: block, scope_id: ast::node_id, val: ValueRef, t: ty::t) {
+pub fn add_clean_temp_mem_in_scope(bcx: @mut Block,
+                                   scope_id: ast::node_id,
+                                   val: ValueRef,
+                                   t: ty::t) {
     add_clean_temp_mem_in_scope_(bcx, Some(scope_id), val, t);
 }
 
-pub fn add_clean_temp_mem_in_scope_(bcx: block, scope_id: Option<ast::node_id>,
+pub fn add_clean_temp_mem_in_scope_(bcx: @mut Block, scope_id: Option<ast::node_id>,
                                     val: ValueRef, t: ty::t) {
     if !ty::type_needs_drop(bcx.tcx(), t) { return; }
     debug!("add_clean_temp_mem(%s, %s, %s)",
@@ -378,7 +379,7 @@ pub fn add_clean_temp_mem_in_scope_(bcx: block, scope_id: Option<ast::node_id>,
         grow_scope_clean(scope_info);
     }
 }
-pub fn add_clean_return_to_mut(bcx: block,
+pub fn add_clean_return_to_mut(bcx: @mut Block,
                                scope_id: ast::node_id,
                                root_key: root_map_key,
                                frozen_val_ref: ValueRef,
@@ -407,14 +408,14 @@ pub fn add_clean_return_to_mut(bcx: block,
         grow_scope_clean(scope_info);
     }
 }
-pub fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
+pub fn add_clean_free(cx: @mut Block, ptr: ValueRef, heap: heap) {
     let free_fn = match heap {
       heap_managed | heap_managed_unique => {
-        let f: @fn(block) -> block = |a| glue::trans_free(a, ptr);
+        let f: @fn(@mut Block) -> @mut Block = |a| glue::trans_free(a, ptr);
         f
       }
       heap_exchange | heap_exchange_closure => {
-        let f: @fn(block) -> block = |a| glue::trans_exchange_free(a, ptr);
+        let f: @fn(@mut Block) -> @mut Block = |a| glue::trans_exchange_free(a, ptr);
         f
       }
     };
@@ -429,7 +430,7 @@ pub fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
 // to a system where we can also cancel the cleanup on local variables, but
 // this will be more involved. For now, we simply zero out the local, and the
 // drop glue checks whether it is zero.
-pub fn revoke_clean(cx: block, val: ValueRef) {
+pub fn revoke_clean(cx: @mut Block, val: ValueRef) {
     do in_scope_cx(cx, None) |scope_info| {
         let cleanup_pos = scope_info.cleanups.iter().position(
             |cu| match *cu {
@@ -446,16 +447,16 @@ pub fn revoke_clean(cx: block, val: ValueRef) {
     }
 }
 
-pub fn block_cleanups(bcx: block) -> ~[cleanup] {
+pub fn block_cleanups(bcx: @mut Block) -> ~[cleanup] {
     match bcx.scope {
        None  => ~[],
        Some(inf) => inf.cleanups.clone(),
     }
 }
 
-pub struct scope_info {
-    parent: Option<@mut scope_info>,
-    loop_break: Option<block>,
+pub struct ScopeInfo {
+    parent: Option<@mut ScopeInfo>,
+    loop_break: Option<@mut Block>,
     loop_label: Option<ident>,
     // A list of functions that must be run at when leaving this
     // block, cleaning up any variables that were introduced in the
@@ -470,7 +471,7 @@ pub struct scope_info {
     node_info: Option<NodeInfo>,
 }
 
-impl scope_info {
+impl ScopeInfo {
     pub fn empty_cleanups(&mut self) -> bool {
         self.cleanups.is_empty()
     }
@@ -513,7 +514,7 @@ pub struct NodeInfo {
 // code.  Each basic block we generate is attached to a function, typically
 // with many basic blocks per function.  All the basic blocks attached to a
 // function are organized as a directed graph.
-pub struct block_ {
+pub struct Block {
     // The BasicBlockRef returned from a call to
     // llvm::LLVMAppendBasicBlock(llfn, name), which adds a basic
     // block to the function pointed to by llfn.  We insert
@@ -522,53 +523,105 @@ pub struct block_ {
     llbb: BasicBlockRef,
     terminated: bool,
     unreachable: bool,
-    parent: Option<block>,
+    parent: Option<@mut Block>,
     // The current scope within this basic block
-    scope: Option<@mut scope_info>,
+    scope: Option<@mut ScopeInfo>,
     // Is this block part of a landing pad?
     is_lpad: bool,
     // info about the AST node this block originated from, if any
     node_info: Option<NodeInfo>,
     // The function context for the function to which this block is
     // attached.
-    fcx: fn_ctxt
-}
+    fcx: @mut FunctionContext
+}
+
+impl Block {
+
+    pub fn new(llbb: BasicBlockRef,
+               parent: Option<@mut Block>,
+               is_lpad: bool,
+               node_info: Option<NodeInfo>,
+               fcx: @mut FunctionContext)
+            -> Block {
+        Block {
+            llbb: llbb,
+            terminated: false,
+            unreachable: false,
+            parent: parent,
+            scope: None,
+            is_lpad: is_lpad,
+            node_info: node_info,
+            fcx: fcx
+        }
+    }
+
+    pub fn ccx(&self) -> @mut CrateContext { self.fcx.ccx }
+    pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx }
+    pub fn sess(&self) -> Session { self.fcx.ccx.sess }
 
-pub fn block_(llbb: BasicBlockRef, parent: Option<block>,
-              is_lpad: bool, node_info: Option<NodeInfo>, fcx: fn_ctxt)
-    -> block_ {
+    pub fn ident(&self, ident: ident) -> @str {
+        token::ident_to_str(&ident)
+    }
 
-    block_ {
-        llbb: llbb,
-        terminated: false,
-        unreachable: false,
-        parent: parent,
-        scope: None,
-        is_lpad: is_lpad,
-        node_info: node_info,
-        fcx: fcx
+    pub fn node_id_to_str(&self, id: ast::node_id) -> ~str {
+        ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
+    }
+
+    pub fn expr_to_str(&self, e: @ast::expr) -> ~str {
+        e.repr(self.tcx())
+    }
+
+    pub fn expr_is_lval(&self, e: &ast::expr) -> bool {
+        ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e)
+    }
+
+    pub fn expr_kind(&self, e: &ast::expr) -> ty::ExprKind {
+        ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e)
+    }
+
+    pub fn def(&self, nid: ast::node_id) -> ast::def {
+        match self.tcx().def_map.find(&nid) {
+            Some(&v) => v,
+            None => {
+                self.tcx().sess.bug(fmt!(
+                    "No def associated with node id %?", nid));
+            }
+        }
+    }
+
+    pub fn val_to_str(&self, val: ValueRef) -> ~str {
+        self.ccx().tn.val_to_str(val)
+    }
+
+    pub fn llty_str(&self, ty: Type) -> ~str {
+        self.ccx().tn.type_to_str(ty)
     }
-}
 
-pub type block = @mut block_;
+    pub fn ty_to_str(&self, t: ty::t) -> ~str {
+        t.repr(self.tcx())
+    }
 
-pub fn mk_block(llbb: BasicBlockRef, parent: Option<block>,
-            is_lpad: bool, node_info: Option<NodeInfo>, fcx: fn_ctxt)
-    -> block {
-    @mut block_(llbb, parent, is_lpad, node_info, fcx)
+    pub fn to_str(&self) -> ~str {
+        unsafe {
+            match self.node_info {
+                Some(node_info) => fmt!("[block %d]", node_info.id),
+                None => fmt!("[block %x]", transmute(&*self)),
+            }
+        }
+    }
 }
 
 pub struct Result {
-    bcx: block,
+    bcx: @mut Block,
     val: ValueRef
 }
 
-pub fn rslt(bcx: block, val: ValueRef) -> Result {
+pub fn rslt(bcx: @mut Block, val: ValueRef) -> Result {
     Result {bcx: bcx, val: val}
 }
 
 impl Result {
-    pub fn unpack(&self, bcx: &mut block) -> ValueRef {
+    pub fn unpack(&self, bcx: &mut @mut Block) -> ValueRef {
         *bcx = self.bcx;
         return self.val;
     }
@@ -580,7 +633,7 @@ pub fn val_ty(v: ValueRef) -> Type {
     }
 }
 
-pub fn in_scope_cx(cx: block, scope_id: Option<ast::node_id>, f: &fn(si: &mut scope_info)) {
+pub fn in_scope_cx(cx: @mut Block, scope_id: Option<ast::node_id>, f: &fn(si: &mut ScopeInfo)) {
     let mut cur = cx;
     let mut cur_scope = cur.scope;
     loop {
@@ -610,7 +663,7 @@ pub fn in_scope_cx(cx: block, scope_id: Option<ast::node_id>, f: &fn(si: &mut sc
     }
 }
 
-pub fn block_parent(cx: block) -> block {
+pub fn block_parent(cx: @mut Block) -> @mut Block {
     match cx.parent {
       Some(b) => b,
       None    => cx.sess().bug(fmt!("block_parent called on root block %?",
@@ -618,64 +671,6 @@ pub fn block_parent(cx: block) -> block {
     }
 }
 
-// Accessors
-
-impl block_ {
-    pub fn ccx(&self) -> @mut CrateContext { self.fcx.ccx }
-    pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx }
-    pub fn sess(&self) -> Session { self.fcx.ccx.sess }
-
-    pub fn ident(&self, ident: ident) -> @str {
-        token::ident_to_str(&ident)
-    }
-
-    pub fn node_id_to_str(&self, id: ast::node_id) -> ~str {
-        ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
-    }
-
-    pub fn expr_to_str(&self, e: @ast::expr) -> ~str {
-        e.repr(self.tcx())
-    }
-
-    pub fn expr_is_lval(&self, e: &ast::expr) -> bool {
-        ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e)
-    }
-
-    pub fn expr_kind(&self, e: &ast::expr) -> ty::ExprKind {
-        ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e)
-    }
-
-    pub fn def(&self, nid: ast::node_id) -> ast::def {
-        match self.tcx().def_map.find(&nid) {
-            Some(&v) => v,
-            None => {
-                self.tcx().sess.bug(fmt!(
-                    "No def associated with node id %?", nid));
-            }
-        }
-    }
-
-    pub fn val_to_str(&self, val: ValueRef) -> ~str {
-        self.ccx().tn.val_to_str(val)
-    }
-
-    pub fn llty_str(&self, ty: Type) -> ~str {
-        self.ccx().tn.type_to_str(ty)
-    }
-
-    pub fn ty_to_str(&self, t: ty::t) -> ~str {
-        t.repr(self.tcx())
-    }
-
-    pub fn to_str(&self) -> ~str {
-        unsafe {
-            match self.node_info {
-                Some(node_info) => fmt!("[block %d]", node_info.id),
-                None => fmt!("[block %x]", transmute(&*self)),
-            }
-        }
-    }
-}
 
 // Let T be the content of a box @T.  tuplify_box_ty(t) returns the
 // representation of @T as a tuple (i.e., the ty::t version of what T_box()
@@ -940,17 +935,17 @@ pub struct mono_id_ {
 
 pub type mono_id = @mono_id_;
 
-pub fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
+pub fn umax(cx: @mut Block, a: ValueRef, b: ValueRef) -> ValueRef {
     let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
     return build::Select(cx, cond, b, a);
 }
 
-pub fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
+pub fn umin(cx: @mut Block, a: ValueRef, b: ValueRef) -> ValueRef {
     let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
     return build::Select(cx, cond, a, b);
 }
 
-pub fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
+pub fn align_to(cx: @mut Block, off: ValueRef, align: ValueRef) -> ValueRef {
     let mask = build::Sub(cx, align, C_int(cx.ccx(), 1));
     let bumped = build::Add(cx, off, mask);
     return build::And(cx, bumped, build::Not(cx, mask));
@@ -974,7 +969,7 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str {
     r
 }
 
-pub fn monomorphize_type(bcx: block, t: ty::t) -> ty::t {
+pub fn monomorphize_type(bcx: @mut Block, t: ty::t) -> ty::t {
     match bcx.fcx.param_substs {
         Some(substs) => {
             ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t)
@@ -987,23 +982,23 @@ pub fn monomorphize_type(bcx: block, t: ty::t) -> ty::t {
     }
 }
 
-pub fn node_id_type(bcx: block, id: ast::node_id) -> ty::t {
+pub fn node_id_type(bcx: @mut Block, id: ast::node_id) -> ty::t {
     let tcx = bcx.tcx();
     let t = ty::node_id_to_type(tcx, id);
     monomorphize_type(bcx, t)
 }
 
-pub fn expr_ty(bcx: block, ex: &ast::expr) -> ty::t {
+pub fn expr_ty(bcx: @mut Block, ex: &ast::expr) -> ty::t {
     node_id_type(bcx, ex.id)
 }
 
-pub fn expr_ty_adjusted(bcx: block, ex: &ast::expr) -> ty::t {
+pub fn expr_ty_adjusted(bcx: @mut Block, ex: &ast::expr) -> ty::t {
     let tcx = bcx.tcx();
     let t = ty::expr_ty_adjusted(tcx, ex);
     monomorphize_type(bcx, t)
 }
 
-pub fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
+pub fn node_id_type_params(bcx: @mut Block, id: ast::node_id) -> ~[ty::t] {
     let tcx = bcx.tcx();
     let params = ty::node_id_to_type_params(tcx, id);
 
@@ -1023,14 +1018,14 @@ pub fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
     }
 }
 
-pub fn node_vtables(bcx: block, id: ast::node_id)
+pub fn node_vtables(bcx: @mut Block, id: ast::node_id)
                  -> Option<typeck::vtable_res> {
     let raw_vtables = bcx.ccx().maps.vtable_map.find(&id);
     raw_vtables.map(
         |&vts| resolve_vtables_in_fn_ctxt(bcx.fcx, *vts))
 }
 
-pub fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res)
+pub fn resolve_vtables_in_fn_ctxt(fcx: &FunctionContext, vts: typeck::vtable_res)
     -> typeck::vtable_res {
     resolve_vtables_under_param_substs(fcx.ccx.tcx,
                                        fcx.param_substs,
@@ -1051,9 +1046,9 @@ pub fn resolve_vtables_under_param_substs(tcx: ty::ctxt,
 }
 
 
-// Apply the typaram substitutions in the fn_ctxt to a vtable. This should
+// Apply the typaram substitutions in the FunctionContext to a vtable. This should
 // eliminate any vtable_params.
-pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: &typeck::vtable_origin)
+pub fn resolve_vtable_in_fn_ctxt(fcx: &FunctionContext, vt: &typeck::vtable_origin)
     -> typeck::vtable_origin {
     resolve_vtable_under_param_substs(fcx.ccx.tcx,
                                       fcx.param_substs,
@@ -1125,7 +1120,7 @@ pub fn dummy_substs(tps: ~[ty::t]) -> ty::substs {
     }
 }
 
-pub fn filename_and_line_num_from_span(bcx: block,
+pub fn filename_and_line_num_from_span(bcx: @mut Block,
                                        span: span) -> (ValueRef, ValueRef) {
     let loc = bcx.sess().parse_sess.cm.lookup_char_pos(span.lo);
     let filename_cstr = C_cstr(bcx.ccx(), loc.file.name);
@@ -1135,11 +1130,11 @@ pub fn filename_and_line_num_from_span(bcx: block,
 }
 
 // Casts a Rust bool value to an i1.
-pub fn bool_to_i1(bcx: block, llval: ValueRef) -> ValueRef {
+pub fn bool_to_i1(bcx: @mut Block, llval: ValueRef) -> ValueRef {
     build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false))
 }
 
-pub fn langcall(bcx: block, span: Option<span>, msg: &str,
+pub fn langcall(bcx: @mut Block, span: Option<span>, msg: &str,
                 li: LangItem) -> ast::def_id {
     match bcx.tcx().lang_items.require(li) {
         Ok(id) => id,
index 9ffe3c9f25cedef6fcac6bd16e15288cf1166f62..9c66beaa8601bc3bdce36857a91043b47fc555ef 100644 (file)
@@ -34,7 +34,7 @@
 use syntax::ast_util;
 use syntax::codemap::span;
 
-pub fn trans_block(bcx: block, b: &ast::Block, dest: expr::Dest) -> block {
+pub fn trans_block(bcx: @mut Block, b: &ast::Block, dest: expr::Dest) -> @mut Block {
     let _icx = push_ctxt("trans_block");
     let mut bcx = bcx;
     for b.stmts.iter().advance |s| {
@@ -53,12 +53,12 @@ pub fn trans_block(bcx: block, b: &ast::Block, dest: expr::Dest) -> block {
     return bcx;
 }
 
-pub fn trans_if(bcx: block,
+pub fn trans_if(bcx: @mut Block,
             cond: @ast::expr,
             thn: &ast::Block,
             els: Option<@ast::expr>,
             dest: expr::Dest)
-         -> block {
+         -> @mut Block {
     debug!("trans_if(bcx=%s, cond=%s, thn=%?, dest=%s)",
            bcx.to_str(), bcx.expr_to_str(cond), thn.id,
            dest.to_str(bcx.ccx()));
@@ -132,8 +132,8 @@ pub fn trans_if(bcx: block,
     return next_bcx;
 
     // trans `else [ if { .. } ... | { .. } ]`
-    fn trans_if_else(bcx: block, elexpr: @ast::expr,
-                     dest: expr::Dest, scope_name: &str) -> (block, block) {
+    fn trans_if_else(bcx: @mut Block, elexpr: @ast::expr,
+                     dest: expr::Dest, scope_name: &str) -> (@mut Block, @mut Block) {
         let else_bcx_in = scope_block(bcx, elexpr.info(), scope_name);
         let else_bcx_out = match elexpr.node {
             ast::expr_if(_, _, _) => {
@@ -152,7 +152,7 @@ fn trans_if_else(bcx: block, elexpr: @ast::expr,
     }
 }
 
-pub fn join_blocks(parent_bcx: block, in_cxs: &[block]) -> block {
+pub fn join_blocks(parent_bcx: @mut Block, in_cxs: &[@mut Block]) -> @mut Block {
     let out = sub_block(parent_bcx, "join");
     let mut reachable = false;
     for in_cxs.iter().advance |bcx| {
@@ -167,7 +167,7 @@ pub fn join_blocks(parent_bcx: block, in_cxs: &[block]) -> block {
     return out;
 }
 
-pub fn trans_while(bcx: block, cond: @ast::expr, body: &ast::Block) -> block {
+pub fn trans_while(bcx: @mut Block, cond: @ast::expr, body: &ast::Block) -> @mut Block {
     let _icx = push_ctxt("trans_while");
     let next_bcx = sub_block(bcx, "while next");
 
@@ -206,10 +206,10 @@ pub fn trans_while(bcx: block, cond: @ast::expr, body: &ast::Block) -> block {
     return next_bcx;
 }
 
-pub fn trans_loop(bcx:block,
+pub fn trans_loop(bcx:@mut Block,
                   body: &ast::Block,
                   opt_label: Option<ident>)
-               -> block {
+               -> @mut Block {
     let _icx = push_ctxt("trans_loop");
     let next_bcx = sub_block(bcx, "next");
     let body_bcx_in = loop_scope_block(bcx, next_bcx, opt_label, "`loop`",
@@ -222,8 +222,8 @@ pub fn trans_loop(bcx:block,
 
 pub fn trans_log(log_ex: &ast::expr,
                  lvl: @ast::expr,
-                 bcx: block,
-                 e: @ast::expr) -> block {
+                 bcx: @mut Block,
+                 e: @ast::expr) -> @mut Block {
     let _icx = push_ctxt("trans_log");
     let ccx = bcx.ccx();
     let mut bcx = bcx;
@@ -286,10 +286,10 @@ pub fn trans_log(log_ex: &ast::expr,
     }
 }
 
-pub fn trans_break_cont(bcx: block,
+pub fn trans_break_cont(bcx: @mut Block,
                         opt_label: Option<ident>,
                         to_end: bool)
-                     -> block {
+                     -> @mut Block {
     let _icx = push_ctxt("trans_break_cont");
     // Locate closest loop block, outputting cleanup as we go.
     let mut unwind = bcx;
@@ -297,7 +297,7 @@ pub fn trans_break_cont(bcx: block,
     let mut target;
     loop {
         cur_scope = match cur_scope {
-            Some(@scope_info {
+            Some(@ScopeInfo {
                 loop_break: Some(brk),
                 loop_label: l,
                 parent,
@@ -340,15 +340,15 @@ pub fn trans_break_cont(bcx: block,
     return bcx;
 }
 
-pub fn trans_break(bcx: block, label_opt: Option<ident>) -> block {
+pub fn trans_break(bcx: @mut Block, label_opt: Option<ident>) -> @mut Block {
     return trans_break_cont(bcx, label_opt, true);
 }
 
-pub fn trans_cont(bcx: block, label_opt: Option<ident>) -> block {
+pub fn trans_cont(bcx: @mut Block, label_opt: Option<ident>) -> @mut Block {
     return trans_break_cont(bcx, label_opt, false);
 }
 
-pub fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
+pub fn trans_ret(bcx: @mut Block, e: Option<@ast::expr>) -> @mut Block {
     let _icx = push_ctxt("trans_ret");
     let mut bcx = bcx;
     let dest = match bcx.fcx.loop_ret {
@@ -380,10 +380,10 @@ pub fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
     return bcx;
 }
 
-pub fn trans_fail_expr(bcx: block,
+pub fn trans_fail_expr(bcx: @mut Block,
                        sp_opt: Option<span>,
                        fail_expr: Option<@ast::expr>)
-                    -> block {
+                    -> @mut Block {
     let _icx = push_ctxt("trans_fail_expr");
     let mut bcx = bcx;
     match fail_expr {
@@ -408,19 +408,19 @@ pub fn trans_fail_expr(bcx: block,
     }
 }
 
-pub fn trans_fail(bcx: block,
+pub fn trans_fail(bcx: @mut Block,
                   sp_opt: Option<span>,
                   fail_str: @str)
-               -> block {
+               -> @mut Block {
     let _icx = push_ctxt("trans_fail");
     let V_fail_str = C_cstr(bcx.ccx(), fail_str);
     return trans_fail_value(bcx, sp_opt, V_fail_str);
 }
 
-fn trans_fail_value(bcx: block,
+fn trans_fail_value(bcx: @mut Block,
                     sp_opt: Option<span>,
                     V_fail_str: ValueRef)
-                 -> block {
+                 -> @mut Block {
     let _icx = push_ctxt("trans_fail_value");
     let ccx = bcx.ccx();
     let (V_filename, V_line) = match sp_opt {
@@ -443,8 +443,8 @@ fn trans_fail_value(bcx: block,
     return bcx;
 }
 
-pub fn trans_fail_bounds_check(bcx: block, sp: span,
-                               index: ValueRef, len: ValueRef) -> block {
+pub fn trans_fail_bounds_check(bcx: @mut Block, sp: span,
+                               index: ValueRef, len: ValueRef) -> @mut Block {
     let _icx = push_ctxt("trans_fail_bounds_check");
     let (filename, line) = filename_and_line_num_from_span(bcx, sp);
     let args = ~[filename, line, index, len];
index efd666c8d9691da794f308e445cb935c4f95a4d6..f929d4f68ae4f83603e5f4b7670b38402abdcaa7 100644 (file)
@@ -128,7 +128,7 @@ pub struct Datum {
 }
 
 pub struct DatumBlock {
-    bcx: block,
+    bcx: @mut Block,
     datum: Datum,
 }
 
@@ -165,14 +165,14 @@ pub fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum {
     return Datum {val: val, ty: ty, mode: ByValue};
 }
 
-pub fn immediate_rvalue_bcx(bcx: block,
+pub fn immediate_rvalue_bcx(bcx: @mut Block,
                             val: ValueRef,
                             ty: ty::t)
                          -> DatumBlock {
     return DatumBlock {bcx: bcx, datum: immediate_rvalue(val, ty)};
 }
 
-pub fn scratch_datum(bcx: block, ty: ty::t, name: &str, zero: bool) -> Datum {
+pub fn scratch_datum(bcx: @mut Block, ty: ty::t, name: &str, zero: bool) -> Datum {
     /*!
      * Allocates temporary space on the stack using alloca() and
      * returns a by-ref Datum pointing to it.  If `zero` is true, the
@@ -206,10 +206,10 @@ pub fn appropriate_mode(tcx: ty::ctxt, ty: ty::t) -> DatumMode {
 
 impl Datum {
     pub fn store_to(&self,
-                    bcx: block,
+                    bcx: @mut Block,
                     action: CopyAction,
                     dst: ValueRef)
-                    -> block {
+                    -> @mut Block {
         /*!
          *
          * Stores this value into its final home.  This moves if
@@ -224,9 +224,9 @@ pub fn store_to(&self,
     }
 
     pub fn store_to_dest(&self,
-                         bcx: block,
+                         bcx: @mut Block,
                          dest: expr::Dest)
-                         -> block {
+                         -> @mut Block {
         match dest {
             expr::Ignore => {
                 return bcx;
@@ -238,30 +238,30 @@ pub fn store_to_dest(&self,
     }
 
     pub fn store_to_datum(&self,
-                          bcx: block,
+                          bcx: @mut Block,
                           action: CopyAction,
                           datum: Datum)
-                          -> block {
+                          -> @mut Block {
         debug!("store_to_datum(self=%s, action=%?, datum=%s)",
                self.to_str(bcx.ccx()), action, datum.to_str(bcx.ccx()));
         assert!(datum.mode.is_by_ref());
         self.store_to(bcx, action, datum.val)
     }
 
-    pub fn move_to_datum(&self, bcx: block, action: CopyAction, datum: Datum)
-                         -> block {
+    pub fn move_to_datum(&self, bcx: @mut Block, action: CopyAction, datum: Datum)
+                         -> @mut Block {
         assert!(datum.mode.is_by_ref());
         self.move_to(bcx, action, datum.val)
     }
 
-    pub fn copy_to_datum(&self, bcx: block, action: CopyAction, datum: Datum)
-                         -> block {
+    pub fn copy_to_datum(&self, bcx: @mut Block, action: CopyAction, datum: Datum)
+                         -> @mut Block {
         assert!(datum.mode.is_by_ref());
         self.copy_to(bcx, action, datum.val)
     }
 
-    pub fn copy_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
-                   -> block {
+    pub fn copy_to(&self, bcx: @mut Block, action: CopyAction, dst: ValueRef)
+                   -> @mut Block {
         /*!
          *
          * Copies the value into `dst`, which should be a pointer to a
@@ -304,10 +304,10 @@ pub fn copy_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
     }
 
     pub fn copy_to_no_check(&self,
-                            bcx: block,
+                            bcx: @mut Block,
                             action: CopyAction,
                             dst: ValueRef)
-                            -> block {
+                            -> @mut Block {
         /*!
          *
          * A helper for `copy_to()` which does not check to see if we
@@ -335,8 +335,8 @@ pub fn copy_to_no_check(&self,
     // This works like copy_val, except that it deinitializes the source.
     // Since it needs to zero out the source, src also needs to be an lval.
     //
-    pub fn move_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
-                   -> block {
+    pub fn move_to(&self, bcx: @mut Block, action: CopyAction, dst: ValueRef)
+                   -> @mut Block {
         let _icx = push_ctxt("move_to");
         let mut bcx = bcx;
 
@@ -365,7 +365,7 @@ pub fn move_to(&self, bcx: block, action: CopyAction, dst: ValueRef)
         return bcx;
     }
 
-    pub fn add_clean(&self, bcx: block) {
+    pub fn add_clean(&self, bcx: @mut Block) {
         /*!
          * Schedules this datum for cleanup in `bcx`.  The datum
          * must be an rvalue.
@@ -385,7 +385,7 @@ pub fn add_clean(&self, bcx: block) {
         }
     }
 
-    pub fn cancel_clean(&self, bcx: block) {
+    pub fn cancel_clean(&self, bcx: @mut Block) {
         if ty::type_needs_drop(bcx.tcx(), self.ty) {
             match self.mode {
                 ByValue |
@@ -410,7 +410,7 @@ pub fn to_str(&self, ccx: &CrateContext) -> ~str {
              self.mode)
     }
 
-    pub fn to_value_datum(&self, bcx: block) -> Datum {
+    pub fn to_value_datum(&self, bcx: @mut Block) -> Datum {
         /*!
          *
          * Yields a by-value form of this datum.  This may involve
@@ -427,7 +427,7 @@ pub fn to_value_datum(&self, bcx: block) -> Datum {
         }
     }
 
-    pub fn to_value_llval(&self, bcx: block) -> ValueRef {
+    pub fn to_value_llval(&self, bcx: @mut Block) -> ValueRef {
         /*!
          *
          * Yields the value itself. */
@@ -448,7 +448,7 @@ pub fn to_value_llval(&self, bcx: block) -> ValueRef {
         }
     }
 
-    pub fn to_ref_datum(&self, bcx: block) -> Datum {
+    pub fn to_ref_datum(&self, bcx: @mut Block) -> Datum {
         /*!
          * Yields a by-ref form of this datum.  This may involve
          * creation of a temporary stack slot.  The value returned by
@@ -465,7 +465,7 @@ pub fn to_ref_datum(&self, bcx: block) -> Datum {
         }
     }
 
-    pub fn to_ref_llval(&self, bcx: block) -> ValueRef {
+    pub fn to_ref_llval(&self, bcx: @mut Block) -> ValueRef {
         match self.mode {
             ByRef(_) => self.val,
             ByValue => {
@@ -480,7 +480,7 @@ pub fn to_ref_llval(&self, bcx: block) -> ValueRef {
         }
     }
 
-    pub fn to_zeroable_ref_llval(&self, bcx: block) -> ValueRef {
+    pub fn to_zeroable_ref_llval(&self, bcx: @mut Block) -> ValueRef {
         /*!
          * Returns a by-ref llvalue that can be zeroed in order to
          * cancel cleanup. This is a kind of hokey bridge used
@@ -511,7 +511,7 @@ pub fn appropriate_mode(&self, tcx: ty::ctxt) -> DatumMode {
         appropriate_mode(tcx, self.ty)
     }
 
-    pub fn to_appropriate_llval(&self, bcx: block) -> ValueRef {
+    pub fn to_appropriate_llval(&self, bcx: @mut Block) -> ValueRef {
         /*!
          *
          * Yields an llvalue with the `appropriate_mode()`. */
@@ -522,7 +522,7 @@ pub fn to_appropriate_llval(&self, bcx: block) -> ValueRef {
         }
     }
 
-    pub fn to_appropriate_datum(&self, bcx: block) -> Datum {
+    pub fn to_appropriate_datum(&self, bcx: @mut Block) -> Datum {
         /*!
          *
          * Yields a datum with the `appropriate_mode()`. */
@@ -534,7 +534,7 @@ pub fn to_appropriate_datum(&self, bcx: block) -> Datum {
     }
 
     pub fn get_element(&self,
-                       bcx: block,
+                       bcx: @mut Block,
                        ty: ty::t,
                        source: DatumCleanup,
                        gep: &fn(ValueRef) -> ValueRef)
@@ -547,7 +547,7 @@ pub fn get_element(&self,
         }
     }
 
-    pub fn drop_val(&self, bcx: block) -> block {
+    pub fn drop_val(&self, bcx: @mut Block) -> @mut Block {
         if !ty::type_needs_drop(bcx.tcx(), self.ty) {
             return bcx;
         }
@@ -558,7 +558,7 @@ pub fn drop_val(&self, bcx: block) -> block {
         };
     }
 
-    pub fn box_body(&self, bcx: block) -> Datum {
+    pub fn box_body(&self, bcx: @mut Block) -> Datum {
         /*!
          *
          * This datum must represent an @T or ~T box.  Returns a new
@@ -591,7 +591,7 @@ pub fn box_body(&self, bcx: block) -> Datum {
         }
     }
 
-    pub fn to_rptr(&self, bcx: block) -> Datum {
+    pub fn to_rptr(&self, bcx: @mut Block) -> Datum {
         //! Returns a new datum of region-pointer type containing the
         //! the same ptr as this datum (after converting to by-ref
         //! using `to_ref_llval()`).
@@ -612,12 +612,12 @@ pub fn to_rptr(&self, bcx: block) -> Datum {
     /// derefs: Number of times deref'd already.
     /// is_auto: If true, only deref if auto-derefable.
     pub fn try_deref(&self,
-                     bcx: block,
+                     bcx: @mut Block,
                      span: span,
                      expr_id: ast::node_id,
                      derefs: uint,
                      is_auto: bool)
-                     -> (Option<Datum>, block) {
+                     -> (Option<Datum>, @mut Block) {
         let ccx = bcx.ccx();
 
         debug!("try_deref(expr_id=%?, derefs=%?, is_auto=%b, self=%?)",
@@ -716,7 +716,7 @@ pub fn try_deref(&self,
             }
         }
 
-        fn deref_ptr(bcx: block, lv: &Datum, ty: ty::t) -> Datum {
+        fn deref_ptr(bcx: @mut Block, lv: &Datum, ty: ty::t) -> Datum {
             Datum {
                 val: lv.to_value_llval(bcx),
                 ty: ty,
@@ -726,7 +726,7 @@ fn deref_ptr(bcx: block, lv: &Datum, ty: ty::t) -> Datum {
     }
 
     /// expr: The deref expression.
-    pub fn deref(&self, bcx: block, expr: &ast::expr, derefs: uint)
+    pub fn deref(&self, bcx: @mut Block, expr: &ast::expr, derefs: uint)
                  -> DatumBlock {
         match self.try_deref(bcx, expr.span, expr.id, derefs, false) {
             (Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres },
@@ -738,7 +738,7 @@ pub fn deref(&self, bcx: block, expr: &ast::expr, derefs: uint)
     }
 
     pub fn autoderef(&self,
-                     bcx: block,
+                     bcx: @mut Block,
                      span: span,
                      expr_id: ast::node_id,
                      max: uint)
@@ -771,11 +771,11 @@ pub fn autoderef(&self,
     }
 
     pub fn get_vec_base_and_len(&self,
-                                mut bcx: block,
+                                mut bcx: @mut Block,
                                 span: span,
                                 expr_id: ast::node_id,
                                 derefs: uint)
-                                -> (block, ValueRef, ValueRef) {
+                                -> (@mut Block, ValueRef, ValueRef) {
         //! Converts a vector into the slice pair. Performs rooting
         //! and write guards checks.
 
@@ -785,7 +785,7 @@ pub fn get_vec_base_and_len(&self,
         (bcx, base, len)
     }
 
-    pub fn get_vec_base_and_len_no_root(&self, bcx: block)
+    pub fn get_vec_base_and_len_no_root(&self, bcx: @mut Block)
                                         -> (ValueRef, ValueRef) {
         //! Converts a vector into the slice pair. Des not root
         //! nor perform write guard checks.
@@ -795,21 +795,21 @@ pub fn get_vec_base_and_len_no_root(&self, bcx: block)
     }
 
     pub fn root_and_write_guard(&self,
-                                bcx: block,
+                                bcx: @mut Block,
                                 span: span,
                                 expr_id: ast::node_id,
                                 derefs: uint)
-                                -> block {
+                                -> @mut Block {
         write_guard::root_and_write_guard(self, bcx, span, expr_id, derefs)
     }
 
-    pub fn to_result(&self, bcx: block) -> common::Result {
+    pub fn to_result(&self, bcx: @mut Block) -> common::Result {
         rslt(bcx, self.to_appropriate_llval(bcx))
     }
 }
 
 impl DatumBlock {
-    pub fn unpack(&self, bcx: &mut block) -> Datum {
+    pub fn unpack(&self, bcx: &mut @mut Block) -> Datum {
         *bcx = self.bcx;
         return self.datum;
     }
@@ -819,22 +819,22 @@ pub fn assert_by_ref(&self) -> DatumBlock {
         *self
     }
 
-    pub fn drop_val(&self) -> block {
+    pub fn drop_val(&self) -> @mut Block {
         self.datum.drop_val(self.bcx)
     }
 
     pub fn store_to(&self,
                     action: CopyAction,
                     dst: ValueRef)
-                    -> block {
+                    -> @mut Block {
         self.datum.store_to(self.bcx, action, dst)
     }
 
-    pub fn copy_to(&self, action: CopyAction, dst: ValueRef) -> block {
+    pub fn copy_to(&self, action: CopyAction, dst: ValueRef) -> @mut Block {
         self.datum.copy_to(self.bcx, action, dst)
     }
 
-    pub fn move_to(&self, action: CopyAction, dst: ValueRef) -> block {
+    pub fn move_to(&self, action: CopyAction, dst: ValueRef) -> @mut Block {
         self.datum.move_to(self.bcx, action, dst)
     }
 
index 7518d4eb8247446c447732a10aeb3f64198abd30..11d21abb2e6d0c19b2b04c8122e5d43cee0bf124 100644 (file)
@@ -134,7 +134,7 @@ pub fn finalize(cx: @mut CrateContext) {
 ///
 /// Adds the created metadata nodes directly to the crate's IR.
 /// The return value should be ignored if called from outside of the debuginfo module.
-pub fn create_local_var_metadata(bcx: block, local: @ast::Local) -> DIVariable {
+pub fn create_local_var_metadata(bcx: @mut Block, local: @ast::Local) -> DIVariable {
     let cx = bcx.ccx();
 
     let ident = match local.pat.node {
@@ -198,7 +198,7 @@ pub fn create_local_var_metadata(bcx: block, local: @ast::Local) -> DIVariable {
 ///
 /// Adds the created metadata nodes directly to the crate's IR.
 /// The return value should be ignored if called from outside of the debuginfo module.
-pub fn create_argument_metadata(bcx: block, arg: &ast::arg, span: span) -> Option<DIVariable> {
+pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) -> Option<DIVariable> {
     debug!("create_argument_metadata");
     if true {
         // XXX create_argument_metadata disabled for now because "node_id_type(bcx, arg.id)" below
@@ -260,7 +260,7 @@ pub fn create_argument_metadata(bcx: block, arg: &ast::arg, span: span) -> Optio
 /// Sets the current debug location at the beginning of the span
 ///
 /// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...)
-pub fn update_source_pos(bcx: block, span: span) {
+pub fn update_source_pos(bcx: @mut Block, span: span) {
     if !bcx.sess().opts.debuginfo || (*span.lo == 0 && *span.hi == 0) {
         return;
     }
@@ -273,9 +273,8 @@ pub fn update_source_pos(bcx: block, span: span) {
 ///
 /// Adds the created metadata nodes directly to the crate's IR.
 /// The return value should be ignored if called from outside of the debuginfo module.
-pub fn create_function_metadata(fcx: fn_ctxt) -> DISubprogram {
+pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram {
     let cx = fcx.ccx;
-    let fcx = &mut *fcx;
     let span = fcx.span.get();
 
     let fnitem = cx.tcx.items.get_copy(&fcx.id);
@@ -445,7 +444,7 @@ fn file_metadata(cx: &mut CrateContext, full_path: &str) -> DIFile {
 }
 
 /// Get or create the lexical block metadata node for the given LLVM basic block.
-fn lexical_block_metadata(bcx: block) -> DILexicalBlock {
+fn lexical_block_metadata(bcx: @mut Block) -> DILexicalBlock {
     let cx = bcx.ccx();
     let mut bcx = bcx;
 
index d9fdf8d52c7dc107b527453f94c2252df874a1d5..f552eded1638af4ab442ac36e4076307137e690d 100644 (file)
@@ -175,13 +175,13 @@ pub fn to_str(&self, ccx: &CrateContext) -> ~str {
     }
 }
 
-fn drop_and_cancel_clean(bcx: block, dat: Datum) -> block {
+fn drop_and_cancel_clean(bcx: @mut Block, dat: Datum) -> @mut Block {
     let bcx = dat.drop_val(bcx);
     dat.cancel_clean(bcx);
     return bcx;
 }
 
-pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
+pub fn trans_to_datum(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
     debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
 
     let mut bcx = bcx;
@@ -231,11 +231,11 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
     debug!("after adjustments, datum=%s", datum.to_str(bcx.ccx()));
     return DatumBlock {bcx: bcx, datum: datum};
 
-    fn auto_ref(bcx: block, datum: Datum) -> DatumBlock {
+    fn auto_ref(bcx: @mut Block, datum: Datum) -> DatumBlock {
         DatumBlock {bcx: bcx, datum: datum.to_rptr(bcx)}
     }
 
-    fn auto_borrow_fn(bcx: block,
+    fn auto_borrow_fn(bcx: @mut Block,
                       adjusted_ty: ty::t,
                       datum: Datum) -> DatumBlock {
         // Currently, all closure types are represented precisely the
@@ -246,7 +246,7 @@ fn auto_borrow_fn(bcx: block,
                                   mode: datum.mode}}
     }
 
-    fn auto_slice(bcx: block,
+    fn auto_slice(bcx: @mut Block,
                   autoderefs: uint,
                   expr: &ast::expr,
                   datum: Datum) -> DatumBlock {
@@ -274,7 +274,7 @@ fn auto_slice(bcx: block,
         DatumBlock {bcx: bcx, datum: scratch}
     }
 
-    fn add_env(bcx: block, expr: &ast::expr, datum: Datum) -> DatumBlock {
+    fn add_env(bcx: @mut Block, expr: &ast::expr, datum: Datum) -> DatumBlock {
         // This is not the most efficient thing possible; since closures
         // are two words it'd be better if this were compiled in
         // 'dest' mode, but I can't find a nice way to structure the
@@ -293,7 +293,7 @@ fn add_env(bcx: block, expr: &ast::expr, datum: Datum) -> DatumBlock {
         DatumBlock {bcx: bcx, datum: scratch}
     }
 
-    fn auto_slice_and_ref(bcx: block,
+    fn auto_slice_and_ref(bcx: @mut Block,
                           autoderefs: uint,
                           expr: &ast::expr,
                           datum: Datum) -> DatumBlock {
@@ -302,7 +302,7 @@ fn auto_slice_and_ref(bcx: block,
     }
 }
 
-pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block {
+pub fn trans_into(bcx: @mut Block, expr: @ast::expr, dest: Dest) -> @mut Block {
     if bcx.tcx().adjustments.contains_key(&expr.id) {
         // use trans_to_datum, which is mildly less efficient but
         // which will perform the adjustments:
@@ -360,7 +360,7 @@ pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block {
     };
 }
 
-fn trans_lvalue(bcx: block, expr: @ast::expr) -> DatumBlock {
+fn trans_lvalue(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
     /*!
      *
      * Translates an lvalue expression, always yielding a by-ref
@@ -379,7 +379,7 @@ fn trans_lvalue(bcx: block, expr: @ast::expr) -> DatumBlock {
     };
 }
 
-fn trans_to_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
+fn trans_to_datum_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
     /*!
      * Translates an expression into a datum.  If this expression
      * is an rvalue, this will result in a temporary value being
@@ -439,13 +439,13 @@ fn trans_to_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
         }
     }
 
-    fn nil(bcx: block, ty: ty::t) -> DatumBlock {
+    fn nil(bcx: @mut Block, ty: ty::t) -> DatumBlock {
         let datum = immediate_rvalue(C_nil(), ty);
         DatumBlock {bcx: bcx, datum: datum}
     }
 }
 
-fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
+fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
     let _icx = push_ctxt("trans_rvalue_datum_unadjusted");
 
     trace_span!(bcx, expr.span, shorten(bcx.expr_to_str(expr)));
@@ -495,7 +495,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
     }
 }
 
-fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
+fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: @ast::expr) -> @mut Block {
     let mut bcx = bcx;
     let _icx = push_ctxt("trans_rvalue_stmt");
 
@@ -551,8 +551,8 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
     };
 }
 
-fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
-                               dest: Dest) -> block {
+fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr,
+                               dest: Dest) -> @mut Block {
     let _icx = push_ctxt("trans_rvalue_dps_unadjusted");
     let tcx = bcx.tcx();
 
@@ -697,8 +697,8 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
     }
 }
 
-fn trans_def_dps_unadjusted(bcx: block, ref_expr: &ast::expr,
-                            def: ast::def, dest: Dest) -> block {
+fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::expr,
+                            def: ast::def, dest: Dest) -> @mut Block {
     let _icx = push_ctxt("trans_def_dps_unadjusted");
     let ccx = bcx.ccx();
 
@@ -743,7 +743,7 @@ fn trans_def_dps_unadjusted(bcx: block, ref_expr: &ast::expr,
     }
 }
 
-fn trans_def_datum_unadjusted(bcx: block,
+fn trans_def_datum_unadjusted(bcx: @mut Block,
                               ref_expr: &ast::expr,
                               def: ast::def) -> DatumBlock
 {
@@ -767,7 +767,7 @@ fn trans_def_datum_unadjusted(bcx: block,
         }
     }
 
-    fn fn_data_to_datum(bcx: block,
+    fn fn_data_to_datum(bcx: @mut Block,
                         ref_expr: &ast::expr,
                         def_id: ast::def_id,
                         fn_data: callee::FnData) -> DatumBlock {
@@ -802,7 +802,7 @@ fn fn_data_to_datum(bcx: block,
     }
 }
 
-fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
+fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
     /*!
      *
      * Translates an lvalue expression, always yielding a by-ref
@@ -841,7 +841,7 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
         }
     };
 
-    fn trans_rec_field(bcx: block,
+    fn trans_rec_field(bcx: @mut Block,
                        base: @ast::expr,
                        field: ast::ident) -> DatumBlock {
         //! Translates `base.field`.
@@ -864,7 +864,7 @@ fn trans_rec_field(bcx: block,
         }
     }
 
-    fn trans_index(bcx: block,
+    fn trans_index(bcx: @mut Block,
                    index_expr: &ast::expr,
                    base: @ast::expr,
                    idx: @ast::expr) -> DatumBlock {
@@ -928,7 +928,7 @@ fn trans_index(bcx: block,
         };
     }
 
-    fn trans_def_lvalue(bcx: block,
+    fn trans_def_lvalue(bcx: @mut Block,
                         ref_expr: &ast::expr,
                         def: ast::def)
         -> DatumBlock
@@ -950,7 +950,7 @@ fn get_did(ccx: @mut CrateContext, did: ast::def_id)
                     }
                 }
 
-                fn get_val(bcx: block, did: ast::def_id, const_ty: ty::t)
+                fn get_val(bcx: @mut Block, did: ast::def_id, const_ty: ty::t)
                            -> ValueRef {
                     // For external constants, we don't inline.
                     if did.crate == ast::local_crate {
@@ -1004,7 +1004,7 @@ fn get_val(bcx: block, did: ast::def_id, const_ty: ty::t)
     }
 }
 
-pub fn trans_local_var(bcx: block, def: ast::def) -> Datum {
+pub fn trans_local_var(bcx: @mut Block, def: ast::def) -> Datum {
     let _icx = push_ctxt("trans_local_var");
 
     return match def {
@@ -1056,7 +1056,7 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum {
         }
     };
 
-    fn take_local(bcx: block,
+    fn take_local(bcx: @mut Block,
                   table: &HashMap<ast::node_id, ValueRef>,
                   nid: ast::node_id) -> Datum {
         let v = match table.find(&nid) {
@@ -1123,12 +1123,12 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
     }
 }
 
-fn trans_rec_or_struct(bcx: block,
+fn trans_rec_or_struct(bcx: @mut Block,
                        fields: &[ast::Field],
                        base: Option<@ast::expr>,
                        expr_span: codemap::span,
                        id: ast::node_id,
-                       dest: Dest) -> block
+                       dest: Dest) -> @mut Block
 {
     let _icx = push_ctxt("trans_rec");
     let bcx = bcx;
@@ -1200,10 +1200,10 @@ struct StructBaseInfo {
  * - `optbase` contains information on the base struct (if any) from
  * which remaining fields are copied; see comments on `StructBaseInfo`.
  */
-fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
+fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: int,
              fields: &[(uint, @ast::expr)],
              optbase: Option<StructBaseInfo>,
-             dest: Dest) -> block {
+             dest: Dest) -> @mut Block {
     let _icx = push_ctxt("trans_adt");
     let mut bcx = bcx;
     let addr = match dest {
@@ -1248,7 +1248,7 @@ fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
 }
 
 
-fn trans_immediate_lit(bcx: block, expr: @ast::expr,
+fn trans_immediate_lit(bcx: @mut Block, expr: @ast::expr,
                        lit: ast::lit) -> DatumBlock {
     // must not be a string constant, that is a RvalueDpsExpr
     let _icx = push_ctxt("trans_immediate_lit");
@@ -1256,7 +1256,7 @@ fn trans_immediate_lit(bcx: block, expr: @ast::expr,
     immediate_rvalue_bcx(bcx, consts::const_lit(bcx.ccx(), expr, lit), ty)
 }
 
-fn trans_unary_datum(bcx: block,
+fn trans_unary_datum(bcx: @mut Block,
                      un_expr: &ast::expr,
                      op: ast::unop,
                      sub_expr: @ast::expr) -> DatumBlock {
@@ -1316,7 +1316,7 @@ fn trans_unary_datum(bcx: block,
         }
     };
 
-    fn trans_boxed_expr(bcx: block,
+    fn trans_boxed_expr(bcx: @mut Block,
                         box_ty: ty::t,
                         contents: @ast::expr,
                         contents_ty: ty::t,
@@ -1342,7 +1342,7 @@ fn trans_boxed_expr(bcx: block,
     }
 }
 
-fn trans_addr_of(bcx: block, expr: &ast::expr,
+fn trans_addr_of(bcx: @mut Block, expr: &ast::expr,
                  subexpr: @ast::expr) -> DatumBlock {
     let _icx = push_ctxt("trans_addr_of");
     let mut bcx = bcx;
@@ -1353,7 +1353,7 @@ fn trans_addr_of(bcx: block, expr: &ast::expr,
 
 // Important to get types for both lhs and rhs, because one might be _|_
 // and the other not.
-fn trans_eager_binop(bcx: block,
+fn trans_eager_binop(bcx: @mut Block,
                      binop_expr: &ast::expr,
                      binop_ty: ty::t,
                      op: ast::binop,
@@ -1456,7 +1456,7 @@ fn trans_eager_binop(bcx: block,
 // refinement types would obviate the need for this
 enum lazy_binop_ty { lazy_and, lazy_or }
 
-fn trans_lazy_binop(bcx: block,
+fn trans_lazy_binop(bcx: @mut Block,
                     binop_expr: &ast::expr,
                     op: lazy_binop_ty,
                     a: @ast::expr,
@@ -1501,7 +1501,7 @@ fn trans_lazy_binop(bcx: block,
     return immediate_rvalue_bcx(join, phi, binop_ty);
 }
 
-fn trans_binary(bcx: block,
+fn trans_binary(bcx: @mut Block,
                 binop_expr: &ast::expr,
                 op: ast::binop,
                 lhs: @ast::expr,
@@ -1527,14 +1527,14 @@ fn trans_binary(bcx: block,
     }
 }
 
-fn trans_overloaded_op(bcx: block,
+fn trans_overloaded_op(bcx: @mut Block,
                        expr: &ast::expr,
                        callee_id: ast::node_id,
                        rcvr: @ast::expr,
                        args: ~[@ast::expr],
                        ret_ty: ty::t,
                        dest: Dest)
-                       -> block {
+                       -> @mut Block {
     let origin = bcx.ccx().maps.method_map.get_copy(&expr.id);
     let fty = node_id_type(bcx, callee_id);
     callee::trans_call_inner(bcx,
@@ -1552,7 +1552,7 @@ fn trans_overloaded_op(bcx: block,
                              DoAutorefArg).bcx
 }
 
-fn int_cast(bcx: block, lldsttype: Type, llsrctype: Type,
+fn int_cast(bcx: @mut Block, lldsttype: Type, llsrctype: Type,
             llsrc: ValueRef, signed: bool) -> ValueRef {
     let _icx = push_ctxt("int_cast");
     unsafe {
@@ -1570,7 +1570,7 @@ fn int_cast(bcx: block, lldsttype: Type, llsrctype: Type,
     }
 }
 
-fn float_cast(bcx: block, lldsttype: Type, llsrctype: Type,
+fn float_cast(bcx: @mut Block, lldsttype: Type, llsrctype: Type,
               llsrc: ValueRef) -> ValueRef {
     let _icx = push_ctxt("float_cast");
     let srcsz = llsrctype.float_width();
@@ -1604,7 +1604,7 @@ pub fn cast_type_kind(t: ty::t) -> cast_kind {
     }
 }
 
-fn trans_imm_cast(bcx: block, expr: @ast::expr,
+fn trans_imm_cast(bcx: @mut Block, expr: @ast::expr,
                   id: ast::node_id) -> DatumBlock {
     let _icx = push_ctxt("trans_cast");
     let ccx = bcx.ccx();
@@ -1666,12 +1666,12 @@ fn trans_imm_cast(bcx: block, expr: @ast::expr,
     return immediate_rvalue_bcx(bcx, newval, t_out);
 }
 
-fn trans_assign_op(bcx: block,
+fn trans_assign_op(bcx: @mut Block,
                    expr: @ast::expr,
                    callee_id: ast::node_id,
                    op: ast::binop,
                    dst: @ast::expr,
-                   src: @ast::expr) -> block
+                   src: @ast::expr) -> @mut Block
 {
     let _icx = push_ctxt("trans_assign_op");
     let mut bcx = bcx;
index c929506b7d52f8af412fff46d6452063f4c2b80b..372d24e664cf87f34beb2a1c0672fecee9306fa8 100644 (file)
@@ -128,11 +128,11 @@ fn shim_types(ccx: @mut CrateContext, id: ast::node_id) -> ShimTypes {
 }
 
 type shim_arg_builder<'self> =
-    &'self fn(bcx: block, tys: &ShimTypes,
+    &'self fn(bcx: @mut Block, tys: &ShimTypes,
               llargbundle: ValueRef) -> ~[ValueRef];
 
 type shim_ret_builder<'self> =
-    &'self fn(bcx: block, tys: &ShimTypes,
+    &'self fn(bcx: @mut Block, tys: &ShimTypes,
               llargbundle: ValueRef,
               llretval: ValueRef);
 
@@ -171,12 +171,12 @@ fn build_shim_fn_(ccx: @mut CrateContext,
     return llshimfn;
 }
 
-type wrap_arg_builder<'self> = &'self fn(bcx: block,
+type wrap_arg_builder<'self> = &'self fn(bcx: @mut Block,
                                          tys: &ShimTypes,
                                          llwrapfn: ValueRef,
                                          llargbundle: ValueRef);
 
-type wrap_ret_builder<'self> = &'self fn(bcx: block,
+type wrap_ret_builder<'self> = &'self fn(bcx: @mut Block,
                                          tys: &ShimTypes,
                                          llargbundle: ValueRef);
 
@@ -369,13 +369,13 @@ fn build_shim_fn(ccx: @mut CrateContext,
 
         let _icx = push_ctxt("foreign::build_shim_fn");
 
-        fn build_args(bcx: block, tys: &ShimTypes, llargbundle: ValueRef)
+        fn build_args(bcx: @mut Block, tys: &ShimTypes, llargbundle: ValueRef)
                    -> ~[ValueRef] {
             let _icx = push_ctxt("foreign::shim::build_args");
             tys.fn_ty.build_shim_args(bcx, tys.llsig.llarg_tys, llargbundle)
         }
 
-        fn build_ret(bcx: block,
+        fn build_ret(bcx: @mut Block,
                      tys: &ShimTypes,
                      llargbundle: ValueRef,
                      llretval: ValueRef) {
@@ -491,7 +491,7 @@ fn build_wrap_fn(ccx: @mut CrateContext,
                        build_args,
                        build_ret);
 
-        fn build_args(bcx: block,
+        fn build_args(bcx: @mut Block,
                       tys: &ShimTypes,
                       llwrapfn: ValueRef,
                       llargbundle: ValueRef) {
@@ -517,7 +517,7 @@ fn build_args(bcx: block,
             }
         }
 
-        fn build_ret(bcx: block,
+        fn build_ret(bcx: @mut Block,
                      shim_types: &ShimTypes,
                      llargbundle: ValueRef) {
             let _icx = push_ctxt("foreign::wrap::build_ret");
@@ -539,7 +539,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
                        ref_id: Option<ast::node_id>) {
     debug!("trans_intrinsic(item.ident=%s)", ccx.sess.str_of(item.ident));
 
-    fn simple_llvm_intrinsic(bcx: block, name: &'static str, num_args: uint) {
+    fn simple_llvm_intrinsic(bcx: @mut Block, name: &'static str, num_args: uint) {
         assert!(num_args <= 4);
         let mut args = [0 as ValueRef, ..4];
         let first_real_arg = bcx.fcx.arg_pos(0u);
@@ -550,7 +550,7 @@ fn simple_llvm_intrinsic(bcx: block, name: &'static str, num_args: uint) {
         Ret(bcx, Call(bcx, llfn, args.slice(0, num_args)));
     }
 
-    fn memcpy_intrinsic(bcx: block, name: &'static str, tp_ty: ty::t, sizebits: u8) {
+    fn memcpy_intrinsic(bcx: @mut Block, name: &'static str, tp_ty: ty::t, sizebits: u8) {
         let ccx = bcx.ccx();
         let lltp_ty = type_of::type_of(ccx, tp_ty);
         let align = C_i32(machine::llalign_of_min(ccx, lltp_ty) as i32);
@@ -571,7 +571,7 @@ fn memcpy_intrinsic(bcx: block, name: &'static str, tp_ty: ty::t, sizebits: u8)
         RetVoid(bcx);
     }
 
-    fn memset_intrinsic(bcx: block, name: &'static str, tp_ty: ty::t, sizebits: u8) {
+    fn memset_intrinsic(bcx: @mut Block, name: &'static str, tp_ty: ty::t, sizebits: u8) {
         let ccx = bcx.ccx();
         let lltp_ty = type_of::type_of(ccx, tp_ty);
         let align = C_i32(machine::llalign_of_min(ccx, lltp_ty) as i32);
@@ -592,7 +592,7 @@ fn memset_intrinsic(bcx: block, name: &'static str, tp_ty: ty::t, sizebits: u8)
         RetVoid(bcx);
     }
 
-    fn count_zeros_intrinsic(bcx: block, name: &'static str) {
+    fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
         let x = get_param(bcx.fcx.llfn, bcx.fcx.arg_pos(0u));
         let y = C_i1(false);
         let llfn = bcx.ccx().intrinsics.get_copy(&name);
@@ -805,6 +805,9 @@ fn count_zeros_intrinsic(bcx: block, name: &'static str) {
                             _ => Ret(bcx, BitCast(bcx, llsrcval, llouttype))
                         }
                     }
+                } else if ty::type_is_immediate(ccx.tcx, out_type) {
+                    let llsrcptr = PointerCast(bcx, llsrcval, llouttype.ptr_to());
+                    Ret(bcx, Load(bcx, llsrcptr));
                 } else {
                     // NB: Do not use a Load and Store here. This causes massive
                     // code bloat when `transmute` is used on large structural
@@ -1020,7 +1023,7 @@ fn build_shim_fn(ccx: @mut CrateContext,
 
         let _icx = push_ctxt("foreign::foreign::build_shim_fn");
 
-        fn build_args(bcx: block, tys: &ShimTypes, llargbundle: ValueRef)
+        fn build_args(bcx: @mut Block, tys: &ShimTypes, llargbundle: ValueRef)
                       -> ~[ValueRef] {
             let _icx = push_ctxt("foreign::extern::shim::build_args");
             let ccx = bcx.ccx();
@@ -1050,7 +1053,7 @@ fn build_args(bcx: block, tys: &ShimTypes, llargbundle: ValueRef)
             return llargvals;
         }
 
-        fn build_ret(bcx: block,
+        fn build_ret(bcx: @mut Block,
                      shim_types: &ShimTypes,
                      llargbundle: ValueRef,
                      llretval: ValueRef) {
@@ -1107,7 +1110,7 @@ fn build_wrap_fn(ccx: @mut CrateContext,
                        build_args,
                        build_ret);
 
-        fn build_args(bcx: block,
+        fn build_args(bcx: @mut Block,
                       tys: &ShimTypes,
                       llwrapfn: ValueRef,
                       llargbundle: ValueRef) {
@@ -1118,7 +1121,7 @@ fn build_args(bcx: block,
                                       llargbundle);
         }
 
-        fn build_ret(bcx: block, tys: &ShimTypes, llargbundle: ValueRef) {
+        fn build_ret(bcx: @mut Block, tys: &ShimTypes, llargbundle: ValueRef) {
             let _icx = push_ctxt("foreign::foreign::wrap::build_ret");
             tys.fn_ty.build_wrap_ret(bcx, tys.llsig.llarg_tys, llargbundle);
         }
index d3f5b9844c930f6c1607c2637a976e063ad973da..024ab7af0814def9ef0f708d7960026c88a904e8 100644 (file)
 
 use middle::trans::type_::Type;
 
-use std::io;
 use std::libc::c_uint;
 use std::str;
 use syntax::ast;
 
-pub fn trans_free(cx: block, v: ValueRef) -> block {
+pub fn trans_free(cx: @mut Block, v: ValueRef) -> @mut Block {
     let _icx = push_ctxt("trans_free");
     callee::trans_lang_call(cx,
         langcall(cx, None, "", FreeFnLangItem),
@@ -50,7 +49,7 @@ pub fn trans_free(cx: block, v: ValueRef) -> block {
         Some(expr::Ignore)).bcx
 }
 
-pub fn trans_exchange_free(cx: block, v: ValueRef) -> block {
+pub fn trans_exchange_free(cx: @mut Block, v: ValueRef) -> @mut Block {
     let _icx = push_ctxt("trans_exchange_free");
     callee::trans_lang_call(cx,
         langcall(cx, None, "", ExchangeFreeFnLangItem),
@@ -58,7 +57,7 @@ pub fn trans_exchange_free(cx: block, v: ValueRef) -> block {
         Some(expr::Ignore)).bcx
 }
 
-pub fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block {
+pub fn take_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     // NB: v is an *alias* of type t here, not a direct value.
     let _icx = push_ctxt("take_ty");
     if ty::type_needs_drop(cx.tcx(), t) {
@@ -67,7 +66,7 @@ pub fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block {
     return cx;
 }
 
-pub fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block {
+pub fn drop_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     // NB: v is an *alias* of type t here, not a direct value.
     let _icx = push_ctxt("drop_ty");
     if ty::type_needs_drop(cx.tcx(), t) {
@@ -76,7 +75,7 @@ pub fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block {
     return cx;
 }
 
-pub fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
+pub fn drop_ty_immediate(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     let _icx = push_ctxt("drop_ty_immediate");
     match ty::get(t).sty {
         ty::ty_uniq(_)
@@ -93,7 +92,7 @@ pub fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
     }
 }
 
-pub fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
+pub fn free_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     // NB: v is an *alias* of type t here, not a direct value.
     let _icx = push_ctxt("free_ty");
     if ty::type_needs_drop(cx.tcx(), t) {
@@ -102,7 +101,7 @@ pub fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
     return cx;
 }
 
-pub fn free_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
+pub fn free_ty_immediate(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     let _icx = push_ctxt("free_ty_immediate");
     match ty::get(t).sty {
       ty::ty_uniq(_) |
@@ -273,7 +272,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
 }
 
 // See [Note-arg-mode]
-pub fn call_tydesc_glue_full(bcx: block,
+pub fn call_tydesc_glue_full(bcx: @mut Block,
                              v: ValueRef,
                              tydesc: ValueRef,
                              field: uint,
@@ -334,15 +333,15 @@ pub fn call_tydesc_glue_full(bcx: block,
 }
 
 // See [Note-arg-mode]
-pub fn call_tydesc_glue(cx: block, v: ValueRef, t: ty::t, field: uint)
-    -> block {
+pub fn call_tydesc_glue(cx: @mut Block, v: ValueRef, t: ty::t, field: uint)
+    -> @mut Block {
     let _icx = push_ctxt("call_tydesc_glue");
     let ti = get_tydesc(cx.ccx(), t);
     call_tydesc_glue_full(cx, v, ti.tydesc, field, Some(ti));
     return cx;
 }
 
-pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) -> block {
+pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     let _icx = push_ctxt("make_visit_glue");
     do with_scope(bcx, None, "visitor cleanup") |bcx| {
         let mut bcx = bcx;
@@ -360,7 +359,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) -> block {
     }
 }
 
-pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) -> block {
+pub fn make_free_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     // NB: v0 is an *alias* of type t here, not a direct value.
     let _icx = push_ctxt("make_free_glue");
     match ty::get(t).sty {
@@ -397,8 +396,8 @@ pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) -> block {
     }
 }
 
-pub fn trans_struct_drop_flag(bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
-                              class_did: ast::def_id, substs: &ty::substs) -> block {
+pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
+                              class_did: ast::def_id, substs: &ty::substs) -> @mut Block {
     let repr = adt::represent_type(bcx.ccx(), t);
     let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0);
     do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
@@ -435,8 +434,8 @@ pub fn trans_struct_drop_flag(bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast:
     }
 }
 
-pub fn trans_struct_drop(mut bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
-                         class_did: ast::def_id, substs: &ty::substs) -> block {
+pub fn trans_struct_drop(mut bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
+                         class_did: ast::def_id, substs: &ty::substs) -> @mut Block {
     let repr = adt::represent_type(bcx.ccx(), t);
 
     // Find and call the actual destructor
@@ -468,7 +467,7 @@ pub fn trans_struct_drop(mut bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::
     bcx
 }
 
-pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) -> block {
+pub fn make_drop_glue(bcx: @mut Block, v0: ValueRef, t: ty::t) -> @mut Block {
     // NB: v0 is an *alias* of type t here, not a direct value.
     let _icx = push_ctxt("make_drop_glue");
     let ccx = bcx.ccx();
@@ -539,10 +538,10 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) -> block {
 }
 
 // box_ptr_ptr is optional, it is constructed if not supplied.
-pub fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef,
+pub fn decr_refcnt_maybe_free(bcx: @mut Block, box_ptr: ValueRef,
                               box_ptr_ptr: Option<ValueRef>,
                               t: ty::t)
-                           -> block {
+                           -> @mut Block {
     let _icx = push_ctxt("decr_refcnt_maybe_free");
     let ccx = bcx.ccx();
 
@@ -566,7 +565,7 @@ pub fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef,
 }
 
 
-pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) -> block {
+pub fn make_take_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
     let _icx = push_ctxt("make_take_glue");
     // NB: v is a *pointer* to type t here, not a direct value.
     match ty::get(t).sty {
@@ -630,7 +629,7 @@ pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) -> block {
     }
 }
 
-pub fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) {
+pub fn incr_refcnt_of_boxed(cx: @mut Block, box_ptr: ValueRef) {
     let _icx = push_ctxt("incr_refcnt_of_boxed");
     let ccx = cx.ccx();
     let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]);
@@ -649,8 +648,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
     let llty = type_of(ccx, t);
 
     if ccx.sess.count_type_sizes() {
-        io::println(fmt!("%u\t%s", llsize_of_real(ccx, llty),
-                         ppaux::ty_to_str(ccx.tcx, t)));
+        printfln!("%u\t%s", llsize_of_real(ccx, llty),
+                  ppaux::ty_to_str(ccx.tcx, t));
     }
 
     let llsize = llsize_of(ccx, llty);
@@ -677,7 +676,7 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
     return inf;
 }
 
-pub type glue_helper<'self> = &'self fn(block, ValueRef, ty::t) -> block;
+pub type glue_helper<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
 
 pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type,
                             name: &str) -> ValueRef {
index bcf3aa6ad50bff0f0ac4235ae55974bc0cacbf62..a65999ff2aa178d08ce6407ead25c035b92ac3f1 100644 (file)
@@ -124,7 +124,7 @@ pub fn trans_method(ccx: @mut CrateContext,
              []);
 }
 
-pub fn trans_self_arg(bcx: block,
+pub fn trans_self_arg(bcx: @mut Block,
                       base: @ast::expr,
                       temp_cleanups: &mut ~[ValueRef],
                       mentry: typeck::method_map_entry) -> Result {
@@ -141,7 +141,7 @@ pub fn trans_self_arg(bcx: block,
                    DontAutorefArg)
 }
 
-pub fn trans_method_callee(bcx: block,
+pub fn trans_method_callee(bcx: @mut Block,
                            callee_id: ast::node_id,
                            this: @ast::expr,
                            mentry: typeck::method_map_entry)
@@ -251,7 +251,7 @@ pub fn trans_method_callee(bcx: block,
     }
 }
 
-pub fn trans_static_method_callee(bcx: block,
+pub fn trans_static_method_callee(bcx: @mut Block,
                                   method_id: ast::def_id,
                                   trait_id: ast::def_id,
                                   callee_id: ast::node_id)
@@ -348,7 +348,7 @@ pub fn method_with_name(ccx: &mut CrateContext,
     meth.def_id
 }
 
-pub fn trans_monomorphized_callee(bcx: block,
+pub fn trans_monomorphized_callee(bcx: @mut Block,
                                   callee_id: ast::node_id,
                                   base: @ast::expr,
                                   mentry: typeck::method_map_entry,
@@ -409,7 +409,7 @@ pub fn trans_monomorphized_callee(bcx: block,
 
 }
 
-pub fn combine_impl_and_methods_tps(bcx: block,
+pub fn combine_impl_and_methods_tps(bcx: @mut Block,
                                     mth_did: ast::def_id,
                                     callee_id: ast::node_id,
                                     rcvr_substs: &[ty::t],
@@ -459,7 +459,7 @@ pub fn combine_impl_and_methods_tps(bcx: block,
 }
 
 
-pub fn trans_trait_callee(bcx: block,
+pub fn trans_trait_callee(bcx: @mut Block,
                           callee_id: ast::node_id,
                           n_method: uint,
                           self_expr: @ast::expr,
@@ -496,7 +496,7 @@ pub fn trans_trait_callee(bcx: block,
                                   explicit_self)
 }
 
-pub fn trans_trait_callee_from_llval(bcx: block,
+pub fn trans_trait_callee_from_llval(bcx: @mut Block,
                                      callee_ty: ty::t,
                                      n_method: uint,
                                      llpair: ValueRef,
@@ -628,7 +628,7 @@ pub fn vtable_id(ccx: @mut CrateContext,
 
 /// Creates a returns a dynamic vtable for the given type and vtable origin.
 /// This is used only for objects.
-pub fn get_vtable(bcx: block,
+pub fn get_vtable(bcx: @mut Block,
                   self_ty: ty::t,
                   origin: typeck::vtable_origin)
                   -> ValueRef {
@@ -672,7 +672,7 @@ pub fn make_vtable(ccx: &mut CrateContext,
 }
 
 /// Generates a dynamic vtable for objects.
-pub fn make_impl_vtable(bcx: block,
+pub fn make_impl_vtable(bcx: @mut Block,
                         impl_id: ast::def_id,
                         self_ty: ty::t,
                         substs: &[ty::t],
@@ -716,12 +716,12 @@ pub fn make_impl_vtable(bcx: block,
     make_vtable(ccx, tydesc, methods)
 }
 
-pub fn trans_trait_cast(bcx: block,
+pub fn trans_trait_cast(bcx: @mut Block,
                         val: @ast::expr,
                         id: ast::node_id,
                         dest: expr::Dest,
                         _store: ty::TraitStore)
-                     -> block {
+                     -> @mut Block {
     let mut bcx = bcx;
     let _icx = push_ctxt("impl::trans_cast");
 
index 6df1df454ff464aea41ec832fcd606fc152b8ff5..84b001953e0459138cefc2ae389e343d8f65ed09 100644 (file)
@@ -37,9 +37,9 @@
 pub struct Reflector {
     visitor_val: ValueRef,
     visitor_methods: @~[@ty::Method],
-    final_bcx: block,
+    final_bcx: @mut Block,
     tydesc_ty: Type,
-    bcx: block
+    bcx: @mut Block
 }
 
 impl Reflector {
@@ -374,11 +374,11 @@ pub fn visit_sig(&mut self, retval: uint, sig: &ty::FnSig) {
 }
 
 // Emit a sequence of calls to visit_ty::visit_foo
-pub fn emit_calls_to_trait_visit_ty(bcx: block,
+pub fn emit_calls_to_trait_visit_ty(bcx: @mut Block,
                                     t: ty::t,
                                     visitor_val: ValueRef,
                                     visitor_trait_id: def_id)
-                                 -> block {
+                                 -> @mut Block {
     let final = sub_block(bcx, "final");
     let tydesc_ty = ty::get_tydesc_ty(bcx.ccx().tcx).unwrap();
     let tydesc_ty = type_of(bcx.ccx(), tydesc_ty);
index 8aca10f9b92e24d39e2d3eb3fee80a1f7edb81f6..2f29d92574c2f8d924fc97b446f1a617dda69336 100644 (file)
@@ -53,18 +53,18 @@ pub fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
     }
 }
 
-pub fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef {
+pub fn get_fill(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
     let _icx = push_ctxt("tvec::get_fill");
     Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]))
 }
-pub fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) {
+pub fn set_fill(bcx: @mut Block, vptr: ValueRef, fill: ValueRef) {
     Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]));
 }
-pub fn get_alloc(bcx: block, vptr: ValueRef) -> ValueRef {
+pub fn get_alloc(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
     Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]))
 }
 
-pub fn get_bodyptr(bcx: block, vptr: ValueRef, t: ty::t) -> ValueRef {
+pub fn get_bodyptr(bcx: @mut Block, vptr: ValueRef, t: ty::t) -> ValueRef {
     if ty::type_contents(bcx.tcx(), t).contains_managed() {
         GEPi(bcx, vptr, [0u, abi::box_field_body])
     } else {
@@ -72,19 +72,19 @@ pub fn get_bodyptr(bcx: block, vptr: ValueRef, t: ty::t) -> ValueRef {
     }
 }
 
-pub fn get_dataptr(bcx: block, vptr: ValueRef) -> ValueRef {
+pub fn get_dataptr(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
     let _icx = push_ctxt("tvec::get_dataptr");
     GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u])
 }
 
-pub fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
+pub fn pointer_add(bcx: @mut Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
     let _icx = push_ctxt("tvec::pointer_add");
     let old_ty = val_ty(ptr);
     let bptr = PointerCast(bcx, ptr, Type::i8p());
     return PointerCast(bcx, InBoundsGEP(bcx, bptr, [bytes]), old_ty);
 }
 
-pub fn alloc_raw(bcx: block, unit_ty: ty::t,
+pub fn alloc_raw(bcx: @mut Block, unit_ty: ty::t,
                  fill: ValueRef, alloc: ValueRef, heap: heap) -> Result {
     let _icx = push_ctxt("tvec::alloc_uniq");
     let ccx = bcx.ccx();
@@ -107,12 +107,12 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t,
     }
 }
 
-pub fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
+pub fn alloc_uniq_raw(bcx: @mut Block, unit_ty: ty::t,
                       fill: ValueRef, alloc: ValueRef) -> Result {
     alloc_raw(bcx, unit_ty, fill, alloc, base::heap_for_unique(bcx, unit_ty))
 }
 
-pub fn alloc_vec(bcx: block,
+pub fn alloc_vec(bcx: @mut Block,
                  unit_ty: ty::t,
                  elts: uint,
                  heap: heap)
@@ -130,8 +130,8 @@ pub fn alloc_vec(bcx: block,
     return rslt(bcx, vptr);
 }
 
-pub fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
-   block {
+pub fn make_drop_glue_unboxed(bcx: @mut Block, vptr: ValueRef, vec_ty: ty::t) ->
+   @mut Block {
     let _icx = push_ctxt("tvec::make_drop_glue_unboxed");
     let tcx = bcx.tcx();
     let unit_ty = ty::sequence_element_type(tcx, vec_ty);
@@ -157,11 +157,11 @@ pub fn to_str(&self, ccx: &CrateContext) -> ~str {
     }
 }
 
-pub fn trans_fixed_vstore(bcx: block,
+pub fn trans_fixed_vstore(bcx: @mut Block,
                           vstore_expr: @ast::expr,
                           content_expr: &ast::expr,
                           dest: expr::Dest)
-                       -> block {
+                       -> @mut Block {
     //!
     //
     // [...] allocates a fixed-size array and moves it around "by value".
@@ -186,11 +186,11 @@ pub fn trans_fixed_vstore(bcx: block,
     };
 }
 
-pub fn trans_slice_vstore(bcx: block,
+pub fn trans_slice_vstore(bcx: @mut Block,
                           vstore_expr: @ast::expr,
                           content_expr: @ast::expr,
                           dest: expr::Dest)
-                       -> block {
+                       -> @mut Block {
     //!
     //
     // &[...] allocates memory on the stack and writes the values into it,
@@ -245,11 +245,11 @@ pub fn trans_slice_vstore(bcx: block,
     return bcx;
 }
 
-pub fn trans_lit_str(bcx: block,
+pub fn trans_lit_str(bcx: @mut Block,
                      lit_expr: @ast::expr,
                      str_lit: @str,
                      dest: Dest)
-                  -> block {
+                  -> @mut Block {
     //!
     //
     // Literal strings translate to slices into static memory.  This is
@@ -280,7 +280,7 @@ pub fn trans_lit_str(bcx: block,
 }
 
 
-pub fn trans_uniq_or_managed_vstore(bcx: block, heap: heap, vstore_expr: @ast::expr,
+pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: @ast::expr,
                                     content_expr: &ast::expr) -> DatumBlock {
     //!
     //
@@ -341,12 +341,12 @@ pub fn trans_uniq_or_managed_vstore(bcx: block, heap: heap, vstore_expr: @ast::e
     return immediate_rvalue_bcx(bcx, val, vt.vec_ty);
 }
 
-pub fn write_content(bcx: block,
+pub fn write_content(bcx: @mut Block,
                      vt: &VecTypes,
                      vstore_expr: @ast::expr,
                      content_expr: &ast::expr,
                      dest: Dest)
-                  -> block {
+                  -> @mut Block {
     let _icx = push_ctxt("tvec::write_content");
     let mut bcx = bcx;
 
@@ -469,12 +469,12 @@ pub fn write_content(bcx: block,
     }
 }
 
-pub fn vec_types_from_expr(bcx: block, vec_expr: &ast::expr) -> VecTypes {
+pub fn vec_types_from_expr(bcx: @mut Block, vec_expr: &ast::expr) -> VecTypes {
     let vec_ty = node_id_type(bcx, vec_expr.id);
     vec_types(bcx, vec_ty)
 }
 
-pub fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes {
+pub fn vec_types(bcx: @mut Block, vec_ty: ty::t) -> VecTypes {
     let ccx = bcx.ccx();
     let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
     let llunit_ty = type_of::type_of(ccx, unit_ty);
@@ -486,7 +486,7 @@ pub fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes {
               llunit_size: llunit_size}
 }
 
-pub fn elements_required(bcx: block, content_expr: &ast::expr) -> uint {
+pub fn elements_required(bcx: @mut Block, content_expr: &ast::expr) -> uint {
     //! Figure out the number of elements we need to store this content
 
     match content_expr.node {
@@ -502,7 +502,7 @@ pub fn elements_required(bcx: block, content_expr: &ast::expr) -> uint {
     }
 }
 
-pub fn get_base_and_len(bcx: block,
+pub fn get_base_and_len(bcx: @mut Block,
                         llval: ValueRef,
                         vec_ty: ty::t) -> (ValueRef, ValueRef) {
     //!
@@ -540,10 +540,10 @@ pub fn get_base_and_len(bcx: block,
     }
 }
 
-pub type iter_vec_block<'self> = &'self fn(block, ValueRef, ty::t) -> block;
+pub type iter_vec_block<'self> = &'self fn(@mut Block, ValueRef, ty::t) -> @mut Block;
 
-pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
-                    fill: ValueRef, f: iter_vec_block) -> block {
+pub fn iter_vec_raw(bcx: @mut Block, data_ptr: ValueRef, vec_ty: ty::t,
+                    fill: ValueRef, f: iter_vec_block) -> @mut Block {
     let _icx = push_ctxt("tvec::iter_vec_raw");
 
     let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
@@ -573,15 +573,15 @@ pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
 
 }
 
-pub fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t,
-                     fill: ValueRef, f: iter_vec_block) -> block {
+pub fn iter_vec_uniq(bcx: @mut Block, vptr: ValueRef, vec_ty: ty::t,
+                     fill: ValueRef, f: iter_vec_block) -> @mut Block {
     let _icx = push_ctxt("tvec::iter_vec_uniq");
     let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr, vec_ty));
     iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
 }
 
-pub fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t,
-                        f: iter_vec_block) -> block {
+pub fn iter_vec_unboxed(bcx: @mut Block, body_ptr: ValueRef, vec_ty: ty::t,
+                        f: iter_vec_block) -> @mut Block {
     let _icx = push_ctxt("tvec::iter_vec_unboxed");
     let fill = get_fill(bcx, body_ptr);
     let dataptr = get_dataptr(bcx, body_ptr);
index e9df83549e28dda9fb4719012131ed473ed8eca5..93335de229275391842d6d2ac37013bf23f23f6c 100644 (file)
@@ -17,8 +17,8 @@
 use middle::trans::glue;
 use middle::ty;
 
-pub fn make_free_glue(bcx: block, vptrptr: ValueRef, box_ty: ty::t)
-    -> block {
+pub fn make_free_glue(bcx: @mut Block, vptrptr: ValueRef, box_ty: ty::t)
+    -> @mut Block {
     let _icx = push_ctxt("uniq::make_free_glue");
     let box_datum = immediate_rvalue(Load(bcx, vptrptr), box_ty);
 
index b9a9a57d0461d576e8b31972ac23cf4c81839d31..13c20591ba3e190bdd6964536d187266342083bc 100644 (file)
 use middle::trans::type_::Type;
 
 pub fn root_and_write_guard(datum: &Datum,
-                            mut bcx: block,
+                            mut bcx: @mut Block,
                             span: span,
                             expr_id: ast::node_id,
-                            derefs: uint) -> block {
+                            derefs: uint) -> @mut Block {
     let key = root_map_key { id: expr_id, derefs: derefs };
     debug!("write_guard::root_and_write_guard(key=%?)", key);
 
@@ -60,12 +60,12 @@ pub fn root_and_write_guard(datum: &Datum,
     }
 }
 
-pub fn return_to_mut(mut bcx: block,
+pub fn return_to_mut(mut bcx: @mut Block,
                      root_key: root_map_key,
                      frozen_val_ref: ValueRef,
                      bits_val_ref: ValueRef,
                      filename_val: ValueRef,
-                     line_val: ValueRef) -> block {
+                     line_val: ValueRef) -> @mut Block {
     debug!("write_guard::return_to_mut(root_key=%?, %s, %s, %s)",
            root_key,
            bcx.to_str(),
@@ -102,10 +102,10 @@ pub fn return_to_mut(mut bcx: block,
 }
 
 fn root(datum: &Datum,
-        mut bcx: block,
+        mut bcx: @mut Block,
         span: span,
         root_key: root_map_key,
-        root_info: RootInfo) -> block {
+        root_info: RootInfo) -> @mut Block {
     //! In some cases, borrowck will decide that an @T/@[]/@str
     //! value must be rooted for the program to be safe.  In that
     //! case, we will call this function, which will stash a copy
@@ -182,8 +182,8 @@ fn root(datum: &Datum,
 }
 
 fn perform_write_guard(datum: &Datum,
-                       bcx: block,
-                       span: span) -> block {
+                       bcx: @mut Block,
+                       span: span) -> @mut Block {
     debug!("perform_write_guard");
 
     let llval = datum.to_value_llval(bcx);
index cd9d744c24034f5ceb7f99357a34d3d2a50175fc..7eea20175f9fc7e77e666849e76da5deb7cbcf6c 100644 (file)
@@ -2712,7 +2712,7 @@ pub fn node_id_to_trait_ref(cx: ctxt, id: ast::node_id) -> @ty::TraitRef {
 }
 
 pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
-    //io::println(fmt!("%?/%?", id, cx.node_types.len()));
+    //printfln!("%?/%?", id, cx.node_types.len());
     match cx.node_types.find(&(id as uint)) {
        Some(&t) => t,
        None => cx.sess.bug(
index 4a32e8bf952c1d70b0530e7bbfc154f176ba24ae..8d546366846b406538c08ea98083e8993c681e8e 100644 (file)
@@ -194,7 +194,6 @@ pub fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
         self.push_inherent_candidates(self_ty);
         self.push_extension_candidates();
 
-        let mut enum_dids = ~[];
         let mut self_ty = self_ty;
         let mut autoderefs = 0;
         loop {
@@ -236,7 +235,7 @@ pub fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
             }
 
             // Otherwise, perform autoderef.
-            match self.deref(self_ty, &mut enum_dids) {
+            match self.deref(self_ty) {
                 None => { break; }
                 Some(ty) => {
                     self_ty = ty;
@@ -248,20 +247,8 @@ pub fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
         self.search_for_autosliced_method(self_ty, autoderefs)
     }
 
-    pub fn deref(&self, ty: ty::t, enum_dids: &mut ~[ast::def_id])
+    pub fn deref(&self, ty: ty::t)
                  -> Option<ty::t> {
-        match ty::get(ty).sty {
-            ty_enum(did, _) => {
-                // Watch out for newtype'd enums like "enum t = @T".
-                // See discussion in typeck::check::do_autoderef().
-                if enum_dids.iter().any(|x| x == &did) {
-                    return None;
-                }
-                enum_dids.push(did);
-            }
-            _ => {}
-        }
-
         match ty::deref(self.tcx(), ty, false) {
             None => None,
             Some(t) => {
@@ -285,7 +272,6 @@ pub fn push_inherent_candidates(&self, self_ty: ty::t) {
          * we'll want to find the inherent impls for `C`.
          */
 
-        let mut enum_dids = ~[];
         let mut self_ty = self_ty;
         loop {
             match get(self_ty).sty {
@@ -314,7 +300,7 @@ pub fn push_inherent_candidates(&self, self_ty: ty::t) {
             // n.b.: Generally speaking, we only loop if we hit the
             // fallthrough case in the match above.  The exception
             // would be newtype enums.
-            self_ty = match self.deref(self_ty, &mut enum_dids) {
+            self_ty = match self.deref(self_ty) {
                 None => { return; }
                 Some(ty) => { ty }
             }
index e97f67ceb9cc4e33cb5dbe479e8af896b9b7c39d..39fbdb92a2feef7fef10a6a9eb87ffdffe2b2f78 100644 (file)
@@ -128,28 +128,28 @@ pub fn version(argv0: &str) {
     let mut vers = ~"unknown version";
     let env_vers = env!("CFG_VERSION");
     if env_vers.len() != 0 { vers = env_vers.to_owned(); }
-    io::println(fmt!("%s %s", argv0, vers));
-    io::println(fmt!("host: %s", host_triple()));
+    printfln!("%s %s", argv0, vers);
+    printfln!("host: %s", host_triple());
 }
 
 pub fn usage(argv0: &str) {
     let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
-    io::println(fmt!("%s\
+    printfln!("%s\
 Additional help:
     -W help             Print 'lint' options and default settings
     -Z help             Print internal options for debugging rustc\n",
-                     groups::usage(message, optgroups())));
+              groups::usage(message, optgroups()));
 }
 
 pub fn describe_warnings() {
     use extra::sort::Sort;
-    io::println(fmt!("
+    printfln!("
 Available lint options:
     -W <foo>           Warn about <foo>
     -A <foo>           Allow <foo>
     -D <foo>           Deny <foo>
     -F <foo>           Forbid <foo> (deny, and deny all overrides)
-"));
+");
 
     let lint_dict = lint::get_lint_dict();
     let mut lint_dict = lint_dict.consume()
@@ -164,28 +164,28 @@ pub fn describe_warnings() {
     fn padded(max: uint, s: &str) -> ~str {
         str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
     }
-    io::println(fmt!("\nAvailable lint checks:\n"));
-    io::println(fmt!("    %s  %7.7s  %s",
-                     padded(max_key, "name"), "default", "meaning"));
-    io::println(fmt!("    %s  %7.7s  %s\n",
-                     padded(max_key, "----"), "-------", "-------"));
+    printfln!("\nAvailable lint checks:\n");
+    printfln!("    %s  %7.7s  %s",
+              padded(max_key, "name"), "default", "meaning");
+    printfln!("    %s  %7.7s  %s\n",
+              padded(max_key, "----"), "-------", "-------");
     for lint_dict.consume_iter().advance |(spec, name)| {
         let name = name.replace("_", "-");
-        io::println(fmt!("    %s  %7.7s  %s",
-                         padded(max_key, name),
-                         lint::level_to_str(spec.default),
-                         spec.desc));
+        printfln!("    %s  %7.7s  %s",
+                  padded(max_key, name),
+                  lint::level_to_str(spec.default),
+                  spec.desc);
     }
     io::println("");
 }
 
 pub fn describe_debug_flags() {
-    io::println(fmt!("\nAvailable debug options:\n"));
+    printfln!("\nAvailable debug options:\n");
     let r = session::debugging_opts_map();
     for r.iter().advance |tuple| {
         match *tuple {
             (ref name, ref desc, _) => {
-                io::println(fmt!("    -Z %-20s -- %s", *name, *desc));
+                printfln!("    -Z %-20s -- %s", *name, *desc);
             }
         }
     }
index 733e8093a9d706788e76c7b34b0019c674ddf00c..6d5498898555d0bc96f465ded8522c89bac72373 100644 (file)
@@ -14,7 +14,6 @@
 use syntax::visit;
 
 use std::hashmap::HashSet;
-use std::io;
 use extra;
 
 pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
@@ -22,7 +21,7 @@ pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
     let start = extra::time::precise_time_s();
     let rv = thunk();
     let end = extra::time::precise_time_s();
-    io::println(fmt!("time: %3.3f s\t%s", end - start, what));
+    printfln!("time: %3.3f s\t%s", end - start, what);
     rv
 }
 
index 675ff7a8b951284759e03757d9961e5c8f374502..de4815ab7a6ede4863e259bd3365c547366baf76 100644 (file)
@@ -74,7 +74,7 @@ pub fn usage() {
     println("Options:\n");
     let r = opts();
     for r.iter().advance |opt| {
-        println(fmt!("    %s", opt.second()));
+        printfln!("    %s", opt.second());
     }
     println("");
 }
index cd2ffd7d602196ebfe683a73850f0a6e587b775c..b738f4a958681c4c04140fd90df5e91029b95f87 100644 (file)
@@ -23,7 +23,6 @@
 extern mod rustc;
 extern mod syntax;
 
-use std::io;
 use std::os;
 
 use config::Config;
@@ -69,7 +68,7 @@ pub fn main() {
     let config = match config::parse_config(args) {
       Ok(config) => config,
       Err(err) => {
-        io::println(fmt!("error: %s", err));
+        printfln!("error: %s", err);
         return;
       }
     };
index 63cf4001594f973835963de654a589ae754b98d0..38c70f8be0595b44ef67757328a2ac9d450e14dc 100644 (file)
@@ -334,7 +334,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
             None => { },
         }
         if (should_compile) {
-            println(fmt!("compiling %s...", src_filename));
+            printfln!("compiling %s...", src_filename);
             driver::compile_upto(sess, cfg, &input, driver::cu_everything,
                                  Some(outputs));
             true
@@ -413,8 +413,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
             if loaded_crates.is_empty() {
                 println("no crates loaded");
             } else {
-                println(fmt!("crates loaded: %s",
-                                 loaded_crates.connect(", ")));
+                printfln!("crates loaded: %s", loaded_crates.connect(", "));
             }
         }
         ~"{" => {
index ed5b1118a9c7c7d90426406f86bf3639274a9b15..700dbea8182d2e4a0b9fb307232f9779e630e61e 100644 (file)
@@ -400,7 +400,7 @@ pub fn mk_output_path(what: OutputType, where: Target,
                                Test => "test",
                                Bench => "bench",
                                _     => ""
-                           }
+                           },
                            os::EXE_SUFFIX))
     };
     if !output_path.is_absolute() {
index ebd6f9bf9d8cd920b5a37b1ad60de527b7966bb4..37eb3aa5911ed3a96f27f86f119db6dfd03db7b8 100644 (file)
@@ -34,7 +34,7 @@ pub fn main() {
     }
 
     if args[2] != ~"install" {
-        io::println(fmt!("Warning: I don't know how to %s", args[2]));
+        printfln!("Warning: I don't know how to %s", args[2]);
         return;
     }
 
index 198e63f83c60ce6eb103b28424f9bf9553718f16..0c2a7bb7b400ca0a79f517a9c20ba0295f4f553a 100644 (file)
@@ -53,6 +53,16 @@ pub trait DoubleEndedIterator<A>: Iterator<A> {
     fn next_back(&mut self) -> Option<A>;
 }
 
+/// An object implementing random access indexing by `uint`
+pub trait RandomAccessIterator<A> {
+    /// Return the number of indexable elements. At most `std::uint::max_value`
+    /// elements are indexable, even if the iterator represents a longer range.
+    fn indexable(&self) -> uint;
+
+    /// Return an element at an index
+    fn idx(&self, index: uint) -> Option<A>;
+}
+
 /// Iterator adaptors provided for every `DoubleEndedIterator` implementation.
 ///
 /// In the future these will be default methods instead of a utility trait.
@@ -316,7 +326,7 @@ fn flat_map_<'r, B, U: Iterator<B>>(self, f: &'r fn(A) -> U)
     /// use std::iterator::Counter;
     ///
     /// for Counter::new(0, 10).advance |i| {
-    ///     io::println(fmt!("%d", i));
+    ///     printfln!("%d", i);
     /// }
     /// ~~~
     fn advance(&mut self, f: &fn(A) -> bool) -> bool;
@@ -836,6 +846,30 @@ fn next_back(&mut self) -> Option<A> {
     }
 }
 
+impl<A, T: RandomAccessIterator<A>, U: RandomAccessIterator<A>> RandomAccessIterator<A>
+for ChainIterator<A, T, U> {
+    #[inline]
+    fn indexable(&self) -> uint {
+        let (a, b) = (self.a.indexable(), self.b.indexable());
+        let total = a + b;
+        if total < a || total < b {
+            uint::max_value
+        } else {
+            total
+        }
+    }
+
+    #[inline]
+    fn idx(&self, index: uint) -> Option<A> {
+        let len = self.a.indexable();
+        if index < len {
+            self.a.idx(index)
+        } else {
+            self.b.idx(index - len)
+        }
+    }
+}
+
 /// An iterator which iterates two other iterators simultaneously
 // FIXME #6967: Dummy A & B parameters to get around type inference bug
 #[deriving(Clone)]
@@ -1718,4 +1752,23 @@ fn test_double_ended_chain() {
         assert_eq!(it.next_back().unwrap(), &7)
         assert_eq!(it.next_back(), None)
     }
+
+    #[test]
+    fn test_random_access_chain() {
+        let xs = [1, 2, 3, 4, 5];
+        let ys = ~[7, 9, 11];
+        let mut it = xs.iter().chain_(ys.iter());
+        assert_eq!(it.idx(0).unwrap(), &1);
+        assert_eq!(it.idx(5).unwrap(), &7);
+        assert_eq!(it.idx(7).unwrap(), &11);
+        assert!(it.idx(8).is_none());
+
+        it.next();
+        it.next();
+        it.next_back();
+
+        assert_eq!(it.idx(0).unwrap(), &3);
+        assert_eq!(it.idx(4).unwrap(), &9);
+        assert!(it.idx(6).is_none());
+    }
 }
index 8e7f49464ffc204c38125c3344183b5e37f9012e..722af828d5c115a5e08784f2da9593772cde3913 100644 (file)
@@ -703,3 +703,27 @@ fn from_str_issue5770() {
         assert_eq!(n, None);
     }
 }
+
+#[cfg(test)]
+mod bench {
+    use extra::test::BenchHarness;
+    use rand::{XorShiftRng,RngUtil};
+    use uint;
+    use float;
+
+    #[bench]
+    fn uint_to_str_rand(bh: &mut BenchHarness) {
+        let mut rng = XorShiftRng::new();
+        do bh.iter {
+            uint::to_str(rng.gen());
+        }
+    }
+
+    #[bench]
+    fn float_to_str_rand(bh: &mut BenchHarness) {
+        let mut rng = XorShiftRng::new();
+        do bh.iter {
+            float::to_str(rng.gen());
+        }
+    }
+}
\ No newline at end of file
index 54c1327fa9303798921d15ce735df9c64f59936f..acf7ea683fb544fd1f98506bffa70a3ad6e5e0e5 100644 (file)
@@ -103,7 +103,7 @@ fn range_step_core(start: $T, stop: $T, step: $T_SIGNED, r: Range, it: &fn($T) -
 /// let nums = [1,2,3,4,5,6,7];
 ///
 /// for uint::range_step(0, nums.len() - 1, 2) |i| {
-///     println(fmt!("%d & %d", nums[i], nums[i+1]));
+///     printfln!("%d & %d", nums[i], nums[i+1]);
 /// }
 /// ~~~
 ///
index 020131ab119e5080f2407d0851548c8f67e4b99b..756b4a10d3c9042ed7aa576b50edad859e515fce 100644 (file)
@@ -81,3 +81,28 @@ pub trait Shr<RHS,Result> {
 pub trait Index<Index,Result> {
     fn index(&self, index: &Index) -> Result;
 }
+
+#[cfg(test)]
+mod bench {
+
+    use extra::test::BenchHarness;
+    use ops::Drop;
+
+    // Overhead of dtors
+
+    struct HasDtor {
+        x: int
+    }
+
+    impl Drop for HasDtor {
+        fn drop(&self) {
+        }
+    }
+
+    #[bench]
+    fn alloc_obj_with_dtor(bh: &mut BenchHarness) {
+        do bh.iter {
+            HasDtor { x : 10 };
+        }
+    }
+}
\ No newline at end of file
index 9af2d8be2970ff2e9972852f594bc91b343c6af7..6d0613b2e674fe40591080cfcb790b3f6aff792a 100644 (file)
@@ -28,7 +28,7 @@
 fn main() {
     let mut rng = rand::rng();
     if rng.gen() { // bool
-        println(fmt!("int: %d, uint: %u", rng.gen(), rng.gen()))
+        printfln!("int: %d, uint: %u", rng.gen(), rng.gen())
     }
 }
 ~~~
@@ -38,7 +38,7 @@ fn main() {
 
 fn main () {
     let tuple_ptr = rand::random::<~(f64, char)>();
-    println(fmt!("%?", tuple_ptr))
+    printfln!(tuple_ptr)
 }
 ~~~
 */
@@ -301,7 +301,7 @@ pub trait RngUtil {
      *
      * fn main() {
      *     let mut rng = rand::rng();
-     *     println(fmt!("%b",rng.gen_weighted_bool(3)));
+     *     printfln!("%b", rng.gen_weighted_bool(3));
      * }
      * ~~~
      */
@@ -335,7 +335,7 @@ pub trait RngUtil {
      *
      * fn main() {
      *     let mut rng = rand::rng();
-     *     println(fmt!("%?",rng.gen_bytes(8)));
+     *     printfln!(rng.gen_bytes(8));
      * }
      * ~~~
      */
@@ -352,7 +352,7 @@ pub trait RngUtil {
      *
      * fn main() {
      *     let mut rng = rand::rng();
-     *     println(fmt!("%d",rng.choose([1,2,4,8,16,32])));
+     *     printfln!("%d", rng.choose([1,2,4,8,16,32]));
      * }
      * ~~~
      */
@@ -375,7 +375,7 @@ pub trait RngUtil {
      *     let x = [rand::Weighted {weight: 4, item: 'a'},
      *              rand::Weighted {weight: 2, item: 'b'},
      *              rand::Weighted {weight: 2, item: 'c'}];
-     *     println(fmt!("%c",rng.choose_weighted(x)));
+     *     printfln!("%c", rng.choose_weighted(x));
      * }
      * ~~~
      */
@@ -396,7 +396,7 @@ pub trait RngUtil {
      *     let x = [rand::Weighted {weight: 4, item: 'a'},
      *              rand::Weighted {weight: 2, item: 'b'},
      *              rand::Weighted {weight: 2, item: 'c'}];
-     *     println(fmt!("%?",rng.choose_weighted_option(x)));
+     *     printfln!(rng.choose_weighted_option(x));
      * }
      * ~~~
      */
@@ -418,7 +418,7 @@ fn choose_weighted_option<T:Clone>(&mut self, v: &[Weighted<T>])
      *     let x = [rand::Weighted {weight: 4, item: 'a'},
      *              rand::Weighted {weight: 2, item: 'b'},
      *              rand::Weighted {weight: 2, item: 'c'}];
-     *     println(fmt!("%?",rng.weighted_vec(x)));
+     *     printfln!(rng.weighted_vec(x));
      * }
      * ~~~
      */
@@ -435,7 +435,7 @@ fn choose_weighted_option<T:Clone>(&mut self, v: &[Weighted<T>])
      *
      * fn main() {
      *     let mut rng = rand::rng();
-     *     println(fmt!("%?",rng.shuffle([1,2,3])));
+     *     printfln!(rng.shuffle([1,2,3]));
      * }
      * ~~~
      */
@@ -454,9 +454,9 @@ fn choose_weighted_option<T:Clone>(&mut self, v: &[Weighted<T>])
      *     let mut rng = rand::rng();
      *     let mut y = [1,2,3];
      *     rng.shuffle_mut(y);
-     *     println(fmt!("%?",y));
+     *     printfln!(y);
      *     rng.shuffle_mut(y);
-     *     println(fmt!("%?",y));
+     *     printfln!(y);
      * }
      * ~~~
      */
@@ -890,7 +890,7 @@ pub fn random<T: Rand>() -> T {
 }
 
 #[cfg(test)]
-mod tests {
+mod test {
     use option::{Option, Some};
     use super::*;
 
@@ -1109,3 +1109,37 @@ pub unsafe fn rand_new_seeded(buf: *u8, sz: size_t)
         }
     }
 }
+
+#[cfg(test)]
+mod bench {
+    use extra::test::BenchHarness;
+    use rand::*;
+    use sys::size_of;
+
+    #[bench]
+    fn rand_xorshift(bh: &mut BenchHarness) {
+        let mut rng = XorShiftRng::new();
+        do bh.iter {
+            rng.gen::<uint>();
+        }
+        bh.bytes = size_of::<uint>() as u64;
+    }
+
+    #[bench]
+    fn rand_isaac(bh: &mut BenchHarness) {
+        let mut rng = IsaacRng::new();
+        do bh.iter {
+            rng.gen::<uint>();
+        }
+        bh.bytes = size_of::<uint>() as u64;
+    }
+
+    #[bench]
+    fn rand_shuffle_100(bh: &mut BenchHarness) {
+        let mut rng = XorShiftRng::new();
+        let x : &mut[uint] = [1,..100];
+        do bh.iter {
+            rng.shuffle_mut(x);
+        }
+    }
+}
\ No newline at end of file
index 4d983b9495446209e0ab401260628866b16e15fb..56eae0428751eef99697c32e05b9d168dcd22ae4 100644 (file)
@@ -70,7 +70,7 @@ fn ziggurat<R:Rng>(rng: &mut R,
 ///
 /// fn main() {
 ///     let normal = 2.0 + (*rand::random::<StandardNormal>()) * 3.0;
-///     println(fmt!("%f is from a N(2, 9) distribution", normal))
+///     printfln!("%f is from a N(2, 9) distribution", normal)
 /// }
 /// ~~~
 pub struct StandardNormal(f64);
@@ -124,7 +124,7 @@ fn zero_case<R:Rng>(rng: &mut R, u: f64) -> f64 {
 ///
 /// fn main() {
 ///     let exp2 = (*rand::random::<Exp1>()) * 0.5;
-///     println(fmt!("%f is from a Exp(2) distribution", exp2));
+///     printfln!("%f is from a Exp(2) distribution", exp2);
 /// }
 /// ~~~
 pub struct Exp1(f64);
index 75ee4f381f6ef6c454f8f351cf670c6f16812570..85cdb9fc941374ab6652d16adc2db313173749b1 100644 (file)
 //! the processes `argc` and `argv` arguments to be stored
 //! in a globally-accessible location for use by the `os` module.
 //!
+//! Only valid to call on linux. Mac and Windows use syscalls to
+//! discover the command line arguments.
+//!
 //! XXX: Would be nice for this to not exist.
 //! XXX: This has a lot of C glue for lack of globals.
 
-use libc;
-use option::{Option, Some, None};
-use str;
-use uint;
-use unstable::finally::Finally;
-use util;
+use option::Option;
 
 /// One-time global initialization.
 pub unsafe fn init(argc: int, argv: **u8) {
-    let args = load_argc_and_argv(argc, argv);
-    put(args);
+    imp::init(argc, argv)
 }
 
 /// One-time global cleanup.
 pub fn cleanup() {
-    rtassert!(take().is_some());
+    imp::cleanup()
 }
 
 /// Take the global arguments from global storage.
 pub fn take() -> Option<~[~str]> {
-    with_lock(|| unsafe {
-        let ptr = get_global_ptr();
-        let val = util::replace(&mut *ptr, None);
-        val.map(|s: &~~[~str]| (**s).clone())
-    })
+    imp::take()
 }
 
 /// Give the global arguments to global storage.
 ///
 /// It is an error if the arguments already exist.
 pub fn put(args: ~[~str]) {
-    with_lock(|| unsafe {
-        let ptr = get_global_ptr();
-        rtassert!((*ptr).is_none());
-        (*ptr) = Some(~args.clone());
-    })
+    imp::put(args)
 }
 
 /// Make a clone of the global arguments.
 pub fn clone() -> Option<~[~str]> {
-    with_lock(|| unsafe {
-        let ptr = get_global_ptr();
-        (*ptr).map(|s: &~~[~str]| (**s).clone())
-    })
+    imp::clone()
 }
 
-fn with_lock<T>(f: &fn() -> T) -> T {
-    do (|| {
-        unsafe {
-            rust_take_global_args_lock();
-            f()
+#[cfg(target_os = "linux")]
+#[cfg(target_os = "android")]
+#[cfg(target_os = "freebsd")]
+mod imp {
+
+    use libc;
+    use option::{Option, Some, None};
+    use str;
+    use uint;
+    use unstable::finally::Finally;
+    use util;
+
+    pub unsafe fn init(argc: int, argv: **u8) {
+        let args = load_argc_and_argv(argc, argv);
+        put(args);
+    }
+
+    pub fn cleanup() {
+        rtassert!(take().is_some());
+    }
+
+    pub fn take() -> Option<~[~str]> {
+        with_lock(|| unsafe {
+            let ptr = get_global_ptr();
+            let val = util::replace(&mut *ptr, None);
+            val.map(|s: &~~[~str]| (**s).clone())
+        })
+    }
+
+    pub fn put(args: ~[~str]) {
+        with_lock(|| unsafe {
+            let ptr = get_global_ptr();
+            rtassert!((*ptr).is_none());
+            (*ptr) = Some(~args.clone());
+        })
+    }
+
+    pub fn clone() -> Option<~[~str]> {
+        with_lock(|| unsafe {
+            let ptr = get_global_ptr();
+            (*ptr).map(|s: &~~[~str]| (**s).clone())
+        })
+    }
+
+    fn with_lock<T>(f: &fn() -> T) -> T {
+        do (|| {
+            unsafe {
+                rust_take_global_args_lock();
+                f()
+            }
+        }).finally {
+            unsafe {
+                rust_drop_global_args_lock();
+            }
         }
-    }).finally {
-        unsafe {
-            rust_drop_global_args_lock();
+    }
+
+    fn get_global_ptr() -> *mut Option<~~[~str]> {
+        unsafe { rust_get_global_args_ptr() }
+    }
+
+    // Copied from `os`.
+    unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
+        let mut args = ~[];
+        for uint::range(0, argc as uint) |i| {
+            args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i)));
         }
+        return args;
     }
-}
 
-fn get_global_ptr() -> *mut Option<~~[~str]> {
-    unsafe { rust_get_global_args_ptr() }
-}
+    extern {
+        fn rust_take_global_args_lock();
+        fn rust_drop_global_args_lock();
+        fn rust_get_global_args_ptr() -> *mut Option<~~[~str]>;
+    }
 
-// Copied from `os`.
-unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
-    let mut args = ~[];
-    for uint::range(0, argc as uint) |i| {
-        args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i)));
+    #[cfg(test)]
+    mod tests {
+        use option::{Some, None};
+        use super::*;
+        use unstable::finally::Finally;
+
+        #[test]
+        fn smoke_test() {
+            // Preserve the actual global state.
+            let saved_value = take();
+
+            let expected = ~[~"happy", ~"today?"];
+
+            put(expected.clone());
+            assert!(clone() == Some(expected.clone()));
+            assert!(take() == Some(expected.clone()));
+            assert!(take() == None);
+
+            do (|| {
+            }).finally {
+                // Restore the actual global state.
+                match saved_value {
+                    Some(ref args) => put(args.clone()),
+                    None => ()
+                }
+            }
+        }
     }
-    return args;
 }
 
-extern {
-    fn rust_take_global_args_lock();
-    fn rust_drop_global_args_lock();
-    fn rust_get_global_args_ptr() -> *mut Option<~~[~str]>;
-}
+#[cfg(target_os = "macos")]
+#[cfg(target_os = "win32")]
+mod imp {
+    use option::Option;
 
-#[cfg(test)]
-mod tests {
-    use option::{Some, None};
-    use super::*;
-    use unstable::finally::Finally;
+    pub unsafe fn init(_argc: int, _argv: **u8) {
+    }
 
-    #[test]
-    fn smoke_test() {
-        // Preserve the actual global state.
-        let saved_value = take();
+    pub fn cleanup() {
+    }
 
-        let expected = ~[~"happy", ~"today?"];
+    pub fn take() -> Option<~[~str]> {
+        fail!()
+    }
 
-        put(expected.clone());
-        assert!(clone() == Some(expected.clone()));
-        assert!(take() == Some(expected.clone()));
-        assert!(take() == None);
+    pub fn put(_args: ~[~str]) {
+        fail!()
+    }
 
-        do (|| {
-        }).finally {
-            // Restore the actual global state.
-            match saved_value {
-                Some(ref args) => put(args.clone()),
-                None => ()
-            }
-        }
+    pub fn clone() -> Option<~[~str]> {
+        fail!()
     }
 }
index 580390c19530edcdaa0ef9b54ee60c0b240acd53..54e9cb263dbe7ffc23835d733d65dfbac1bf451d 100644 (file)
@@ -101,3 +101,22 @@ pub unsafe fn exchange_free_(ptr: *c_char) {
 pub unsafe fn exchange_free(ptr: *c_char) {
     free(ptr as *c_void);
 }
+
+#[cfg(test)]
+mod bench {
+    use extra::test::BenchHarness;
+
+    #[bench]
+    fn alloc_owned_small(bh: &mut BenchHarness) {
+        do bh.iter {
+            ~10;
+        }
+    }
+
+    #[bench]
+    fn alloc_owned_big(bh: &mut BenchHarness) {
+        do bh.iter {
+            ~[10, ..1000];
+        }
+    }
+}
index c909bdb62850aa7d51d5ff31bfedd62aad4f4ba8..85917ae3edf12c1f0206b6512d902303fcd41a14 100644 (file)
@@ -135,3 +135,22 @@ fn rust_boxed_region_realloc(region: *BoxedRegion,
     fn rust_boxed_region_free(region: *BoxedRegion, box: *OpaqueBox);
     fn rust_current_boxed_region() -> *BoxedRegion;
 }
+
+#[cfg(test)]
+mod bench {
+    use extra::test::BenchHarness;
+
+    #[bench]
+    fn alloc_managed_small(bh: &mut BenchHarness) {
+        do bh.iter {
+            @10;
+        }
+    }
+
+    #[bench]
+    fn alloc_managed_big(bh: &mut BenchHarness) {
+        do bh.iter {
+            @[10, ..1000];
+        }
+    }
+}
index cbf00f43c61b9364eefe68f44bfbfcf0c9e400cd..bbbc1702c626178aeb9a05fe7c790747c507a1cb 100644 (file)
@@ -63,6 +63,9 @@
 #[deny(non_camel_case_types)];
 #[deny(missing_doc)];
 
+// Make extra accessible for benchmarking
+#[cfg(test)] extern mod extra(vers="0.8-pre");
+
 // Make std testable by not duplicating lang items. See #2912
 #[cfg(test)] extern mod realstd(name = "std");
 #[cfg(test)] pub use kinds = realstd::kinds;
index 125df156ed0b2f3203ba4d3bba386a8ec3002d9c..5b83112fe6bc048e72a58c6b801569e24f39146e 100644 (file)
@@ -1727,7 +1727,7 @@ fn is_char_boundary(&self, index: uint) -> bool {
      * let i = 0u;
      * while i < s.len() {
      *     let CharRange {ch, next} = s.char_range_at(i);
-     *     std::io::println(fmt!("%u: %c",i,ch));
+     *     printfln!("%u: %c", i, ch);
      *     i = next;
      * }
      * ~~~
@@ -3532,3 +3532,50 @@ fn sum_len<S: Container>(v: &[S]) -> uint {
         assert_eq!(5, sum_len([s.as_slice()]));
     }
 }
+
+#[cfg(test)]
+mod bench {
+    use extra::test::BenchHarness;
+    use str;
+
+    #[bench]
+    fn is_utf8_100_ascii(bh: &mut BenchHarness) {
+
+        let s = bytes!("Hello there, the quick brown fox jumped over the lazy dog! \
+                        Lorem ipsum dolor sit amet, consectetur. ");
+
+        assert_eq!(100, s.len());
+        do bh.iter {
+            str::is_utf8(s);
+        }
+    }
+
+    #[bench]
+    fn is_utf8_100_multibyte(bh: &mut BenchHarness) {
+        let s = bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰");
+        assert_eq!(100, s.len());
+        do bh.iter {
+            str::is_utf8(s);
+        }
+    }
+
+    #[bench]
+    fn map_chars_100_ascii(bh: &mut BenchHarness) {
+        let s = "HelloHelloHelloHelloHelloHelloHelloHelloHelloHello\
+                 HelloHelloHelloHelloHelloHelloHelloHelloHelloHello";
+        do bh.iter {
+            s.map_chars(|c| ((c as uint) + 1) as char);
+        }
+    }
+
+    #[bench]
+    fn map_chars_100_multibytes(bh: &mut BenchHarness) {
+        let s = "𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑\
+                 𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑\
+                 𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑\
+                 𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑";
+        do bh.iter {
+            s.map_chars(|c| ((c as uint) + 1) as char);
+        }
+    }
+}
index 227712e31e675f3a20193788f027d23aea6709f6..50cbd36ced9f9dd1a72302c9cd4d5ac8dc67ab72 100644 (file)
@@ -50,7 +50,7 @@ fn to_str(&self) -> ~str {
     }
 }
 
-impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
+impl<A:ToStr+Hash+Eq, B:ToStr> ToStr for HashMap<A, B> {
     #[inline]
     fn to_str(&self) -> ~str {
         let mut acc = ~"{";
@@ -182,6 +182,8 @@ mod tests {
     use hashmap::HashMap;
     use hashmap::HashSet;
     use container::{MutableSet, MutableMap};
+    use super::*;
+
     #[test]
     fn test_simple_types() {
         assert_eq!(1i.to_str(), ~"1");
@@ -212,17 +214,27 @@ fn test_vectors() {
                ~"[[], [1], [1, 1]]");
     }
 
+    struct StructWithToStrWithoutEqOrHash {
+        value: int
+    }
+
+    impl ToStr for StructWithToStrWithoutEqOrHash {
+        fn to_str(&self) -> ~str {
+            fmt!("s%d", self.value)
+        }
+    }
+
     #[test]
     fn test_hashmap() {
-        let mut table: HashMap<int, int> = HashMap::new();
-        let empty: HashMap<int, int> = HashMap::new();
+        let mut table: HashMap<int, StructWithToStrWithoutEqOrHash> = HashMap::new();
+        let empty: HashMap<int, StructWithToStrWithoutEqOrHash> = HashMap::new();
 
-        table.insert(3, 4);
-        table.insert(1, 2);
+        table.insert(3, StructWithToStrWithoutEqOrHash { value: 4 });
+        table.insert(1, StructWithToStrWithoutEqOrHash { value: 2 });
 
         let table_str = table.to_str();
 
-        assert!(table_str == ~"{1: 2, 3: 4}" || table_str == ~"{3: 4, 1: 2}");
+        assert!(table_str == ~"{1: s2, 3: s4}" || table_str == ~"{3: s4, 1: s2}");
         assert_eq!(empty.to_str(), ~"{}");
     }
 
index dbb9c83ea39546b01d293e819c8af2102150c9df..b595d3e1a806d8116243914f50a64429435cc63b 100644 (file)
@@ -68,8 +68,10 @@ pub struct AtomicOption<T> {
 }
 
 pub enum Ordering {
+    Relaxed,
     Release,
     Acquire,
+    AcqRel,
     SeqCst
 }
 
@@ -318,6 +320,7 @@ pub unsafe fn atomic_store<T>(dst: &mut T, val: T, order:Ordering) {
 
     match order {
         Release => intrinsics::atomic_store_rel(dst, val),
+        Relaxed => intrinsics::atomic_store_relaxed(dst, val),
         _       => intrinsics::atomic_store(dst, val)
     }
 }
@@ -328,6 +331,7 @@ pub unsafe fn atomic_load<T>(dst: &T, order:Ordering) -> T {
 
     cast::transmute(match order {
         Acquire => intrinsics::atomic_load_acq(dst),
+        Relaxed => intrinsics::atomic_load_relaxed(dst),
         _       => intrinsics::atomic_load(dst)
     })
 }
@@ -340,6 +344,8 @@ pub unsafe fn atomic_swap<T>(dst: &mut T, val: T, order: Ordering) -> T {
     cast::transmute(match order {
         Acquire => intrinsics::atomic_xchg_acq(dst, val),
         Release => intrinsics::atomic_xchg_rel(dst, val),
+        AcqRel  => intrinsics::atomic_xchg_acqrel(dst, val),
+        Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),
         _       => intrinsics::atomic_xchg(dst, val)
     })
 }
@@ -353,6 +359,8 @@ pub unsafe fn atomic_add<T>(dst: &mut T, val: T, order: Ordering) -> T {
     cast::transmute(match order {
         Acquire => intrinsics::atomic_xadd_acq(dst, val),
         Release => intrinsics::atomic_xadd_rel(dst, val),
+        AcqRel  => intrinsics::atomic_xadd_acqrel(dst, val),
+        Relaxed => intrinsics::atomic_xadd_relaxed(dst, val),
         _       => intrinsics::atomic_xadd(dst, val)
     })
 }
@@ -366,6 +374,8 @@ pub unsafe fn atomic_sub<T>(dst: &mut T, val: T, order: Ordering) -> T {
     cast::transmute(match order {
         Acquire => intrinsics::atomic_xsub_acq(dst, val),
         Release => intrinsics::atomic_xsub_rel(dst, val),
+        AcqRel  => intrinsics::atomic_xsub_acqrel(dst, val),
+        Relaxed => intrinsics::atomic_xsub_relaxed(dst, val),
         _       => intrinsics::atomic_xsub(dst, val)
     })
 }
@@ -379,6 +389,8 @@ pub unsafe fn atomic_compare_and_swap<T>(dst:&mut T, old:T, new:T, order: Orderi
     cast::transmute(match order {
         Acquire => intrinsics::atomic_cxchg_acq(dst, old, new),
         Release => intrinsics::atomic_cxchg_rel(dst, old, new),
+        AcqRel  => intrinsics::atomic_cxchg_acqrel(dst, old, new),
+        Relaxed => intrinsics::atomic_cxchg_relaxed(dst, old, new),
         _       => intrinsics::atomic_cxchg(dst, old, new),
     })
 }
index 5ae45b74dd8ca2fb27daf1d9c4daa23901239136..8fcfa083cb65cae8762c50091246d8753af6d7ac 100644 (file)
@@ -195,3 +195,68 @@ fn drop(&self) {
         unsafe { assert_eq!(did_run, true); }
     }
 }
+
+/// Completely miscellaneous language-construct benchmarks.
+#[cfg(test)]
+mod bench {
+
+    use extra::test::BenchHarness;
+    use option::{Some,None};
+
+    // Static/dynamic method dispatch
+
+    struct Struct {
+        field: int
+    }
+
+    trait Trait {
+        fn method(&self) -> int;
+    }
+
+    impl Trait for Struct {
+        fn method(&self) -> int {
+            self.field
+        }
+    }
+
+    #[bench]
+    fn trait_vtable_method_call(bh: &mut BenchHarness) {
+        let s = Struct { field: 10 };
+        let t = &s as &Trait;
+        do bh.iter {
+            t.method();
+        }
+    }
+
+    #[bench]
+    fn trait_static_method_call(bh: &mut BenchHarness) {
+        let s = Struct { field: 10 };
+        do bh.iter {
+            s.method();
+        }
+    }
+
+    // Overhead of various match forms
+
+    #[bench]
+    fn match_option_some(bh: &mut BenchHarness) {
+        let x = Some(10);
+        do bh.iter {
+            let _q = match x {
+                Some(y) => y,
+                None => 11
+            };
+        }
+    }
+
+    #[bench]
+    fn match_vec_pattern(bh: &mut BenchHarness) {
+        let x = [1,2,3,4,5,6];
+        do bh.iter {
+            let _q = match x {
+                [1,2,3,.._] => 10,
+                _ => 11
+            };
+        }
+    }
+}
index baeb87e51b9107dcf297244c8cbda60c10528a54..8432f28a969863b624a9abb1e73dc95a38bd0149 100644 (file)
@@ -833,7 +833,7 @@ fn rsplitn_iter(self, n: uint, pred: &'self fn(&T) -> bool) -> VecRSplitIterator
      * ~~~ {.rust}
      * let v = &[1,2,3,4];
      * for v.window_iter().advance |win| {
-     *     io::println(fmt!("%?", win));
+     *     printfln!(win);
      * }
      * ~~~
      *
@@ -862,7 +862,7 @@ fn window_iter(self, size: uint) -> VecWindowIter<'self, T> {
      * ~~~ {.rust}
      * let v = &[1,2,3,4,5];
      * for v.chunk_iter().advance |win| {
-     *     io::println(fmt!("%?", win));
+     *     printfln!(win);
      * }
      * ~~~
      *
@@ -2116,8 +2116,7 @@ fn next(&mut self) -> Option<$elem> {
 
             #[inline]
             fn size_hint(&self) -> (uint, Option<uint>) {
-                let diff = (self.end as uint) - (self.ptr as uint);
-                let exact = diff / sys::nonzero_size_of::<$elem>();
+                let exact = self.indexable();
                 (exact, Some(exact))
             }
         }
@@ -2145,6 +2144,28 @@ fn next_back(&mut self) -> Option<$elem> {
     }
 }
 
+macro_rules! random_access_iterator {
+    (impl $name:ident -> $elem:ty) => {
+        impl<'self, T> RandomAccessIterator<$elem> for $name<'self, T> {
+            #[inline]
+            fn indexable(&self) -> uint {
+                let diff = (self.end as uint) - (self.ptr as uint);
+                diff / sys::nonzero_size_of::<T>()
+            }
+
+            fn idx(&self, index: uint) -> Option<$elem> {
+                unsafe {
+                    if index < self.indexable() {
+                        cast::transmute(self.ptr.offset(index))
+                    } else {
+                        None
+                    }
+                }
+            }
+        }
+    }
+}
+
 //iterator!{struct VecIterator -> *T, &'self T}
 /// An iterator for iterating over a vector.
 pub struct VecIterator<'self, T> {
@@ -2154,6 +2175,7 @@ pub struct VecIterator<'self, T> {
 }
 iterator!{impl VecIterator -> &'self T}
 double_ended_iterator!{impl VecIterator -> &'self T}
+random_access_iterator!{impl VecIterator -> &'self T}
 pub type VecRevIterator<'self, T> = InvertIterator<&'self T, VecIterator<'self, T>>;
 
 impl<'self, T> Clone for VecIterator<'self, T> {
@@ -2169,6 +2191,7 @@ pub struct VecMutIterator<'self, T> {
 }
 iterator!{impl VecMutIterator -> &'self mut T}
 double_ended_iterator!{impl VecMutIterator -> &'self mut T}
+random_access_iterator!{impl VecMutIterator -> &'self mut T}
 pub type VecMutRevIterator<'self, T> = InvertIterator<&'self mut T, VecMutIterator<'self, T>>;
 
 /// An iterator that moves out of a vector.
@@ -3108,6 +3131,45 @@ fn test_iterator() {
         assert!(it.next().is_none());
     }
 
+    #[test]
+    fn test_random_access_iterator() {
+        use iterator::*;
+        let xs = [1, 2, 5, 10, 11];
+        let mut it = xs.iter();
+
+        assert_eq!(it.indexable(), 5);
+        assert_eq!(it.idx(0).unwrap(), &1);
+        assert_eq!(it.idx(2).unwrap(), &5);
+        assert_eq!(it.idx(4).unwrap(), &11);
+        assert!(it.idx(5).is_none());
+
+        assert_eq!(it.next().unwrap(), &1);
+        assert_eq!(it.indexable(), 4);
+        assert_eq!(it.idx(0).unwrap(), &2);
+        assert_eq!(it.idx(3).unwrap(), &11);
+        assert!(it.idx(4).is_none());
+
+        assert_eq!(it.next().unwrap(), &2);
+        assert_eq!(it.indexable(), 3);
+        assert_eq!(it.idx(1).unwrap(), &10);
+        assert!(it.idx(3).is_none());
+
+        assert_eq!(it.next().unwrap(), &5);
+        assert_eq!(it.indexable(), 2);
+        assert_eq!(it.idx(1).unwrap(), &11);
+
+        assert_eq!(it.next().unwrap(), &10);
+        assert_eq!(it.indexable(), 1);
+        assert_eq!(it.idx(0).unwrap(), &11);
+        assert!(it.idx(1).is_none());
+
+        assert_eq!(it.next().unwrap(), &11);
+        assert_eq!(it.indexable(), 0);
+        assert!(it.idx(0).is_none());
+
+        assert!(it.next().is_none());
+    }
+
     #[test]
     fn test_iter_size_hints() {
         use iterator::*;
index e831e32f23d49ac57d2d6392303d3eba21949ea0..a5c8f2a235ed91a0af5e2789b67975c01cb84997 100644 (file)
@@ -357,15 +357,16 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt,
     }
 }
 
-pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree])
-                       -> ~[@ast::expr] {
+pub fn get_exprs_from_tts(cx: @ExtCtxt,
+                          sp: span,
+                          tts: &[ast::token_tree]) -> ~[@ast::expr] {
     let p = parse::new_parser_from_tts(cx.parse_sess(),
                                        cx.cfg(),
                                        tts.to_owned());
     let mut es = ~[];
     while *p.token != token::EOF {
-        if es.len() != 0 {
-            p.eat(&token::COMMA);
+        if es.len() != 0 && !p.eat(&token::COMMA) {
+            cx.span_fatal(sp, "expected token: `,`");
         }
         es.push(p.parse_expr());
     }
index 3f64654dd802500957b39699e634286158196c07..2092c45074eb638e4cca2edb184a64dedd952ff9 100644 (file)
@@ -18,7 +18,7 @@
 
 pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult {
     // Gather all argument expressions
-    let exprs = get_exprs_from_tts(cx, tts);
+    let exprs = get_exprs_from_tts(cx, sp, tts);
     let mut bytes = ~[];
 
     for exprs.iter().advance |expr| {
index 333570b6c9d7e5156cb7518d996c6b7b01054e3f..737127fcae73d9ee2739440122b16713e851c65d 100644 (file)
@@ -26,7 +26,7 @@
 
 pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
     -> base::MacResult {
-    let args = get_exprs_from_tts(cx, tts);
+    let args = get_exprs_from_tts(cx, sp, tts);
     if args.len() == 0 {
         cx.span_fatal(sp, "fmt! takes at least 1 argument.");
     }
index c20e35c299afd59cffdc947e33f30d80bdc02d41..4b3c8498380cc10f9412e37d697e5c4bffff05cd 100644 (file)
@@ -23,8 +23,6 @@
 use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt};
 use print;
 
-use std::io;
-
 pub fn add_new_extension(cx: @ExtCtxt,
                          sp: span,
                          name: ident,
@@ -82,11 +80,11 @@ fn generic_extension(cx: @ExtCtxt, sp: span, name: ident,
     -> MacResult {
 
         if cx.trace_macros() {
-            io::println(fmt!("%s! { %s }",
-                             cx.str_of(name),
-                             print::pprust::tt_to_str(
-                                 &ast::tt_delim(@mut arg.to_owned()),
-                                 get_ident_interner())));
+            printfln!("%s! { %s }",
+                      cx.str_of(name),
+                      print::pprust::tt_to_str(
+                          &ast::tt_delim(@mut arg.to_owned()),
+                          get_ident_interner()));
         }
 
         // Which arm's failure should we report? (the one furthest along)
index 2d15d0ab7e82b189840ad23c3cc0565ffeee7c97..52b6d4459bf4854199964137b418e2f1162aac10 100644 (file)
@@ -686,7 +686,7 @@ mod test {
     use std::io;
     #[test] fn t1() {
         let a = fresh_name("ghi");
-        io::println(fmt!("interned name: %u,\ntextual name: %s\n",
-                         a,interner_get(a)));
+        printfln!("interned name: %u,\ntextual name: %s\n",
+                  a, interner_get(a));
     }
 }
index a57840ffe09556ef138f009c1ae0d0a2d85c7151..64d17ebc3ad266be757929590ee0929ebc78f57d 100644 (file)
@@ -68,7 +68,7 @@ public:
             return &reinterpret_cast<const cratemap_v0 *>(this)->
                 m_children[0];
         case 1:
-            return &m_children[1];
+            return &m_children[0];
         default: assert(false && "Unknown crate map version!");
             return NULL; // Appease -Werror=return-type
         }
diff --git a/src/test/auxiliary/issue_5844_aux.rs b/src/test/auxiliary/issue_5844_aux.rs
new file mode 100644 (file)
index 0000000..78e87f3
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::libc;
+
+extern "C" {
+    pub fn rand() -> libc::c_int;
+}
+
index 730b175a49944a7e57687c21a45863492f0caf4e..3bd0157c48a568649893d94380fc21211347870e 100644 (file)
@@ -24,7 +24,7 @@ fn timed(label: &str, f: &fn()) {
     let start = time::precise_time_s();
     f();
     let end = time::precise_time_s();
-    io::println(fmt!("  %s: %f", label, end - start));
+    printfln!("  %s: %f", label, end - start);
 }
 
 fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
@@ -116,7 +116,7 @@ fn main() {
         }
     }
 
-    io::println(fmt!("%? keys", n_keys));
+    printfln!("%? keys", n_keys);
 
     io::println("\nTreeMap:");
 
index ea5aa309dc6c916bf898bc41b3386fd4d2a97413..0d93bdb6f9446347d80912c2487b3d8f9ccc98c2 100644 (file)
@@ -58,7 +58,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) {
     test();
     let stop = precise_time_s();
 
-    io::println(fmt!("%s:\t\t%f ms", name, (stop - start) * 1000f));
+    printfln!("%s:\t\t%f ms", name, (stop - start) * 1000f);
 }
 
 fn shift_push() {
index 86784c0b7d3bc2714f1add8dbd9f003ca2055ff6..0fa641e395eeefdfaa67ed919fa3ba1bd020c609 100644 (file)
@@ -119,8 +119,7 @@ fn main() {
     let elapsed = (stop - start);
     let rate = (num_msgs as float) / elapsed;
 
-    io::println(fmt!("Sent %? messages in %? seconds",
-                     num_msgs, elapsed));
-    io::println(fmt!("  %? messages / second", rate));
-    io::println(fmt!("  %? μs / message", 1000000. / rate));
+    printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
+    printfln!("  %? messages / second", rate);
+    printfln!("  %? μs / message", 1000000. / rate);
 }
index b79f171147aa04225315f0f601960b5dbad6ef4d..9eb415e88923374ebd539912f47656d1a5d9f534 100644 (file)
@@ -105,8 +105,7 @@ fn main() {
     let elapsed = (stop - start);
     let rate = (num_msgs as float) / elapsed;
 
-    io::println(fmt!("Sent %? messages in %? seconds",
-                     num_msgs, elapsed));
-    io::println(fmt!("  %? messages / second", rate));
-    io::println(fmt!("  %? μs / message", 1000000. / rate));
+    printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
+    printfln!("  %? messages / second", rate);
+    printfln!("  %? μs / message", 1000000. / rate);
 }
index b4037d866a010e32f2bc2f5c7ba259cdadd11630..09d1c632d0e48f035d71f5f7a422887990903432 100644 (file)
@@ -115,8 +115,7 @@ fn main() {
     let elapsed = (stop - start);
     let rate = (num_msgs as float) / elapsed;
 
-    io::println(fmt!("Sent %? messages in %? seconds",
-                     num_msgs, elapsed));
-    io::println(fmt!("  %? messages / second", rate));
-    io::println(fmt!("  %? μs / message", 1000000. / rate));
+    printfln!("Sent %? messages in %? seconds", num_msgs, elapsed);
+    printfln!("  %? messages / second", rate);
+    printfln!("  %? μs / message", 1000000. / rate);
 }
index 2eb274378900a3ca95f0cfcfc6199c236ff4336e..b11daeef12f51a48c0ef6998d9af7560fbe736ad 100644 (file)
@@ -198,13 +198,13 @@ fn main() {
     let bounded = do timeit { bounded(count) };
     let unbounded = do timeit { unbounded(count) };
 
-    io::println(fmt!("count: %?\n", count));
-    io::println(fmt!("bounded:   %? s\t(%? μs/message)",
-                     bounded, bounded * 1000000. / (count as float)));
-    io::println(fmt!("unbounded: %? s\t(%? μs/message)",
-                     unbounded, unbounded * 1000000. / (count as float)));
-
-    io::println(fmt!("\n\
-                      bounded is %?%% faster",
-                     (unbounded - bounded) / bounded * 100.));
+    printfln!("count: %?\n", count);
+    printfln!("bounded:   %? s\t(%? μs/message)",
+              bounded, bounded * 1000000. / (count as float));
+    printfln!("unbounded: %? s\t(%? μs/message)",
+              unbounded, unbounded * 1000000. / (count as float));
+
+    printfln!("\n\
+               bounded is %?%% faster",
+              (unbounded - bounded) / bounded * 100.);
 }
index ff806c8b5d44d6aa7003358ab38f1721d7304ab2..e06ff02a0b38f403404e78706b1e9f7046b6d0c5 100644 (file)
@@ -36,5 +36,5 @@ fn main() {
         args
     };
     let n = int::from_str(args[1]).get();
-    io::println(fmt!("Ack(3,%d): %d\n", n, ack(3, n)));
+    printfln!("Ack(3,%d): %d\n", n, ack(3, n));
 }
index d88843e11804537ffc5e2ce6115e09404f5a4fdc..596a5b5422a5dccbd8e12c81b3db9055bc58c767 100644 (file)
@@ -61,9 +61,9 @@ fn main() {
     let stretch_depth = max_depth + 1;
     let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth);
 
-    println(fmt!("stretch tree of depth %d\t check: %d",
-                          stretch_depth,
-                          item_check(stretch_tree)));
+    printfln!("stretch tree of depth %d\t check: %d",
+              stretch_depth,
+              item_check(stretch_tree));
 
     let long_lived_arena = arena::Arena();
     let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth);
@@ -79,12 +79,11 @@ fn main() {
             chk += item_check(temp_tree);
             i += 1;
         }
-        println(fmt!("%d\t trees of depth %d\t check: %d",
-                         iterations * 2, depth,
-                         chk));
+        printfln!("%d\t trees of depth %d\t check: %d",
+                  iterations * 2, depth, chk);
         depth += 2;
     }
-    println(fmt!("long lived tree of depth %d\t check: %d",
-                     max_depth,
-                     item_check(long_lived_tree)));
+    printfln!("long lived tree of depth %d\t check: %d",
+              max_depth,
+              item_check(long_lived_tree));
 }
index 1d2095df9dfd50fa5019b180d5ae740f3629df12..97c2cba3b9e3146d2d5d1389c996f62dece1633a 100644 (file)
@@ -93,5 +93,5 @@ fn fannkuch_redux(n: i32) -> i32 {
 #[fixed_stack_segment]
 fn main() {
     let n: i32 = FromStr::from_str(os::args()[1]).get();
-    println(fmt!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int));
+    printfln!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int);
 }
index de36a59dd6507d59fd1582defc39efd65a7747db..7b8bc31bf1c8326331e70180ac69e178b18cfa11 100644 (file)
@@ -32,5 +32,5 @@ fn main() {
         args
     };
     let n = int::from_str(args[1]).get();
-    io::println(fmt!("%d\n", fib(n)));
+    printfln!("%d\n", fib(n));
 }
index 405aa68c483ba74470405e99cad98a9f72be61c1..a7b784e1a96e875b8f51dcc8a8b8a07ba3e934df 100644 (file)
@@ -82,7 +82,7 @@ fn f(&self, entry: &mut Entry) {
 
 impl TableCallback for PrintCallback {
     fn f(&self, entry: &mut Entry) {
-        println(fmt!("%d\t%s", entry.count as int, **self));
+        printfln!("%d\t%s", entry.count as int, **self);
     }
 }
 
@@ -279,9 +279,9 @@ fn print_frequencies(frequencies: &Table, frame: i32) {
     }
 
     for vector.each |&(key, count)| {
-        println(fmt!("%s %.3f",
-                     key.unpack(frame),
-                     (count as float * 100.0) / (total_count as float)));
+        printfln!("%s %.3f",
+                  key.unpack(frame),
+                  (count as float * 100.0) / (total_count as float));
     }
 }
 
index b79ecd03c0c68b685021dc62fc44b535658880fc..594593e2ea343787d8b5c3240e87f858aad86c6a 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
         let mut byte_acc: i8 = 0;
         let mut bit_num: i32 = 0;
 
-        println(fmt!("P4\n%d %d", w as int, h as int));
+        printfln!("P4\n%d %d", w as int, h as int);
 
         let mode = "w";
         let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));
index 1fab646fb37a7c9caf98d8cd3d3b1e92331ce847..6d04292588d459bc4ca5529234b843d51ca2ec86 100644 (file)
@@ -142,9 +142,9 @@ fn main() {
     let mut bodies = BODIES;
 
     offset_momentum(&mut bodies);
-    println(fmt!("%.9f", energy(&bodies) as float));
+    printfln!("%.9f", energy(&bodies) as float);
 
     advance(&mut bodies, 0.01, n);
 
-    println(fmt!("%.9f", energy(&bodies) as float));
+    printfln!("%.9f", energy(&bodies) as float);
 }
index 3e3df53eaad97d556112e0acfef34b695e90bc05..388613482c2cfcd17b96fbdb0806fd69d6770cfa 100644 (file)
@@ -61,5 +61,5 @@ fn main() {
         mult_AtAv(v, u, tmp);
     }
 
-    println(fmt!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float));
+    printfln!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float);
 }
index 7e75ac858485574ee87400d0a6aeddc6544af323..203b9c297fa6b402d806f7719f9fa08053bf239f 100644 (file)
@@ -40,7 +40,7 @@ fn roundtrip(id: int, n_tasks: int, p: &Port<int>, ch: &Chan<int>) {
     while (true) {
         match p.recv() {
           1 => {
-            println(fmt!("%d\n", id));
+            printfln!("%d\n", id);
             return;
           }
           token => {
index e2fbce6e195f579783b00938340fbbaebad8fc8a..9a82dd3f512ca36b1a16d2ecc3cd0c680f830595 100644 (file)
@@ -18,7 +18,7 @@ struct Foo {
 
 impl Foo {
     pub fn printme(&mut self) {
-        io::println(fmt!("%d", self.x));
+        printfln!("%d", self.x);
     }
 }
 
index c02a0b4cfafd5c4068e675873286f945c76eec2b..e3e12a4a4168bc0114229773d134c5d47dab01d2 100644 (file)
@@ -9,5 +9,5 @@ fn a() -> &int {
 
 fn main() {
     let fifth = a();
-    println(fmt!("%d", *fifth));
+    printfln!("%d", *fifth);
 }
index 8fafd04d1e2a52b1da8d3da1e42e48fbcaf8c4b2..04c3a0624264d306c3e625c8f023645208506e4b 100644 (file)
@@ -22,5 +22,5 @@ fn main() {
     let u = Thing {x: 2};
     let _v = u.mul(&3); // This is ok
     let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
-    println(fmt!("%i", w.x));
+    printfln!("%i", w.x);
 }
index ffa11e592608de38fa6e24a445102278e6d65c4f..9ec1f5cd441b0e127abb5a02b77c0412136696bc 100644 (file)
@@ -14,5 +14,5 @@ fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cann
 
 fn main() {
     let v = &5;
-    println(fmt!("%d", f(v)()));
+    printfln!("%d", f(v)());
 }
diff --git a/src/test/compile-fail/issue-5844.rs b/src/test/compile-fail/issue-5844.rs
new file mode 100644 (file)
index 0000000..9d4c3cf
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//aux-build:issue_5844_aux.rs
+
+extern mod issue_5844_aux;
+
+fn main () {
+    issue_5844_aux::rand(); //~ ERROR: requires unsafe
+}
+
index f05c30c3355e0830b57d1425204ad4fd22a1e4fd..19a3ce4f8384b37e07d00816a16575c9fb2d9911 100644 (file)
@@ -28,7 +28,7 @@ fn innocent_looking_victim() {
             match x {
                 Some(ref msg) => {
                     (f.c)(f, true);
-                    println(fmt!("%?", msg));
+                    printfln!(msg);
                 },
                 None => fail!("oops"),
             }
index 45cb137b08459a7dfc24b801ca9a54839dd2105d..c27debdbc7fb99dc7ca3f084bec1bff30b057db3 100644 (file)
@@ -14,7 +14,7 @@ fn o<T: Send>(_: &T) {}
 fn c<T: Freeze>(_: &T) {}
 
 fn main() {
-    let x = extra::rc::rc_mut_from_owned(0);
+    let x = extra::rc::RcMut::from_owned(0);
     o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Send`
     c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Freeze`
 }
index 785eeb24784fa71416829353e6df0ac6315bb457..4640957a9a894e0b693f5247f8a3f04a19bf0190 100644 (file)
@@ -13,7 +13,7 @@
 fn main() {
     let x = Foo(1, 2);
     match x {   //~ ERROR non-exhaustive
-        Foo(1, b) => println(fmt!("%d", b)),
-        Foo(2, b) => println(fmt!("%d", b))
+        Foo(1, b) => printfln!("%d", b),
+        Foo(2, b) => printfln!("%d", b)
     }
 }
index 91df90f8b3ac950406e23a2c30a306bcdb5a817c..8ed3297e7d142d07b964f732e7fec2e776c193c2 100644 (file)
@@ -33,5 +33,5 @@ pub fn main()
     let z = @mut [1,2,3];
     let z2 = z;
     add(z.my_mut_slice(), z2.my_slice());
-    print(fmt!("%d\n", z[0]));
+    printfln!("%d", z[0]);
 }
index bae693ce4eae2efb99ffd0951a8ee2abfdd1b86d..d2971ad40ab44894e79a73604c3916200a5a8af3 100644 (file)
@@ -12,5 +12,5 @@ pub fn main()
     let z = @mut [1,2,3];
     let z2 = z;
     add(z, z2);
-    print(fmt!("%d\n", z[0]));
+    printfln!("%d", z[0]);
 }
index 9e2a02b32dfed076bf4c1af93074ee451ffdab63..df096e8292f827b2b8b987826a6ba79faf41a5aa 100644 (file)
@@ -13,5 +13,5 @@ pub fn main()
     let z = @mut [1,2,3];
     let z2 = z;
     add(&mut z[0], &z2[0]);
-    print(fmt!("%d\n", z[0]));
+    printfln!("%d", z[0]);
 }
index ad68448876028c62313e188d9e17358764e3b27a..98bb72c93408b5e89513895525ef7effa5b7b1d3 100644 (file)
@@ -13,5 +13,5 @@ pub fn main()
     let z = @mut [1,2,3];
     let z2 = z;
     add(&mut z[0], &mut z2[0]);
-    print(fmt!("%d\n", z[0]));
+    printfln!("%d", z[0]);
 }
index 6eb8090af95fae6085e0e7b0d43d5d7292e33641..fa8cd005c04567b3fdb36171e1e1829489d29e56 100644 (file)
@@ -11,6 +11,8 @@
 // xfail-test
 // error-pattern:index out of bounds
 
+use std::uint;
+
 fn main() {
     let x = ~[1u,2u,3u];
 
index 8aec9782bf75dc5a999c41c5d6fe68f3a46373d1..2a5b45435765903e7badfee4404530917e37559f 100644 (file)
@@ -11,6 +11,8 @@
 // xfail-test
 // error-pattern:index out of bounds
 
+use std::u64;
+
 #[cfg(target_arch="x86")]
 fn main() {
     let x = ~[1u,2u,3u];
index 16d0fe346687c8627609356e6f2c08cb428cbb71..04dea449172da60bce8f612e062c3f2d88befe67 100644 (file)
@@ -15,7 +15,7 @@
 // during unwinding
 
 fn recurse() {
-    log(debug, "don't optimize me out");
+    info!("don't optimize me out");
     recurse();
 }
 
@@ -35,9 +35,7 @@ fn drop(&self) {
 }
 
 fn r(recursed: *mut bool) -> r {
-    unsafe {
-        r { recursed: recursed }
-    }
+    r { recursed: recursed }
 }
 
 fn main() {
index 75af701cedeae70620042153bd003c6c9a6b1660..bfcd2e8f8db828a64ac2564d288facf0ab9417b2 100644 (file)
@@ -8,17 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test - issue #5512, fails but exits with 0
-
+// exec-env:RUST_NEWRT=1
 // error-pattern:fail
 
 fn main() {
     let count = @mut 0u;
     let mut map = std::hashmap::HashMap::new();
     let mut arr = ~[];
-    for uint::range(0u, 10u) |i| {
-        arr += ~[@~"key stuff"];
-        map.insert(arr.clone(), arr + ~[@~"value stuff"]);
+    for std::uint::range(0u, 10u) |i| {
+        arr.push(@~"key stuff");
+        map.insert(arr.clone(), arr + &[@~"value stuff"]);
         if arr.len() == 5 {
             fail!();
         }
index 7171b0ee86c4bc212c16e161575222ff93709209..cc14af45c85cbaa12b751d5c075dc113ff36b120 100644 (file)
@@ -18,7 +18,7 @@ trait Stuff {
 
 impl Stuff for Foo {
     fn printme(&self) {
-        println(fmt!("%d", self.x));
+        printfln!("%d", self.x);
     }
 }
 
index 20f824e969a48de8941ee64f6772b3df8658b305..306141354ca7679d64346ada76888c1d35d0fc9a 100644 (file)
@@ -10,5 +10,5 @@ pub fn main()
     let z = @mut [1,2,3];
     let z2 = z;
     add(&z[0], &z2[0]);
-    print(fmt!("%d\n", z[0]));
+    printfln!("%d", z[0]);
 }
index 097184540fdfcb4994c7e7c0c768a2cbc593ac61..30adaf2dae4a35526705c0bed8b2e5a72b40b051 100644 (file)
@@ -19,7 +19,7 @@ pub fn main() {
     //info!("%?", bt0);
 
     do 3u.to(10u) |i| {
-        print(fmt!("%u\n", i));
+        printfln!("%u", i);
 
         //let bt1 = sys::frame_address();
         //info!("%?", bt1);
index a8c0583701380f1a8f05d52b9351aeb0985a0445..4db0b1871d078d9d370cc8c0673df9f3e1961a1c 100644 (file)
@@ -17,7 +17,7 @@ pub fn main() {
     //let bt0 = sys::rusti::frame_address(1u32);
     //info!("%?", bt0);
     do cci_iter_lib::iter(~[1, 2, 3]) |i| {
-        print(fmt!("%d", *i));
+        printf!("%d", *i);
         //assert!(bt0 == sys::rusti::frame_address(2u32));
     }
 }
index 83a77ad987736455270e0a691e8bb6b284e9f623..6459239e46959505596b1d9a6f655ab9a77c1487 100644 (file)
@@ -23,7 +23,7 @@ pub fn main() {
     //let bt0 = sys::frame_address();
     //info!("%?", bt0);
     do iter(~[1u, 2u, 3u]) |i| {
-        print(fmt!("%u\n", i));
+        printfln!("%u", i);
 
         //let bt1 = sys::frame_address();
         //info!("%?", bt1);
index 990e5e6721915e7282ea12d7379ca8dfd793eafe..6dca5d60f11114b1fc7952fd6eb8976048466999 100644 (file)
@@ -27,9 +27,9 @@ struct D { d: int, e: int }
 static m : int = k.c.e;
 
 pub fn main() {
-    io::println(fmt!("%?", p));
-    io::println(fmt!("%?", q));
-    io::println(fmt!("%?", t));
+    printfln!(p);
+    printfln!(q);
+    printfln!(t);
     assert_eq!(p, 3);
     assert_eq!(q, 3);
     assert_eq!(t, 20);
index 31b806bf41a1b29d271d14609cae6feef7bdf0d5..5b80988dcdfb00e4e058f2ba2f570eadb7ccea52 100644 (file)
@@ -21,5 +21,5 @@ struct AnotherPair { x: (i64, i64), y: Pair }
 pub fn main() {
     let (p, _) = y.x;
     assert_eq!(p, - 1085102592571150096);
-    println(fmt!("0x%x", p as uint));
+    printfln!("0x%x", p as uint);
 }
index cdc71292ae069762d8f9b4351b0d5a32d59543a4..c2103a40bfea7025d9ea561b033c690f26e91a31 100644 (file)
@@ -17,8 +17,8 @@ struct Pair<'self> { a: int, b: &'self int }
 static y: &'static Pair<'static> = &Pair {a: 15, b: x};
 
 pub fn main() {
-    io::println(fmt!("x = %?", *x));
-    io::println(fmt!("y = {a: %?, b: %?}", y.a, *(y.b)));
+    printfln!("x = %?", *x);
+    printfln!("y = {a: %?, b: %?}", y.a, *(y.b));
     assert_eq!(*x, 10);
     assert_eq!(*(y.b), 10);
 }
index 8a93a3e4c1ccbc86992c928e8e675773eb9c0aae..c62fcd8980fad1e5d16598e112cc8bba8e9ffd9c 100644 (file)
@@ -30,6 +30,6 @@ pub fn main() {
     assert_eq!(x.b, 2);
     assert_eq!(x, y);
     assert_eq!(z.b, 22);
-    io::println(fmt!("0x%x", x.b as uint));
-    io::println(fmt!("0x%x", z.c as uint));
+    printfln!("0x%x", x.b as uint);
+    printfln!("0x%x", z.c as uint);
 }
index 0aee53a4ed2d2efbc32b458fdef5d4452b996010..01ef3284e32f9eabdd94fc144449015de1d8ae11 100644 (file)
@@ -14,8 +14,8 @@
 static y : &'static [int] = &[1,2,3,4];
 
 pub fn main() {
-    io::println(fmt!("%?", x[1]));
-    io::println(fmt!("%?", y[1]));
+    printfln!(x[1]);
+    printfln!(y[1]);
     assert_eq!(x[1], 2);
     assert_eq!(x[3], 4);
     assert_eq!(x[3], y[3]);
index 6d95f6b23ab351f018299acfdbd3196736c65c1c..0cd9b2adf7ce6f5c8a9e1ee09411dd4d9633f4b7 100644 (file)
@@ -16,5 +16,5 @@ struct Foo {
 pub fn main() {
     let a = Foo { x: 1, y: 2 };
     let c = Foo { x: 4, .. a};
-    println(fmt!("%?", c));
+    printfln!(c);
 }
index 5b320ddc06bb64b384b0c595a106da2fd0aa43c2..c84386c722da745774a4a2a999bac04f20a5fe2b 100644 (file)
@@ -80,5 +80,5 @@ pub fn main() {
         a);
     let sum = foldl(filt, 0u, |accum, &&n: uint| accum + n );
 
-    io::println(fmt!("%u", sum));
+    printfln!("%u", sum);
 }
index 5b3333fb998cc205ad71f54a5a497231dc27187a..d4cbfa91fb6a4f098b25645ca762a62a7ce17fcf 100644 (file)
@@ -42,7 +42,7 @@ pub fn main() {
     let bools2 = to_bools(Storage{storage: ~[0b01100100]});
 
     for uint::range(0, 8) |i| {
-        io::println(fmt!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint));
+        printfln!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint);
     }
 
     assert_eq!(bools, bools2);
index c7b0823296c67a454ff764a0ffd59345b17cd3d5..3e3e6d6f99215c4afd9f6f4d2cf7d10ad1549e84 100644 (file)
@@ -4,5 +4,5 @@ pub fn main() {
         x += 1;
     }
     assert_eq!(x, 4096);
-    println(fmt!("x = %u", x));
+    printfln!("x = %u", x);
 }
index e9c2ab87c2b3df93801a443f53507992e59e69cc..e42b70b5a5e0d8a8e0390605e8d86e7826702d3e 100644 (file)
@@ -42,11 +42,11 @@ pub fn main() {
 
     // the following compiles and works properly
     let v1: Vec2 = a * 3f;
-    io::println(fmt!("%f %f", v1.x, v1.y));
+    printfln!("%f %f", v1.x, v1.y);
 
     // the following compiles but v2 will not be Vec2 yet and
     // using it later will cause an error that the type of v2
     // must be known
     let v2 = a * 3f;
-    io::println(fmt!("%f %f", v2.x, v2.y)); // error regarding v2's type
+    printfln!("%f %f", v2.x, v2.y); // error regarding v2's type
 }
index a94abe04fded2b7e829788686b62b0f9bacbcd1a..12ec501788de81e5d14e9b6eb4b34896d0ade368 100644 (file)
@@ -35,5 +35,5 @@ pub fn area(&self, sh: Shape) -> float {
 
 pub fn main(){
     let s = Circle(Point { x: 1f, y: 2f }, 3f);
-    println(fmt!("%f", s.area(s)));
+    printfln!("%f", s.area(s));
 }
index 1c1eb75c220c1f898e0cb013010870ad933f439b..5ec8383dd20b2ab3b881cdf0b335af388fa0f947 100644 (file)
@@ -19,7 +19,7 @@ struct S {
 
 impl T for S {
     fn print(&self) {
-        io::println(fmt!("%?", self));
+        printfln!(self);
     }
 }
 
index 6b0796a1260d5a5528a5d2b1d9c2d7b265de0a62..98b7741461ec4412467c85d9a829bc36e328f71f 100644 (file)
@@ -12,7 +12,7 @@
 type ErrPrinter = &fn(&str, &str);
 
 fn example_err(prog: &str, arg: &str) {
-    io::println(fmt!("%s: %s", prog, arg))
+    printfln!("%s: %s", prog, arg)
 }
 
 fn exit(+print: ErrPrinter, prog: &str, arg: &str) {
index 1f5da69018ab5211b141ca8ac788927e5515a7a3..857ecb3f9cbcfeb70a300c7b4bd12de7858e9022 100644 (file)
@@ -114,7 +114,7 @@ fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result {
   //io::println(cmd);
   sb.write_str(cmd);
   let res = parse_response(@sb as @io::Reader);
-  //io::println(fmt!("%?", res));
+  //printfln!(res);
   res
 }
 
@@ -122,7 +122,7 @@ fn query2(cmd: ~[~str]) -> Result {
   let _cmd = cmd_to_str(cmd);
     do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| {
     let res = parse_response(@sb as @io::Reader);
-    io::println(fmt!("%?", res));
+    printfln!(res);
     res
     }
 }
index d0d211c109c852218af93b8252ee903ab38cb219..e993d827abb7d7d5fd5321917ab020524c78e6a8 100644 (file)
@@ -4,5 +4,5 @@ pub fn main() {
         count += 1;
     }
     assert_eq!(count, 999_999);
-    println(fmt!("%u", count));
+    printfln!("%u", count);
 }
diff --git a/src/test/run-pass/link-section.rs b/src/test/run-pass/link-section.rs
new file mode 100644 (file)
index 0000000..ff1e474
--- /dev/null
@@ -0,0 +1,34 @@
+#[cfg(not(target_os = "macos"))]
+#[link_section=".moretext"]
+fn i_live_in_more_text() -> &'static str {
+    "knock knock"
+}
+
+#[cfg(not(target_os = "macos"))]
+#[link_section=".imm"]
+static magic: uint = 42;
+
+#[cfg(not(target_os = "macos"))]
+#[link_section=".mut"]
+static mut frobulator: uint = 0xdeadbeef;
+
+#[cfg(target_os = "macos")]
+#[link_section="__TEXT,__moretext"]
+fn i_live_in_more_text() -> &'static str {
+    "knock knock"
+}
+
+#[cfg(target_os = "macos")]
+#[link_section="__RODATA,__imm"]
+static magic: uint = 42;
+
+#[cfg(target_os = "macos")]
+#[link_section="__DATA,__mut"]
+static mut frobulator: uint = 0xdeadbeef;
+
+fn main() {
+    unsafe {
+        frobulator = 0xcafebabe;
+        printfln!("%? %? %?", i_live_in_more_text(), magic, frobulator);
+    }
+}
index c34067c329d27a537c2e17bbcda1533c1a4d7f48..685a11c79ee32536478c08d8648ef5b358f233ff 100644 (file)
@@ -35,5 +35,5 @@ fn Foo(x: int, y: int) -> Foo {
 
 pub fn main() {
     let foo = Foo(3, 20);
-    println(fmt!("%d %d", foo.sum(), foo.product()));
+    printfln!("%d %d", foo.sum(), foo.product());
 }
index 2da532422c0cb76ba20084a8bcd17df144ff07f9..a00bfceab0f4d51305ac0327e302561e9a13a845 100644 (file)
@@ -13,5 +13,5 @@
 static FOO: int = 3;
 
 pub fn main() {
-    println(fmt!("%d", FOO));
+    printfln!("%d", FOO);
 }
index 41704c252c8dbf775b4d5ac45304cfd669bc0a15..488bd65f5484a19d40d1316867dc365a1cf01983 100644 (file)
@@ -13,5 +13,5 @@
 static FOO: [int, ..3] = [1, 2, 3];
 
 pub fn main() {
-    println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2]));
+    printfln!("%d %d %d", FOO[0], FOO[1], FOO[2]);
 }
index d26210e9a4c1ccd15b4cf5782cb69c09d80354e8..3e2308bfcaf660e7c8a51dd66fc48af73b3ed23b 100644 (file)
@@ -16,6 +16,6 @@ struct Mytype {compute: extern fn(mytype) -> int, val: int}
 
 pub fn main() {
     let myval = mytype(Mytype{compute: compute, val: 30});
-    println(fmt!("%d", compute(myval)));
+    printfln!("%d", compute(myval));
     assert_eq!((myval.compute)(myval), 50);
 }
index 7262339e431d9c293b7e7f36438ce85fdde4f70f..e40a183243e01d3a6b34174d1e499e9262bde4a9 100644 (file)
@@ -56,13 +56,13 @@ pub fn main() {
     let primes = [2,3,5,7,11];
     let mut prod = 1i;
     for uint_range_rev(5, 0) |i| {
-        println(fmt!("uint 4 downto 0: %u", i));
+        printfln!("uint 4 downto 0: %u", i);
         prod *= int::pow(primes[i], i);
     }
     assert_eq!(prod, 11*11*11*11*7*7*7*5*5*3*1);
     let mut prod = 1i;
     for int_range_rev(5, 0) |i| {
-        println(fmt!("int 4 downto 0: %d", i));
+        printfln!("int 4 downto 0: %d", i);
         prod *= int::pow(primes[i], i as uint);
     }
     assert_eq!(prod, 11*11*11*11*7*7*7*5*5*3*1);
index 7c1f905a049b6f4db40964ad810ecdc7a40f940e..d01b22404467a1cc58d1100617f283894413736d 100644 (file)
@@ -28,7 +28,7 @@ fn uint_range_step(a: uint, b: uint, s: int, it: &fn(uint) -> bool) -> bool {
 }
 
 pub fn main() {
-    println(fmt!("num-range start"));
+    println("num-range start");
     // int and uint have same result for
     //   Sum{2 <= i < 100} == (Sum{1 <= i <= 99} - 1) == n*(n+1)/2 - 1 for n=99
     let mut sum = 0u;
@@ -105,7 +105,7 @@ pub fn main() {
     let mut saw21 = false;
     for uint::range_step_inclusive(0, 21, 3) |x| {
         assert!(x <= 21);
-        println(fmt!("saw: %u", x));
+        printfln!("saw: %u", x);
         if x == 21 { saw21 = true; }
     }
     assert!(saw21);
index 839f40fe67f57c2d185a235bbbcdf52911929497..9500f83b76b09132b6ea729b5a6758640c0219a6 100644 (file)
@@ -17,6 +17,6 @@ pub fn main() {
     let mut arena = arena::Arena();
     let p = &mut arena;
     let x = p.alloc(|| 4u);
-    print(fmt!("%u", *x));
+    printf!("%u", *x);
     assert_eq!(*x, 4u);
 }
index 092cd3d8ed5bb8aa003b8447742eb13ec46818a2..07a5c10ab1fd1c910f088eeaa2ca63d160538f3e 100644 (file)
@@ -30,5 +30,5 @@ fn test<T:Dot> (n:int, i:int, first:T, second:T) ->int {
 }
 pub fn main() {
   let n = test(1, 0, Nil, Nil);
-  io::println(fmt!("%d", n));
+  printfln!("%d", n);
 }
index 88fac13c33e8f288b42ecad443eeff222f1c8e04..21d13c722e752aea7e4bdb136f809c8b7c22e5ee 100644 (file)
@@ -667,7 +667,7 @@ pub fn main() {
 
         let r = u.vals.clone();
         for r.iter().advance |s| {
-            println(fmt!("val: %s", *s));
+            printfln!("val: %s", *s);
         }
         error!("%?", u.vals.clone());
         assert_eq!(u.vals.clone(),
index b3c5acd7dd5c416bc2dd0dcb52cdcd819d7c6dcb..dc639bad75efa0e3e20829f0e727d914beef726d 100644 (file)
@@ -171,7 +171,7 @@ pub fn main() {
     visit_ty::<~[int]>(vv);
 
     for v.types.iter().advance |s| {
-        println(fmt!("type: %s", (*s).clone()));
+        printfln!("type: %s", (*s).clone());
     }
     assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]);
 }
index 68fa137397525321f0cdad4fae049841c213f05d..3d8c2b7f56a0d8c24d5dadb41e9b8c6ad304f232 100644 (file)
@@ -16,6 +16,6 @@ struct Foo {
 pub fn main() {
     let a = Foo { x: 1, y: 2 };
     match a {
-        Foo { x: x, y: y } => println(fmt!("yes, %d, %d", x, y))
+        Foo { x: x, y: y } => printfln!("yes, %d, %d", x, y)
     }
 }
index bc1583a08780a29626d11c108365ddabc8b27c9b..4003a83e80bb07bde4a496b4ac28a59e7bfc403d 100644 (file)
@@ -99,7 +99,7 @@ impl FloatExt for f64 {}
 impl FloatExt for float {}
 
 
-fn test_float_ext<T:FloatExt>(n: T) { println(fmt!("%?", n < n)) }
+fn test_float_ext<T:FloatExt>(n: T) { printfln!(n < n) }
 
 pub fn main() {
     test_float_ext(1f32);
index e0285a7b598315e1e860413a26f2a33caec4640d..2d6b5e1132536054c3b90022e99bbf6738776d4f 100644 (file)
@@ -16,7 +16,7 @@ pub trait NumExt: Eq + Ord + Num + NumCast {}
 impl NumExt for f32 {}
 
 fn num_eq_one<T:NumExt>(n: T) {
-    println(fmt!("%?", n == NumCast::from(1)))
+    printfln!(n == NumCast::from(1))
 }
 
 pub fn main() {
diff --git a/src/test/run-pass/transmute-non-immediate-to-immediate.rs b/src/test/run-pass/transmute-non-immediate-to-immediate.rs
new file mode 100644 (file)
index 0000000..2f097bc
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Issue #7988
+// Transmuting non-immediate type to immediate type
+
+fn main() {
+    unsafe {
+        ::std::cast::transmute::<[int,..1],int>([1])
+    };
+}
index 20be5df3242e734e564a814c99d13f9d4dc2b457..9f1b930f16835b9502710ca49651f8ad2fa3757d 100644 (file)
@@ -12,5 +12,5 @@
 
 pub fn main() {
     let x = Foo(1, 2);
-    println(fmt!("%?", x));
+    printfln!(x);
 }
index 4a1258264f8d1d85836d480c4f4ecfe71a26e8ff..a1b1f36dc413124f0744f877ca8b7a431078d83a 100644 (file)
@@ -13,7 +13,7 @@
 pub fn main() {
     let x = Foo(1, 2);
     let Foo(y, z) = x;
-    println(fmt!("%d %d", y, z));
+    printfln!("%d %d", y, z);
     assert_eq!(y, 1);
     assert_eq!(z, 2);
 }
index 261b913b1d2c83cdf8b5fee7f23834f8a05300cd..36467189bbd9b8f31a321bbf73ecbc81cca7c25d 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
         Foo(a, b) => {
             assert_eq!(a, 1);
             assert_eq!(b, 2);
-            println(fmt!("%d %d", a, b));
+            printfln!("%d %d", a, b);
         }
     }
 }
index 56adc6d259881714c51adcc4f70d0e239f6bdfee..e4c6bcf6791e291c3fc2bc9842641957e5ce8a31 100644 (file)
@@ -10,5 +10,5 @@
 
 pub fn main() {
     let x: [int, ..4] = [1, 2, 3, 4];
-    println(fmt!("%d", x[0]));
+    printfln!("%d", x[0]);
 }
index aae287deb8a1e56b85c3241daaa49bee3ae8ac81..08b62cce715626d347b84c6e2c4255fe53377e77 100644 (file)
@@ -5,6 +5,6 @@ pub fn main() {
             [1, ..ref tail] => &tail[0],
             _ => ::std::util::unreachable()
         };
-        println(fmt!("%d", *el));
+        printfln!("%d", *el);
     }
 }