Remove 'deprecated mutable...' from our code

This should make compilation a bit less noisy.
This commit is contained in:
Marijn Haverbeke
2011-05-05 20:17:44 +02:00
parent 3d738e9e06
commit 1f45dda9d2
15 changed files with 43 additions and 43 deletions

View File

@@ -382,7 +382,7 @@ fn scan_dec_digits(reader rdr) -> str {
ret res; ret res;
} }
fn scan_number(mutable char c, reader rdr) -> token.token { fn scan_number(char c, reader rdr) -> token.token {
auto accum_int = 0; auto accum_int = 0;
let str dec_str = ""; let str dec_str = "";
let bool is_dec_integer = false; let bool is_dec_integer = false;

View File

@@ -497,7 +497,7 @@ fn parse_arg(parser p) -> ast.arg {
fn parse_seq_to_end[T](token.token ket, fn parse_seq_to_end[T](token.token ket,
option.t[token.token] sep, option.t[token.token] sep,
(fn(parser) -> T) f, (fn(parser) -> T) f,
mutable uint hi, uint hi,
parser p) -> vec[T] { parser p) -> vec[T] {
let bool first = true; let bool first = true;
let vec[T] v = vec(); let vec[T] v = vec();

View File

@@ -2281,7 +2281,7 @@ mod Unify {
case (_) { case (_) {
// Just bind the type variable to the expected type. // Just bind the type variable to the expected type.
auto vlen = _vec.len[mutable vec[t]](cx.types); auto vlen = _vec.len[vec[t]](cx.types);
if (actual_n < vlen) { if (actual_n < vlen) {
cx.types.(actual_n) += vec(expected); cx.types.(actual_n) += vec(expected);
} else { } else {
@@ -2649,7 +2649,7 @@ mod Unify {
case (ty.ty_var(?expected_id)) { case (ty.ty_var(?expected_id)) {
// Add a binding. // Add a binding.
auto expected_n = get_or_create_set(cx, expected_id); auto expected_n = get_or_create_set(cx, expected_id);
auto vlen = _vec.len[mutable vec[t]](cx.types); auto vlen = _vec.len[vec[t]](cx.types);
if (expected_n < vlen) { if (expected_n < vlen) {
cx.types.(expected_n) += vec(actual); cx.types.(expected_n) += vec(actual);
} else { } else {
@@ -2713,7 +2713,7 @@ mod Unify {
fn unify_sets(@ctxt cx) -> vec[t] { fn unify_sets(@ctxt cx) -> vec[t] {
let vec[t] throwaway = vec(); let vec[t] throwaway = vec();
let vec[mutable vec[t]] set_types = vec(mutable throwaway); let vec[mutable vec[t]] set_types = vec(mutable throwaway);
_vec.pop[mutable vec[t]](set_types); // FIXME: botch _vec.pop[vec[t]](set_types); // FIXME: botch
for (UFind.node node in cx.sets.nodes) { for (UFind.node node in cx.sets.nodes) {
let vec[t] v = vec(); let vec[t] v = vec();
@@ -2721,7 +2721,7 @@ mod Unify {
} }
auto i = 0u; auto i = 0u;
while (i < _vec.len[mutable vec[t]](set_types)) { while (i < _vec.len[vec[t]](set_types)) {
auto root = UFind.find(cx.sets, i); auto root = UFind.find(cx.sets, i);
set_types.(root) += cx.types.(i); set_types.(root) += cx.types.(i);
i += 1u; i += 1u;
@@ -2746,7 +2746,7 @@ mod Unify {
ty_ctxt tcx) -> result { ty_ctxt tcx) -> result {
let vec[t] throwaway = vec(); let vec[t] throwaway = vec();
let vec[mutable vec[t]] types = vec(mutable throwaway); let vec[mutable vec[t]] types = vec(mutable throwaway);
_vec.pop[mutable vec[t]](types); // FIXME: botch _vec.pop[vec[t]](types); // FIXME: botch
auto cx = @rec(sets=UFind.make(), auto cx = @rec(sets=UFind.make(),
var_ids=common.new_int_hash[uint](), var_ids=common.new_int_hash[uint](),
@@ -2759,7 +2759,7 @@ mod Unify {
case (ures_ok(?typ)) { case (ures_ok(?typ)) {
// Fast path: if there are no local variables, don't perform // Fast path: if there are no local variables, don't perform
// substitutions. // substitutions.
if (_vec.len[mutable UFind.node](cx.sets.nodes) == 0u) { if (_vec.len(cx.sets.nodes) == 0u) {
ret ures_ok(typ); ret ures_ok(typ);
} }

View File

@@ -843,7 +843,7 @@ mod Unify {
// FIXME: horrid botch // FIXME: horrid botch
let vec[mutable ty.t] param_substs = let vec[mutable ty.t] param_substs =
vec(mutable ty.mk_nil(fcx.ccx.tcx)); vec(mutable ty.mk_nil(fcx.ccx.tcx));
_vec.pop[mutable ty.t](param_substs); _vec.pop(param_substs);
ret with_params(fcx, expected, actual, param_substs); ret with_params(fcx, expected, actual, param_substs);
} }
@@ -1000,7 +1000,7 @@ mod Demand {
let vec[mutable ty.t] ty_param_substs = let vec[mutable ty.t] ty_param_substs =
vec(mutable ty.mk_nil(fcx.ccx.tcx)); vec(mutable ty.mk_nil(fcx.ccx.tcx));
_vec.pop[mutable ty.t](ty_param_substs); // FIXME: horrid botch _vec.pop(ty_param_substs); // FIXME: horrid botch
for (ty.t ty_param_subst in ty_param_substs_0) { for (ty.t ty_param_subst in ty_param_substs_0) {
ty_param_substs += vec(mutable ty_param_subst); ty_param_substs += vec(mutable ty_param_subst);
} }
@@ -1009,7 +1009,7 @@ mod Demand {
case (ures_ok(?t)) { case (ures_ok(?t)) {
// TODO: Use "freeze", when we have it. // TODO: Use "freeze", when we have it.
let vec[ty.t] result_ty_param_substs = vec(); let vec[ty.t] result_ty_param_substs = vec();
for (mutable ty.t ty_param_subst in ty_param_substs) { for (ty.t ty_param_subst in ty_param_substs) {
result_ty_param_substs += vec(ty_param_subst); result_ty_param_substs += vec(ty_param_subst);
} }
@@ -2782,7 +2782,7 @@ fn hash_unify_cache_entry(&unify_cache_entry uce) -> uint {
h += h << 5u + ty.hash_ty(uce._1); h += h << 5u + ty.hash_ty(uce._1);
auto i = 0u; auto i = 0u;
auto tys_len = _vec.len[mutable ty.t](uce._2); auto tys_len = _vec.len(uce._2);
while (i < tys_len) { while (i < tys_len) {
h += h << 5u + ty.hash_ty(uce._2.(i)); h += h << 5u + ty.hash_ty(uce._2.(i));
i += 1u; i += 1u;
@@ -2795,8 +2795,8 @@ fn eq_unify_cache_entry(&unify_cache_entry a, &unify_cache_entry b) -> bool {
if (!ty.eq_ty(a._0, b._0) || !ty.eq_ty(a._1, b._1)) { ret false; } if (!ty.eq_ty(a._0, b._0) || !ty.eq_ty(a._1, b._1)) { ret false; }
auto i = 0u; auto i = 0u;
auto tys_len = _vec.len[mutable ty.t](a._2); auto tys_len = _vec.len(a._2);
if (_vec.len[mutable ty.t](b._2) != tys_len) { ret false; } if (_vec.len(b._2) != tys_len) { ret false; }
while (i < tys_len) { while (i < tys_len) {
if (!ty.eq_ty(a._2.(i), b._2.(i))) { ret false; } if (!ty.eq_ty(a._2.(i), b._2.(i))) { ret false; }

View File

@@ -8,12 +8,12 @@ type ufind = rec(mutable vec[mutable node] nodes);
fn make() -> ufind { fn make() -> ufind {
let vec[mutable node] v = vec(mutable none[uint]); let vec[mutable node] v = vec(mutable none[uint]);
_vec.pop[mutable node](v); // FIXME: botch _vec.pop(v); // FIXME: botch
ret rec(mutable nodes=v); ret rec(mutable nodes=v);
} }
fn make_set(&ufind ufnd) -> uint { fn make_set(&ufind ufnd) -> uint {
auto idx = _vec.len[mutable node](ufnd.nodes); auto idx = _vec.len(ufnd.nodes);
ufnd.nodes += vec(mutable none[uint]); ufnd.nodes += vec(mutable none[uint]);
ret idx; ret idx;
} }

View File

@@ -142,7 +142,7 @@ fn unsafe_from_bytes(vec[mutable? u8] v) -> str {
// FIXME even temp-er thing; rustc can use "unsafe_from_bytes" above // FIXME even temp-er thing; rustc can use "unsafe_from_bytes" above
fn unsafe_from_mutable_bytes(vec[mutable u8] mv) -> str { fn unsafe_from_mutable_bytes(vec[mutable u8] mv) -> str {
let vec[u8] v = vec(); let vec[u8] v = vec();
for (mutable u8 b in mv) { for (u8 b in mv) {
v += vec(b); v += vec(b);
} }
ret rustrt.str_from_vec(v); ret rustrt.str_from_vec(v);

View File

@@ -11,7 +11,7 @@ fn ne(u8 x, u8 y) -> bool { ret x != y; }
fn ge(u8 x, u8 y) -> bool { ret x >= y; } fn ge(u8 x, u8 y) -> bool { ret x >= y; }
fn gt(u8 x, u8 y) -> bool { ret x > y; } fn gt(u8 x, u8 y) -> bool { ret x > y; }
iter range(mutable u8 lo, u8 hi) -> u8 { iter range(u8 lo, u8 hi) -> u8 {
while (lo < hi) { while (lo < hi) {
put lo; put lo;
lo += 1u8; lo += 1u8;

View File

@@ -190,7 +190,7 @@ fn unshift[T](&mutable array[T] v, &T t) {
v = res; v = res;
} }
fn grow[T](&mutable array[T] v, uint n, &T initval) { fn grow[T](&array[T] v, uint n, &T initval) {
let uint i = n; let uint i = n;
while (i > 0u) { while (i > 0u) {
i -= 1u; i -= 1u;
@@ -198,10 +198,10 @@ fn grow[T](&mutable array[T] v, uint n, &T initval) {
} }
} }
fn grow_set[T](&mutable vec[mutable T] v, uint index, &T initval, &T val) { fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) {
auto length = _vec.len[mutable T](v); auto length = _vec.len(v);
if (index >= length) { if (index >= length) {
grow[mutable T](v, index - length + 1u, initval); grow(v, index - length + 1u, initval);
} }
v.(index) = val; v.(index) = val;
} }

View File

@@ -26,9 +26,9 @@ fn create(uint nbits, bool init) -> t {
} }
fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool { fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
auto len = _vec.len[mutable uint](v1.storage); auto len = _vec.len(v1.storage);
assert (_vec.len[mutable uint](v0.storage) == len); assert (_vec.len(v0.storage) == len);
assert (v0.nbits == v1.nbits); assert (v0.nbits == v1.nbits);
auto changed = false; auto changed = false;
@@ -76,7 +76,7 @@ fn copy(&t v0, t v1) -> bool {
fn clone(t v) -> t { fn clone(t v) -> t {
auto storage = _vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u); auto storage = _vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
auto len = _vec.len[mutable uint](v.storage); auto len = _vec.len(v.storage);
for each (uint i in _uint.range(0u, len)) { for each (uint i in _uint.range(0u, len)) {
storage.(i) = v.storage.(i); storage.(i) = v.storage.(i);
} }
@@ -97,7 +97,7 @@ fn get(&t v, uint i) -> bool {
fn equal(&t v0, &t v1) -> bool { fn equal(&t v0, &t v1) -> bool {
// FIXME: when we can break or return from inside an iterator loop, // FIXME: when we can break or return from inside an iterator loop,
// we can eliminate this painful while-loop // we can eliminate this painful while-loop
auto len = _vec.len[mutable uint](v1.storage); auto len = _vec.len(v1.storage);
auto i = 0u; auto i = 0u;
while (i < len) { while (i < len) {
if (v0.storage.(i) != v1.storage.(i)) { if (v0.storage.(i) != v1.storage.(i)) {
@@ -109,13 +109,13 @@ fn equal(&t v0, &t v1) -> bool {
} }
fn clear(&t v) { fn clear(&t v) {
for each (uint i in _uint.range(0u, _vec.len[mutable uint](v.storage))) { for each (uint i in _uint.range(0u, _vec.len(v.storage))) {
v.storage.(i) = 0u; v.storage.(i) = 0u;
} }
} }
fn invert(&t v) { fn invert(&t v) {
for each (uint i in _uint.range(0u, _vec.len[mutable uint](v.storage))) { for each (uint i in _uint.range(0u, _vec.len(v.storage))) {
v.storage.(i) = ~v.storage.(i); v.storage.(i) = ~v.storage.(i);
} }
} }

View File

@@ -19,7 +19,7 @@ type t[T] = obj {
fn create[T]() -> t[T] { fn create[T]() -> t[T] {
type cell[T] = mutable option.t[T]; type cell[T] = option.t[T];
let uint initial_capacity = 32u; // 2^5 let uint initial_capacity = 32u; // 2^5

View File

@@ -451,7 +451,7 @@ type mutable_byte_buf = @rec(mutable vec[mutable u8] buf, mutable uint pos);
state obj byte_buf_writer(mutable_byte_buf buf) { state obj byte_buf_writer(mutable_byte_buf buf) {
fn write(vec[u8] v) { fn write(vec[u8] v) {
// Fast path. // Fast path.
if (buf.pos == _vec.len[mutable u8](buf.buf)) { if (buf.pos == _vec.len(buf.buf)) {
// FIXME: Fix our type system. There's no reason you shouldn't be // FIXME: Fix our type system. There's no reason you shouldn't be
// able to add a mutable vector to an immutable one. // able to add a mutable vector to an immutable one.
auto mv = _vec.rustrt.unsafe_vec_to_mut[u8](v); auto mv = _vec.rustrt.unsafe_vec_to_mut[u8](v);
@@ -465,7 +465,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
auto vpos = 0u; auto vpos = 0u;
while (vpos < vlen) { while (vpos < vlen) {
auto b = v.(vpos); auto b = v.(vpos);
if (buf.pos == _vec.len[mutable u8](buf.buf)) { if (buf.pos == _vec.len(buf.buf)) {
buf.buf += vec(mutable b); buf.buf += vec(mutable b);
} else { } else {
buf.buf.(buf.pos) = b; buf.buf.(buf.pos) = b;
@@ -477,7 +477,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
fn seek(int offset, seek_style whence) { fn seek(int offset, seek_style whence) {
auto pos = buf.pos; auto pos = buf.pos;
auto len = _vec.len[mutable u8](buf.buf); auto len = _vec.len(buf.buf);
buf.pos = seek_in_buf(offset, pos, len, whence); buf.pos = seek_in_buf(offset, pos, len, whence);
} }
@@ -487,7 +487,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
fn string_writer() -> str_writer { fn string_writer() -> str_writer {
// FIXME: yikes, this is bad. Needs fixing of mutable syntax. // FIXME: yikes, this is bad. Needs fixing of mutable syntax.
let vec[mutable u8] b = vec(mutable 0u8); let vec[mutable u8] b = vec(mutable 0u8);
_vec.pop[mutable u8](b); _vec.pop(b);
let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u); let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u);
state obj str_writer_wrap(writer wr, mutable_byte_buf buf) { state obj str_writer_wrap(writer wr, mutable_byte_buf buf) {

View File

@@ -66,7 +66,7 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) { fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0); let vec[mutable int] fds = vec(mutable 0, 0);
assert (os.libc.pipe(_vec.buf[mutable int](fds)) == 0); assert (os.libc.pipe(_vec.buf(fds)) == 0);
ret tup(fds.(0), fds.(1)); ret tup(fds.(0), fds.(1));
} }
@@ -76,7 +76,7 @@ fn fd_FILE(int fd) -> libc.FILE {
fn waitpid(int pid) -> int { fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0); let vec[mutable int] status = vec(mutable 0);
assert (os.libc.waitpid(pid, _vec.buf[mutable int](status), 0) != -1); assert (os.libc.waitpid(pid, _vec.buf(status), 0) != -1);
ret status.(0); ret status.(0);
} }

View File

@@ -67,7 +67,7 @@ fn mk_sha1() -> sha1 {
fn process_msg_block(&sha1state st) { fn process_msg_block(&sha1state st) {
// FIXME: Make precondition // FIXME: Make precondition
assert (_vec.len[mutable u32](st.h) == digest_buf_len); assert (_vec.len(st.h) == digest_buf_len);
// Constants // Constants
auto k = vec(0x5A827999u32, auto k = vec(0x5A827999u32,
@@ -192,7 +192,7 @@ fn mk_sha1() -> sha1 {
*/ */
fn pad_msg(&sha1state st) { fn pad_msg(&sha1state st) {
// FIXME: Should be a precondition // FIXME: Should be a precondition
assert (_vec.len[mutable u8](st.msg_block) == msg_block_len); assert (_vec.len(st.msg_block) == msg_block_len);
/* /*
* Check to see if the current message block is too small to hold * Check to see if the current message block is too small to hold
@@ -236,7 +236,7 @@ fn mk_sha1() -> sha1 {
fn reset() { fn reset() {
// FIXME: Should be typestate precondition // FIXME: Should be typestate precondition
assert (_vec.len[mutable u32](st.h) == digest_buf_len); assert (_vec.len(st.h) == digest_buf_len);
st.len_low = 0u32; st.len_low = 0u32;
st.len_high = 0u32; st.len_high = 0u32;

View File

@@ -2,11 +2,11 @@
fn main() { fn main() {
obj foo() { obj foo() {
fn m1(mutable int i) { fn m1(int i) {
i += 1; i += 1;
log "hi!"; log "hi!";
} }
fn m2(mutable int i) { fn m2(int i) {
i += 1; i += 1;
self.m1(i); self.m1(i);
} }

View File

@@ -2,14 +2,14 @@
fn main() { fn main() {
obj foo() { obj foo() {
fn m1(mutable int i) -> int { fn m1(int i) -> int {
i += 1; i += 1;
ret i; ret i;
} }
fn m2(mutable int i) -> int { fn m2(int i) -> int {
ret self.m1(i); ret self.m1(i);
} }
fn m3(mutable int i) -> int { fn m3(int i) -> int {
i += 1; i += 1;
ret self.m1(i); ret self.m1(i);
} }