Skip to content

Commit

Permalink
issue #1352: change param order on vec::init_elt, putting block in fi…
Browse files Browse the repository at this point in the history
…nal position.

To match the init_fn() and init_fn_mut() changes.
  • Loading branch information
gmfawcett committed Jan 18, 2012
1 parent fc95249 commit 8f33d3d
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 56 deletions.
8 changes: 4 additions & 4 deletions src/comp/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
let s = "fn(";
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
let n_args = llvm::LLVMCountParamTypes(ty) as uint;
let args: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_args);
let args: [TypeRef] = vec::init_elt::<TypeRef>(n_args, 0 as TypeRef);
unsafe {
llvm::LLVMGetParamTypes(ty, vec::to_ptr(args));
}
Expand All @@ -984,7 +984,7 @@ fn type_to_str_inner(names: type_names, outer0: [TypeRef], ty: TypeRef) ->
10 {
let s: str = "{";
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
let elts: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_elts);
let elts: [TypeRef] = vec::init_elt::<TypeRef>(n_elts, 0 as TypeRef);
unsafe {
llvm::LLVMGetStructElementTypes(ty, vec::to_ptr(elts));
}
Expand Down Expand Up @@ -1027,8 +1027,8 @@ fn float_width(llt: TypeRef) -> uint {
}

fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] unsafe {
let args = vec::init_elt(0 as TypeRef,
llvm::LLVMCountParamTypes(fn_ty) as uint);
let args = vec::init_elt(llvm::LLVMCountParamTypes(fn_ty) as uint,
0 as TypeRef);
llvm::LLVMGetParamTypes(fn_ty, vec::to_ptr(args));
ret args;
}
Expand Down
4 changes: 2 additions & 2 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ fn get_simple_extern_fn(cx: @block_ctxt,
llmod: ModuleRef,
name: str, n_args: int) -> ValueRef {
let ccx = cx.fcx.lcx.ccx;
let inputs = vec::init_elt::<TypeRef>(ccx.int_type, n_args as uint);
let inputs = vec::init_elt::<TypeRef>(n_args as uint, ccx.int_type);
let output = ccx.int_type;
let t = T_fn(inputs, output);
ret get_extern_fn(externs, llmod, name,
Expand Down Expand Up @@ -2869,7 +2869,7 @@ fn lval_maybe_callee_to_lval(c: lval_maybe_callee, ty: ty::t) -> lval_result {
alt c.generic {
some(gi) {
let n_args = vec::len(ty::ty_fn_args(bcx_tcx(c.bcx), ty));
let args = vec::init_elt(none::<@ast::expr>, n_args);
let args = vec::init_elt(n_args, none::<@ast::expr>);
let space = alloc_ty(c.bcx, ty);
let bcx = trans_closure::trans_bind_1(space.bcx, ty, c, args, ty,
save_in(space.val));
Expand Down
8 changes: 4 additions & 4 deletions src/comp/middle/trans_alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn enter_opt(ccx: @crate_ctxt, m: match, opt: opt, col: uint, tag_size: uint,
ast::pat_range(l1, l2) {
ret if opt_eq(range(l1, l2), opt) { some([]) } else { none };
}
_ { ret some(vec::init_elt(dummy, size)); }
_ { ret some(vec::init_elt(size, dummy)); }
}
}
ret enter_match(m, col, val, bind e(ccx, dummy, opt, tag_size, _));
Expand All @@ -197,7 +197,7 @@ fn enter_rec(m: match, col: uint, fields: [ast::ident], val: ValueRef) ->
}
ret some(pats);
}
_ { ret some(vec::init_elt(dummy, vec::len(fields))); }
_ { ret some(vec::init_elt(vec::len(fields), dummy)); }
}
}
ret enter_match(m, col, val, bind e(dummy, fields, _));
Expand All @@ -209,7 +209,7 @@ fn enter_tup(m: match, col: uint, val: ValueRef, n_elts: uint) -> match {
option::t<[@ast::pat]> {
alt p.node {
ast::pat_tup(elts) { ret some(elts); }
_ { ret some(vec::init_elt(dummy, n_elts)); }
_ { ret some(vec::init_elt(n_elts, dummy)); }
}
}
ret enter_match(m, col, val, bind e(dummy, n_elts, _));
Expand Down Expand Up @@ -343,7 +343,7 @@ fn pick_col(m: match) -> uint {
_ { 0u }
}
}
let scores = vec::init_elt_mut(0u, vec::len(m[0].pats));
let scores = vec::init_elt_mut(vec::len(m[0].pats), 0u);
for br: match_branch in m {
let i = 0u;
for p: @ast::pat in br.pats { scores[i] += score(p); i += 1u; }
Expand Down
8 changes: 4 additions & 4 deletions src/comp/middle/trans_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ fn val_str(tn: type_names, v: ValueRef) -> str { ret ty_str(tn, val_ty(v)); }
fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe {
let elt_count = llvm::LLVMCountStructElementTypes(llstructty) as uint;
assert (n < elt_count);
let elt_tys = vec::init_elt(T_nil(), elt_count);
let elt_tys = vec::init_elt(elt_count, T_nil());
llvm::LLVMGetStructElementTypes(llstructty, to_ptr(elt_tys));
ret llvm::LLVMGetElementType(elt_tys[n]);
}
Expand Down Expand Up @@ -594,8 +594,8 @@ fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe {
// Bit of a kludge: pick the fn typeref out of the tydesc..

let tydesc_elts: [TypeRef] =
vec::init_elt::<TypeRef>(T_nil(),
abi::n_tydesc_fields as uint);
vec::init_elt::<TypeRef>(abi::n_tydesc_fields as uint,
T_nil());
llvm::LLVMGetStructElementTypes(cx.tydesc_type,
to_ptr::<TypeRef>(tydesc_elts));
let t = llvm::LLVMGetElementType(tydesc_elts[field]);
Expand Down Expand Up @@ -729,7 +729,7 @@ fn T_opaque_tag_ptr(cx: @crate_ctxt) -> TypeRef {
}

fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef {
ret T_struct(vec::init_elt::<TypeRef>(T_ptr(cx.tydesc_type), n));
ret T_struct(vec::init_elt::<TypeRef>(n, T_ptr(cx.tydesc_type)));
}

fn T_opaque_iface_ptr(cx: @crate_ctxt) -> TypeRef {
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/trans_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fn trans_iface_callee(bcx: @block_ctxt, fld_expr: @ast::expr,
fn llfn_arg_tys(ft: TypeRef) -> {inputs: [TypeRef], output: TypeRef} {
let out_ty = llvm::LLVMGetReturnType(ft);
let n_args = llvm::LLVMCountParamTypes(ft);
let args = vec::init_elt(0 as TypeRef, n_args as uint);
let args = vec::init_elt(n_args as uint, 0 as TypeRef);
unsafe { llvm::LLVMGetParamTypes(ft, vec::to_ptr(args)); }
{inputs: args, output: out_ty}
}
Expand Down
12 changes: 6 additions & 6 deletions src/comp/middle/tstate/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
alt e.node {
expr_vec(elts, _) {
ret find_pre_post_state_exprs(fcx, pres, e.id,
vec::init_elt(init_assign,
vec::len(elts)), elts,
vec::init_elt(vec::len(elts),
init_assign), elts,
return_val);
}
expr_call(operator, operands, _) {
Expand Down Expand Up @@ -386,8 +386,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
expr_rec(fields, maybe_base) {
let changed =
find_pre_post_state_exprs(fcx, pres, e.id,
vec::init_elt(init_assign,
vec::len(fields)),
vec::init_elt(vec::len(fields),
init_assign),
field_exprs(fields), return_val);
alt maybe_base {
none. {/* do nothing */ }
Expand All @@ -402,8 +402,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
}
expr_tup(elts) {
ret find_pre_post_state_exprs(fcx, pres, e.id,
vec::init_elt(init_assign,
vec::len(elts)), elts,
vec::init_elt(vec::len(elts),
init_assign), elts,
return_val);
}
expr_copy(a) { ret find_pre_post_state_sub(fcx, pres, a, e.id, none); }
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
// HACK: build an arguments list with dummy arguments to
// check against
let dummy = {mode: ast::by_ref, ty: ty::mk_bot(fcx.ccx.tcx)};
arg_tys = vec::init_elt(dummy, supplied_arg_count);
arg_tys = vec::init_elt(supplied_arg_count, dummy);
}

// Check the arguments.
Expand Down
6 changes: 3 additions & 3 deletions src/comp/syntax/print/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
// fall behind.
let n: uint = 3u * linewidth;
#debug("mk_printer %u", linewidth);
let token: [mutable token] = vec::init_elt_mut(EOF, n);
let size: [mutable int] = vec::init_elt_mut(0, n);
let scan_stack: [mutable uint] = vec::init_elt_mut(0u, n);
let token: [mutable token] = vec::init_elt_mut(n, EOF);
let size: [mutable int] = vec::init_elt_mut(n, 0);
let scan_stack: [mutable uint] = vec::init_elt_mut(n, 0u);
let print_stack: [print_stack_elt] = [];
@{out: out,
buf_len: n,
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
procres: procres) {

// true if we found the error in question
let found_flags = vec::init_elt_mut(false, vec::len(expected_errors));
let found_flags = vec::init_elt_mut(vec::len(expected_errors), false);

if procres.status == 0 {
fatal("process did not return an error status");
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/extfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ mod rt {

// FIXME: This might be useful in str: but needs to be utf8 safe first
fn str_init_elt(c: char, n_elts: uint) -> str {
let svec = vec::init_elt::<u8>(c as u8, n_elts);
let svec = vec::init_elt::<u8>(n_elts, c as u8);

ret str::unsafe_from_bytes(svec);
}
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Creates and initializes an immutable vector.
Creates an immutable vector of size `n_elts` and initializes the elements
to the value `t`.
*/
fn init_elt<T: copy>(t: T, n_elts: uint) -> [T] {
fn init_elt<T: copy>(n_elts: uint, t: T) -> [T] {
let v = [];
reserve(v, n_elts);
let i: uint = 0u;
Expand All @@ -138,7 +138,7 @@ Creates and initializes a mutable vector.
Creates a mutable vector of size `n_elts` and initializes the elements
to the value `t`.
*/
fn init_elt_mut<T: copy>(t: T, n_elts: uint) -> [mutable T] {
fn init_elt_mut<T: copy>(n_elts: uint, t: T) -> [mutable T] {
let v = [mutable];
reserve(v, n_elts);
let i: uint = 0u;
Expand Down Expand Up @@ -1045,13 +1045,13 @@ mod tests {
#[test]
fn test_init_elt() {
// Test on-stack init_elt.
let v = init_elt(10u, 2u);
let v = init_elt(2u, 10u);
assert (len(v) == 2u);
assert (v[0] == 10u);
assert (v[1] == 10u);

// Test on-heap init_elt.
v = init_elt(20u, 6u);
v = init_elt(6u, 20u);
assert (v[0] == 20u);
assert (v[1] == 20u);
assert (v[2] == 20u);
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ init - If true then the bits are initialized to 1, otherwise 0
*/
fn create(nbits: uint, init: bool) -> t {
let elt = if init { !0u } else { 0u };
let storage = vec::init_elt_mut::<uint>(elt, nbits / uint_bits + 1u);
let storage = vec::init_elt_mut::<uint>(nbits / uint_bits + 1u, elt);
ret @{storage: storage, nbits: nbits};
}

Expand Down Expand Up @@ -117,7 +117,7 @@ Function: clone
Makes a copy of a bitvector
*/
fn clone(v: t) -> t {
let storage = vec::init_elt_mut::<uint>(0u, v.nbits / uint_bits + 1u);
let storage = vec::init_elt_mut::<uint>(v.nbits / uint_bits + 1u, 0u);
let len = vec::len(v.storage);
uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
ret @{storage: storage, nbits: v.nbits};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn create<T: copy>() -> t<T> {
mutable nelts: 0u,
mutable lo: 0u,
mutable hi: 0u,
mutable elts: vec::init_elt_mut(none, initial_capacity)
mutable elts: vec::init_elt_mut(initial_capacity, none)
};
repr as t::<T>
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/extfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ mod rt {

// FIXME: This might be useful in str: but needs to be utf8 safe first
fn str_init_elt(c: char, n_elts: uint) -> str {
let svec = vec::init_elt::<u8>(c as u8, n_elts);
let svec = vec::init_elt::<u8>(n_elts, c as u8);

ret str::unsafe_from_bytes(svec);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/freebsd_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
/// followed by a path separator
fn get_exe_path() -> option::t<fs::path> unsafe {
let bufsize = 1023u;
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize));
let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
let mib = [libc_constants::CTL_KERN,
libc_constants::KERN_PROC,
libc_constants::KERN_PROC_PATHNAME, -1i32];
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/linux_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
/// followed by a path separator
fn get_exe_path() -> option::t<fs::path> {
let bufsize = 1023u;
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize));
let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
ret str::as_buf("/proc/self/exe", { |proc_self_buf|
str::as_buf(path, { |path_buf|
if libc::readlink(proc_self_buf, path_buf, bufsize) != -1 {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/macos_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; }
fn get_exe_path() -> option::t<fs::path> {
// FIXME: This doesn't handle the case where the buffer is too small
let bufsize = 1023u32;
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize as uint));
let path = str::unsafe_from_bytes(vec::init_elt(bufsize as uint, 0u8));
ret str::as_buf(path, { |path_buf|
if mac_libc::_NSGetExecutablePath(path_buf,
ptr::mut_addr_of(bufsize)) == 0i32 {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ mod chained {
}

fn chains<K: copy, V: copy>(nchains: uint) -> [mutable chain<K,V>] {
ret vec::init_elt_mut(absent, nchains);
ret vec::init_elt_mut(nchains, absent);
}

fn foreach_entry<K: copy, V: copy>(chain0: chain<K,V>,
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/md4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} {
}

let i = 0u, e = vec::len(msg);
let x = vec::init_elt_mut(0u32, 16u);
let x = vec::init_elt_mut(16u, 0u32);
while i < e {
let aa = a, bb = b, cc = c, dd = d;

Expand Down
10 changes: 5 additions & 5 deletions src/libstd/rope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn concat(v: [rope]) -> rope {
//Copy `v` into a mutable vector
let len = vec::len(v);
if len == 0u { ret node::empty; }
let ropes = vec::init_elt_mut(v[0], len);
let ropes = vec::init_elt_mut(len, v[0]);
uint::range(1u, len) {|i|
ropes[i] = v[i];
}
Expand Down Expand Up @@ -779,7 +779,7 @@ mod node {
//Firstly, split `str` in slices of hint_max_leaf_char_len
let leaves = uint::div_ceil(char_len, hint_max_leaf_char_len);
//Number of leaves
let nodes = vec::init_elt_mut(candidate, leaves);
let nodes = vec::init_elt_mut(leaves, candidate);

let i = 0u;
let offset = byte_start;
Expand Down Expand Up @@ -892,7 +892,7 @@ mod node {
}

fn serialize_node(node: @node) -> str unsafe {
let buf = vec::init_elt_mut(0u8, byte_len(node));
let buf = vec::init_elt_mut(byte_len(node), 0u8);
let offset = 0u;//Current position in the buffer
let it = leaf_iterator::start(node);
while true {
Expand Down Expand Up @@ -1223,7 +1223,7 @@ mod node {
}

fn start(node: @node) -> t {
let stack = vec::init_elt_mut(node, height(node)+1u);
let stack = vec::init_elt_mut(height(node)+1u, node);
ret {
stack: stack,
mutable stackpos: 0
Expand Down Expand Up @@ -1490,7 +1490,7 @@ mod tests {
}

//Same rope, obtained with rope::concat
let r2 = concat(vec::init_elt(chunk, 10u));
let r2 = concat(vec::init_elt(10u, chunk));

assert eq(r, r2);
}
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ fn mk_sha1() -> sha1 {
}
}
let st = {
h: vec::init_elt_mut(0u32, digest_buf_len),
h: vec::init_elt_mut(digest_buf_len, 0u32),
mutable len_low: 0u32,
mutable len_high: 0u32,
msg_block: vec::init_elt_mut(0u8, msg_block_len),
msg_block: vec::init_elt_mut(msg_block_len, 0u8),
mutable msg_block_idx: 0u,
mutable computed: false,
work_buf: vec::init_elt_mut(0u32, work_buf_len)
work_buf: vec::init_elt_mut(work_buf_len, 0u32)
};
let sh = st as sha1;
sh.reset();
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/win32_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn getcwd() -> str { ret rustrt::rust_getcwd(); }
fn get_exe_path() -> option::t<fs::path> {
// FIXME: This doesn't handle the case where the buffer is too small
let bufsize = 1023u;
let path = str::unsafe_from_bytes(vec::init_elt(0u8, bufsize));
let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
ret str::as_buf(path, { |path_buf|
if kernel32::GetModuleFileNameA(0u, path_buf,
bufsize as u32) != 0u32 {
Expand Down
2 changes: 1 addition & 1 deletion src/rustdoc/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn write_markdown(
}

fn write_header(ctxt: ctxt, title: str) {
let hashes = str::from_chars(vec::init_elt('#', ctxt.depth));
let hashes = str::from_chars(vec::init_elt(ctxt.depth, '#'));
ctxt.w.write_line(#fmt("%s %s", hashes, title));
ctxt.w.write_line("");
}
Expand Down
Loading

0 comments on commit 8f33d3d

Please sign in to comment.