";
- if (_vec.len[t](tps) > 0u) {
+ if (Vec.len[t](tps) > 0u) {
auto f = bind ty_to_str(cx, _);
- auto strs = _vec.map[t,str](f, tps);
- s += "[" + _str.connect(strs, ",") + "]";
+ auto strs = Vec.map[t,str](f, tps);
+ s += "[" + Str.connect(strs, ",") + "]";
}
}
@@ -623,8 +623,8 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
case (ty_obj(?meths)) {
auto f = bind method_to_str(cx, _);
- auto m = _vec.map[method,str](f, meths);
- s += "obj {\n\t" + _str.connect(m, "\n\t") + "\n}";
+ auto m = Vec.map[method,str](f, meths);
+ s += "obj {\n\t" + Str.connect(m, "\n\t") + "\n}";
}
case (ty_var(?v)) {
@@ -637,11 +637,11 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
}
case (ty_param(?id)) {
- s += "'" + _str.unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
+ s += "'" + Str.unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
}
case (ty_bound_param(?id)) {
- s += "''" + _str.unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
+ s += "''" + Str.unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
}
}
@@ -652,7 +652,7 @@ fn ty_to_short_str(ctxt cx, t typ) -> str {
auto f = def_to_str;
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata.ac_no_abbrevs);
auto s = metadata.Encode.ty_str(ecx, typ);
- if (_str.byte_len(s) >= 64u) { s = _str.substr(s, 0u, 64u); }
+ if (Str.byte_len(s) >= 64u) { s = Str.substr(s, 0u, 64u); }
ret s;
}
@@ -956,14 +956,14 @@ fn type_has_dynamic_size(ctxt cx, t ty) -> bool {
alt (struct(cx, ty)) {
case (ty_tup(?mts)) {
auto i = 0u;
- while (i < _vec.len[mt](mts)) {
+ while (i < Vec.len[mt](mts)) {
if (type_has_dynamic_size(cx, mts.(i).ty)) { ret true; }
i += 1u;
}
}
case (ty_rec(?fields)) {
auto i = 0u;
- while (i < _vec.len[field](fields)) {
+ while (i < Vec.len[field](fields)) {
if (type_has_dynamic_size(cx, fields.(i).mt.ty)) {
ret true;
}
@@ -972,7 +972,7 @@ fn type_has_dynamic_size(ctxt cx, t ty) -> bool {
}
case (ty_tag(_, ?subtys)) {
auto i = 0u;
- while (i < _vec.len[t](subtys)) {
+ while (i < Vec.len[t](subtys)) {
if (type_has_dynamic_size(cx, subtys.(i))) { ret true; }
i += 1u;
}
@@ -1041,7 +1041,7 @@ fn type_is_signed(ctxt cx, t ty) -> bool {
fail;
}
-fn type_param(ctxt cx, t ty) -> option.t[uint] {
+fn type_param(ctxt cx, t ty) -> Option.t[uint] {
alt (struct(cx, ty)) {
case (ty_param(?id)) { ret some[uint](id); }
case (_) { /* fall through */ }
@@ -1174,7 +1174,7 @@ fn hash_type_structure(&sty st) -> uint {
case (ty_obj(?methods)) {
auto h = 27u;
for (method m in methods) {
- h += h << 5u + _str.hash(m.ident);
+ h += h << 5u + Str.hash(m.ident);
}
ret h;
}
@@ -1187,11 +1187,11 @@ fn hash_type_structure(&sty st) -> uint {
}
}
-fn hash_type_info(&sty st, option.t[str] cname_opt) -> uint {
+fn hash_type_info(&sty st, Option.t[str] cname_opt) -> uint {
auto h = hash_type_structure(st);
alt (cname_opt) {
case (none[str]) { /* no-op */ }
- case (some[str](?s)) { h += h << 5u + _str.hash(s); }
+ case (some[str](?s)) { h += h << 5u + Str.hash(s); }
}
ret h;
}
@@ -1297,8 +1297,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
vec[arg] args_b, t rty_b) -> bool {
if (!eq_ty(rty_a, rty_b)) { ret false; }
- auto len = _vec.len[arg](args_a);
- if (len != _vec.len[arg](args_b)) { ret false; }
+ auto len = Vec.len[arg](args_a);
+ if (len != Vec.len[arg](args_b)) { ret false; }
auto i = 0u;
while (i < len) {
@@ -1370,8 +1370,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_tag(?id_b, ?tys_b)) {
if (!equal_def(id_a, id_b)) { ret false; }
- auto len = _vec.len[t](tys_a);
- if (len != _vec.len[t](tys_b)) { ret false; }
+ auto len = Vec.len[t](tys_a);
+ if (len != Vec.len[t](tys_b)) { ret false; }
auto i = 0u;
while (i < len) {
if (!eq_ty(tys_a.(i), tys_b.(i))) { ret false; }
@@ -1415,8 +1415,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_tup(?mts_a)) {
alt (b) {
case (ty_tup(?mts_b)) {
- auto len = _vec.len[mt](mts_a);
- if (len != _vec.len[mt](mts_b)) { ret false; }
+ auto len = Vec.len[mt](mts_a);
+ if (len != Vec.len[mt](mts_b)) { ret false; }
auto i = 0u;
while (i < len) {
if (!equal_mt(mts_a.(i), mts_b.(i))) { ret false; }
@@ -1430,12 +1430,12 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_rec(?flds_a)) {
alt (b) {
case (ty_rec(?flds_b)) {
- auto len = _vec.len[field](flds_a);
- if (len != _vec.len[field](flds_b)) { ret false; }
+ auto len = Vec.len[field](flds_a);
+ if (len != Vec.len[field](flds_b)) { ret false; }
auto i = 0u;
while (i < len) {
auto fld_a = flds_a.(i); auto fld_b = flds_b.(i);
- if (!_str.eq(fld_a.ident, fld_b.ident) ||
+ if (!Str.eq(fld_a.ident, fld_b.ident) ||
!equal_mt(fld_a.mt, fld_b.mt)) {
ret false;
}
@@ -1467,13 +1467,13 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_obj(?methods_a)) {
alt (b) {
case (ty_obj(?methods_b)) {
- auto len = _vec.len[method](methods_a);
- if (len != _vec.len[method](methods_b)) { ret false; }
+ auto len = Vec.len[method](methods_a);
+ if (len != Vec.len[method](methods_b)) { ret false; }
auto i = 0u;
while (i < len) {
auto m_a = methods_a.(i); auto m_b = methods_b.(i);
if (!equal_proto(m_a.proto, m_b.proto) ||
- !_str.eq(m_a.ident, m_b.ident) ||
+ !Str.eq(m_a.ident, m_b.ident) ||
!equal_fn(m_a.inputs, m_a.output,
m_b.inputs, m_b.output)) {
ret false;
@@ -1546,7 +1546,7 @@ fn eq_ty_full(&t a, &t b) -> bool {
case (some[str](?s_a)) {
alt (b.cname) {
case (some[str](?s_b)) {
- if (!_str.eq(s_a, s_b)) { ret false; }
+ if (!Str.eq(s_a, s_b)) { ret false; }
}
case (_) { ret false; }
}
@@ -1651,7 +1651,7 @@ fn count_ty_params(ctxt cx, t ty) -> uint {
let @mutable vec[uint] param_indices = @mutable v;
auto f = bind counter(cx, param_indices, _);
walk_ty(cx, f, ty);
- ret _vec.len[uint](*param_indices);
+ ret Vec.len[uint](*param_indices);
}
fn type_contains_vars(ctxt cx, t typ) -> bool {
@@ -1721,7 +1721,7 @@ fn native_item_ty(@ast.native_item it) -> ty_param_count_and_ty {
auto result_ty;
alt (it.node) {
case (ast.native_item_fn(_, _, _, ?tps, _, ?ann)) {
- ty_param_count = _vec.len[ast.ty_param](tps);
+ ty_param_count = Vec.len[ast.ty_param](tps);
result_ty = ann_to_type(ann);
}
}
@@ -1737,22 +1737,22 @@ fn item_ty(@ast.item it) -> ty_param_count_and_ty {
result_ty = ann_to_type(ann);
}
case (ast.item_fn(_, _, ?tps, _, ?ann)) {
- ty_param_count = _vec.len[ast.ty_param](tps);
+ ty_param_count = Vec.len[ast.ty_param](tps);
result_ty = ann_to_type(ann);
}
case (ast.item_mod(_, _, _)) {
fail; // modules are typeless
}
case (ast.item_ty(_, _, ?tps, _, ?ann)) {
- ty_param_count = _vec.len[ast.ty_param](tps);
+ ty_param_count = Vec.len[ast.ty_param](tps);
result_ty = ann_to_type(ann);
}
case (ast.item_tag(_, _, ?tps, ?did, ?ann)) {
- ty_param_count = _vec.len[ast.ty_param](tps);
+ ty_param_count = Vec.len[ast.ty_param](tps);
result_ty = ann_to_type(ann);
}
case (ast.item_obj(_, _, ?tps, _, ?ann)) {
- ty_param_count = _vec.len[ast.ty_param](tps);
+ ty_param_count = Vec.len[ast.ty_param](tps);
result_ty = ann_to_type(ann);
}
}
@@ -1924,7 +1924,7 @@ fn expr_has_ty_params(@ast.expr expr) -> bool {
alt (expr_ann(expr)) {
case (ast.ann_none) { fail; }
case (ast.ann_type(_, ?tps_opt, _)) {
- ret !option.is_none[vec[t]](tps_opt);
+ ret !Option.is_none[vec[t]](tps_opt);
}
}
}
@@ -1987,7 +1987,7 @@ fn field_num(session.session sess, &span sp, &ast.ident id) -> uint {
accum += (c as uint) - ('0' as uint);
} else {
auto s = "";
- s += _str.unsafe_from_byte(c);
+ s += Str.unsafe_from_byte(c);
sess.span_err(sp,
"bad numeric field on tuple: "
+ " non-digit character: "
@@ -2003,7 +2003,7 @@ fn field_idx(session.session sess, &span sp,
&ast.ident id, vec[field] fields) -> uint {
let uint i = 0u;
for (field f in fields) {
- if (_str.eq(f.ident, id)) {
+ if (Str.eq(f.ident, id)) {
ret i;
}
i += 1u;
@@ -2016,7 +2016,7 @@ fn method_idx(session.session sess, &span sp,
&ast.ident id, vec[method] meths) -> uint {
let uint i = 0u;
for (method m in meths) {
- if (_str.eq(m.ident, id)) {
+ if (Str.eq(m.ident, id)) {
ret i;
}
i += 1u;
@@ -2027,10 +2027,10 @@ fn method_idx(session.session sess, &span sp,
fn sort_methods(vec[method] meths) -> vec[method] {
fn method_lteq(&method a, &method b) -> bool {
- ret _str.lteq(a.ident, b.ident);
+ ret Str.lteq(a.ident, b.ident);
}
- ret std.sort.merge_sort[method](bind method_lteq(_,_), meths);
+ ret std.Sort.merge_sort[method](bind method_lteq(_,_), meths);
}
fn is_lval(@ast.expr expr) -> bool {
@@ -2078,7 +2078,7 @@ mod Unify {
// Unifies two mutability flags.
fn unify_mut(ast.mutability expected, ast.mutability actual)
- -> option.t[ast.mutability] {
+ -> Option.t[ast.mutability] {
if (expected == actual) {
ret some[ast.mutability](expected);
}
@@ -2102,8 +2102,8 @@ mod Unify {
vec[arg] expected_inputs, t expected_output,
vec[arg] actual_inputs, t actual_output)
-> fn_common_res {
- auto expected_len = _vec.len[arg](expected_inputs);
- auto actual_len = _vec.len[arg](actual_inputs);
+ auto expected_len = Vec.len[arg](expected_inputs);
+ auto actual_len = Vec.len[arg](actual_inputs);
if (expected_len != actual_len) {
ret fn_common_res_err(ures_err(terr_arg_count,
expected, actual));
@@ -2213,8 +2213,8 @@ mod Unify {
vec[method] actual_meths) -> result {
let vec[method] result_meths = vec();
let uint i = 0u;
- let uint expected_len = _vec.len[method](expected_meths);
- let uint actual_len = _vec.len[method](actual_meths);
+ let uint expected_len = Vec.len[method](expected_meths);
+ let uint actual_len = Vec.len[method](actual_meths);
if (expected_len != actual_len) {
ret ures_err(terr_meth_count, expected, actual);
@@ -2223,7 +2223,7 @@ mod Unify {
while (i < expected_len) {
auto e_meth = expected_meths.(i);
auto a_meth = actual_meths.(i);
- if (! _str.eq(e_meth.ident, a_meth.ident)) {
+ if (! Str.eq(e_meth.ident, a_meth.ident)) {
ret ures_err(terr_obj_meths(e_meth.ident, a_meth.ident),
expected, actual);
}
@@ -2287,7 +2287,7 @@ mod Unify {
case (_) {
// Just bind the type variable to the expected type.
- auto vlen = _vec.len[vec[t]](cx.types);
+ auto vlen = Vec.len[vec[t]](cx.types);
if (actual_n < vlen) {
cx.types.(actual_n) += vec(expected);
} else {
@@ -2354,7 +2354,7 @@ mod Unify {
// ty.ty_tup case
let vec[t] result_tps = vec();
auto i = 0u;
- auto expected_len = _vec.len[t](expected_tps);
+ auto expected_len = Vec.len[t](expected_tps);
while (i < expected_len) {
auto expected_tp = expected_tps.(i);
auto actual_tp = actual_tps.(i);
@@ -2365,7 +2365,7 @@ mod Unify {
alt (result) {
case (ures_ok(?rty)) {
- _vec.push[t](result_tps, rty);
+ Vec.push[t](result_tps, rty);
}
case (_) {
ret result;
@@ -2494,8 +2494,8 @@ mod Unify {
case (ty.ty_tup(?expected_elems)) {
alt (struct(cx.tcx, actual)) {
case (ty.ty_tup(?actual_elems)) {
- auto expected_len = _vec.len[ty.mt](expected_elems);
- auto actual_len = _vec.len[ty.mt](actual_elems);
+ auto expected_len = Vec.len[ty.mt](expected_elems);
+ auto actual_len = Vec.len[ty.mt](actual_elems);
if (expected_len != actual_len) {
auto err = terr_tuple_size(expected_len,
actual_len);
@@ -2548,8 +2548,8 @@ mod Unify {
case (ty.ty_rec(?expected_fields)) {
alt (struct(cx.tcx, actual)) {
case (ty.ty_rec(?actual_fields)) {
- auto expected_len = _vec.len[field](expected_fields);
- auto actual_len = _vec.len[field](actual_fields);
+ auto expected_len = Vec.len[field](expected_fields);
+ auto actual_len = Vec.len[field](actual_fields);
if (expected_len != actual_len) {
auto err = terr_record_size(expected_len,
actual_len);
@@ -2574,7 +2574,7 @@ mod Unify {
case (some[ast.mutability](?m)) { mut = m; }
}
- if (!_str.eq(expected_field.ident,
+ if (!Str.eq(expected_field.ident,
actual_field.ident)) {
auto err =
terr_record_fields(expected_field.ident,
@@ -2588,7 +2588,7 @@ mod Unify {
alt (result) {
case (ures_ok(?rty)) {
auto mt = rec(ty=rty, mut=mut);
- _vec.push[field]
+ Vec.push[field]
(result_fields,
rec(mt=mt with expected_field));
}
@@ -2655,7 +2655,7 @@ mod Unify {
case (ty.ty_var(?expected_id)) {
// Add a binding.
auto expected_n = get_or_create_set(cx, expected_id);
- auto vlen = _vec.len[vec[t]](cx.types);
+ auto vlen = Vec.len[vec[t]](cx.types);
if (expected_n < vlen) {
cx.types.(expected_n) += vec(actual);
} else {
@@ -2719,7 +2719,7 @@ mod Unify {
fn unify_sets(@ctxt cx) -> vec[t] {
let vec[t] throwaway = vec();
let vec[mutable vec[t]] set_types = vec(mutable throwaway);
- _vec.pop[vec[t]](set_types); // FIXME: botch
+ Vec.pop[vec[t]](set_types); // FIXME: botch
for (UFind.node node in cx.sets.nodes) {
let vec[t] v = vec();
@@ -2727,7 +2727,7 @@ mod Unify {
}
auto i = 0u;
- while (i < _vec.len[vec[t]](set_types)) {
+ while (i < Vec.len[vec[t]](set_types)) {
auto root = UFind.find(cx.sets, i);
set_types.(root) += cx.types.(i);
i += 1u;
@@ -2735,7 +2735,7 @@ mod Unify {
let vec[t] result = vec();
for (vec[t] types in set_types) {
- if (_vec.len[t](types) > 1u) {
+ if (Vec.len[t](types) > 1u) {
log_err "unification of > 1 types in a type set is " +
"unimplemented";
fail;
@@ -2752,7 +2752,7 @@ mod Unify {
ty_ctxt tcx) -> result {
let vec[t] throwaway = vec();
let vec[mutable vec[t]] types = vec(mutable throwaway);
- _vec.pop[vec[t]](types); // FIXME: botch
+ Vec.pop[vec[t]](types); // FIXME: botch
auto cx = @rec(sets=UFind.make(),
var_ids=common.new_int_hash[uint](),
@@ -2765,7 +2765,7 @@ mod Unify {
case (ures_ok(?typ)) {
// Fast path: if there are no local variables, don't perform
// substitutions.
- if (_vec.len(cx.sets.nodes) == 0u) {
+ if (Vec.len(cx.sets.nodes) == 0u) {
ret ures_ok(typ);
}
@@ -2791,16 +2791,16 @@ fn type_err_to_str(&ty.type_err err) -> str {
ret "vectors differ in mutability";
}
case (terr_tuple_size(?e_sz, ?a_sz)) {
- ret "expected a tuple with " + _uint.to_str(e_sz, 10u) +
- " elements but found one with " + _uint.to_str(a_sz, 10u) +
+ ret "expected a tuple with " + UInt.to_str(e_sz, 10u) +
+ " elements but found one with " + UInt.to_str(a_sz, 10u) +
" elements";
}
case (terr_tuple_mutability) {
ret "tuple elements differ in mutability";
}
case (terr_record_size(?e_sz, ?a_sz)) {
- ret "expected a record with " + _uint.to_str(e_sz, 10u) +
- " fields but found one with " + _uint.to_str(a_sz, 10u) +
+ ret "expected a record with " + UInt.to_str(e_sz, 10u) +
+ " fields but found one with " + UInt.to_str(a_sz, 10u) +
" fields";
}
case (terr_record_mutability) {
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 65e443dfffc2..091616fcda70 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -32,15 +32,15 @@ import middle.ty.ty_nil;
import middle.ty.Unify.ures_ok;
import middle.ty.Unify.ures_err;
-import std._str;
-import std._uint;
-import std._vec;
-import std.map;
-import std.map.hashmap;
-import std.option;
-import std.option.none;
-import std.option.some;
-import std.option.from_maybe;
+import std.Str;
+import std.UInt;
+import std.Vec;
+import std.Map;
+import std.Map.hashmap;
+import std.Option;
+import std.Option.none;
+import std.Option.some;
+import std.Option.from_maybe;
import util.typestate_ann.ts_ann;
@@ -61,7 +61,7 @@ type crate_ctxt = rec(session.session sess,
ty.type_cache type_cache,
@ty_item_table item_items,
vec[ast.obj_field] obj_fields,
- option.t[ast.def_id] this_obj,
+ Option.t[ast.def_id] this_obj,
@fn_purity_table fn_purity_table,
mutable int next_var_id,
unify_cache unify_cache,
@@ -91,12 +91,12 @@ fn substitute_ty_params(&@crate_ctxt ccx,
}
}
- auto supplied_len = _vec.len[ty.t](supplied);
+ auto supplied_len = Vec.len[ty.t](supplied);
if (ty_param_count != supplied_len) {
ccx.sess.span_err(sp, "expected " +
- _uint.to_str(ty_param_count, 10u) +
+ UInt.to_str(ty_param_count, 10u) +
" type parameter(s) but found " +
- _uint.to_str(supplied_len, 10u) + " parameter(s)");
+ UInt.to_str(supplied_len, 10u) + " parameter(s)");
fail;
}
@@ -181,7 +181,7 @@ fn instantiate_path(@fn_ctxt fcx, &ast.path pth, &ty_param_count_and_ty tpt,
auto t = bind_params_in_type(fcx.ccx.tcx, tpt._1);
auto ty_substs_opt;
- auto ty_substs_len = _vec.len[@ast.ty](pth.node.types);
+ auto ty_substs_len = Vec.len[@ast.ty](pth.node.types);
if (ty_substs_len > 0u) {
let vec[ty.t] ty_substs = vec();
auto i = 0u;
@@ -281,7 +281,7 @@ fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t {
case (ast.ty_tup(?fields)) {
let vec[ty.mt] flds = vec();
for (ast.mt field in fields) {
- _vec.push[ty.mt](flds, ast_mt_to_mt(tcx, getter, field));
+ Vec.push[ty.mt](flds, ast_mt_to_mt(tcx, getter, field));
}
typ = ty.mk_tup(tcx, flds);
}
@@ -289,21 +289,21 @@ fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t {
let vec[field] flds = vec();
for (ast.ty_field f in fields) {
auto tm = ast_mt_to_mt(tcx, getter, f.mt);
- _vec.push[field](flds, rec(ident=f.ident, mt=tm));
+ Vec.push[field](flds, rec(ident=f.ident, mt=tm));
}
typ = ty.mk_rec(tcx, flds);
}
case (ast.ty_fn(?proto, ?inputs, ?output)) {
auto f = bind ast_arg_to_arg(tcx, getter, _);
- auto i = _vec.map[ast.ty_arg, arg](f, inputs);
+ auto i = Vec.map[ast.ty_arg, arg](f, inputs);
auto out_ty = ast_ty_to_ty(tcx, getter, output);
typ = ty.mk_fn(tcx, proto, i, out_ty);
}
case (ast.ty_path(?path, ?def)) {
assert (def != none[ast.def]);
- alt (option.get[ast.def](def)) {
+ alt (Option.get[ast.def](def)) {
case (ast.def_ty(?id)) {
typ = instantiate(tcx, getter, id, path.node.types);
}
@@ -325,9 +325,9 @@ fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t {
let vec[ty.method] tmeths = vec();
auto f = bind ast_arg_to_arg(tcx, getter, _);
for (ast.ty_method m in meths) {
- auto ins = _vec.map[ast.ty_arg, arg](f, m.inputs);
+ auto ins = Vec.map[ast.ty_arg, arg](f, m.inputs);
auto out = ast_ty_to_ty(tcx, getter, m.output);
- _vec.push[ty.method](tmeths,
+ Vec.push[ty.method](tmeths,
rec(proto=m.proto,
ident=m.ident,
inputs=ins,
@@ -383,10 +383,10 @@ mod Collect {
ast.proto proto,
vec[ast.ty_param] ty_params,
ast.def_id def_id) -> ty.ty_param_count_and_ty {
- auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
+ auto input_tys = Vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
auto output_ty = convert(decl.output);
auto t_fn = ty.mk_fn(cx.tcx, proto, input_tys, output_ty);
- auto ty_param_count = _vec.len[ast.ty_param](ty_params);
+ auto ty_param_count = Vec.len[ast.ty_param](ty_params);
auto tpt = tup(ty_param_count, t_fn);
cx.type_cache.insert(def_id, tpt);
ret tpt;
@@ -399,10 +399,10 @@ mod Collect {
ast.native_abi abi,
vec[ast.ty_param] ty_params,
ast.def_id def_id) -> ty.ty_param_count_and_ty {
- auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
+ auto input_tys = Vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
auto output_ty = convert(decl.output);
auto t_fn = ty.mk_native_fn(cx.tcx, abi, input_tys, output_ty);
- auto ty_param_count = _vec.len[ast.ty_param](ty_params);
+ auto ty_param_count = Vec.len[ast.ty_param](ty_params);
auto tpt = tup(ty_param_count, t_fn);
cx.type_cache.insert(def_id, tpt);
ret tpt;
@@ -438,7 +438,7 @@ mod Collect {
auto get = bind getter(cx, _);
auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
auto f = bind ty_of_arg(cx, _);
- auto inputs = _vec.map[ast.arg,arg](f, m.node.meth.decl.inputs);
+ auto inputs = Vec.map[ast.arg,arg](f, m.node.meth.decl.inputs);
auto output = convert(m.node.meth.decl.output);
ret rec(proto=m.node.meth.proto, ident=m.node.ident,
inputs=inputs, output=output);
@@ -449,11 +449,11 @@ mod Collect {
&ast._obj obj_info,
vec[ast.ty_param] ty_params) -> ty.ty_param_count_and_ty {
auto f = bind ty_of_method(cx, _);
- auto methods = _vec.map[@ast.method,method](f, obj_info.methods);
+ auto methods = Vec.map[@ast.method,method](f, obj_info.methods);
auto t_obj = ty.mk_obj(cx.tcx, ty.sort_methods(methods));
t_obj = ty.rename(cx.tcx, t_obj, id);
- auto ty_param_count = _vec.len[ast.ty_param](ty_params);
+ auto ty_param_count = Vec.len[ast.ty_param](ty_params);
ret tup(ty_param_count, t_obj);
}
@@ -468,7 +468,7 @@ mod Collect {
for (ast.obj_field f in obj_info.fields) {
auto g = bind getter(cx, _);
auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
- _vec.push[arg](t_inputs, rec(mode=ast.alias, ty=t_field));
+ Vec.push[arg](t_inputs, rec(mode=ast.alias, ty=t_field));
}
cx.type_cache.insert(obj_ty_id, t_obj);
@@ -515,7 +515,7 @@ mod Collect {
// Tell ast_ty_to_ty() that we want to perform a recursive
// call to resolve any named types.
auto typ = convert(t);
- auto ty_param_count = _vec.len[ast.ty_param](tps);
+ auto ty_param_count = Vec.len[ast.ty_param](tps);
auto tpt = tup(ty_param_count, typ);
cx.type_cache.insert(def_id, tpt);
ret tpt;
@@ -533,7 +533,7 @@ mod Collect {
auto t = ty.mk_tag(cx.tcx, def_id, subtys);
- auto ty_param_count = _vec.len[ast.ty_param](tps);
+ auto ty_param_count = Vec.len[ast.ty_param](tps);
auto tpt = tup(ty_param_count, t);
cx.type_cache.insert(def_id, tpt);
ret tpt;
@@ -585,13 +585,13 @@ mod Collect {
i += 1u;
}
- auto ty_param_count = _vec.len[ast.ty_param](ty_params);
+ auto ty_param_count = Vec.len[ast.ty_param](ty_params);
for (ast.variant variant in variants) {
// Nullary tag constructors get turned into constants; n-ary tag
// constructors get turned into functions.
auto result_ty;
- if (_vec.len[ast.variant_arg](variant.node.args) == 0u) {
+ if (Vec.len[ast.variant_arg](variant.node.args) == 0u) {
result_ty = ty.mk_tag(cx.tcx, tag_id, ty_param_tys);
} else {
// As above, tell ast_ty_to_ty() that trans_ty_item_to_ty()
@@ -691,7 +691,7 @@ mod Collect {
ret @fold.respan[ast.item_](sp, item);
}
- fn fold_native_item_fn(&@env e, &span sp, ast.ident i, option.t[str] ln,
+ fn fold_native_item_fn(&@env e, &span sp, ast.ident i, Option.t[str] ln,
&ast.fn_decl d, vec[ast.ty_param] ty_params,
ast.def_id id, ast.ann a) -> @ast.native_item {
// assert (e.cx.type_cache.contains_key(id));
@@ -746,7 +746,7 @@ mod Collect {
with meth.node
);
m = @rec(node=m_ with *meth);
- _vec.push[@ast.method](methods, m);
+ Vec.push[@ast.method](methods, m);
}
auto g = bind getter(e.cx, _);
for (ast.obj_field fld in ob.fields) {
@@ -754,7 +754,7 @@ mod Collect {
let ast.obj_field f = rec(ann=triv_ann(fty)
with fld
);
- _vec.push[ast.obj_field](fields, f);
+ Vec.push[ast.obj_field](fields, f);
}
auto dtor = none[@ast.method];
@@ -847,7 +847,7 @@ mod Unify {
// FIXME: horrid botch
let vec[mutable ty.t] param_substs =
vec(mutable ty.mk_nil(fcx.ccx.tcx));
- _vec.pop(param_substs);
+ Vec.pop(param_substs);
ret with_params(fcx, expected, actual, param_substs);
}
@@ -865,7 +865,7 @@ mod Unify {
}
obj unify_handler(@fn_ctxt fcx, vec[mutable ty.t] param_substs) {
- fn resolve_local(ast.def_id id) -> option.t[ty.t] {
+ fn resolve_local(ast.def_id id) -> Option.t[ty.t] {
alt (fcx.locals.find(id)) {
case (none[ty.t]) { ret none[ty.t]; }
case (some[ty.t](?existing_type)) {
@@ -905,7 +905,7 @@ mod Unify {
}
fn record_param(uint index, ty.t binding) -> ty.Unify.result {
// Unify with the appropriate type in the parameter
- // substitution list.
+ // substitution List.
auto old_subst = param_substs.(index);
auto result = with_params(fcx, old_subst, binding,
@@ -1004,7 +1004,7 @@ mod Demand {
let vec[mutable ty.t] ty_param_substs =
vec(mutable ty.mk_nil(fcx.ccx.tcx));
- _vec.pop(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) {
ty_param_substs += vec(mutable ty_param_subst);
}
@@ -1047,7 +1047,7 @@ fn are_compatible(&@fn_ctxt fcx, ty.t expected, ty.t actual) -> bool {
// Returns the types of the arguments to a tag variant.
fn variant_arg_types(@crate_ctxt ccx, &span sp, ast.def_id vid,
vec[ty.t] tag_ty_params) -> vec[ty.t] {
- auto ty_param_count = _vec.len[ty.t](tag_ty_params);
+ auto ty_param_count = Vec.len[ty.t](tag_ty_params);
let vec[ty.t] result = vec();
@@ -1130,7 +1130,7 @@ mod Pushdown {
}
// Get the types of the arguments of the variant.
- auto vdef = option.get[ast.variant_def](vdef_opt);
+ auto vdef = Option.get[ast.variant_def](vdef_opt);
auto arg_tys = variant_arg_types(fcx.ccx, pat.span, vdef._1,
tag_tps);
@@ -1218,7 +1218,7 @@ mod Pushdown {
case (none[@ast.expr]) {
auto i = 0u;
for (ast.field field_0 in fields_0) {
- assert (_str.eq(field_0.ident,
+ assert (Str.eq(field_0.ident,
field_mts.(i).ident));
auto e_1 =
pushdown_expr(fcx,
@@ -1240,7 +1240,7 @@ mod Pushdown {
for (ast.field field_0 in fields_0) {
for (ty.field ft in field_mts) {
- if (_str.eq(field_0.ident,
+ if (Str.eq(field_0.ident,
ft.ident)) {
auto e_1 =
pushdown_expr(fcx, ft.mt.ty,
@@ -1508,9 +1508,9 @@ mod Pushdown {
// Local variable resolution: the phase that finds all the types in the AST
// and replaces opaque "ty_local" types with the resolved local types.
-fn writeback_local(&option.t[@fn_ctxt] env, &span sp, @ast.local local)
+fn writeback_local(&Option.t[@fn_ctxt] env, &span sp, @ast.local local)
-> @ast.decl {
- auto fcx = option.get[@fn_ctxt](env);
+ auto fcx = Option.get[@fn_ctxt](env);
auto local_ty;
alt (fcx.locals.find(local.id)) {
@@ -1530,7 +1530,7 @@ fn writeback_local(&option.t[@fn_ctxt] env, &span sp, @ast.local local)
ret @fold.respan[ast.decl_](sp, ast.decl_local(local_wb));
}
-fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
+fn resolve_local_types_in_annotation(&Option.t[@fn_ctxt] env, ast.ann ann)
-> ast.ann {
fn resolver(@fn_ctxt fcx, ty.t typ) -> ty.t {
alt (struct(fcx.ccx.tcx, typ)) {
@@ -1539,7 +1539,7 @@ fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
}
}
- auto fcx = option.get[@fn_ctxt](env);
+ auto fcx = Option.get[@fn_ctxt](env);
alt (ann) {
case (ast.ann_none) {
log "warning: no type for expression";
@@ -1559,16 +1559,16 @@ fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block)
-> ast.block {
- fn update_env_for_item(&option.t[@fn_ctxt] env, @ast.item i)
- -> option.t[@fn_ctxt] {
+ fn update_env_for_item(&Option.t[@fn_ctxt] env, @ast.item i)
+ -> Option.t[@fn_ctxt] {
ret none[@fn_ctxt];
}
- fn keep_going(&option.t[@fn_ctxt] env) -> bool {
- ret !option.is_none[@fn_ctxt](env);
+ fn keep_going(&Option.t[@fn_ctxt] env) -> bool {
+ ret !Option.is_none[@fn_ctxt](env);
}
// FIXME: rustboot bug prevents us from using these functions directly
- auto fld = fold.new_identity_fold[option.t[@fn_ctxt]]();
+ auto fld = fold.new_identity_fold[Option.t[@fn_ctxt]]();
auto wbl = writeback_local;
auto rltia = bind resolve_local_types_in_annotation(_,_);
auto uefi = update_env_for_item;
@@ -1580,7 +1580,7 @@ fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block)
keep_going = kg
with *fld
);
- ret fold.fold_block[option.t[@fn_ctxt]](some[@fn_ctxt](fcx), fld, block);
+ ret fold.fold_block[Option.t[@fn_ctxt]](some[@fn_ctxt](fcx), fld, block);
}
// AST fragment checking
@@ -1616,10 +1616,10 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
new_pat = ast.pat_bind(id, def_id, ann);
}
case (ast.pat_tag(?p, ?subpats, ?vdef_opt, _)) {
- auto vdef = option.get[ast.variant_def](vdef_opt);
+ auto vdef = Option.get[ast.variant_def](vdef_opt);
auto t = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, vdef._1)._1;
- auto len = _vec.len[ast.ident](p.node.idents);
+ auto len = Vec.len[ast.ident](p.node.idents);
auto last_id = p.node.idents.(len - 1u);
auto tpt = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
@@ -1629,14 +1629,14 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
alt (struct(fcx.ccx.tcx, t)) {
// N-ary variants have function types.
case (ty.ty_fn(_, ?args, ?tag_ty)) {
- auto arg_len = _vec.len[arg](args);
- auto subpats_len = _vec.len[@ast.pat](subpats);
+ auto arg_len = Vec.len[arg](args);
+ auto subpats_len = Vec.len[@ast.pat](subpats);
if (arg_len != subpats_len) {
// TODO: pluralize properly
auto err_msg = "tag type " + last_id + " has " +
- _uint.to_str(subpats_len, 10u) +
+ UInt.to_str(subpats_len, 10u) +
" field(s), but this pattern has " +
- _uint.to_str(arg_len, 10u) +
+ UInt.to_str(arg_len, 10u) +
" field(s)";
fcx.ccx.sess.span_err(pat.span, err_msg);
@@ -1653,13 +1653,13 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
// Nullary variants have tag types.
case (ty.ty_tag(?tid, _)) {
- auto subpats_len = _vec.len[@ast.pat](subpats);
+ auto subpats_len = Vec.len[@ast.pat](subpats);
if (subpats_len > 0u) {
// TODO: pluralize properly
auto err_msg = "tag type " + last_id +
" has no field(s)," +
" but this pattern has " +
- _uint.to_str(subpats_len, 10u) +
+ UInt.to_str(subpats_len, 10u) +
" field(s)";
fcx.ccx.sess.span_err(pat.span, err_msg);
@@ -1689,7 +1689,7 @@ fn require_impure(&session.session sess,
}
fn get_function_purity(@crate_ctxt ccx, &ast.def_id d_id) -> ast.purity {
- let option.t[ast.purity] o = ccx.fn_purity_table.find(d_id);
+ let Option.t[ast.purity] o = ccx.fn_purity_table.find(d_id);
ret from_maybe[ast.purity](ast.impure_fn, o);
}
@@ -1738,16 +1738,16 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
// A generic function to factor out common logic from call and bind
// expressions.
fn check_call_or_bind(&@fn_ctxt fcx, &@ast.expr f,
- &vec[option.t[@ast.expr]] args)
- -> tup(@ast.expr, vec[option.t[@ast.expr]]) {
+ &vec[Option.t[@ast.expr]] args)
+ -> tup(@ast.expr, vec[Option.t[@ast.expr]]) {
// Check the function.
auto f_0 = check_expr(fcx, f);
// Check the arguments and generate the argument signature.
- let vec[option.t[@ast.expr]] args_0 = vec();
+ let vec[Option.t[@ast.expr]] args_0 = vec();
let vec[arg] arg_tys_0 = vec();
- for (option.t[@ast.expr] a_opt in args) {
+ for (Option.t[@ast.expr] a_opt in args) {
alt (a_opt) {
case (some[@ast.expr](?a)) {
auto a_0 = check_expr(fcx, a);
@@ -1756,14 +1756,14 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
// FIXME: this breaks aliases. We need a ty_fn_arg.
auto arg_ty = rec(mode=ast.val,
ty=expr_ty(fcx.ccx.tcx, a_0));
- _vec.push[arg](arg_tys_0, arg_ty);
+ Vec.push[arg](arg_tys_0, arg_ty);
}
case (none[@ast.expr]) {
args_0 += vec(none[@ast.expr]);
// FIXME: breaks aliases too?
auto typ = next_ty_var(fcx.ccx);
- _vec.push[arg](arg_tys_0, rec(mode=ast.val, ty=typ));
+ Vec.push[arg](arg_tys_0, rec(mode=ast.val, ty=typ));
}
}
}
@@ -1812,7 +1812,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
fn check_call(&@fn_ctxt fcx, @ast.expr f, vec[@ast.expr] args)
-> tup(@ast.expr, vec[@ast.expr]) {
- let vec[option.t[@ast.expr]] args_opt_0 = vec();
+ let vec[Option.t[@ast.expr]] args_opt_0 = vec();
for (@ast.expr arg in args) {
args_opt_0 += vec(some[@ast.expr](arg));
}
@@ -1822,8 +1822,8 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
// Pull out the arguments.
let vec[@ast.expr] args_1 = vec();
- for (option.t[@ast.expr] arg in result._1) {
- args_1 += vec(option.get[@ast.expr](arg));
+ for (Option.t[@ast.expr] arg in result._1) {
+ args_1 += vec(Option.get[@ast.expr](arg));
}
ret tup(result._0, args_1);
@@ -1901,7 +1901,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
case (ast.expr_path(?pth, ?defopt, _)) {
auto t = ty.mk_nil(fcx.ccx.tcx);
assert (defopt != none[ast.def]);
- auto defn = option.get[ast.def](defopt);
+ auto defn = Option.get[ast.def](defopt);
auto tpt = ty_param_count_and_ty_for_def(fcx, expr.span, defn);
@@ -1913,7 +1913,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
// The definition doesn't take type parameters. If the programmer
// supplied some, that's an error.
- if (_vec.len[@ast.ty](pth.node.types) > 0u) {
+ if (Vec.len[@ast.ty](pth.node.types) > 0u) {
fcx.ccx.sess.span_err(expr.span, "this kind of value does " +
"not take type parameters");
fail;
@@ -2295,7 +2295,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
// For each blank argument, add the type of that argument
// to the resulting function type.
auto i = 0u;
- while (i < _vec.len[option.t[@ast.expr]](args)) {
+ while (i < Vec.len[Option.t[@ast.expr]](args)) {
alt (args.(i)) {
case (some[@ast.expr](_)) { /* no-op */ }
case (none[@ast.expr]) {
@@ -2434,7 +2434,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
let vec[@ast.expr] args_1 = vec();
let ty.t t;
- if (_vec.len[@ast.expr](args) == 0u) {
+ if (Vec.len[@ast.expr](args) == 0u) {
t = next_ty_var(fcx.ccx);
} else {
auto expr_1 = check_expr(fcx, args.(0));
@@ -2445,7 +2445,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
auto expr_1 = check_expr(fcx, e);
auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
Demand.simple(fcx, expr.span, t, expr_t);
- _vec.push[@ast.expr](args_1,expr_1);
+ Vec.push[@ast.expr](args_1,expr_1);
}
auto ann = triv_ann(ty.mk_vec(fcx.ccx.tcx,
@@ -2461,7 +2461,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
for (ast.elt e in elts) {
auto expr_1 = check_expr(fcx, e.expr);
auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
- _vec.push[ast.elt](elts_1, rec(expr=expr_1 with e));
+ Vec.push[ast.elt](elts_1, rec(expr=expr_1 with e));
elts_mt += vec(rec(ty=expr_t, mut=e.mut));
}
@@ -2486,10 +2486,10 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
for (ast.field f in fields) {
auto expr_1 = check_expr(fcx, f.expr);
auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
- _vec.push[ast.field](fields_1, rec(expr=expr_1 with f));
+ Vec.push[ast.field](fields_1, rec(expr=expr_1 with f));
auto expr_mt = rec(ty=expr_t, mut=f.mut);
- _vec.push[field](fields_t, rec(ident=f.ident, mt=expr_mt));
+ Vec.push[field](fields_t, rec(ident=f.ident, mt=expr_mt));
}
auto ann = ast.ann_none;
@@ -2521,7 +2521,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
for (ty.field f in fields_t) {
auto found = false;
for (ty.field bf in base_fields) {
- if (_str.eq(f.ident, bf.ident)) {
+ if (Str.eq(f.ident, bf.ident)) {
Demand.simple(fcx, expr.span, f.mt.ty,
bf.mt.ty);
found = true;
@@ -2549,7 +2549,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
case (ty.ty_tup(?args)) {
let uint ix = ty.field_num(fcx.ccx.sess,
expr.span, field);
- if (ix >= _vec.len[ty.mt](args)) {
+ if (ix >= Vec.len[ty.mt](args)) {
fcx.ccx.sess.span_err(expr.span,
"bad index on tuple");
}
@@ -2563,7 +2563,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
case (ty.ty_rec(?fields)) {
let uint ix = ty.field_idx(fcx.ccx.sess,
expr.span, field, fields);
- if (ix >= _vec.len[typeck.field](fields)) {
+ if (ix >= Vec.len[typeck.field](fields)) {
fcx.ccx.sess.span_err(expr.span,
"bad index on record");
}
@@ -2577,7 +2577,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
case (ty.ty_obj(?methods)) {
let uint ix = ty.method_idx(fcx.ccx.sess,
expr.span, field, methods);
- if (ix >= _vec.len[typeck.method](methods)) {
+ if (ix >= Vec.len[typeck.method](methods)) {
fcx.ccx.sess.span_err(expr.span,
"bad index on obj");
}
@@ -2775,7 +2775,7 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
let vec[@ast.stmt] stmts = vec();
for (@ast.stmt s in block.node.stmts) {
- _vec.push[@ast.stmt](stmts, check_stmt(fcx, s));
+ Vec.push[@ast.stmt](stmts, check_stmt(fcx, s));
}
auto expr = none[@ast.expr];
@@ -2900,7 +2900,7 @@ fn hash_unify_cache_entry(&unify_cache_entry uce) -> uint {
h += h << 5u + ty.hash_ty(uce._1);
auto i = 0u;
- auto tys_len = _vec.len(uce._2);
+ auto tys_len = Vec.len(uce._2);
while (i < tys_len) {
h += h << 5u + ty.hash_ty(uce._2.(i));
i += 1u;
@@ -2913,8 +2913,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; }
auto i = 0u;
- auto tys_len = _vec.len(a._2);
- if (_vec.len(b._2) != tys_len) { ret false; }
+ auto tys_len = Vec.len(a._2);
+ if (Vec.len(b._2) != tys_len) { ret false; }
while (i < tys_len) {
if (!ty.eq_ty(a._2.(i), b._2.(i))) { ret false; }
@@ -2957,7 +2957,7 @@ fn check_crate(ty.ctxt tcx, @ast.crate crate)
auto hasher = hash_unify_cache_entry;
auto eqer = eq_unify_cache_entry;
auto unify_cache =
- map.mk_hashmap[unify_cache_entry,ty.Unify.result](hasher, eqer);
+ Map.mk_hashmap[unify_cache_entry,ty.Unify.result](hasher, eqer);
auto fpt =
mk_fn_purity_table(crate); // use a variation on Collect
diff --git a/src/comp/middle/typestate_check.rs b/src/comp/middle/typestate_check.rs
index e15c720a3d95..e571fa21ee56 100644
--- a/src/comp/middle/typestate_check.rs
+++ b/src/comp/middle/typestate_check.rs
@@ -155,37 +155,37 @@ import pretty.pprust.print_block;
import pretty.pprust.print_expr;
import pretty.pprust.print_decl;
import pretty.pp.mkstate;
-import std.io.stdout;
-import std.io.str_writer;
-import std.io.string_writer;
-import std._vec.map;
-import std._vec;
-import std._vec.len;
-import std._vec.pop;
-import std._vec.push;
-import std._vec.slice;
-import std._vec.unzip;
-import std._vec.plus_option;
-import std._vec.cat_options;
-import std.option;
-import std.option.t;
-import std.option.some;
-import std.option.none;
-import std.option.from_maybe;
-import std.option.maybe;
-import std.option.is_none;
-import std.option.get;
-import std.map.hashmap;
-import std.list;
-import std.list.list;
-import std.list.cons;
-import std.list.nil;
-import std.list.foldl;
-import std.list.find;
-import std._uint;
-import std.bitv;
-import std.util.fst;
-import std.util.snd;
+import std.IO.stdout;
+import std.IO.str_writer;
+import std.IO.string_writer;
+import std.Vec.map;
+import std.Vec;
+import std.Vec.len;
+import std.Vec.pop;
+import std.Vec.push;
+import std.Vec.slice;
+import std.Vec.unzip;
+import std.Vec.plus_option;
+import std.Vec.cat_options;
+import std.Option;
+import std.Option.t;
+import std.Option.some;
+import std.Option.none;
+import std.Option.from_maybe;
+import std.Option.maybe;
+import std.Option.is_none;
+import std.Option.get;
+import std.Map.hashmap;
+import std.List;
+import std.List.list;
+import std.List.cons;
+import std.List.nil;
+import std.List.foldl;
+import std.List.find;
+import std.UInt;
+import std.BitV;
+import std.Util.fst;
+import std.Util.snd;
import util.typestate_ann;
import util.typestate_ann.difference;
@@ -195,22 +195,22 @@ import util.typestate_ann.require_and_preserve;
/**** debugging junk ****/
-fn bitv_to_str(fn_info enclosing, bitv.t v) -> str {
+fn bitv_to_str(fn_info enclosing, BitV.t v) -> str {
auto s = "";
for each (@tup(def_id, tup(uint, ident)) p in enclosing.items()) {
- if (bitv.get(v, p._1._0)) {
+ if (BitV.get(v, p._1._0)) {
s += " " + p._1._1 + " ";
}
}
ret s;
}
-fn log_bitv(fn_info enclosing, bitv.t v) {
+fn log_bitv(fn_info enclosing, BitV.t v) {
log(bitv_to_str(enclosing, v));
}
-fn log_bitv_err(fn_info enclosing, bitv.t v) {
+fn log_bitv_err(fn_info enclosing, BitV.t v) {
log_err(bitv_to_str(enclosing, v));
}
@@ -235,8 +235,8 @@ fn log_cond_err(vec[uint] v) -> () {
}
fn log_pp(&pre_and_post pp) -> () {
- auto p1 = bitv.to_vec(pp.precondition);
- auto p2 = bitv.to_vec(pp.postcondition);
+ auto p1 = BitV.to_vec(pp.precondition);
+ auto p2 = BitV.to_vec(pp.postcondition);
log("pre:");
log_cond(p1);
log("post:");
@@ -244,8 +244,8 @@ fn log_pp(&pre_and_post pp) -> () {
}
fn log_pp_err(&pre_and_post pp) -> () {
- auto p1 = bitv.to_vec(pp.precondition);
- auto p2 = bitv.to_vec(pp.postcondition);
+ auto p1 = BitV.to_vec(pp.precondition);
+ auto p2 = BitV.to_vec(pp.postcondition);
log_err("pre:");
log_cond_err(p1);
log_err("post:");
@@ -253,8 +253,8 @@ fn log_pp_err(&pre_and_post pp) -> () {
}
fn log_states(&pre_and_post_state pp) -> () {
- auto p1 = bitv.to_vec(pp.prestate);
- auto p2 = bitv.to_vec(pp.poststate);
+ auto p1 = BitV.to_vec(pp.prestate);
+ auto p2 = BitV.to_vec(pp.poststate);
log("prestate:");
log_cond(p1);
log("poststate:");
@@ -262,8 +262,8 @@ fn log_states(&pre_and_post_state pp) -> () {
}
fn log_states_err(&pre_and_post_state pp) -> () {
- auto p1 = bitv.to_vec(pp.prestate);
- auto p2 = bitv.to_vec(pp.poststate);
+ auto p1 = BitV.to_vec(pp.prestate);
+ auto p2 = BitV.to_vec(pp.poststate);
log_err("prestate:");
log_cond_err(p1);
log_err("poststate:");
@@ -288,9 +288,9 @@ fn print_idents(vec[ident] idents) -> () {
variable in a given function) to bit number
(also remembers the ident for error-logging purposes) */
type var_info = tup(uint, ident);
-type fn_info = std.map.hashmap[def_id, var_info];
+type fn_info = std.Map.hashmap[def_id, var_info];
/* mapping from function name to fn_info map */
-type fn_info_map = std.map.hashmap[def_id, fn_info];
+type fn_info_map = std.Map.hashmap[def_id, fn_info];
fn bit_num(def_id v, fn_info m) -> uint {
assert (m.contains_key(v));
@@ -312,12 +312,12 @@ fn num_locals(fn_info m) -> uint {
fn collect_local(&@vec[tup(ident, def_id)] vars, &span sp, @ast.local loc)
-> @decl {
log("collect_local: pushing " + loc.ident);
- _vec.push[tup(ident, def_id)](*vars, tup(loc.ident, loc.id));
+ Vec.push[tup(ident, def_id)](*vars, tup(loc.ident, loc.id));
ret @respan(sp, decl_local(loc));
}
fn find_locals(_fn f) -> @vec[tup(ident,def_id)] {
- auto res = @_vec.alloc[tup(ident,def_id)](0u);
+ auto res = @Vec.alloc[tup(ident,def_id)](0u);
auto fld = fold.new_identity_fold[@vec[tup(ident, def_id)]]();
fld = @rec(fold_decl_local = bind collect_local(_,_,_) with *fld);
@@ -343,7 +343,7 @@ fn mk_fn_info(_fn f) -> fn_info {
just collect locally declared vars */
let @vec[tup(ident,def_id)] locals = find_locals(f);
- log(uistr(_vec.len[tup(ident, def_id)](*locals)) + " locals");
+ log(uistr(Vec.len[tup(ident, def_id)](*locals)) + " locals");
for (tup(ident,def_id) p in *locals) {
next = add_var(p._1, p._0, next, res);
}
@@ -364,7 +364,7 @@ fn mk_fn_info_item_fn(&fn_info_map fi, &span sp, ident i, &ast._fn f,
function IDs to fn_info maps */
fn mk_fn_info_item_obj(&fn_info_map fi, &span sp, ident i, &ast._obj o,
vec[ast.ty_param] ty_params, ast.obj_def_ids odid, ann a) -> @item {
- auto all_methods = _vec.clone[@method](o.methods);
+ auto all_methods = Vec.clone[@method](o.methods);
plus_option[@method](all_methods, o.dtor);
for (@method m in all_methods) {
fi.insert(m.node.id, mk_fn_info(m.node.meth));
@@ -403,7 +403,7 @@ fn ann_to_ts_ann(ann a, uint nv) -> ts_ann {
}
}
-fn ann_to_ts_ann_fail(ann a) -> option.t[@ts_ann] {
+fn ann_to_ts_ann_fail(ann a) -> Option.t[@ts_ann] {
alt (a) {
case (ann_none) {
log("ann_to_ts_ann_fail: didn't expect ann_none here");
@@ -432,7 +432,7 @@ fn ann_to_poststate(ann a) -> poststate {
ret (ann_to_ts_ann_fail_more(a)).states.poststate;
}
-fn stmt_to_ann(&stmt s) -> option.t[@ts_ann] {
+fn stmt_to_ann(&stmt s) -> Option.t[@ts_ann] {
alt (s.node) {
case (stmt_decl(_,?a)) {
ret ann_to_ts_ann_fail(a);
@@ -652,7 +652,7 @@ fn seq_preconds(fn_info enclosing, vec[pre_and_post] pps) -> precond {
/* works on either postconds or preconds
should probably rethink the whole type synonym situation */
fn union_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
- auto sz = _vec.len[postcond](rest);
+ auto sz = Vec.len[postcond](rest);
if (sz > 0u) {
auto other = rest.(0);
@@ -665,7 +665,7 @@ fn union_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
fn union_postconds(uint nv, &vec[postcond] pcs) -> postcond {
if (len[postcond](pcs) > 0u) {
- ret union_postconds_go(bitv.clone(pcs.(0)), pcs);
+ ret union_postconds_go(BitV.clone(pcs.(0)), pcs);
}
else {
ret empty_prestate(nv);
@@ -674,7 +674,7 @@ fn union_postconds(uint nv, &vec[postcond] pcs) -> postcond {
/* Gee, maybe we could use foldl or something */
fn intersect_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
- auto sz = _vec.len[postcond](rest);
+ auto sz = Vec.len[postcond](rest);
if (sz > 0u) {
auto other = rest.(0);
@@ -689,7 +689,7 @@ fn intersect_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
fn intersect_postconds(&vec[postcond] pcs) -> postcond {
assert (len[postcond](pcs) > 0u);
- ret intersect_postconds_go(bitv.clone(pcs.(0)), pcs);
+ ret intersect_postconds_go(BitV.clone(pcs.(0)), pcs);
}
/******* AST-traversing code ********/
@@ -720,8 +720,8 @@ fn find_pre_post_obj(&fn_info_map fm, _obj o) -> () {
find_pre_post_fn(fm, fm.get(m.node.id), m.node.meth);
}
auto f = bind do_a_method(fm,_);
- _vec.map[@method, ()](f, o.methods);
- option.map[@method, ()](f, o.dtor);
+ Vec.map[@method, ()](f, o.methods);
+ Option.map[@method, ()](f, o.dtor);
}
fn find_pre_post_state_obj(fn_info_map fm, _obj o) -> bool {
@@ -730,8 +730,8 @@ fn find_pre_post_state_obj(fn_info_map fm, _obj o) -> bool {
ret find_pre_post_state_fn(fm, fm.get(m.node.id), m.node.meth);
}
auto f = bind do_a_method(fm,_);
- auto flags = _vec.map[@method, bool](f, o.methods);
- auto changed = _vec.or(flags);
+ auto flags = Vec.map[@method, bool](f, o.methods);
+ auto changed = Vec.or(flags);
changed = changed || maybe[@method, bool](false, f, o.dtor);
ret changed;
}
@@ -777,19 +777,19 @@ fn find_pre_post_exprs(&fn_info_map fm, &fn_info enclosing,
}
auto f = bind do_one(fm, enclosing, _);
- _vec.map[@expr, ()](f, args);
+ Vec.map[@expr, ()](f, args);
fn get_pp(&@expr e) -> pre_and_post {
ret expr_pp(e);
}
auto g = get_pp;
- auto pps = _vec.map[@expr, pre_and_post](g, args);
+ auto pps = Vec.map[@expr, pre_and_post](g, args);
auto h = get_post;
set_pre_and_post(a,
rec(precondition=seq_preconds(enclosing, pps),
postcondition=union_postconds
- (nv, (_vec.map[pre_and_post, postcond](h, pps)))));
+ (nv, (Vec.map[pre_and_post, postcond](h, pps)))));
}
fn find_pre_post_loop(&fn_info_map fm, &fn_info enclosing, &@decl d,
@@ -822,13 +822,13 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () {
alt (e.node) {
case (expr_call(?operator, ?operands, ?a)) {
- auto args = _vec.clone[@expr](operands);
- _vec.push[@expr](args, operator);
+ auto args = Vec.clone[@expr](operands);
+ Vec.push[@expr](args, operator);
find_pre_post_exprs(fm, enclosing, args, a);
}
case (expr_spawn(_, _, ?operator, ?operands, ?a)) {
- auto args = _vec.clone[@expr](operands);
- _vec.push[@expr](args, operator);
+ auto args = Vec.clone[@expr](operands);
+ Vec.push[@expr](args, operator);
find_pre_post_exprs(fm, enclosing, args, a);
}
case (expr_vec(?args, _, ?a)) {
@@ -888,7 +888,7 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () {
}
case (expr_rec(?fields,?maybe_base,?a)) {
auto es = field_exprs(fields);
- _vec.plus_option[@expr](es, maybe_base);
+ Vec.plus_option[@expr](es, maybe_base);
find_pre_post_exprs(fm, enclosing, es, a);
}
case (expr_assign(?lhs, ?rhs, ?a)) {
@@ -1051,7 +1051,7 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () {
ret block_pp(an_alt.block);
}
auto f = bind do_an_alt(fm, enclosing, _);
- auto alt_pps = _vec.map[arm, pre_and_post](f, alts);
+ auto alt_pps = Vec.map[arm, pre_and_post](f, alts);
fn combine_pp(pre_and_post antec,
fn_info enclosing, &pre_and_post pp,
&pre_and_post next) -> pre_and_post {
@@ -1065,7 +1065,7 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () {
postcondition=false_postcond(num_local_vars));
auto g = bind combine_pp(antec_pp, enclosing, _, _);
- auto alts_overall_pp = _vec.foldl[pre_and_post, pre_and_post]
+ auto alts_overall_pp = Vec.foldl[pre_and_post, pre_and_post]
(g, e_pp, alt_pps);
set_pre_and_post(a, alts_overall_pp);
@@ -1091,8 +1091,8 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () {
set_pre_and_post(a, expr_pp(p));
}
case(expr_bind(?operator, ?maybe_args, ?a)) {
- auto args = _vec.cat_options[@expr](maybe_args);
- _vec.push[@expr](args, operator); /* ??? order of eval? */
+ auto args = Vec.cat_options[@expr](maybe_args);
+ Vec.push[@expr](args, operator); /* ??? order of eval? */
find_pre_post_exprs(fm, enclosing, args, a);
}
case (expr_break(?a)) {
@@ -1210,12 +1210,12 @@ fn find_pre_post_block(&fn_info_map fm, &fn_info enclosing, block b)
}
auto do_one = bind do_one_(fm, enclosing, _);
- _vec.map[@stmt, ()](do_one, b.node.stmts);
+ Vec.map[@stmt, ()](do_one, b.node.stmts);
fn do_inner_(fn_info_map fm, fn_info i, &@expr e) -> () {
find_pre_post_expr(fm, i, e);
}
auto do_inner = bind do_inner_(fm, enclosing, _);
- option.map[@expr, ()](do_inner, b.node.expr);
+ Option.map[@expr, ()](do_inner, b.node.expr);
let vec[pre_and_post] pps = vec();
@@ -1223,20 +1223,20 @@ fn find_pre_post_block(&fn_info_map fm, &fn_info enclosing, block b)
ret stmt_pp(*s);
}
auto f = get_pp_stmt;
- pps += _vec.map[@stmt, pre_and_post](f, b.node.stmts);
+ pps += Vec.map[@stmt, pre_and_post](f, b.node.stmts);
fn get_pp_expr(&@expr e) -> pre_and_post {
ret expr_pp(e);
}
auto g = get_pp_expr;
plus_option[pre_and_post](pps,
- option.map[@expr, pre_and_post](g, b.node.expr));
+ Option.map[@expr, pre_and_post](g, b.node.expr));
auto block_precond = seq_preconds(enclosing, pps);
auto h = get_post;
- auto postconds = _vec.map[pre_and_post, postcond](h, pps);
+ auto postconds = Vec.map[pre_and_post, postcond](h, pps);
/* A block may be empty, so this next line ensures that the postconds
vector is non-empty. */
- _vec.push[postcond](postconds, block_precond);
+ Vec.push[postcond](postconds, block_precond);
auto block_postcond = empty_poststate(nv);
/* conservative approximation */
if (! has_nonlocal_exits(b)) {
@@ -1696,7 +1696,7 @@ fn find_pre_post_state_expr(&fn_info_map fm, &fn_info enclosing,
changed = find_pre_post_state_expr(fm, enclosing, pres, e) || changed;
auto e_post = expr_poststate(e);
auto a_post;
- if (_vec.len[arm](alts) > 0u) {
+ if (Vec.len[arm](alts) > 0u) {
a_post = false_postcond(num_local_vars);
for (arm an_alt in alts) {
changed = find_pre_post_state_block(fm, enclosing, e_post,
@@ -1775,9 +1775,9 @@ fn find_pre_post_state_stmt(&fn_info_map fm, &fn_info enclosing,
log("*At beginning: stmt = ");
log_stmt(*s);
log("*prestate = ");
- log(bitv.to_str(stmt_ann.states.prestate));
+ log(BitV.to_str(stmt_ann.states.prestate));
log("*poststate =");
- log(bitv.to_str(stmt_ann.states.poststate));
+ log(BitV.to_str(stmt_ann.states.poststate));
log("*changed =");
log(changed);
@@ -1798,7 +1798,7 @@ fn find_pre_post_state_stmt(&fn_info_map fm, &fn_info enclosing,
log("Summary: stmt = ");
log_stmt(*s);
log("prestate = ");
- log(bitv.to_str(stmt_ann.states.prestate));
+ log(BitV.to_str(stmt_ann.states.prestate));
log_bitv(enclosing, stmt_ann.states.prestate);
log("poststate =");
log_bitv(enclosing, stmt_ann.states.poststate);
@@ -1835,10 +1835,10 @@ fn find_pre_post_state_stmt(&fn_info_map fm, &fn_info enclosing,
log("Summary: stmt = ");
log_stmt(*s);
log("prestate = ");
- log(bitv.to_str(stmt_ann.states.prestate));
+ log(BitV.to_str(stmt_ann.states.prestate));
log_bitv(enclosing, stmt_ann.states.prestate);
log("poststate =");
- log(bitv.to_str(stmt_ann.states.poststate));
+ log(BitV.to_str(stmt_ann.states.poststate));
log_bitv(enclosing, stmt_ann.states.poststate);
log("changed =");
log(changed);
@@ -1986,12 +1986,12 @@ fn check_states_against_conditions(fn_info enclosing, &ast._fn f) -> () {
}
auto do_one = bind do_one_(enclosing, _);
- _vec.map[@stmt, ()](do_one, f.body.node.stmts);
+ Vec.map[@stmt, ()](do_one, f.body.node.stmts);
fn do_inner_(fn_info i, &@expr e) -> () {
check_states_expr(i, e);
}
auto do_inner = bind do_inner_(enclosing, _);
- option.map[@expr, ()](do_inner, f.body.node.expr);
+ Option.map[@expr, ()](do_inner, f.body.node.expr);
}
@@ -2027,13 +2027,13 @@ fn check_method_states(&fn_info_map f_info_map, @method m) -> () {
}
fn check_obj_state(&fn_info_map f_info_map, vec[obj_field] fields,
- vec[@method] methods, option.t[@method] dtor) -> ast._obj {
+ vec[@method] methods, Option.t[@method] dtor) -> ast._obj {
fn one(fn_info_map fm, &@method m) -> () {
ret check_method_states(fm, m);
}
auto f = bind one(f_info_map,_);
- _vec.map[@method, ()](f, methods);
- option.map[@method, ()](f, dtor);
+ Vec.map[@method, ()](f, methods);
+ Option.map[@method, ()](f, dtor);
ret rec(fields=fields, methods=methods, dtor=dtor);
}
@@ -2122,7 +2122,7 @@ fn annotate_exprs(&fn_info_map fm, &vec[@expr] es) -> vec[@expr] {
ret annotate_expr(fm, e);
}
auto f = bind one(fm,_);
- ret _vec.map[@expr, @expr](f, es);
+ ret Vec.map[@expr, @expr](f, es);
}
fn annotate_elts(&fn_info_map fm, &vec[elt] es) -> vec[elt] {
fn one(fn_info_map fm, &elt e) -> elt {
@@ -2130,7 +2130,7 @@ fn annotate_elts(&fn_info_map fm, &vec[elt] es) -> vec[elt] {
expr=annotate_expr(fm, e.expr));
}
auto f = bind one(fm,_);
- ret _vec.map[elt, elt](f, es);
+ ret Vec.map[elt, elt](f, es);
}
fn annotate_fields(&fn_info_map fm, &vec[field] fs) -> vec[field] {
fn one(fn_info_map fm, &field f) -> field {
@@ -2139,23 +2139,23 @@ fn annotate_fields(&fn_info_map fm, &vec[field] fs) -> vec[field] {
expr=annotate_expr(fm, f.expr));
}
auto f = bind one(fm,_);
- ret _vec.map[field, field](f, fs);
+ ret Vec.map[field, field](f, fs);
}
-fn annotate_option_exp(&fn_info_map fm, &option.t[@expr] o)
- -> option.t[@expr] {
+fn annotate_option_exp(&fn_info_map fm, &Option.t[@expr] o)
+ -> Option.t[@expr] {
fn one(fn_info_map fm, &@expr e) -> @expr {
ret annotate_expr(fm, e);
}
auto f = bind one(fm,_);
- ret option.map[@expr, @expr](f, o);
+ ret Option.map[@expr, @expr](f, o);
}
-fn annotate_option_exprs(&fn_info_map fm, &vec[option.t[@expr]] es)
- -> vec[option.t[@expr]] {
- fn one(fn_info_map fm, &option.t[@expr] o) -> option.t[@expr] {
+fn annotate_option_exprs(&fn_info_map fm, &vec[Option.t[@expr]] es)
+ -> vec[Option.t[@expr]] {
+ fn one(fn_info_map fm, &Option.t[@expr] o) -> Option.t[@expr] {
ret annotate_option_exp(fm, o);
}
auto f = bind one(fm,_);
- ret _vec.map[option.t[@expr], option.t[@expr]](f, es);
+ ret Vec.map[Option.t[@expr], Option.t[@expr]](f, es);
}
fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl {
auto d1 = d.node;
@@ -2163,7 +2163,7 @@ fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl {
case (decl_local(?l)) {
alt(l.init) {
case (some[initializer](?init)) {
- let option.t[initializer] an_i =
+ let Option.t[initializer] an_i =
some[initializer]
(rec(expr=annotate_expr(fm, init.expr)
with init));
@@ -2186,7 +2186,7 @@ fn annotate_alts(&fn_info_map fm, &vec[arm] alts) -> vec[arm] {
index=a.index);
}
auto f = bind one(fm,_);
- ret _vec.map[arm, arm](f, alts);
+ ret Vec.map[arm, arm](f, alts);
}
fn annotate_expr(&fn_info_map fm, &@expr e) -> @expr {
@@ -2338,7 +2338,7 @@ fn annotate_block(&fn_info_map fm, &block b) -> block {
for (@stmt s in b.node.stmts) {
auto new_s = annotate_stmt(fm, s);
- _vec.push[@stmt](new_stmts, new_s);
+ Vec.push[@stmt](new_stmts, new_s);
ast.index_stmt(new_index, new_s);
}
fn ann_e(fn_info_map fm, &@expr e) -> @expr {
@@ -2346,7 +2346,7 @@ fn annotate_block(&fn_info_map fm, &block b) -> block {
}
auto f = bind ann_e(fm,_);
- auto new_e = option.map[@expr, @expr](f, b.node.expr);
+ auto new_e = Option.map[@expr, @expr](f, b.node.expr);
ret respan(b.span,
rec(stmts=new_stmts, expr=new_e, index=new_index with b.node));
@@ -2362,7 +2362,7 @@ fn annotate_mod(&fn_info_map fm, &ast._mod m) -> ast._mod {
for (@item i in m.items) {
auto new_i = annotate_item(fm, i);
- _vec.push[@item](new_items, new_i);
+ Vec.push[@item](new_items, new_i);
ast.index_item(new_index, new_i);
}
ret rec(items=new_items, index=new_index with m);
@@ -2383,8 +2383,8 @@ fn annotate_obj(&fn_info_map fm, &ast._obj o) -> ast._obj {
ret annotate_method(fm, m);
}
auto f = bind one(fm,_);
- auto new_methods = _vec.map[@method, @method](f, o.methods);
- auto new_dtor = option.map[@method, @method](f, o.dtor);
+ auto new_methods = Vec.map[@method, @method](f, o.methods);
+ auto new_dtor = Option.map[@method, @method](f, o.dtor);
ret rec(methods=new_methods, dtor=new_dtor with o);
}
@@ -2476,7 +2476,7 @@ fn annotate_module(&fn_info_map fm, &ast._mod module) -> ast._mod {
for (@item i in module.items) {
auto new_item = annotate_item(fm, i);
- _vec.push[@item](new_items, new_item);
+ Vec.push[@item](new_items, new_item);
ast.index_item(new_index, new_item);
}
diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs
index 8a5d40dc563c..2df69261f383 100644
--- a/src/comp/middle/walk.rs
+++ b/src/comp/middle/walk.rs
@@ -1,8 +1,8 @@
import front.ast;
-import std.option;
-import std.option.some;
-import std.option.none;
+import std.Option;
+import std.Option.some;
+import std.Option.none;
type ast_visitor =
rec(fn () -> bool keep_going,
@@ -257,7 +257,7 @@ fn walk_decl(&ast_visitor v, @ast.decl d) {
v.visit_decl_post(d);
}
-fn walk_expr_opt(&ast_visitor v, option.t[@ast.expr] eo) {
+fn walk_expr_opt(&ast_visitor v, Option.t[@ast.expr] eo) {
alt (eo) {
case (none[@ast.expr]) {}
case (some[@ast.expr](?e)) {
@@ -297,7 +297,7 @@ fn walk_expr(&ast_visitor v, @ast.expr e) {
case (ast.expr_self_method(_, _)) { }
case (ast.expr_bind(?callee, ?args, _)) {
walk_expr(v, callee);
- for (option.t[@ast.expr] eo in args) {
+ for (Option.t[@ast.expr] eo in args) {
walk_expr_opt(v, eo);
}
}
diff --git a/src/comp/pretty/pp.rs b/src/comp/pretty/pp.rs
index 85651c78c3c7..f966704253c8 100644
--- a/src/comp/pretty/pp.rs
+++ b/src/comp/pretty/pp.rs
@@ -1,6 +1,6 @@
-import std.io;
-import std._vec;
-import std._str;
+import std.IO;
+import std.Vec;
+import std.Str;
tag boxtype {box_h; box_v; box_hv; box_align;}
tag contexttype {cx_h; cx_v;}
@@ -19,7 +19,7 @@ type context = rec(contexttype tp, uint indent);
type ps = @rec(mutable vec[context] context,
uint width,
- io.writer out,
+ IO.writer out,
mutable uint col,
mutable uint spaces,
mutable vec[token] buffered,
@@ -30,7 +30,7 @@ type ps = @rec(mutable vec[context] context,
mutable bool start_of_box,
mutable bool potential_brk);
-fn mkstate(io.writer out, uint width) -> ps {
+fn mkstate(IO.writer out, uint width) -> ps {
let vec[context] stack = vec(rec(tp=cx_v, indent=0u));
let vec[token] buff = vec();
let vec[boxtype] sd = vec();
@@ -57,12 +57,12 @@ fn write_spaces(ps p, uint i) {
fn push_context(ps p, contexttype tp, uint indent) {
before_print(p, false);
- _vec.push[context](p.context, rec(tp=tp, indent=indent));
+ Vec.push[context](p.context, rec(tp=tp, indent=indent));
p.start_of_box = true;
}
fn pop_context(ps p) {
- _vec.pop[context](p.context);
+ Vec.pop[context](p.context);
}
fn add_token(ps p, token tok) {
@@ -89,7 +89,7 @@ fn buffer_token(ps p, token tok) {
} else {
alt (tok) {
case (open(?tp,_)) {
- _vec.push[boxtype](p.scandepth, tp);
+ Vec.push[boxtype](p.scandepth, tp);
if (p.scanning == scan_h) {
if (tp == box_h) {
check_potential_brk(p);
@@ -97,14 +97,14 @@ fn buffer_token(ps p, token tok) {
}
}
case (close) {
- _vec.pop[boxtype](p.scandepth);
- if (_vec.len[boxtype](p.scandepth) == 0u) {
+ Vec.pop[boxtype](p.scandepth);
+ if (Vec.len[boxtype](p.scandepth) == 0u) {
finish_scan(p, true);
}
}
case (brk(_)) {
if (p.scanning == scan_h) {
- if (p.scandepth.(_vec.len[boxtype](p.scandepth)-1u) == box_v) {
+ if (p.scandepth.(Vec.len[boxtype](p.scandepth)-1u) == box_v) {
finish_scan(p, true);
}
}
@@ -123,7 +123,7 @@ fn check_potential_brk(ps p) {
fn finish_scan(ps p, bool fits) {
auto buf = p.buffered;
- auto front = _vec.shift[token](buf);
+ auto front = Vec.shift[token](buf);
auto chosen_tp = cx_h;
if (!fits) {chosen_tp = cx_v;}
alt (front) {
@@ -154,10 +154,10 @@ fn start_scan(ps p, token tok, scantype tp) {
}
fn cur_context(ps p) -> context {
- ret p.context.(_vec.len[context](p.context)-1u);
+ ret p.context.(Vec.len[context](p.context)-1u);
}
fn base_indent(ps p) -> uint {
- auto i = _vec.len[context](p.context);
+ auto i = Vec.len[context](p.context);
while (i > 0u) {
i -= 1u;
auto cx = p.context.(i);
@@ -190,7 +190,7 @@ fn do_token(ps p, token tok) {
line_break(p);
}
case (word(?w)) {
- auto len = _str.char_len(w);
+ auto len = Str.char_len(w);
if (len + p.col + p.spaces > p.width && !start_of_box &&
!p.start_of_line) {
line_break(p);
@@ -202,7 +202,7 @@ fn do_token(ps p, token tok) {
case (cword(?w)) {
before_print(p, true);
p.out.write_str(w);
- p.col += _str.char_len(w);
+ p.col += Str.char_len(w);
}
case (open(?tp, ?indent)) {
if (tp == box_v) {
@@ -247,8 +247,8 @@ fn token_size(token tok) -> uint {
alt (tok) {
case (brk(?sz)) {ret sz;}
case (hardbrk) {ret 0xFFFFFFu;}
- case (word(?w)) {ret _str.char_len(w);}
- case (cword(?w)) {ret _str.char_len(w);}
+ case (word(?w)) {ret Str.char_len(w);}
+ case (cword(?w)) {ret Str.char_len(w);}
case (open(_, _)) {ret 0u;}
case (close) {ret 0u;}
}
diff --git a/src/comp/pretty/pprust.rs b/src/comp/pretty/pprust.rs
index 3111b0127a0d..17547bb65ac2 100644
--- a/src/comp/pretty/pprust.rs
+++ b/src/comp/pretty/pprust.rs
@@ -1,7 +1,7 @@
-import std._vec;
-import std._str;
-import std.io;
-import std.option;
+import std.Vec;
+import std.Str;
+import std.IO;
+import std.Option;
import front.ast;
import front.lexer;
import util.common;
@@ -12,39 +12,39 @@ const int as_prec = 5;
const uint default_columns = 78u;
type ps = @rec(pp.ps s,
- option.t[vec[lexer.cmnt]] comments,
+ Option.t[vec[lexer.cmnt]] comments,
mutable uint cur_cmnt);
-fn print_file(ast._mod _mod, str filename, io.writer out) {
+fn print_file(ast._mod _mod, str filename, IO.writer out) {
auto cmnts = lexer.gather_comments(filename);
auto s = @rec(s=pp.mkstate(out, default_columns),
- comments=option.some[vec[lexer.cmnt]](cmnts),
+ comments=Option.some[vec[lexer.cmnt]](cmnts),
mutable cur_cmnt=0u);
print_mod(s, _mod);
}
fn ty_to_str(&@ast.ty ty) -> str {
- auto writer = io.string_writer();
+ auto writer = IO.string_writer();
auto s = @rec(s=pp.mkstate(writer.get_writer(), 0u),
- comments=option.none[vec[lexer.cmnt]],
+ comments=Option.none[vec[lexer.cmnt]],
mutable cur_cmnt=0u);
print_type(s, ty);
ret writer.get_str();
}
fn block_to_str(&ast.block blk) -> str {
- auto writer = io.string_writer();
+ auto writer = IO.string_writer();
auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u),
- comments=option.none[vec[lexer.cmnt]],
+ comments=Option.none[vec[lexer.cmnt]],
mutable cur_cmnt=0u);
print_block(s, blk);
ret writer.get_str();
}
fn pat_to_str(&@ast.pat p) -> str {
- auto writer = io.string_writer();
+ auto writer = IO.string_writer();
auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u),
- comments=option.none[vec[lexer.cmnt]],
+ comments=Option.none[vec[lexer.cmnt]],
mutable cur_cmnt=0u);
print_pat(s, p);
ret writer.get_str();
@@ -92,7 +92,7 @@ fn commasep[IN](ps s, vec[IN] elts, fn(ps, &IN) op) {
}
fn commasep_cmnt[IN](ps s, vec[IN] elts, fn(ps, &IN) op,
fn(&IN) -> common.span get_span) {
- auto len = _vec.len[IN](elts);
+ auto len = Vec.len[IN](elts);
auto i = 0u;
for (IN elt in elts) {
op(s, elt);
@@ -160,7 +160,7 @@ fn print_type(ps s, &@ast.ty ty) {
fn get_span(&ast.ty_field f) -> common.span {
// Try to reconstruct the span for this field
auto sp = f.mt.ty.span;
- auto hi = sp.hi + _str.char_len(f.ident) + 1u;
+ auto hi = sp.hi + Str.char_len(f.ident) + 1u;
ret rec(hi=hi with sp);
}
auto f = print_field;
@@ -173,7 +173,7 @@ fn print_type(ps s, &@ast.ty ty) {
bopen(s);
for (ast.ty_method m in methods) {
hbox(s);
- print_ty_fn(s, m.proto, option.some[str](m.ident),
+ print_ty_fn(s, m.proto, Option.some[str](m.ident),
m.inputs, m.output);
wrd(s.s, ";");
end(s.s);
@@ -182,7 +182,7 @@ fn print_type(ps s, &@ast.ty ty) {
bclose_c(s, ty.span);
}
case (ast.ty_fn(?proto,?inputs,?output)) {
- print_ty_fn(s, proto, option.none[str], inputs, output);
+ print_ty_fn(s, proto, Option.none[str], inputs, output);
}
case (ast.ty_path(?path,_)) {
print_path(s, path);
@@ -240,8 +240,8 @@ fn print_item(ps s, @ast.item item) {
?typarams,_,_)) {
print_fn(s, decl, id, typarams);
alt (lname) {
- case (option.none[str]) {}
- case (option.some[str](?ss)) {
+ case (Option.none[str]) {}
+ case (Option.some[str](?ss)) {
print_string(s, ss);
}
}
@@ -270,7 +270,7 @@ fn print_item(ps s, @ast.item item) {
for (ast.variant v in variants) {
maybe_print_comment(s, v.span.lo);
wrd(s.s, v.node.name);
- if (_vec.len[ast.variant_arg](v.node.args) > 0u) {
+ if (Vec.len[ast.variant_arg](v.node.args) > 0u) {
popen(s);
fn print_variant_arg(ps s, &ast.variant_arg arg) {
print_type(s, arg.ty);
@@ -314,7 +314,7 @@ fn print_item(ps s, @ast.item item) {
line(s.s);
}
alt (_obj.dtor) {
- case (option.some[@ast.method](?dtor)) {
+ case (Option.some[@ast.method](?dtor)) {
hbox(s);
wrd1(s, "close");
print_block(s, dtor.node.meth.body);
@@ -344,7 +344,7 @@ fn print_block(ps s, ast.block blk) {
if (!maybe_print_line_comment(s, st.span)) {line(s.s);}
}
alt (blk.node.expr) {
- case (option.some[@ast.expr](?expr)) {
+ case (Option.some[@ast.expr](?expr)) {
print_expr(s, expr);
if (!maybe_print_line_comment(s, expr.span)) {line(s.s);}
}
@@ -358,7 +358,7 @@ fn print_literal(ps s, @ast.lit lit) {
alt (lit.node) {
case (ast.lit_str(?st)) {print_string(s, st);}
case (ast.lit_char(?ch)) {
- wrd(s.s, "'" + escape_str(_str.from_bytes(vec(ch as u8)), '\'')
+ wrd(s.s, "'" + escape_str(Str.from_bytes(vec(ch as u8)), '\'')
+ "'");
}
case (ast.lit_int(?val)) {
@@ -432,8 +432,8 @@ fn print_expr(ps s, &@ast.expr expr) {
auto gs = get_span;
commasep_cmnt[ast.field](s, fields, f, gs);
alt (wth) {
- case (option.some[@ast.expr](?expr)) {
- if (_vec.len[ast.field](fields) > 0u) {space(s.s);}
+ case (Option.some[@ast.expr](?expr)) {
+ if (Vec.len[ast.field](fields) > 0u) {space(s.s);}
hbox(s);
wrd1(s, "with");
print_expr(s, expr);
@@ -454,9 +454,9 @@ fn print_expr(ps s, &@ast.expr expr) {
print_ident(s, ident);
}
case (ast.expr_bind(?func,?args,_)) {
- fn print_opt(ps s, &option.t[@ast.expr] expr) {
+ fn print_opt(ps s, &Option.t[@ast.expr] expr) {
alt (expr) {
- case (option.some[@ast.expr](?expr)) {
+ case (Option.some[@ast.expr](?expr)) {
print_expr(s, expr);
}
case (_) {wrd(s.s, "_");}
@@ -466,7 +466,7 @@ fn print_expr(ps s, &@ast.expr expr) {
print_expr(s, func);
popen(s);
auto f = print_opt;
- commasep[option.t[@ast.expr]](s, args, f);
+ commasep[Option.t[@ast.expr]](s, args, f);
pclose(s);
}
case (ast.expr_spawn(_,_,?e,?es,_)) {
@@ -504,7 +504,7 @@ fn print_expr(ps s, &@ast.expr expr) {
space(s.s);
print_block(s, block);
alt (elseopt) {
- case (option.some[@ast.expr](?_else)) {
+ case (Option.some[@ast.expr](?_else)) {
space(s.s);
wrd1(s, "else");
print_expr(s, _else);
@@ -627,7 +627,7 @@ fn print_expr(ps s, &@ast.expr expr) {
case (ast.expr_ret(?result,_)) {
wrd(s.s, "ret");
alt (result) {
- case (option.some[@ast.expr](?expr)) {
+ case (Option.some[@ast.expr](?expr)) {
space(s.s);
print_expr(s, expr);
}
@@ -637,7 +637,7 @@ fn print_expr(ps s, &@ast.expr expr) {
case (ast.expr_put(?result,_)) {
wrd(s.s, "put");
alt (result) {
- case (option.some[@ast.expr](?expr)) {
+ case (Option.some[@ast.expr](?expr)) {
space(s.s);
print_expr(s, expr);
}
@@ -670,7 +670,7 @@ fn print_expr(ps s, &@ast.expr expr) {
case (ast.expr_ext(?path, ?args, ?body, _, _)) {
wrd(s.s, "#");
print_path(s, path);
- if (_vec.len[@ast.expr](args) > 0u) {
+ if (Vec.len[@ast.expr](args) > 0u) {
popen(s);
commasep_exprs(s, args);
pclose(s);
@@ -698,7 +698,7 @@ fn print_decl(ps s, @ast.decl decl) {
alt (decl.node) {
case (ast.decl_local(?loc)) {
alt (loc.ty) {
- case (option.some[@ast.ty](?ty)) {
+ case (Option.some[@ast.ty](?ty)) {
wrd1(s, "let");
print_type(s, ty);
space(s.s);
@@ -709,7 +709,7 @@ fn print_decl(ps s, @ast.decl decl) {
}
wrd(s.s, loc.ident);
alt (loc.init) {
- case (option.some[ast.initializer](?init)) {
+ case (Option.some[ast.initializer](?init)) {
space(s.s);
alt (init.op) {
case (ast.init_assign) {
@@ -738,7 +738,7 @@ fn print_ident(ps s, ast.ident ident) {
fn print_for_decl(ps s, @ast.decl decl) {
alt (decl.node) {
case (ast.decl_local(?loc)) {
- print_type(s, option.get[@ast.ty](loc.ty));
+ print_type(s, Option.get[@ast.ty](loc.ty));
space(s.s);
wrd(s.s, loc.ident);
}
@@ -753,7 +753,7 @@ fn print_path(ps s, ast.path path) {
else {wrd(s.s, ".");}
wrd(s.s, id);
}
- if (_vec.len[@ast.ty](path.node.types) > 0u) {
+ if (Vec.len[@ast.ty](path.node.types) > 0u) {
wrd(s.s, "[");
auto f = print_type;
commasep[@ast.ty](s, path.node.types, f);
@@ -769,7 +769,7 @@ fn print_pat(ps s, &@ast.pat pat) {
case (ast.pat_lit(?lit,_)) {print_literal(s, lit);}
case (ast.pat_tag(?path,?args,_,_)) {
print_path(s, path);
- if (_vec.len[@ast.pat](args) > 0u) {
+ if (Vec.len[@ast.pat](args) > 0u) {
popen_h(s);
auto f = print_pat;
commasep[@ast.pat](s, args, f);
@@ -814,7 +814,7 @@ fn print_fn(ps s, ast.fn_decl decl, str name,
}
fn print_type_params(ps s, vec[ast.ty_param] params) {
- if (_vec.len[ast.ty_param](params) > 0u) {
+ if (Vec.len[ast.ty_param](params) > 0u) {
wrd(s.s, "[");
fn printParam(ps s, &ast.ty_param param) {
wrd(s.s, param);
@@ -832,7 +832,7 @@ fn print_view_item(ps s, @ast.view_item item) {
case (ast.view_item_use(?id,?mta,_,_)) {
wrd1(s, "use");
wrd(s.s, id);
- if (_vec.len[@ast.meta_item](mta) > 0u) {
+ if (Vec.len[@ast.meta_item](mta) > 0u) {
popen(s);
fn print_meta(ps s, &@ast.meta_item item) {
hbox(s);
@@ -848,7 +848,7 @@ fn print_view_item(ps s, @ast.view_item item) {
}
case (ast.view_item_import(?id,?ids,_,_)) {
wrd1(s, "import");
- if (!_str.eq(id, ids.(_vec.len[str](ids)-1u))) {
+ if (!Str.eq(id, ids.(Vec.len[str](ids)-1u))) {
wrd1(s, id);
wrd1(s, "=");
}
@@ -898,7 +898,7 @@ fn print_maybe_parens(ps s, @ast.expr expr, int outer_prec) {
fn escape_str(str st, char to_escape) -> str {
let str out = "";
- auto len = _str.byte_len(st);
+ auto len = Str.byte_len(st);
auto i = 0u;
while (i < len) {
alt (st.(i) as char) {
@@ -908,7 +908,7 @@ fn escape_str(str st, char to_escape) -> str {
case ('\\') {out += "\\\\";}
case (?cur) {
if (cur == to_escape) {out += "\\";}
- _str.push_byte(out, cur as u8);
+ Str.push_byte(out, cur as u8);
}
}
i += 1u;
@@ -929,12 +929,12 @@ fn print_string(ps s, str st) {
wrd(s.s, "\""); wrd(s.s, escape_str(st, '"')); wrd(s.s, "\"");
}
-fn print_ty_fn(ps s, ast.proto proto, option.t[str] id,
+fn print_ty_fn(ps s, ast.proto proto, Option.t[str] id,
vec[ast.ty_arg] inputs, @ast.ty output) {
if (proto == ast.proto_fn) {wrd(s.s, "fn");}
else {wrd(s.s, "iter");}
alt (id) {
- case (option.some[str](?id)) {space(s.s); wrd(s.s, id);}
+ case (Option.some[str](?id)) {space(s.s); wrd(s.s, id);}
case (_) {}
}
popen_h(s);
@@ -955,21 +955,21 @@ fn print_ty_fn(ps s, ast.proto proto, option.t[str] id,
}
}
-fn next_comment(ps s) -> option.t[lexer.cmnt] {
+fn next_comment(ps s) -> Option.t[lexer.cmnt] {
alt (s.comments) {
- case (option.some[vec[lexer.cmnt]](?cmnts)) {
- if (s.cur_cmnt < _vec.len[lexer.cmnt](cmnts)) {
- ret option.some[lexer.cmnt](cmnts.(s.cur_cmnt));
- } else {ret option.none[lexer.cmnt];}
+ case (Option.some[vec[lexer.cmnt]](?cmnts)) {
+ if (s.cur_cmnt < Vec.len[lexer.cmnt](cmnts)) {
+ ret Option.some[lexer.cmnt](cmnts.(s.cur_cmnt));
+ } else {ret Option.none[lexer.cmnt];}
}
- case (_) {ret option.none[lexer.cmnt];}
+ case (_) {ret Option.none[lexer.cmnt];}
}
}
fn maybe_print_comment(ps s, uint pos) {
while (true) {
alt (next_comment(s)) {
- case (option.some[lexer.cmnt](?cmnt)) {
+ case (Option.some[lexer.cmnt](?cmnt)) {
if (cmnt.pos < pos) {
print_comment(s, cmnt.val);
if (cmnt.space_after) {line(s.s);}
@@ -983,7 +983,7 @@ fn maybe_print_comment(ps s, uint pos) {
fn maybe_print_line_comment(ps s, common.span span) -> bool {
alt (next_comment(s)) {
- case (option.some[lexer.cmnt](?cmnt)) {
+ case (Option.some[lexer.cmnt](?cmnt)) {
if (span.hi + 4u >= cmnt.pos) {
wrd(s.s, " ");
print_comment(s, cmnt.val);
@@ -999,7 +999,7 @@ fn maybe_print_line_comment(ps s, common.span span) -> bool {
fn print_remaining_comments(ps s) {
while (true) {
alt (next_comment(s)) {
- case (option.some[lexer.cmnt](?cmnt)) {
+ case (Option.some[lexer.cmnt](?cmnt)) {
print_comment(s, cmnt.val);
if (cmnt.space_after) {line(s.s);}
s.cur_cmnt += 1u;
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs
index b736b0482785..b1a398939868 100644
--- a/src/comp/util/common.rs
+++ b/src/comp/util/common.rs
@@ -1,18 +1,18 @@
-import std.map;
-import std.map.hashmap;
-import std._uint;
-import std._int;
-import std._vec;
-import std.option.none;
+import std.Map;
+import std.Map.hashmap;
+import std.UInt;
+import std.Int;
+import std.Vec;
+import std.Option.none;
import front.ast;
import util.typestate_ann.ts_ann;
import middle.fold;
import middle.fold.respan;
-import std.io.stdout;
-import std.io.str_writer;
-import std.io.string_writer;
+import std.IO.stdout;
+import std.IO.str_writer;
+import std.IO.string_writer;
import pretty.pprust.print_block;
import pretty.pprust.print_expr;
import pretty.pprust.print_decl;
@@ -56,10 +56,10 @@ fn ty_mach_to_str(ty_mach tm) -> str {
}
}
-fn new_str_hash[V]() -> std.map.hashmap[str,V] {
- let std.map.hashfn[str] hasher = std._str.hash;
- let std.map.eqfn[str] eqer = std._str.eq;
- ret std.map.mk_hashmap[str,V](hasher, eqer);
+fn new_str_hash[V]() -> std.Map.hashmap[str,V] {
+ let std.Map.hashfn[str] hasher = std.Str.hash;
+ let std.Map.eqfn[str] eqer = std.Str.eq;
+ ret std.Map.mk_hashmap[str,V](hasher, eqer);
}
fn def_eq(&ast.def_id a, &ast.def_id b) -> bool {
@@ -73,48 +73,48 @@ fn hash_def(&ast.def_id d) -> uint {
ret h;
}
-fn new_def_hash[V]() -> std.map.hashmap[ast.def_id,V] {
- let std.map.hashfn[ast.def_id] hasher = hash_def;
- let std.map.eqfn[ast.def_id] eqer = def_eq;
- ret std.map.mk_hashmap[ast.def_id,V](hasher, eqer);
+fn new_def_hash[V]() -> std.Map.hashmap[ast.def_id,V] {
+ let std.Map.hashfn[ast.def_id] hasher = hash_def;
+ let std.Map.eqfn[ast.def_id] eqer = def_eq;
+ ret std.Map.mk_hashmap[ast.def_id,V](hasher, eqer);
}
-fn new_int_hash[V]() -> std.map.hashmap[int,V] {
+fn new_int_hash[V]() -> std.Map.hashmap[int,V] {
fn hash_int(&int x) -> uint { ret x as uint; }
fn eq_int(&int a, &int b) -> bool { ret a == b; }
auto hasher = hash_int;
auto eqer = eq_int;
- ret std.map.mk_hashmap[int,V](hasher, eqer);
+ ret std.Map.mk_hashmap[int,V](hasher, eqer);
}
-fn new_uint_hash[V]() -> std.map.hashmap[uint,V] {
+fn new_uint_hash[V]() -> std.Map.hashmap[uint,V] {
fn hash_uint(&uint x) -> uint { ret x; }
fn eq_uint(&uint a, &uint b) -> bool { ret a == b; }
auto hasher = hash_uint;
auto eqer = eq_uint;
- ret std.map.mk_hashmap[uint,V](hasher, eqer);
+ ret std.Map.mk_hashmap[uint,V](hasher, eqer);
}
fn istr(int i) -> str {
- ret _int.to_str(i, 10u);
+ ret Int.to_str(i, 10u);
}
fn uistr(uint i) -> str {
- ret _uint.to_str(i, 10u);
+ ret UInt.to_str(i, 10u);
}
fn elt_expr(&ast.elt e) -> @ast.expr { ret e.expr; }
fn elt_exprs(&vec[ast.elt] elts) -> vec[@ast.expr] {
auto f = elt_expr;
- ret _vec.map[ast.elt, @ast.expr](f, elts);
+ ret Vec.map[ast.elt, @ast.expr](f, elts);
}
fn field_expr(&ast.field f) -> @ast.expr { ret f.expr; }
fn field_exprs(vec[ast.field] fields) -> vec [@ast.expr] {
auto f = field_expr;
- ret _vec.map[ast.field, @ast.expr](f, fields);
+ ret Vec.map[ast.field, @ast.expr](f, fields);
}
fn plain_ann(middle.ty.ctxt tcx) -> ast.ann {
diff --git a/src/comp/util/typestate_ann.rs b/src/comp/util/typestate_ann.rs
index 9e815b464849..949eaeb2f54b 100644
--- a/src/comp/util/typestate_ann.rs
+++ b/src/comp/util/typestate_ann.rs
@@ -1,21 +1,21 @@
import front.ast.ident;
-import std._vec;
-import std.bitv;
+import std.Vec;
+import std.BitV;
/*
This says: this expression requires the idents in to be initialized,
and given the precondition, it guarantees that the idents in are
initialized.
*/
-type precond = bitv.t; /* 1 means "this variable must be initialized"
+type precond = BitV.t; /* 1 means "this variable must be initialized"
0 means "don't care about this variable" */
-type postcond = bitv.t; /* 1 means "this variable is initialized"
+type postcond = BitV.t; /* 1 means "this variable is initialized"
0 means "don't know about this variable */
-type prestate = bitv.t; /* 1 means "this variable is definitely initialized"
+type prestate = BitV.t; /* 1 means "this variable is definitely initialized"
0 means "don't know whether this variable is
initialized" */
-type poststate = bitv.t; /* 1 means "this variable is definitely initialized"
+type poststate = BitV.t; /* 1 means "this variable is definitely initialized"
0 means "don't know whether this variable is
initialized" */
@@ -29,7 +29,7 @@ type pre_and_post_state = rec(prestate prestate, poststate poststate);
type ts_ann = rec(pre_and_post conditions, pre_and_post_state states);
fn true_precond(uint num_vars) -> precond {
- be bitv.create(num_vars, false);
+ be BitV.create(num_vars, false);
}
fn true_postcond(uint num_vars) -> postcond {
@@ -45,7 +45,7 @@ fn empty_poststate(uint num_vars) -> poststate {
}
fn false_postcond(uint num_vars) -> postcond {
- be bitv.create(num_vars, true);
+ be BitV.create(num_vars, true);
}
fn empty_pre_post(uint num_vars) -> pre_and_post {
@@ -72,15 +72,15 @@ fn get_post(&pre_and_post p) -> postcond {
}
fn difference(&precond p1, &precond p2) -> bool {
- be bitv.difference(p1, p2);
+ be BitV.difference(p1, p2);
}
fn union(&precond p1, &precond p2) -> bool {
- be bitv.union(p1, p2);
+ be BitV.union(p1, p2);
}
fn intersect(&precond p1, &precond p2) -> bool {
- be bitv.intersect(p1, p2);
+ be BitV.intersect(p1, p2);
}
fn pps_len(&pre_and_post p) -> uint {
@@ -91,62 +91,62 @@ fn pps_len(&pre_and_post p) -> uint {
fn require_and_preserve(uint i, &pre_and_post p) -> () {
// sets the ith bit in p's pre and post
- bitv.set(p.precondition, i, true);
- bitv.set(p.postcondition, i, true);
+ BitV.set(p.precondition, i, true);
+ BitV.set(p.postcondition, i, true);
}
fn set_in_postcond(uint i, &pre_and_post p) -> bool {
// sets the ith bit in p's post
- auto was_set = bitv.get(p.postcondition, i);
- bitv.set(p.postcondition, i, true);
+ auto was_set = BitV.get(p.postcondition, i);
+ BitV.set(p.postcondition, i, true);
ret !was_set;
}
fn set_in_poststate(uint i, &pre_and_post_state s) -> bool {
// sets the ith bit in p's post
- auto was_set = bitv.get(s.poststate, i);
- bitv.set(s.poststate, i, true);
+ auto was_set = BitV.get(s.poststate, i);
+ BitV.set(s.poststate, i, true);
ret !was_set;
}
// Sets all the bits in a's precondition to equal the
// corresponding bit in p's precondition.
fn set_precondition(&ts_ann a, &precond p) -> () {
- bitv.copy(a.conditions.precondition, p);
+ BitV.copy(a.conditions.precondition, p);
}
// Sets all the bits in a's postcondition to equal the
// corresponding bit in p's postcondition.
fn set_postcondition(&ts_ann a, &postcond p) -> () {
- bitv.copy(a.conditions.postcondition, p);
+ BitV.copy(a.conditions.postcondition, p);
}
// Sets all the bits in a's prestate to equal the
// corresponding bit in p's prestate.
fn set_prestate(@ts_ann a, &prestate p) -> bool {
- ret bitv.copy(a.states.prestate, p);
+ ret BitV.copy(a.states.prestate, p);
}
// Sets all the bits in a's postcondition to equal the
// corresponding bit in p's postcondition.
fn set_poststate(@ts_ann a, &poststate p) -> bool {
- ret bitv.copy(a.states.poststate, p);
+ ret BitV.copy(a.states.poststate, p);
}
// Set all the bits in p that are set in new
fn extend_prestate(&prestate p, &poststate new) -> bool {
- ret bitv.union(p, new);
+ ret BitV.union(p, new);
}
// Set all the bits in p that are set in new
fn extend_poststate(&poststate p, &poststate new) -> bool {
- ret bitv.union(p, new);
+ ret BitV.union(p, new);
}
// Clears the given bit in p
fn relax_prestate(uint i, &prestate p) -> bool {
- auto was_set = bitv.get(p, i);
- bitv.set(p, i, false);
+ auto was_set = BitV.get(p, i);
+ BitV.set(p, i, false);
ret was_set;
}
@@ -164,16 +164,16 @@ fn pp_clone(&pre_and_post p) -> pre_and_post {
}
fn clone(prestate p) -> prestate {
- ret bitv.clone(p);
+ ret BitV.clone(p);
}
// returns true if a implies b
// that is, returns true except if for some bits c and d,
// c = 1 and d = 0
-fn implies(bitv.t a, bitv.t b) -> bool {
- auto tmp = bitv.clone(b);
- bitv.difference(tmp, a);
- ret bitv.is_false(tmp);
+fn implies(BitV.t a, BitV.t b) -> bool {
+ auto tmp = BitV.clone(b);
+ BitV.difference(tmp, a);
+ ret BitV.is_false(tmp);
}
//
diff --git a/src/lib/bitv.rs b/src/lib/BitV.rs
similarity index 86%
rename from src/lib/bitv.rs
rename to src/lib/BitV.rs
index 1002abc83a6b..b0a4c9ea7f7b 100644
--- a/src/lib/bitv.rs
+++ b/src/lib/BitV.rs
@@ -21,19 +21,19 @@ fn create(uint nbits, bool init) -> t {
elt = 0u;
}
- auto storage = _vec.init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
+ auto storage = Vec.init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
ret rec(storage = storage, nbits = nbits);
}
fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
- auto len = _vec.len(v1.storage);
+ auto len = Vec.len(v1.storage);
- assert (_vec.len(v0.storage) == len);
+ assert (Vec.len(v0.storage) == len);
assert (v0.nbits == v1.nbits);
auto changed = false;
- for each (uint i in _uint.range(0u, len)) {
+ for each (uint i in UInt.range(0u, len)) {
auto w0 = v0.storage.(i);
auto w1 = v1.storage.(i);
@@ -75,9 +75,9 @@ fn copy(&t v0, t v1) -> bool {
}
fn clone(t v) -> t {
- auto storage = _vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
- auto len = _vec.len(v.storage);
- for each (uint i in _uint.range(0u, len)) {
+ auto storage = Vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
+ auto len = Vec.len(v.storage);
+ for each (uint i in UInt.range(0u, len)) {
storage.(i) = v.storage.(i);
}
ret rec(storage = storage, nbits = v.nbits);
@@ -97,7 +97,7 @@ fn get(&t v, uint i) -> bool {
fn equal(&t v0, &t v1) -> bool {
// FIXME: when we can break or return from inside an iterator loop,
// we can eliminate this painful while-loop
- auto len = _vec.len(v1.storage);
+ auto len = Vec.len(v1.storage);
auto i = 0u;
while (i < len) {
if (v0.storage.(i) != v1.storage.(i)) {
@@ -109,13 +109,13 @@ fn equal(&t v0, &t v1) -> bool {
}
fn clear(&t v) {
- for each (uint i in _uint.range(0u, _vec.len(v.storage))) {
+ for each (uint i in UInt.range(0u, Vec.len(v.storage))) {
v.storage.(i) = 0u;
}
}
fn invert(&t v) {
- for each (uint i in _uint.range(0u, _vec.len(v.storage))) {
+ for each (uint i in UInt.range(0u, Vec.len(v.storage))) {
v.storage.(i) = ~v.storage.(i);
}
}
@@ -176,13 +176,13 @@ fn init_to_vec(t v, uint i) -> uint {
fn to_vec(&t v) -> vec[uint] {
auto sub = bind init_to_vec(v, _);
- ret _vec.init_fn[uint](sub, v.nbits);
+ ret Vec.init_fn[uint](sub, v.nbits);
}
fn to_str(&t v) -> str {
auto res = "";
- for (uint i in bitv.to_vec(v)) {
+ for (uint i in BitV.to_vec(v)) {
if (i == 1u) {
res += "1";
}
@@ -196,7 +196,7 @@ fn to_str(&t v) -> str {
// FIXME: can we just use structural equality on to_vec?
fn eq_vec(&t v0, &vec[uint] v1) -> bool {
- assert (v0.nbits == _vec.len[uint](v1));
+ assert (v0.nbits == Vec.len[uint](v1));
auto len = v0.nbits;
auto i = 0u;
while (i < len) {
diff --git a/src/lib/dbg.rs b/src/lib/Dbg.rs
similarity index 98%
rename from src/lib/dbg.rs
rename to src/lib/Dbg.rs
index b63f363e7027..f155d1198f8a 100644
--- a/src/lib/dbg.rs
+++ b/src/lib/Dbg.rs
@@ -20,7 +20,7 @@ native "rust" mod rustrt {
}
fn debug_vec[T](vec[T] v) {
- _vec.print_debug_info[T](v);
+ Vec.print_debug_info[T](v);
}
fn debug_tydesc[T]() {
diff --git a/src/lib/deque.rs b/src/lib/Deque.rs
similarity index 75%
rename from src/lib/deque.rs
rename to src/lib/Deque.rs
index b8404a7d885e..a38e4fec4469 100644
--- a/src/lib/deque.rs
+++ b/src/lib/Deque.rs
@@ -19,7 +19,7 @@ type t[T] = obj {
fn create[T]() -> t[T] {
- type cell[T] = option.t[T];
+ type cell[T] = Option.t[T];
let uint initial_capacity = 32u; // 2^5
@@ -28,25 +28,25 @@ fn create[T]() -> t[T] {
* elsewhere.
*/
fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] {
- assert (nelts == _vec.len[cell[T]](elts));
+ assert (nelts == Vec.len[cell[T]](elts));
fn fill[T](uint i, uint nelts, uint lo,
vec[cell[T]] old) -> cell[T] {
if (i < nelts) {
ret old.((lo + i) % nelts);
} else {
- ret option.none[T];
+ ret Option.none[T];
}
}
- let uint nalloc = _uint.next_power_of_two(nelts + 1u);
- let _vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
- ret _vec.init_fn[cell[T]](copy_op, nalloc);
+ let uint nalloc = UInt.next_power_of_two(nelts + 1u);
+ let Vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
+ ret Vec.init_fn[cell[T]](copy_op, nalloc);
}
fn get[T](vec[cell[T]] elts, uint i) -> T {
alt (elts.(i)) {
- case (option.some[T](?t)) { ret t; }
+ case (Option.some[T](?t)) { ret t; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
@@ -63,18 +63,18 @@ fn create[T]() -> t[T] {
let uint oldlo = lo;
if (lo == 0u) {
- lo = _vec.len[cell[T]](elts) - 1u;
+ lo = Vec.len[cell[T]](elts) - 1u;
} else {
lo -= 1u;
}
if (lo == hi) {
elts = grow[T](nelts, oldlo, elts);
- lo = _vec.len[cell[T]](elts) - 1u;
+ lo = Vec.len[cell[T]](elts) - 1u;
hi = nelts;
}
- elts.(lo) = option.some[T](t);
+ elts.(lo) = Option.some[T](t);
nelts += 1u;
}
@@ -85,8 +85,8 @@ fn create[T]() -> t[T] {
hi = nelts;
}
- elts.(hi) = option.some[T](t);
- hi = (hi + 1u) % _vec.len[cell[T]](elts);
+ elts.(hi) = Option.some[T](t);
+ hi = (hi + 1u) % Vec.len[cell[T]](elts);
nelts += 1u;
}
@@ -96,21 +96,21 @@ fn create[T]() -> t[T] {
*/
fn pop_front() -> T {
let T t = get[T](elts, lo);
- elts.(lo) = option.none[T];
- lo = (lo + 1u) % _vec.len[cell[T]](elts);
+ elts.(lo) = Option.none[T];
+ lo = (lo + 1u) % Vec.len[cell[T]](elts);
nelts -= 1u;
ret t;
}
fn pop_back() -> T {
if (hi == 0u) {
- hi = _vec.len[cell[T]](elts) - 1u;
+ hi = Vec.len[cell[T]](elts) - 1u;
} else {
hi -= 1u;
}
let T t = get[T](elts, hi);
- elts.(hi) = option.none[T];
+ elts.(hi) = Option.none[T];
nelts -= 1u;
ret t;
}
@@ -124,12 +124,12 @@ fn create[T]() -> t[T] {
}
fn get(int i) -> T {
- let uint idx = (lo + (i as uint)) % _vec.len[cell[T]](elts);
+ let uint idx = (lo + (i as uint)) % Vec.len[cell[T]](elts);
ret get[T](elts, idx);
}
}
- let vec[cell[T]] v = _vec.init_elt[cell[T]](option.none[T],
+ let vec[cell[T]] v = Vec.init_elt[cell[T]](Option.none[T],
initial_capacity);
ret deque[T](0u, 0u, 0u, v);
diff --git a/src/lib/ebml.rs b/src/lib/EBML.rs
similarity index 88%
rename from src/lib/ebml.rs
rename to src/lib/EBML.rs
index 9bad0f3311d8..9b17bf06a682 100644
--- a/src/lib/ebml.rs
+++ b/src/lib/EBML.rs
@@ -2,8 +2,8 @@
// cursor model. See the specification here:
// http://www.matroska.org/technical/specs/rfc/index.html
-import option.none;
-import option.some;
+import Option.none;
+import Option.some;
type ebml_tag = rec(uint id, uint size);
type ebml_state = rec(ebml_tag ebml_tag, uint tag_pos, uint data_pos);
@@ -38,7 +38,7 @@ fn vint_at(vec[u8] data, uint start) -> tup(uint, uint) {
}
fn new_doc(vec[u8] data) -> doc {
- ret rec(data=data, start=0u, end=_vec.len[u8](data));
+ ret rec(data=data, start=0u, end=Vec.len[u8](data));
}
fn doc_at(vec[u8] data, uint start) -> doc {
@@ -48,7 +48,7 @@ fn doc_at(vec[u8] data, uint start) -> doc {
ret rec(data=data, start=elt_size._1, end=end);
}
-fn maybe_get_doc(doc d, uint tg) -> option.t[doc] {
+fn maybe_get_doc(doc d, uint tg) -> Option.t[doc] {
auto pos = d.start;
while (pos < d.end) {
auto elt_tag = vint_at(d.data, pos);
@@ -65,7 +65,7 @@ fn get_doc(doc d, uint tg) -> doc {
alt (maybe_get_doc(d, tg)) {
case (some[doc](?d)) {ret d;}
case (none[doc]) {
- log_err "failed to find block with tag " + _uint.to_str(tg, 10u);
+ log_err "failed to find block with tag " + UInt.to_str(tg, 10u);
fail;
}
}
@@ -94,7 +94,7 @@ iter tagged_docs(doc d, uint tg) -> doc {
}
fn doc_data(doc d) -> vec[u8] {
- ret _vec.slice[u8](d.data, d.start, d.end);
+ ret Vec.slice[u8](d.data, d.start, d.end);
}
fn be_uint_from_bytes(vec[u8] data, uint start, uint size) -> uint {
@@ -116,9 +116,9 @@ fn doc_as_uint(doc d) -> uint {
// EBML writing
-type writer = rec(io.buf_writer writer, mutable vec[uint] size_positions);
+type writer = rec(IO.buf_writer writer, mutable vec[uint] size_positions);
-fn write_sized_vint(&io.buf_writer w, uint n, uint size) {
+fn write_sized_vint(&IO.buf_writer w, uint n, uint size) {
let vec[u8] buf;
alt (size) {
case (1u) {
@@ -148,7 +148,7 @@ fn write_sized_vint(&io.buf_writer w, uint n, uint size) {
w.write(buf);
}
-fn write_vint(&io.buf_writer w, uint n) {
+fn write_vint(&IO.buf_writer w, uint n) {
if (n < 0x7fu) { write_sized_vint(w, n, 1u); ret; }
if (n < 0x4000u) { write_sized_vint(w, n, 2u); ret; }
if (n < 0x200000u) { write_sized_vint(w, n, 3u); ret; }
@@ -157,7 +157,7 @@ fn write_vint(&io.buf_writer w, uint n) {
fail;
}
-fn create_writer(&io.buf_writer w) -> writer {
+fn create_writer(&IO.buf_writer w) -> writer {
let vec[uint] size_positions = vec();
ret rec(writer=w, mutable size_positions=size_positions);
}
@@ -175,11 +175,11 @@ fn start_tag(&writer w, uint tag_id) {
}
fn end_tag(&writer w) {
- auto last_size_pos = _vec.pop[uint](w.size_positions);
+ auto last_size_pos = Vec.pop[uint](w.size_positions);
auto cur_pos = w.writer.tell();
- w.writer.seek(last_size_pos as int, io.seek_set);
+ w.writer.seek(last_size_pos as int, IO.seek_set);
write_sized_vint(w.writer, cur_pos - last_size_pos - 4u, 4u);
- w.writer.seek(cur_pos as int, io.seek_set);
+ w.writer.seek(cur_pos as int, IO.seek_set);
}
// TODO: optionally perform "relaxations" on end_tag to more efficiently
diff --git a/src/lib/ExtFmt.rs b/src/lib/ExtFmt.rs
index c71e49a39b21..0510a2a87ec3 100644
--- a/src/lib/ExtFmt.rs
+++ b/src/lib/ExtFmt.rs
@@ -13,8 +13,8 @@
* combinations at the moment.
*/
-import option.none;
-import option.some;
+import Option.none;
+import Option.some;
/*
* We have a CT (compile-time) module that parses format strings into a
@@ -66,7 +66,7 @@ mod CT {
}
// A formatted conversion from an expression to a string
- type conv = rec(option.t[int] param,
+ type conv = rec(Option.t[int] param,
vec[flag] flags,
count width,
count precision,
@@ -80,11 +80,11 @@ mod CT {
fn parse_fmt_string(str s) -> vec[piece] {
let vec[piece] pieces = vec();
- auto lim = _str.byte_len(s);
+ auto lim = Str.byte_len(s);
auto buf = "";
fn flush_buf(str buf, &vec[piece] pieces) -> str {
- if (_str.byte_len(buf) > 0u) {
+ if (Str.byte_len(buf) > 0u) {
auto piece = piece_string(buf);
pieces += vec(piece);
}
@@ -93,15 +93,15 @@ mod CT {
auto i = 0u;
while (i < lim) {
- auto curr = _str.substr(s, i, 1u);
- if (_str.eq(curr, "%")) {
+ auto curr = Str.substr(s, i, 1u);
+ if (Str.eq(curr, "%")) {
i += 1u;
if (i >= lim) {
log_err "unterminated conversion at end of string";
fail;
}
- auto curr2 = _str.substr(s, i, 1u);
- if (_str.eq(curr2, "%")) {
+ auto curr2 = Str.substr(s, i, 1u);
+ if (Str.eq(curr2, "%")) {
i += 1u;
} else {
buf = flush_buf(buf, pieces);
@@ -118,14 +118,14 @@ mod CT {
ret pieces;
}
- fn peek_num(str s, uint i, uint lim) -> option.t[tup(uint, uint)] {
+ fn peek_num(str s, uint i, uint lim) -> Option.t[tup(uint, uint)] {
if (i >= lim) {
ret none[tup(uint, uint)];
}
auto c = s.(i);
if (!('0' as u8 <= c && c <= '9' as u8)) {
- ret option.none[tup(uint, uint)];
+ ret Option.none[tup(uint, uint)];
}
auto n = (c - ('0' as u8)) as uint;
@@ -156,7 +156,7 @@ mod CT {
ty._1);
}
- fn parse_parameter(str s, uint i, uint lim) -> tup(option.t[int], uint) {
+ fn parse_parameter(str s, uint i, uint lim) -> tup(Option.t[int], uint) {
if (i >= lim) {
ret tup(none[int], i);
}
@@ -270,27 +270,27 @@ mod CT {
}
auto t;
- auto tstr = _str.substr(s, i, 1u);
- if (_str.eq(tstr, "b")) {
+ auto tstr = Str.substr(s, i, 1u);
+ if (Str.eq(tstr, "b")) {
t = ty_bool;
- } else if (_str.eq(tstr, "s")) {
+ } else if (Str.eq(tstr, "s")) {
t = ty_str;
- } else if (_str.eq(tstr, "c")) {
+ } else if (Str.eq(tstr, "c")) {
t = ty_char;
- } else if (_str.eq(tstr, "d")
- || _str.eq(tstr, "i")) {
+ } else if (Str.eq(tstr, "d")
+ || Str.eq(tstr, "i")) {
// TODO: Do we really want two signed types here?
// How important is it to be printf compatible?
t = ty_int(signed);
- } else if (_str.eq(tstr, "u")) {
+ } else if (Str.eq(tstr, "u")) {
t = ty_int(unsigned);
- } else if (_str.eq(tstr, "x")) {
+ } else if (Str.eq(tstr, "x")) {
t = ty_hex(case_lower);
- } else if (_str.eq(tstr, "X")) {
+ } else if (Str.eq(tstr, "X")) {
t = ty_hex(case_upper);
- } else if (_str.eq(tstr, "t")) {
+ } else if (Str.eq(tstr, "t")) {
t = ty_bits;
- } else if (_str.eq(tstr, "o")) {
+ } else if (Str.eq(tstr, "o")) {
t = ty_octal;
} else {
log_err "unknown type in conversion";
@@ -364,7 +364,7 @@ mod RT {
res = uint_to_str_prec(u, 16u, prec);
}
case (ty_hex_upper) {
- res = _str.to_upper(uint_to_str_prec(u, 16u, prec));
+ res = Str.to_upper(uint_to_str_prec(u, 16u, prec));
}
case (ty_bits) {
res = uint_to_str_prec(u, 2u, prec);
@@ -389,7 +389,7 @@ mod RT {
}
fn conv_char(&conv cv, char c) -> str {
- ret pad(cv, _str.from_char(c), pad_nozero);
+ ret pad(cv, Str.from_char(c), pad_nozero);
}
fn conv_str(&conv cv, str s) -> str {
@@ -399,9 +399,9 @@ mod RT {
}
case (count_is(?max)) {
// For strings, precision is the maximum characters displayed
- if (max as uint < _str.char_len(s)) {
+ if (max as uint < Str.char_len(s)) {
// FIXME: substr works on bytes, not chars!
- unpadded = _str.substr(s, 0u, max as uint);
+ unpadded = Str.substr(s, 0u, max as uint);
}
}
}
@@ -420,15 +420,15 @@ mod RT {
// Convert a uint to string with a minimum number of digits. If precision
// is 0 and num is 0 then the result is the empty string. Could move this
- // to _uint, but it doesn't seem all that useful.
+ // to UInt. but it doesn't seem all that useful.
fn uint_to_str_prec(uint num, uint radix, uint prec) -> str {
auto s;
if (prec == 0u && num == 0u) {
s = "";
} else {
- s = _uint.to_str(num, radix);
- auto len = _str.char_len(s);
+ s = UInt.to_str(num, radix);
+ auto len = Str.char_len(s);
if (len < prec) {
auto diff = prec - len;
auto pad = str_init_elt('0', diff);
@@ -450,12 +450,12 @@ mod RT {
}
}
- // FIXME: This might be useful in _str, but needs to be utf8 safe first
+ // FIXME: This might be useful in Str. but needs to be utf8 safe first
fn str_init_elt(char c, uint n_elts) -> str {
- auto svec = _vec.init_elt[u8](c as u8, n_elts);
+ auto svec = Vec.init_elt[u8](c as u8, n_elts);
// FIXME: Using unsafe_from_bytes because rustboot
// can't figure out the is_utf8 predicate on from_bytes?
- ret _str.unsafe_from_bytes(svec);
+ ret Str.unsafe_from_bytes(svec);
}
tag pad_mode {
@@ -476,7 +476,7 @@ mod RT {
}
}
- auto strlen = _str.char_len(s);
+ auto strlen = Str.char_len(s);
if (uwidth <= strlen) {
ret s;
}
@@ -532,16 +532,16 @@ mod RT {
// instead.
if (signed
&& zero_padding
- && _str.byte_len(s) > 0u) {
+ && Str.byte_len(s) > 0u) {
auto head = s.(0);
if (head == '+' as u8
|| head == '-' as u8
|| head == ' ' as u8) {
- auto headstr = _str.unsafe_from_bytes(vec(head));
- auto bytelen = _str.byte_len(s);
- auto numpart = _str.substr(s, 1u, bytelen - 1u);
+ auto headstr = Str.unsafe_from_bytes(vec(head));
+ auto bytelen = Str.byte_len(s);
+ auto numpart = Str.substr(s, 1u, bytelen - 1u);
ret headstr + padstr + numpart;
}
}
diff --git a/src/lib/fs.rs b/src/lib/FS.rs
similarity index 58%
rename from src/lib/fs.rs
rename to src/lib/FS.rs
index 0a951e5a6d6a..69edf247a3ec 100644
--- a/src/lib/fs.rs
+++ b/src/lib/FS.rs
@@ -3,25 +3,25 @@ native "rust" mod rustrt {
}
fn path_sep() -> str {
- ret _str.from_char(os_fs.path_sep);
+ ret Str.from_char(OS_FS.path_sep);
}
type path = str;
fn dirname(path p) -> path {
- let int i = _str.rindex(p, os_fs.path_sep as u8);
+ let int i = Str.rindex(p, OS_FS.path_sep as u8);
if (i == -1) {
- i = _str.rindex(p, os_fs.alt_path_sep as u8);
+ i = Str.rindex(p, OS_FS.alt_path_sep as u8);
if (i == -1) {
ret p;
}
}
- ret _str.substr(p, 0u, i as uint);
+ ret Str.substr(p, 0u, i as uint);
}
fn connect(path pre, path post) -> path {
- auto len = _str.byte_len(pre);
- if (pre.(len - 1u) == (os_fs.path_sep as u8)) { // Trailing '/'?
+ auto len = Str.byte_len(pre);
+ if (pre.(len - 1u) == (OS_FS.path_sep as u8)) { // Trailing '/'?
ret pre + post;
}
ret pre + path_sep() + post;
@@ -32,14 +32,14 @@ fn file_is_dir(path p) -> bool {
}
fn list_dir(path p) -> vec[str] {
- auto pl = _str.byte_len(p);
- if (pl == 0u || p.(pl - 1u) as char != os_fs.path_sep) {
+ auto pl = Str.byte_len(p);
+ if (pl == 0u || p.(pl - 1u) as char != OS_FS.path_sep) {
p += path_sep();
}
let vec[str] full_paths = vec();
- for (str filename in os_fs.list_dir(p)) {
- if (!_str.eq(filename, ".")) {if (!_str.eq(filename, "..")) {
- _vec.push[str](full_paths, p + filename);
+ for (str filename in OS_FS.list_dir(p)) {
+ if (!Str.eq(filename, ".")) {if (!Str.eq(filename, "..")) {
+ Vec.push[str](full_paths, p + filename);
}}
}
ret full_paths;
diff --git a/src/lib/GenericOS.rs b/src/lib/GenericOS.rs
index 2d375652140f..c60fa2b8ed17 100644
--- a/src/lib/GenericOS.rs
+++ b/src/lib/GenericOS.rs
@@ -1,4 +1,4 @@
fn getenv(str n) -> str {
- ret _str.str_from_cstr(os.libc.getenv(_str.buf(n)));
+ ret Str.str_from_cstr(OS.libc.getenv(Str.buf(n)));
}
diff --git a/src/lib/GetOpts.rs b/src/lib/GetOpts.rs
index f85ce85c136f..0cacf3ffc653 100644
--- a/src/lib/GetOpts.rs
+++ b/src/lib/GetOpts.rs
@@ -7,8 +7,8 @@
* argument values out of the match object.
*/
-import option.some;
-import option.none;
+import Option.some;
+import Option.none;
tag name { long(str); short(char); }
tag hasarg { yes; no; maybe; }
@@ -17,7 +17,7 @@ tag occur { req; optional; multi; }
type opt = rec(name name, hasarg hasarg, occur occur);
fn mkname(str nm) -> name {
- if (_str.char_len(nm) == 1u) { ret short(_str.char_at(nm, 0u)); }
+ if (Str.char_len(nm) == 1u) { ret short(Str.char_at(nm, 0u)); }
else { ret long(nm); }
}
fn reqopt(str name) -> opt {
@@ -41,11 +41,11 @@ tag optval {
type match = rec(vec[opt] opts, vec[mutable vec[optval]] vals, vec[str] free);
fn is_arg(str arg) -> bool {
- ret _str.byte_len(arg) > 1u && arg.(0) == '-' as u8;
+ ret Str.byte_len(arg) > 1u && arg.(0) == '-' as u8;
}
fn name_str(name nm) -> str {
alt (nm) {
- case (short(?ch)) {ret _str.from_char(ch);}
+ case (short(?ch)) {ret Str.from_char(ch);}
case (long(?s)) {ret s;}
}
}
@@ -55,16 +55,16 @@ fn name_eq(name a, name b) -> bool {
alt (a) {
case (long(?a)) {
alt (b) {
- case (long(?b)) { ret _str.eq(a, b); }
+ case (long(?b)) { ret Str.eq(a, b); }
case (_) { ret false; }
}
}
case (_) { if (a == b) { ret true; } else {ret false; } }
}
}
-fn find_opt(vec[opt] opts, name nm) -> option.t[uint] {
+fn find_opt(vec[opt] opts, name nm) -> Option.t[uint] {
auto i = 0u;
- auto l = _vec.len[opt](opts);
+ auto l = Vec.len[opt](opts);
while (i < l) {
if (name_eq(opts.(i).name, nm)) { ret some[uint](i); }
i += 1u;
@@ -102,41 +102,41 @@ tag result {
}
fn getopts(vec[str] args, vec[opt] opts) -> result {
- auto n_opts = _vec.len[opt](opts);
- fn empty_(uint x) -> vec[optval]{ret _vec.empty[optval]();}
+ auto n_opts = Vec.len[opt](opts);
+ fn empty_(uint x) -> vec[optval]{ret Vec.empty[optval]();}
auto f = empty_;
- auto vals = _vec.init_fn_mut[vec[optval]](f, n_opts);
+ auto vals = Vec.init_fn_mut[vec[optval]](f, n_opts);
let vec[str] free = vec();
- auto l = _vec.len[str](args);
+ auto l = Vec.len[str](args);
auto i = 0u;
while (i < l) {
auto cur = args.(i);
- auto curlen = _str.byte_len(cur);
+ auto curlen = Str.byte_len(cur);
if (!is_arg(cur)) {
- _vec.push[str](free, cur);
- } else if (_str.eq(cur, "--")) {
- free += _vec.slice[str](args, i + 1u, l);
+ Vec.push[str](free, cur);
+ } else if (Str.eq(cur, "--")) {
+ free += Vec.slice[str](args, i + 1u, l);
break;
} else {
auto names;
- auto i_arg = option.none[str];
+ auto i_arg = Option.none[str];
if (cur.(1) == '-' as u8) {
- auto tail = _str.slice(cur, 2u, curlen);
- auto eq = _str.index(tail, '=' as u8);
+ auto tail = Str.slice(cur, 2u, curlen);
+ auto eq = Str.index(tail, '=' as u8);
if (eq == -1) {
names = vec(long(tail));
} else {
- names = vec(long(_str.slice(tail, 0u, eq as uint)));
- i_arg = option.some[str]
- (_str.slice(tail, (eq as uint) + 1u, curlen - 2u));
+ names = vec(long(Str.slice(tail, 0u, eq as uint)));
+ i_arg = Option.some[str]
+ (Str.slice(tail, (eq as uint) + 1u, curlen - 2u));
}
} else {
auto j = 1u;
names = vec();
while (j < curlen) {
- auto range = _str.char_range_at(cur, j);
- _vec.push[name](names, short(range._0));
+ auto range = Str.char_range_at(cur, j);
+ Vec.push[name](names, short(range._0));
j = range._1;
}
}
@@ -152,29 +152,29 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
}
alt (opts.(optid).hasarg) {
case (no) {
- _vec.push[optval](vals.(optid), given);
+ Vec.push[optval](vals.(optid), given);
}
case (maybe) {
- if (!option.is_none[str](i_arg)) {
- _vec.push[optval](vals.(optid),
- val(option.get[str](i_arg)));
- } else if (name_pos < _vec.len[name](names) ||
+ if (!Option.is_none[str](i_arg)) {
+ Vec.push[optval](vals.(optid),
+ val(Option.get[str](i_arg)));
+ } else if (name_pos < Vec.len[name](names) ||
i + 1u == l || is_arg(args.(i + 1u))) {
- _vec.push[optval](vals.(optid), given);
+ Vec.push[optval](vals.(optid), given);
} else {
i += 1u;
- _vec.push[optval](vals.(optid), val(args.(i)));
+ Vec.push[optval](vals.(optid), val(args.(i)));
}
}
case (yes) {
- if (!option.is_none[str](i_arg)) {
- _vec.push[optval](vals.(optid),
- val(option.get[str](i_arg)));
+ if (!Option.is_none[str](i_arg)) {
+ Vec.push[optval](vals.(optid),
+ val(Option.get[str](i_arg)));
} else if (i + 1u == l) {
ret failure(argument_missing(name_str(nm)));
} else {
i += 1u;
- _vec.push[optval](vals.(optid), val(args.(i)));
+ Vec.push[optval](vals.(optid), val(args.(i)));
}
}
}
@@ -185,7 +185,7 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
i = 0u;
while (i < n_opts) {
- auto n = _vec.len[optval](vals.(i));
+ auto n = Vec.len[optval](vals.(i));
auto occ = opts.(i).occur;
if (occ == req) {if (n == 0u) {
ret failure(option_missing(name_str(opts.(i).name)));
@@ -212,7 +212,7 @@ fn opt_val(match m, str nm) -> optval {
ret opt_vals(m, nm).(0);
}
fn opt_present(match m, str nm) -> bool {
- ret _vec.len[optval](opt_vals(m, nm)) > 0u;
+ ret Vec.len[optval](opt_vals(m, nm)) > 0u;
}
fn opt_str(match m, str nm) -> str {
alt (opt_val(m, nm)) {
@@ -224,15 +224,15 @@ fn opt_strs(match m, str nm) -> vec[str] {
let vec[str] acc = vec();
for (optval v in opt_vals(m, nm)) {
alt (v) {
- case (val(?s)) { _vec.push[str](acc, s); }
+ case (val(?s)) { Vec.push[str](acc, s); }
case (_) {}
}
}
ret acc;
}
-fn opt_maybe_str(match m, str nm) -> option.t[str] {
+fn opt_maybe_str(match m, str nm) -> Option.t[str] {
auto vals = opt_vals(m, nm);
- if (_vec.len[optval](vals) == 0u) { ret none[str]; }
+ if (Vec.len[optval](vals) == 0u) { ret none[str]; }
alt (vals.(0)) {
case (val(?s)) { ret some[str](s); }
case (_) { ret none[str]; }
diff --git a/src/lib/io.rs b/src/lib/IO.rs
similarity index 80%
rename from src/lib/io.rs
rename to src/lib/IO.rs
index 364810ba3d3a..60416ab1e77b 100644
--- a/src/lib/io.rs
+++ b/src/lib/IO.rs
@@ -1,8 +1,8 @@
-import os.libc;
+import OS.libc;
native "rust" mod rustrt {
- fn rust_get_stdin() -> os.libc.FILE;
- fn rust_get_stdout() -> os.libc.FILE;
+ fn rust_get_stdin() -> OS.libc.FILE;
+ fn rust_get_stdout() -> OS.libc.FILE;
}
// Reading
@@ -55,30 +55,30 @@ fn convert_whence(seek_style whence) -> int {
}
}
-state obj FILE_buf_reader(os.libc.FILE f, bool must_close) {
+state obj FILE_buf_reader(OS.libc.FILE f, bool must_close) {
fn read(uint len) -> vec[u8] {
- auto buf = _vec.alloc[u8](len);
- auto read = os.libc.fread(_vec.buf[u8](buf), 1u, len, f);
- _vec.len_set[u8](buf, read);
+ auto buf = Vec.alloc[u8](len);
+ auto read = OS.libc.fread(Vec.buf[u8](buf), 1u, len, f);
+ Vec.len_set[u8](buf, read);
ret buf;
}
fn read_byte() -> int {
- ret os.libc.fgetc(f);
+ ret OS.libc.fgetc(f);
}
fn unread_byte(int byte) {
- os.libc.ungetc(byte, f);
+ OS.libc.ungetc(byte, f);
}
fn eof() -> bool {
- ret os.libc.feof(f) != 0;
+ ret OS.libc.feof(f) != 0;
}
fn seek(int offset, seek_style whence) {
- assert (os.libc.fseek(f, offset, convert_whence(whence)) == 0);
+ assert (OS.libc.fseek(f, offset, convert_whence(whence)) == 0);
}
fn tell() -> uint {
- ret os.libc.ftell(f) as uint;
+ ret OS.libc.ftell(f) as uint;
}
drop {
- if (must_close) { os.libc.fclose(f); }
+ if (must_close) { OS.libc.fclose(f); }
}
}
@@ -100,7 +100,7 @@ state obj new_reader(buf_reader rdr) {
auto c0 = rdr.read_byte();
if (c0 == -1) {ret -1 as char;} // FIXME will this stay valid?
auto b0 = c0 as u8;
- auto w = _str.utf8_char_width(b0);
+ auto w = Str.utf8_char_width(b0);
assert (w > 0u);
if (w == 1u) {ret b0 as char;}
auto val = 0u;
@@ -112,7 +112,7 @@ state obj new_reader(buf_reader rdr) {
val <<= 6u;
val += (next & 0x3f) as uint;
}
- // See _str.char_at
+ // See Str.char_at
val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u);
ret val as char;
}
@@ -126,9 +126,9 @@ state obj new_reader(buf_reader rdr) {
while (go_on) {
auto ch = rdr.read_byte();
if (ch == -1 || ch == 10) {go_on = false;}
- else {_vec.push[u8](buf, ch as u8);}
+ else {Vec.push[u8](buf, ch as u8);}
}
- ret _str.unsafe_from_bytes(buf);
+ ret Str.unsafe_from_bytes(buf);
}
fn read_c_str() -> str {
let vec[u8] buf = vec();
@@ -136,9 +136,9 @@ state obj new_reader(buf_reader rdr) {
while (go_on) {
auto ch = rdr.read_byte();
if (ch < 1) {go_on = false;}
- else {_vec.push[u8](buf, ch as u8);}
+ else {Vec.push[u8](buf, ch as u8);}
}
- ret _str.unsafe_from_bytes(buf);
+ ret Str.unsafe_from_bytes(buf);
}
// FIXME deal with eof?
fn read_le_uint(uint size) -> uint {
@@ -191,7 +191,7 @@ fn stdin() -> reader {
}
fn file_reader(str path) -> reader {
- auto f = os.libc.fopen(_str.buf(path), _str.buf("r"));
+ auto f = OS.libc.fopen(Str.buf(path), Str.buf("r"));
if (f as uint == 0u) {
log_err "error opening " + path;
fail;
@@ -212,17 +212,17 @@ type byte_buf = @rec(vec[u8] buf, mutable uint pos);
state obj byte_buf_reader(byte_buf bbuf) {
fn read(uint len) -> vec[u8] {
- auto rest = _vec.len[u8](bbuf.buf) - bbuf.pos;
+ auto rest = Vec.len[u8](bbuf.buf) - bbuf.pos;
auto to_read = len;
if (rest < to_read) {
to_read = rest;
}
- auto range = _vec.slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read);
+ auto range = Vec.slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read);
bbuf.pos += to_read;
ret range;
}
fn read_byte() -> int {
- if (bbuf.pos == _vec.len[u8](bbuf.buf)) {ret -1;}
+ if (bbuf.pos == Vec.len[u8](bbuf.buf)) {ret -1;}
auto b = bbuf.buf.(bbuf.pos);
bbuf.pos += 1u;
ret b as int;
@@ -234,12 +234,12 @@ state obj byte_buf_reader(byte_buf bbuf) {
}
fn eof() -> bool {
- ret bbuf.pos == _vec.len[u8](bbuf.buf);
+ ret bbuf.pos == Vec.len[u8](bbuf.buf);
}
fn seek(int offset, seek_style whence) {
auto pos = bbuf.pos;
- auto len = _vec.len[u8](bbuf.buf);
+ auto len = Vec.len[u8](bbuf.buf);
bbuf.pos = seek_in_buf(offset, pos, len, whence);
}
@@ -268,40 +268,40 @@ type buf_writer = state obj {
fn tell() -> uint; // FIXME: eventually u64
};
-state obj FILE_writer(os.libc.FILE f, bool must_close) {
+state obj FILE_writer(OS.libc.FILE f, bool must_close) {
fn write(vec[u8] v) {
- auto len = _vec.len[u8](v);
- auto vbuf = _vec.buf[u8](v);
- auto nout = os.libc.fwrite(vbuf, len, 1u, f);
+ auto len = Vec.len[u8](v);
+ auto vbuf = Vec.buf[u8](v);
+ auto nout = OS.libc.fwrite(vbuf, len, 1u, f);
if (nout < 1u) {
log_err "error dumping buffer";
}
}
fn seek(int offset, seek_style whence) {
- assert (os.libc.fseek(f, offset, convert_whence(whence)) == 0);
+ assert (OS.libc.fseek(f, offset, convert_whence(whence)) == 0);
}
fn tell() -> uint {
- ret os.libc.ftell(f) as uint;
+ ret OS.libc.ftell(f) as uint;
}
drop {
- if (must_close) {os.libc.fclose(f);}
+ if (must_close) {OS.libc.fclose(f);}
}
}
state obj fd_buf_writer(int fd, bool must_close) {
fn write(vec[u8] v) {
- auto len = _vec.len[u8](v);
+ auto len = Vec.len[u8](v);
auto count = 0u;
auto vbuf;
while (count < len) {
- vbuf = _vec.buf_off[u8](v, count);
- auto nout = os.libc.write(fd, vbuf, len);
+ vbuf = Vec.buf_off[u8](v, count);
+ auto nout = OS.libc.write(fd, vbuf, len);
if (nout < 0) {
log_err "error dumping buffer";
- log_err sys.rustrt.last_os_error();
+ log_err Sys.rustrt.last_os_error();
fail;
}
count += nout as uint;
@@ -319,32 +319,32 @@ state obj fd_buf_writer(int fd, bool must_close) {
}
drop {
- if (must_close) {os.libc.close(fd);}
+ if (must_close) {OS.libc.close(fd);}
}
}
fn file_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
let int fflags =
- os.libc_constants.O_WRONLY() |
- os.libc_constants.O_BINARY();
+ OS.libc_constants.O_WRONLY() |
+ OS.libc_constants.O_BINARY();
for (fileflag f in flags) {
alt (f) {
- case (append) { fflags |= os.libc_constants.O_APPEND(); }
- case (create) { fflags |= os.libc_constants.O_CREAT(); }
- case (truncate) { fflags |= os.libc_constants.O_TRUNC(); }
+ case (append) { fflags |= OS.libc_constants.O_APPEND(); }
+ case (create) { fflags |= OS.libc_constants.O_CREAT(); }
+ case (truncate) { fflags |= OS.libc_constants.O_TRUNC(); }
case (none) {}
}
}
- auto fd = os.libc.open(_str.buf(path),
+ auto fd = OS.libc.open(Str.buf(path),
fflags,
- os.libc_constants.S_IRUSR() |
- os.libc_constants.S_IWUSR());
+ OS.libc_constants.S_IRUSR() |
+ OS.libc_constants.S_IWUSR());
if (fd < 0) {
log_err "error opening file for writing";
- log_err sys.rustrt.last_os_error();
+ log_err Sys.rustrt.last_os_error();
fail;
}
ret fd_buf_writer(fd, true);
@@ -390,17 +390,17 @@ state obj new_writer(buf_writer out) {
ret out;
}
fn write_str(str s) {
- out.write(_str.bytes(s));
+ out.write(Str.bytes(s));
}
fn write_char(char ch) {
// FIXME needlessly consy
- out.write(_str.bytes(_str.from_char(ch)));
+ out.write(Str.bytes(Str.from_char(ch)));
}
fn write_int(int n) {
- out.write(_str.bytes(_int.to_str(n, 10u)));
+ out.write(Str.bytes(Int.to_str(n, 10u)));
}
fn write_uint(uint n) {
- out.write(_str.bytes(_uint.to_str(n, 10u)));
+ out.write(Str.bytes(UInt.to_str(n, 10u)));
}
fn write_bytes(vec[u8] bytes) {
out.write(bytes);
@@ -427,7 +427,7 @@ fn file_writer(str path, vec[fileflag] flags) -> writer {
// FIXME: fileflags
fn buffered_file_buf_writer(str path) -> buf_writer {
- auto f = os.libc.fopen(_str.buf(path), _str.buf("w"));
+ auto f = OS.libc.fopen(Str.buf(path), Str.buf("w"));
if (f as uint == 0u) {
log_err "error opening " + path;
fail;
@@ -451,21 +451,21 @@ type mutable_byte_buf = @rec(mutable vec[mutable u8] buf, mutable uint pos);
state obj byte_buf_writer(mutable_byte_buf buf) {
fn write(vec[u8] v) {
// Fast path.
- if (buf.pos == _vec.len(buf.buf)) {
+ if (buf.pos == Vec.len(buf.buf)) {
// FIXME: Fix our type system. There's no reason you shouldn't be
// 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);
buf.buf += mv;
- buf.pos += _vec.len[u8](v);
+ buf.pos += Vec.len[u8](v);
ret;
}
// FIXME: Optimize. These should be unique pointers.
- auto vlen = _vec.len[u8](v);
+ auto vlen = Vec.len[u8](v);
auto vpos = 0u;
while (vpos < vlen) {
auto b = v.(vpos);
- if (buf.pos == _vec.len(buf.buf)) {
+ if (buf.pos == Vec.len(buf.buf)) {
buf.buf += vec(mutable b);
} else {
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) {
auto pos = buf.pos;
- auto len = _vec.len(buf.buf);
+ auto len = Vec.len(buf.buf);
buf.pos = seek_in_buf(offset, pos, len, whence);
}
@@ -487,12 +487,12 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
fn string_writer() -> str_writer {
// FIXME: yikes, this is bad. Needs fixing of mutable syntax.
let vec[mutable u8] b = vec(mutable 0u8);
- _vec.pop(b);
+ Vec.pop(b);
let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u);
state obj str_writer_wrap(writer wr, mutable_byte_buf buf) {
fn get_writer() -> writer {ret wr;}
- fn get_str() -> str {ret _str.unsafe_from_mutable_bytes(buf.buf);}
+ fn get_str() -> str {ret Str.unsafe_from_mutable_bytes(buf.buf);}
}
ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
}
diff --git a/src/lib/_int.rs b/src/lib/Int.rs
similarity index 93%
rename from src/lib/_int.rs
rename to src/lib/Int.rs
index 1824d142dab7..59fb507f7fb1 100644
--- a/src/lib/_int.rs
+++ b/src/lib/Int.rs
@@ -29,9 +29,9 @@ fn to_str(int n, uint radix) -> str
{
assert (0u < radix && radix <= 16u);
if (n < 0) {
- ret "-" + _uint.to_str((-n) as uint, radix);
+ ret "-" + UInt.to_str((-n) as uint, radix);
} else {
- ret _uint.to_str(n as uint, radix);
+ ret UInt.to_str(n as uint, radix);
}
}
diff --git a/src/lib/list.rs b/src/lib/List.rs
similarity index 93%
rename from src/lib/list.rs
rename to src/lib/List.rs
index 33f7c06003f9..58ea29f2964b 100644
--- a/src/lib/list.rs
+++ b/src/lib/List.rs
@@ -1,5 +1,5 @@
-import option.some;
-import option.none;
+import Option.some;
+import Option.none;
// FIXME: It would probably be more appealing to define this as
// type list[T] = rec(T hd, option[@list[T]] tl), but at the moment
@@ -27,7 +27,7 @@ fn foldl[T,U](&list[T] ls, &U u, fn(&T t, &U u) -> U f) -> U {
}
fn find[T,U](&list[T] ls,
- (fn(&T) -> option.t[U]) f) -> option.t[U] {
+ (fn(&T) -> Option.t[U]) f) -> Option.t[U] {
alt(ls) {
case (cons[T](?hd, ?tl)) {
alt (f(hd)) {
diff --git a/src/lib/map.rs b/src/lib/Map.rs
similarity index 88%
rename from src/lib/map.rs
rename to src/lib/Map.rs
index 4ab2f076b9ca..6f1ad6d70299 100644
--- a/src/lib/map.rs
+++ b/src/lib/Map.rs
@@ -11,8 +11,8 @@ state type hashmap[K, V] = state obj {
fn insert(&K key, &V val) -> bool;
fn contains_key(&K key) -> bool;
fn get(&K key) -> V;
- fn find(&K key) -> option.t[V];
- fn remove(&K key) -> option.t[V];
+ fn find(&K key) -> Option.t[V];
+ fn remove(&K key) -> Option.t[V];
fn rehash();
iter items() -> @tup(K,V);
};
@@ -20,7 +20,7 @@ state type hashmap[K, V] = state obj {
fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
let uint initial_capacity = 32u; // 2^5
- let util.rational load_factor = rec(num=3, den=4);
+ let Util.rational load_factor = rec(num=3, den=4);
tag bucket[K, V] {
nil;
@@ -29,7 +29,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
}
fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] {
- ret _vec.init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
+ ret Vec.init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
}
// Derive two hash functions from the one given by taking the upper
@@ -96,7 +96,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
vec[mutable bucket[K, V]] bkts,
uint nbkts,
&K key)
- -> option.t[V]
+ -> Option.t[V]
{
let uint i = 0u;
let uint h = hasher(key);
@@ -105,17 +105,17 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
alt (bkts.(j)) {
case (some[K, V](?k, ?v)) {
if (eqer(key, k)) {
- ret option.some[V](v);
+ ret Option.some[V](v);
}
}
case (nil[K, V]) {
- ret option.none[V];
+ ret Option.none[V];
}
case (deleted[K, V]) { }
}
i += 1u;
}
- ret option.none[V];
+ ret Option.none[V];
}
@@ -140,15 +140,15 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
mutable vec[mutable bucket[K, V]] bkts,
mutable uint nbkts,
mutable uint nelts,
- util.rational lf)
+ Util.rational lf)
{
fn size() -> uint { ret nelts; }
fn insert(&K key, &V val) -> bool {
- let util.rational load = rec(num=(nelts + 1u) as int,
+ let Util.rational load = rec(num=(nelts + 1u) as int,
den=nbkts as int);
- if (!util.rational_leq(load, lf)) {
- let uint nnewbkts = _uint.next_power_of_two(nbkts + 1u);
+ if (!Util.rational_leq(load, lf)) {
+ let uint nnewbkts = UInt.next_power_of_two(nbkts + 1u);
let vec[mutable bucket[K, V]] newbkts =
make_buckets[K, V](nnewbkts);
rehash[K, V](hasher, eqer, bkts, nbkts,
@@ -167,7 +167,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
fn contains_key(&K key) -> bool {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
- case (option.some[V](_)) { ret true; }
+ case (Option.some[V](_)) { ret true; }
case (_) { ret false; }
}
fail; // FIXME: remove me when exhaustiveness checking works
@@ -175,19 +175,19 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
fn get(&K key) -> V {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
- case (option.some[V](?val)) { ret val; }
+ case (Option.some[V](?val)) { ret val; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
}
- fn find(&K key) -> option.t[V] {
+ fn find(&K key) -> Option.t[V] {
// FIXME: should be 'be' but parametric tail-calls don't
// work at the moment.
ret find_common[K, V](hasher, eqer, bkts, nbkts, key);
}
- fn remove(&K key) -> option.t[V] {
+ fn remove(&K key) -> Option.t[V] {
let uint i = 0u;
let uint h = hasher(key);
while (i < nbkts) {
@@ -197,17 +197,17 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
if (eqer(key, k)) {
bkts.(j) = deleted[K, V];
nelts -= 1u;
- ret option.some[V](v);
+ ret Option.some[V](v);
}
}
case (deleted[K, V]) { }
case (nil[K, V]) {
- ret option.none[V];
+ ret Option.none[V];
}
}
i += 1u;
}
- ret option.none[V];
+ ret Option.none[V];
}
fn rehash() {
diff --git a/src/lib/option.rs b/src/lib/Option.rs
similarity index 95%
rename from src/lib/option.rs
rename to src/lib/Option.rs
index e214c77487f7..3fb9aa3b6135 100644
--- a/src/lib/option.rs
+++ b/src/lib/Option.rs
@@ -1,4 +1,4 @@
-// lib/option.rs
+// lib/Option.rs
tag t[T] {
none;
@@ -39,7 +39,7 @@ fn is_none[T](&t[T] opt) -> bool {
}
fn from_maybe[T](&T def, &t[T] opt) -> T {
- auto f = bind util.id[T](_);
+ auto f = bind Util.id[T](_);
ret maybe[T, T](def, f, opt);
}
diff --git a/src/lib/rand.rs b/src/lib/Rand.rs
similarity index 100%
rename from src/lib/rand.rs
rename to src/lib/Rand.rs
diff --git a/src/lib/run_program.rs b/src/lib/Run_Program.rs
similarity index 60%
rename from src/lib/run_program.rs
rename to src/lib/Run_Program.rs
index 31758984f9eb..30c0ee9c9a2f 100644
--- a/src/lib/run_program.rs
+++ b/src/lib/Run_Program.rs
@@ -1,74 +1,74 @@
-import _str.sbuf;
-import _vec.vbuf;
+import Str.sbuf;
+import Vec.vbuf;
native "rust" mod rustrt {
fn rust_run_program(vbuf argv, int in_fd, int out_fd, int err_fd) -> int;
}
fn argvec(str prog, vec[str] args) -> vec[sbuf] {
- auto argptrs = vec(_str.buf(prog));
+ auto argptrs = vec(Str.buf(prog));
for (str arg in args) {
- _vec.push[sbuf](argptrs, _str.buf(arg));
+ Vec.push[sbuf](argptrs, Str.buf(arg));
}
- _vec.push[sbuf](argptrs, 0 as sbuf);
+ Vec.push[sbuf](argptrs, 0 as sbuf);
ret argptrs;
}
fn run_program(str prog, vec[str] args) -> int {
- auto pid = rustrt.rust_run_program(_vec.buf[sbuf](argvec(prog, args)),
+ auto pid = rustrt.rust_run_program(Vec.buf[sbuf](argvec(prog, args)),
0, 0, 0);
- ret os.waitpid(pid);
+ ret OS.waitpid(pid);
}
type program =
state obj {
fn get_id() -> int;
- fn input() -> io.writer;
- fn output() -> io.reader;
+ fn input() -> IO.writer;
+ fn output() -> IO.reader;
fn close_input();
fn finish() -> int;
};
fn start_program(str prog, vec[str] args) -> @program {
- auto pipe_input = os.pipe();
- auto pipe_output = os.pipe();
+ auto pipe_input = OS.pipe();
+ auto pipe_output = OS.pipe();
auto pid = rustrt.rust_run_program
- (_vec.buf[sbuf](argvec(prog, args)),
+ (Vec.buf[sbuf](argvec(prog, args)),
pipe_input._0, pipe_output._1, 0);
if (pid == -1) {fail;}
- os.libc.close(pipe_input._0);
- os.libc.close(pipe_output._1);
+ OS.libc.close(pipe_input._0);
+ OS.libc.close(pipe_output._1);
state obj new_program(int pid,
int in_fd,
- os.libc.FILE out_file,
+ OS.libc.FILE out_file,
mutable bool finished) {
fn get_id() -> int {ret pid;}
- fn input() -> io.writer {
- ret io.new_writer(io.fd_buf_writer(in_fd, false));
+ fn input() -> IO.writer {
+ ret IO.new_writer(IO.fd_buf_writer(in_fd, false));
}
- fn output() -> io.reader {
- ret io.new_reader(io.FILE_buf_reader(out_file, false));
+ fn output() -> IO.reader {
+ ret IO.new_reader(IO.FILE_buf_reader(out_file, false));
}
fn close_input() {
- os.libc.close(in_fd);
+ OS.libc.close(in_fd);
}
fn finish() -> int {
if (finished) {ret 0;}
finished = true;
- os.libc.close(in_fd);
- ret os.waitpid(pid);
+ OS.libc.close(in_fd);
+ ret OS.waitpid(pid);
}
drop {
if (!finished) {
- os.libc.close(in_fd);
- os.waitpid(pid);
+ OS.libc.close(in_fd);
+ OS.waitpid(pid);
}
- os.libc.fclose(out_file);
+ OS.libc.fclose(out_file);
}
}
ret @new_program(pid, pipe_input._1,
- os.fd_FILE(pipe_output._0),
+ OS.fd_FILE(pipe_output._0),
false);
}
@@ -80,7 +80,7 @@ fn program_output(str prog, vec[str] args)
auto buf = "";
while (!out.eof()) {
auto bytes = out.read_bytes(4096u);
- buf += _str.unsafe_from_bytes(bytes);
+ buf += Str.unsafe_from_bytes(bytes);
}
ret rec(status=pr.finish(), out=buf);
}
diff --git a/src/lib/sha1.rs b/src/lib/SHA1.rs
similarity index 94%
rename from src/lib/sha1.rs
rename to src/lib/SHA1.rs
index e84787a23d71..b6ac0521f14c 100644
--- a/src/lib/sha1.rs
+++ b/src/lib/SHA1.rs
@@ -67,7 +67,7 @@ fn mk_sha1() -> sha1 {
fn process_msg_block(&sha1state st) {
// FIXME: Make precondition
- assert (_vec.len(st.h) == digest_buf_len);
+ assert (Vec.len(st.h) == digest_buf_len);
// Constants
auto k = vec(0x5A827999u32,
@@ -76,7 +76,7 @@ fn mk_sha1() -> sha1 {
0xCA62C1D6u32);
let int t; // Loop counter
- let vec[mutable u32] w = _vec.init_elt_mut[u32](0u32, 80u);
+ let vec[mutable u32] w = Vec.init_elt_mut[u32](0u32, 80u);
// Initialize the first 16 words of the vector w
t = 0;
@@ -192,7 +192,7 @@ fn mk_sha1() -> sha1 {
*/
fn pad_msg(&sha1state st) {
// FIXME: Should be a precondition
- assert (_vec.len(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
@@ -236,7 +236,7 @@ fn mk_sha1() -> sha1 {
fn reset() {
// FIXME: Should be typestate precondition
- assert (_vec.len(st.h) == digest_buf_len);
+ assert (Vec.len(st.h) == digest_buf_len);
st.len_low = 0u32;
st.len_high = 0u32;
@@ -256,7 +256,7 @@ fn mk_sha1() -> sha1 {
}
fn input_str(&str msg) {
- add_input(st, _str.bytes(msg));
+ add_input(st, Str.bytes(msg));
}
fn result() -> vec[u8] {
@@ -267,16 +267,16 @@ fn mk_sha1() -> sha1 {
auto r = mk_result(st);
auto s = "";
for (u8 b in r) {
- s += _uint.to_str(b as uint, 16u);
+ s += UInt.to_str(b as uint, 16u);
}
ret s;
}
}
- auto st = rec(h = _vec.init_elt_mut[u32](0u32, digest_buf_len),
+ auto st = rec(h = Vec.init_elt_mut[u32](0u32, digest_buf_len),
mutable len_low = 0u32,
mutable len_high = 0u32,
- msg_block = _vec.init_elt_mut[u8](0u8, msg_block_len),
+ msg_block = Vec.init_elt_mut[u8](0u8, msg_block_len),
mutable msg_block_idx = 0u,
mutable computed = false);
auto sh = sha1(st);
diff --git a/src/lib/sort.rs b/src/lib/Sort.rs
similarity index 98%
rename from src/lib/sort.rs
rename to src/lib/Sort.rs
index f712d22e621f..7ecaaaba0cf6 100644
--- a/src/lib/sort.rs
+++ b/src/lib/Sort.rs
@@ -1,5 +1,5 @@
-import _vec.len;
-import _vec.slice;
+import Vec.len;
+import Vec.slice;
type lteq[T] = fn(&T a, &T b) -> bool;
diff --git a/src/lib/_str.rs b/src/lib/Str.rs
similarity index 98%
rename from src/lib/_str.rs
rename to src/lib/Str.rs
index 5239afb1fea0..3886ee19164d 100644
--- a/src/lib/_str.rs
+++ b/src/lib/Str.rs
@@ -1,6 +1,6 @@
import rustrt.sbuf;
-import _vec.rustrt.vbuf;
+import Vec.rustrt.vbuf;
native "rust" mod rustrt {
type sbuf;
@@ -83,7 +83,7 @@ const uint tag_six_b = 0xfc_u;
fn is_utf8(vec[u8] v) -> bool {
auto i = 0u;
- auto total = _vec.len[u8](v);
+ auto total = Vec.len[u8](v);
while (i < total) {
auto chsize = utf8_char_width(v.(i));
if (chsize == 0u) {ret false;}
@@ -261,7 +261,7 @@ fn to_chars(str s) -> vec[char] {
auto len = byte_len(s);
while (i < len) {
auto cur = char_range_at(s, i);
- _vec.push[char](buf, cur._0);
+ Vec.push[char](buf, cur._0);
i = cur._1;
}
ret buf;
@@ -296,7 +296,7 @@ fn unshift_char(&mutable str s, char ch) {
fn refcount(str s) -> uint {
auto r = rustrt.refcount[u8](s);
- if (r == dbg.const_refcount) {
+ if (r == Dbg.const_refcount) {
ret r;
} else {
// -1 because calling this function incremented the refcount.
@@ -319,7 +319,7 @@ fn index(str s, u8 c) -> int {
}
fn rindex(str s, u8 c) -> int {
- let int n = _str.byte_len(s) as int;
+ let int n = Str.byte_len(s) as int;
while (n >= 0) {
if (s.(n) == c) {
ret n;
@@ -443,7 +443,7 @@ fn split(str s, u8 sep) -> vec[str] {
ends_with_sep = false;
}
}
- if (_str.byte_len(accum) != 0u ||
+ if (Str.byte_len(accum) != 0u ||
ends_with_sep) {
v += vec(accum);
}
diff --git a/src/lib/sys.rs b/src/lib/Sys.rs
similarity index 100%
rename from src/lib/sys.rs
rename to src/lib/Sys.rs
diff --git a/src/lib/_task.rs b/src/lib/Task.rs
similarity index 100%
rename from src/lib/_task.rs
rename to src/lib/Task.rs
diff --git a/src/lib/Term.rs b/src/lib/Term.rs
index 368fe21710ed..fca04bffb566 100644
--- a/src/lib/Term.rs
+++ b/src/lib/Term.rs
@@ -21,20 +21,20 @@ const u8 color_bright_magenta = 13u8;
const u8 color_bright_cyan = 14u8;
const u8 color_bright_white = 15u8;
-fn esc(io.buf_writer writer) {
+fn esc(IO.buf_writer writer) {
writer.write(vec(0x1bu8, '[' as u8));
}
-fn reset(io.buf_writer writer) {
+fn reset(IO.buf_writer writer) {
esc(writer);
writer.write(vec('0' as u8, 'm' as u8));
}
fn color_supported() -> bool {
- ret _str.eq(GenericOS.getenv("TERM"), "xterm-color");
+ ret Str.eq(GenericOS.getenv("TERM"), "xterm-color");
}
-fn set_color(io.buf_writer writer, u8 first_char, u8 color) {
+fn set_color(IO.buf_writer writer, u8 first_char, u8 color) {
assert (color < 16u8);
esc(writer);
@@ -45,11 +45,11 @@ fn set_color(io.buf_writer writer, u8 first_char, u8 color) {
writer.write(vec(first_char, ('0' as u8) + color, 'm' as u8));
}
-fn fg(io.buf_writer writer, u8 color) {
+fn fg(IO.buf_writer writer, u8 color) {
ret set_color(writer, '3' as u8, color);
}
-fn bg(io.buf_writer writer, u8 color) {
+fn bg(IO.buf_writer writer, u8 color) {
ret set_color(writer, '4' as u8, color);
}
diff --git a/src/lib/_u8.rs b/src/lib/U8.rs
similarity index 100%
rename from src/lib/_u8.rs
rename to src/lib/U8.rs
diff --git a/src/lib/UFind.rs b/src/lib/UFind.rs
index 9593e787e0d7..0bb06d7cfb89 100644
--- a/src/lib/UFind.rs
+++ b/src/lib/UFind.rs
@@ -1,19 +1,19 @@
-import option.none;
-import option.some;
+import Option.none;
+import Option.some;
// A very naive implementation of union-find with unsigned integer nodes.
-type node = option.t[uint];
+type node = Option.t[uint];
type ufind = rec(mutable vec[mutable node] nodes);
fn make() -> ufind {
let vec[mutable node] v = vec(mutable none[uint]);
- _vec.pop(v); // FIXME: botch
+ Vec.pop(v); // FIXME: botch
ret rec(mutable nodes=v);
}
fn make_set(&ufind ufnd) -> uint {
- auto idx = _vec.len(ufnd.nodes);
+ auto idx = Vec.len(ufnd.nodes);
ufnd.nodes += vec(mutable none[uint]);
ret idx;
}
diff --git a/src/lib/_uint.rs b/src/lib/UInt.rs
similarity index 89%
rename from src/lib/_uint.rs
rename to src/lib/UInt.rs
index 2d373cdd2bab..eea523256940 100644
--- a/src/lib/_uint.rs
+++ b/src/lib/UInt.rs
@@ -23,7 +23,7 @@ iter range(uint lo, uint hi) -> uint {
fn next_power_of_two(uint n) -> uint {
// FIXME change |* uint(4)| below to |* uint(8) / uint(2)| and watch the
// world explode.
- let uint halfbits = sys.rustrt.size_of[uint]() * 4u;
+ let uint halfbits = Sys.rustrt.size_of[uint]() * 4u;
let uint tmp = n - 1u;
let uint shift = 1u;
while (shift <= halfbits) {
@@ -34,12 +34,12 @@ fn next_power_of_two(uint n) -> uint {
}
fn parse_buf(vec[u8] buf, uint radix) -> uint {
- if (_vec.len[u8](buf) == 0u) {
+ if (Vec.len[u8](buf) == 0u) {
log_err "parse_buf(): buf is empty";
fail;
}
- auto i = _vec.len[u8](buf) - 1u;
+ auto i = Vec.len[u8](buf) - 1u;
auto power = 1u;
auto n = 0u;
while (true) {
@@ -83,15 +83,15 @@ fn to_str(uint num, uint radix) -> str
let str s = "";
while (n != 0u) {
- s += _str.unsafe_from_byte(digit(n % radix) as u8);
+ s += Str.unsafe_from_byte(digit(n % radix) as u8);
n /= radix;
}
let str s1 = "";
- let uint len = _str.byte_len(s);
+ let uint len = Str.byte_len(s);
while (len != 0u) {
len -= 1u;
- s1 += _str.unsafe_from_byte(s.(len));
+ s1 += Str.unsafe_from_byte(s.(len));
}
ret s1;
diff --git a/src/lib/util.rs b/src/lib/Util.rs
similarity index 91%
rename from src/lib/util.rs
rename to src/lib/Util.rs
index 2f797f69216f..a385aafda647 100644
--- a/src/lib/util.rs
+++ b/src/lib/Util.rs
@@ -4,7 +4,7 @@ fn id[T](&T x) -> T {
/* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment
* the constraint once fixed. */
-type rational = rec(int num, int den); // : _int.positive(*.den);
+type rational = rec(int num, int den); // : Int.positive(*.den);
fn rational_leq(&rational x, &rational y) -> bool {
// NB: Uses the fact that rationals have positive denominators WLOG.
diff --git a/src/lib/_vec.rs b/src/lib/Vec.rs
similarity index 93%
rename from src/lib/_vec.rs
rename to src/lib/Vec.rs
index 3a197ac24bfd..28b5d018d54c 100644
--- a/src/lib/_vec.rs
+++ b/src/lib/Vec.rs
@@ -1,6 +1,6 @@
-import option.none;
-import option.some;
-import util.orb;
+import Option.none;
+import Option.some;
+import Util.orb;
type vbuf = rustrt.vbuf;
@@ -47,7 +47,7 @@ fn alloc_mut[T](uint n_elts) -> vec[mutable T] {
fn refcount[T](array[T] v) -> uint {
auto r = rustrt.refcount[T](v);
- if (r == dbg.const_refcount) {
+ if (r == Dbg.const_refcount) {
ret r;
} else {
// -1 because calling this function incremented the refcount.
@@ -140,7 +140,7 @@ fn print_debug_info[T](array[T] v) {
}
// Returns the last element of v.
-fn last[T](array[T] v) -> option.t[T] {
+fn last[T](array[T] v) -> Option.t[T] {
auto l = len[T](v);
if (l == 0u) {
ret none[T];
@@ -199,14 +199,14 @@ fn grow[T](&array[T] v, uint n, &T initval) {
}
fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) {
- auto length = _vec.len(v);
+ auto length = Vec.len(v);
if (index >= length) {
grow(v, index - length + 1u, initval);
}
v.(index) = val;
}
-fn map[T, U](&option.operator[T,U] f, &array[T] v) -> vec[U] {
+fn map[T, U](&Option.operator[T,U] f, &array[T] v) -> vec[U] {
let vec[U] u = alloc[U](len[T](v));
for (T ve in v) {
u += vec(f(ve));
@@ -230,7 +230,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &array[T] v0, &array[U] v1) -> vec[V] {
ret u;
}
-fn find[T](fn (&T) -> bool f, &array[T] v) -> option.t[T] {
+fn find[T](fn (&T) -> bool f, &array[T] v) -> Option.t[T] {
for (T elt in v) {
if (f(elt)) {
ret some[T](elt);
@@ -270,24 +270,24 @@ fn unzip[T, U](&vec[tup(T, U)] v) -> tup(vec[T], vec[U]) {
fn or(&vec[bool] v) -> bool {
auto f = orb;
- ret _vec.foldl[bool, bool](f, false, v);
+ ret Vec.foldl[bool, bool](f, false, v);
}
fn clone[T](&vec[T] v) -> vec[T] {
ret slice[T](v, 0u, len[T](v));
}
-fn plus_option[T](&vec[T] v, &option.t[T] o) -> () {
+fn plus_option[T](&vec[T] v, &Option.t[T] o) -> () {
alt (o) {
case (none[T]) {}
case (some[T](?x)) { v += vec(x); }
}
}
-fn cat_options[T](&vec[option.t[T]] v) -> vec[T] {
+fn cat_options[T](&vec[Option.t[T]] v) -> vec[T] {
let vec[T] res = vec();
- for (option.t[T] o in v) {
+ for (Option.t[T] o in v) {
alt (o) {
case (none[T]) { }
case (some[T](?t)) {
diff --git a/src/lib/linux_os.rs b/src/lib/linux_OS.rs
similarity index 92%
rename from src/lib/linux_os.rs
rename to src/lib/linux_OS.rs
index a37db418109b..02c9183bded9 100644
--- a/src/lib/linux_os.rs
+++ b/src/lib/linux_OS.rs
@@ -1,5 +1,5 @@
-import _str.sbuf;
-import _vec.vbuf;
+import Str.sbuf;
+import Vec.vbuf;
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
// by https://github.com/graydon/rust/issues#issue/268
@@ -66,17 +66,17 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
- assert (os.libc.pipe(_vec.buf(fds)) == 0);
+ assert (OS.libc.pipe(Vec.buf(fds)) == 0);
ret tup(fds.(0), fds.(1));
}
fn fd_FILE(int fd) -> libc.FILE {
- ret libc.fdopen(fd, _str.buf("r"));
+ ret libc.fdopen(fd, Str.buf("r"));
}
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
- assert (os.libc.waitpid(pid, _vec.buf(status), 0) != -1);
+ assert (OS.libc.waitpid(pid, Vec.buf(status), 0) != -1);
ret status.(0);
}
diff --git a/src/lib/macos_os.rs b/src/lib/macos_OS.rs
similarity index 90%
rename from src/lib/macos_os.rs
rename to src/lib/macos_OS.rs
index a52b02c5658e..700ac17c7b66 100644
--- a/src/lib/macos_os.rs
+++ b/src/lib/macos_OS.rs
@@ -1,5 +1,5 @@
-import _str.sbuf;
-import _vec.vbuf;
+import Str.sbuf;
+import Vec.vbuf;
native mod libc = "libc.dylib" {
@@ -63,17 +63,17 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
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[mutable int](fds)) == 0);
ret tup(fds.(0), fds.(1));
}
fn fd_FILE(int fd) -> libc.FILE {
- ret libc.fdopen(fd, _str.buf("r"));
+ ret libc.fdopen(fd, Str.buf("r"));
}
fn waitpid(int pid) -> int {
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[mutable int](status), 0) != -1);
ret status.(0);
}
diff --git a/src/lib/posix_fs.rs b/src/lib/posix_FS.rs
similarity index 67%
rename from src/lib/posix_fs.rs
rename to src/lib/posix_FS.rs
index 99f411e7343b..b1f01a66414c 100644
--- a/src/lib/posix_fs.rs
+++ b/src/lib/posix_FS.rs
@@ -1,21 +1,21 @@
native "rust" mod rustrt {
- fn rust_dirent_filename(os.libc.dirent ent) -> str;
+ fn rust_dirent_filename(OS.libc.dirent ent) -> str;
}
fn list_dir(str path) -> vec[str] {
// TODO ensure this is always closed
- auto dir = os.libc.opendir(_str.buf(path));
+ auto dir = OS.libc.opendir(Str.buf(path));
assert (dir as uint != 0u);
let vec[str] result = vec();
while (true) {
- auto ent = os.libc.readdir(dir);
+ auto ent = OS.libc.readdir(dir);
if (ent as int == 0) {
- os.libc.closedir(dir);
+ OS.libc.closedir(dir);
ret result;
}
- _vec.push[str](result, rustrt.rust_dirent_filename(ent));
+ Vec.push[str](result, rustrt.rust_dirent_filename(ent));
}
- os.libc.closedir(dir);
+ OS.libc.closedir(dir);
ret result;
}
diff --git a/src/lib/std.rc b/src/lib/std.rc
index 44a0689c09f6..a317b1148f74 100644
--- a/src/lib/std.rc
+++ b/src/lib/std.rc
@@ -6,39 +6,38 @@ meta (name = "std",
// Built-in types support modules.
-mod _int;
-mod _uint;
-mod _u8;
-mod _vec;
-mod _str;
+mod Int;
+mod UInt;
+mod U8;
+mod Vec;
+mod Str;
// General IO and system-services modules.
-mod io;
-mod sys;
-mod _task;
+mod IO;
+mod Sys;
+mod Task;
// Utility modules.
-mod option;
-mod util;
+mod Option;
+mod Util;
// Authorize various rule-bendings.
-auth io = unsafe;
-auth fs = unsafe;
-auth os = unsafe;
-auth os_fs = unsafe;
-auth run = unsafe;
-auth _str = unsafe;
-auth _vec = unsafe;
-auth _task = unsafe;
+auth IO = unsafe;
+auth FS = unsafe;
+auth OS_FS = unsafe;
+auth Run = unsafe;
+auth Str = unsafe;
+auth Vec = unsafe;
+auth Task = unsafe;
-auth dbg = unsafe;
+auth Dbg = unsafe;
-auth _uint.next_power_of_two = unsafe;
-auth map.mk_hashmap = unsafe;
-auth rand.mk_rng = unsafe;
+auth UInt.next_power_of_two = unsafe;
+auth Map.mk_hashmap = unsafe;
+auth Rand.mk_rng = unsafe;
// Target-OS module.
@@ -47,30 +46,30 @@ mod GenericOS;
alt (target_os) {
case ("win32") {
- mod os = "win32_os.rs";
- mod os_fs = "win32_fs.rs";
+ mod OS = "win32_OS.rs";
+ mod OS_FS = "win32_FS.rs";
} case ("macos") {
- mod os = "macos_os.rs";
- mod os_fs = "posix_fs.rs";
+ mod OS = "macos_OS.rs";
+ mod OS_FS = "posix_FS.rs";
} else {
- mod os = "linux_os.rs";
- mod os_fs = "posix_fs.rs";
+ mod OS = "linux_OS.rs";
+ mod OS_FS = "posix_FS.rs";
}
}
-mod run = "run_program.rs";
-mod fs;
+mod Run = "Run_Program.rs";
+mod FS;
// FIXME: parametric
-mod map;
-mod deque;
-mod list;
-mod rand;
-mod dbg;
-mod bitv;
-mod sort;
-mod sha1;
-mod ebml;
+mod Map;
+mod Deque;
+mod List;
+mod Rand;
+mod Dbg;
+mod BitV;
+mod Sort;
+mod SHA1;
+mod EBML;
mod UFind;
mod ExtFmt;
mod Box;
diff --git a/src/lib/win32_fs.rs b/src/lib/win32_FS.rs
similarity index 100%
rename from src/lib/win32_fs.rs
rename to src/lib/win32_FS.rs
diff --git a/src/lib/win32_os.rs b/src/lib/win32_OS.rs
similarity index 93%
rename from src/lib/win32_os.rs
rename to src/lib/win32_OS.rs
index 1c6521e31f69..b799287c9506 100644
--- a/src/lib/win32_os.rs
+++ b/src/lib/win32_OS.rs
@@ -1,5 +1,5 @@
-import _str.sbuf;
-import _vec.vbuf;
+import Str.sbuf;
+import Vec.vbuf;
native mod libc = "msvcrt.dll" {
fn open(sbuf s, int flags, uint mode) -> int = "_open";
@@ -53,13 +53,13 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
- assert (os.libc._pipe(_vec.buf[mutable int](fds), 1024u,
+ assert (OS.libc._pipe(Vec.buf[mutable int](fds), 1024u,
libc_constants.O_BINARY()) == 0);
ret tup(fds.(0), fds.(1));
}
fn fd_FILE(int fd) -> libc.FILE {
- ret libc._fdopen(fd, _str.buf("r"));
+ ret libc._fdopen(fd, Str.buf("r"));
}
native "rust" mod rustrt {
diff --git a/src/test/bench/99-bottles/99bob-iter.rs b/src/test/bench/99-bottles/99bob-iter.rs
index 096389416a85..e8cc4b4bb911 100644
--- a/src/test/bench/99-bottles/99bob-iter.rs
+++ b/src/test/bench/99-bottles/99bob-iter.rs
@@ -3,8 +3,8 @@
* http://99-bottles-of-beer.net/
*/
use std;
-import std._int;
-import std._str;
+import std.Int;
+import std.Str;
fn b1() -> str {
ret "# of beer on the wall, # of beer.";
@@ -32,15 +32,15 @@ case (1) {
ns = "1 bottle";
}
case (_) {
- ns = _int.to_str(n, 10u) + " bottles";
+ ns = Int.to_str(n, 10u) + " bottles";
}
}
- while (i < _str.byte_len(t)) {
+ while (i < Str.byte_len(t)) {
if (t.(i) == ('#' as u8)) {
b += ns;
}
else {
- _str.push_byte(b, t.(i));
+ Str.push_byte(b, t.(i));
}
i += 1u;
}
diff --git a/src/test/bench/99-bottles/99bob-pattern.rs b/src/test/bench/99-bottles/99bob-pattern.rs
index 58d2d2c3e543..fc9ddddb35df 100644
--- a/src/test/bench/99-bottles/99bob-pattern.rs
+++ b/src/test/bench/99-bottles/99bob-pattern.rs
@@ -3,8 +3,8 @@
* http://99-bottles-of-beer.net/
*/
use std;
-import std._int;
-import std._str;
+import std.Int;
+import std.Str;
tag bottle { none; dual; single; multiple(int);}
@@ -25,8 +25,8 @@ fn show(bottle b) {
log "Take one down and pass it around, 1 bottle of beer on the wall.";
}
case (multiple(?n)) {
- let str nb = _int.to_str(n, 10u);
- let str mb = _int.to_str(n - 1, 10u);
+ let str nb = Int.to_str(n, 10u);
+ let str mb = Int.to_str(n - 1, 10u);
log nb + " bottles of beer on the wall, " + nb + " bottles of beer,";
log "Take one down and pass it around, "
+ mb + " bottles of beer on the wall.";
diff --git a/src/test/bench/99-bottles/99bob-simple.rs b/src/test/bench/99-bottles/99bob-simple.rs
index 3c426f51036c..5c0f08240590 100644
--- a/src/test/bench/99-bottles/99bob-simple.rs
+++ b/src/test/bench/99-bottles/99bob-simple.rs
@@ -3,8 +3,8 @@
* http://99-bottles-of-beer.net/
*/
use std;
-import std._int;
-import std._str;
+import std.Int;
+import std.Str;
fn b1() -> str {
ret "# of beer on the wall, # of beer.";
@@ -31,15 +31,15 @@ case (1) {
ns = "1 bottle";
}
case (_) {
- ns = _int.to_str(n, 10u) + " bottles";
+ ns = Int.to_str(n, 10u) + " bottles";
}
}
- while (i < _str.byte_len(t)) {
+ while (i < Str.byte_len(t)) {
if (t.(i) == ('#' as u8)) {
b += ns;
}
else {
- _str.push_byte(b, t.(i));
+ Str.push_byte(b, t.(i));
}
i += 1u;
}
diff --git a/src/test/bench/99-bottles/99bob-tail.rs b/src/test/bench/99-bottles/99bob-tail.rs
index 16e66d333d3e..985d9b4b7093 100644
--- a/src/test/bench/99-bottles/99bob-tail.rs
+++ b/src/test/bench/99-bottles/99bob-tail.rs
@@ -3,13 +3,13 @@
* http://99-bottles-of-beer.net/
*/
use std;
-import std._int;
-import std._str;
+import std.Int;
+import std.Str;
fn main() {
fn multiple(int n) {
- let str nb = _int.to_str(n, 10u);
- let str mb = _int.to_str(n - 1, 10u);
+ let str nb = Int.to_str(n, 10u);
+ let str mb = Int.to_str(n - 1, 10u);
log nb + " bottles of beer on the wall, " + nb + " bottles of beer,";
log "Take one down and pass it around, "
+ mb + " bottles of beer on the wall.";
diff --git a/src/test/bench/shootout/binarytrees.rs b/src/test/bench/shootout/binarytrees.rs
index 92bedb8b9e64..aa81aaac31df 100644
--- a/src/test/bench/shootout/binarytrees.rs
+++ b/src/test/bench/shootout/binarytrees.rs
@@ -1,6 +1,6 @@
use std;
-import std._int;
+import std.Int;
tag tree {
nil;
@@ -49,7 +49,7 @@ fn main() {
auto depth = min_depth;
while (depth <= max_depth) {
- auto iterations = _int.pow(2, (max_depth - depth + min_depth) as uint);
+ auto iterations = Int.pow(2, (max_depth - depth + min_depth) as uint);
auto chk = 0;
auto i = 1;
diff --git a/src/test/bench/shootout/fannkuchredux.rs b/src/test/bench/shootout/fannkuchredux.rs
index 7853a89210be..ad3d7dd253d3 100644
--- a/src/test/bench/shootout/fannkuchredux.rs
+++ b/src/test/bench/shootout/fannkuchredux.rs
@@ -2,8 +2,8 @@
use std;
-import std._int;
-import std._vec;
+import std.Int;
+import std.Vec;
fn fannkuch(int n) -> int {
@@ -12,9 +12,9 @@ fn fannkuch(int n) -> int {
}
auto perm1init_ = perm1init; // Rustboot workaround
- auto perm = _vec.init_elt[mutable int](0, n as uint);
- auto perm1 = _vec.init_fn[mutable int](perm1init_, n as uint);
- auto count = _vec.init_elt[mutable int](0, n as uint);
+ auto perm = Vec.init_elt[mutable int](0, n as uint);
+ auto perm1 = Vec.init_fn[mutable int](perm1init_, n as uint);
+ auto count = Vec.init_elt[mutable int](0, n as uint);
auto f = 0;
auto i = 0;
diff --git a/src/test/bench/shootout/fasta.rs b/src/test/bench/shootout/fasta.rs
index 7afa1a7a8d65..3543c2987543 100644
--- a/src/test/bench/shootout/fasta.rs
+++ b/src/test/bench/shootout/fasta.rs
@@ -7,10 +7,10 @@
* http://shootout.alioth.debian.org/
*/
use std;
-import std._vec;
-import std._str;
-import std._uint;
-import std._int;
+import std.Vec;
+import std.Str;
+import std.UInt;
+import std.Int;
fn LINE_LENGTH() -> uint {
ret 60u;
@@ -54,21 +54,21 @@ fn select_random(u32 r, vec[aminoacids] genelist) -> char {
ret v.(hi)._0;
}
}
- ret bisect(genelist, 0u, _vec.len[aminoacids](genelist) - 1u, r);
+ ret bisect(genelist, 0u, Vec.len[aminoacids](genelist) - 1u, r);
}
fn make_random_fasta(str id, str desc, vec[aminoacids] genelist, int n) {
log(">" + id + " " + desc);
- auto rng = myrandom(std.rand.mk_rng().next());
+ auto rng = myrandom(std.Rand.mk_rng().next());
let str op = "";
- for each (uint i in _uint.range(0u, n as uint)) {
- _str.push_byte(op, select_random(rng.next(100u32), genelist) as u8);
- if (_str.byte_len(op) >= LINE_LENGTH()) {
+ for each (uint i in UInt.range(0u, n as uint)) {
+ Str.push_byte(op, select_random(rng.next(100u32), genelist) as u8);
+ if (Str.byte_len(op) >= LINE_LENGTH()) {
log(op);
op = "";
}
}
- if (_str.byte_len(op) > 0u) {
+ if (Str.byte_len(op) > 0u) {
log(op);
}
}
@@ -76,16 +76,16 @@ fn make_random_fasta(str id, str desc, vec[aminoacids] genelist, int n) {
fn make_repeat_fasta(str id, str desc, str s, int n) {
log(">" + id + " " + desc);
let str op = "";
- let uint sl = _str.byte_len(s);
- for each (uint i in _uint.range(0u, n as uint)) {
+ let uint sl = Str.byte_len(s);
+ for each (uint i in UInt.range(0u, n as uint)) {
- _str.push_byte(op, s.(i % sl));
- if (_str.byte_len(op) >= LINE_LENGTH()) {
+ Str.push_byte(op, s.(i % sl));
+ if (Str.byte_len(op) >= LINE_LENGTH()) {
log(op);
op = "";
}
}
- if (_str.byte_len(op) > 0u) {
+ if (Str.byte_len(op) > 0u) {
log(op);
}
}
diff --git a/src/test/run-pass/alt-join.rs b/src/test/run-pass/alt-join.rs
index 152fac5d7bc1..8f45e6ff5ac0 100644
--- a/src/test/run-pass/alt-join.rs
+++ b/src/test/run-pass/alt-join.rs
@@ -1,10 +1,10 @@
use std;
-import std.option;
-import std.option.t;
-import std.option.none;
-import std.option.some;
+import std.Option;
+import std.Option.t;
+import std.Option.none;
+import std.Option.some;
-fn foo[T](&option.t[T] y) {
+fn foo[T](&Option.t[T] y) {
let int x;
let vec[int] res = vec();
diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs
index b92ffd7481bd..76e7c3aa18d7 100644
--- a/src/test/run-pass/alt-pattern-drop.rs
+++ b/src/test/run-pass/alt-pattern-drop.rs
@@ -1,9 +1,9 @@
// -*- rust -*-
use std;
-import std._str;
+import std.Str;
-// FIXME: import std.dbg.const_refcount. Currently
+// FIXME: import std.Dbg.const_refcount. Currently
// cross-crate const references don't work.
const uint const_refcount = 0x7bad_face_u;
@@ -20,13 +20,13 @@ fn foo(str s) {
case (_) { log "?"; fail; }
}
- log _str.refcount(s);
- assert (_str.refcount(s) == const_refcount);
+ log Str.refcount(s);
+ assert (Str.refcount(s) == const_refcount);
}
fn main() {
let str s = "hi"; // ref up
foo(s); // ref up then down
- log _str.refcount(s);
- assert (_str.refcount(s) == const_refcount);
+ log Str.refcount(s);
+ assert (Str.refcount(s) == const_refcount);
}
diff --git a/src/test/run-pass/lib-bitv.rs b/src/test/run-pass/lib-bitv.rs
index 8f2d939005c7..b047f47a5cb3 100644
--- a/src/test/run-pass/lib-bitv.rs
+++ b/src/test/run-pass/lib-bitv.rs
@@ -1,132 +1,132 @@
use std;
-import std._vec;
-import std.bitv;
+import std.Vec;
+import std.BitV;
fn test_0_elements() {
auto act;
auto exp;
- act = bitv.create(0u, false);
- exp = _vec.init_elt[uint](0u, 0u);
+ act = BitV.create(0u, false);
+ exp = Vec.init_elt[uint](0u, 0u);
// FIXME: why can't I write vec[uint]()?
- assert (bitv.eq_vec(act, exp));
+ assert (BitV.eq_vec(act, exp));
}
fn test_1_element() {
auto act;
- act = bitv.create(1u, false);
- assert (bitv.eq_vec(act, vec(0u)));
+ act = BitV.create(1u, false);
+ assert (BitV.eq_vec(act, vec(0u)));
- act = bitv.create(1u, true);
- assert (bitv.eq_vec(act, vec(1u)));
+ act = BitV.create(1u, true);
+ assert (BitV.eq_vec(act, vec(1u)));
}
fn test_10_elements() {
auto act;
// all 0
- act = bitv.create(10u, false);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
+ act = BitV.create(10u, false);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// all 1
- act = bitv.create(10u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
+ act = BitV.create(10u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
// mixed
- act = bitv.create(10u, false);
- bitv.set(act, 0u, true);
- bitv.set(act, 1u, true);
- bitv.set(act, 2u, true);
- bitv.set(act, 3u, true);
- bitv.set(act, 4u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u)));
+ act = BitV.create(10u, false);
+ BitV.set(act, 0u, true);
+ BitV.set(act, 1u, true);
+ BitV.set(act, 2u, true);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 4u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u)));
// mixed
- act = bitv.create(10u, false);
- bitv.set(act, 5u, true);
- bitv.set(act, 6u, true);
- bitv.set(act, 7u, true);
- bitv.set(act, 8u, true);
- bitv.set(act, 9u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u)));
+ act = BitV.create(10u, false);
+ BitV.set(act, 5u, true);
+ BitV.set(act, 6u, true);
+ BitV.set(act, 7u, true);
+ BitV.set(act, 8u, true);
+ BitV.set(act, 9u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u)));
// mixed
- act = bitv.create(10u, false);
- bitv.set(act, 0u, true);
- bitv.set(act, 3u, true);
- bitv.set(act, 6u, true);
- bitv.set(act, 9u, true);
- assert (bitv.eq_vec(act, vec(1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u)));
+ act = BitV.create(10u, false);
+ BitV.set(act, 0u, true);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 6u, true);
+ BitV.set(act, 9u, true);
+ assert (BitV.eq_vec(act, vec(1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u)));
}
fn test_31_elements() {
auto act;
// all 0
- act = bitv.create(31u, false);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(31u, false);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// all 1
- act = bitv.create(31u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
+ act = BitV.create(31u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u)));
// mixed
- act = bitv.create(31u, false);
- bitv.set(act, 0u, true);
- bitv.set(act, 1u, true);
- bitv.set(act, 2u, true);
- bitv.set(act, 3u, true);
- bitv.set(act, 4u, true);
- bitv.set(act, 5u, true);
- bitv.set(act, 6u, true);
- bitv.set(act, 7u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
+ act = BitV.create(31u, false);
+ BitV.set(act, 0u, true);
+ BitV.set(act, 1u, true);
+ BitV.set(act, 2u, true);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 4u, true);
+ BitV.set(act, 5u, true);
+ BitV.set(act, 6u, true);
+ BitV.set(act, 7u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// mixed
- act = bitv.create(31u, false);
- bitv.set(act, 16u, true);
- bitv.set(act, 17u, true);
- bitv.set(act, 18u, true);
- bitv.set(act, 19u, true);
- bitv.set(act, 20u, true);
- bitv.set(act, 21u, true);
- bitv.set(act, 22u, true);
- bitv.set(act, 23u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(31u, false);
+ BitV.set(act, 16u, true);
+ BitV.set(act, 17u, true);
+ BitV.set(act, 18u, true);
+ BitV.set(act, 19u, true);
+ BitV.set(act, 20u, true);
+ BitV.set(act, 21u, true);
+ BitV.set(act, 22u, true);
+ BitV.set(act, 23u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// mixed
- act = bitv.create(31u, false);
- bitv.set(act, 24u, true);
- bitv.set(act, 25u, true);
- bitv.set(act, 26u, true);
- bitv.set(act, 27u, true);
- bitv.set(act, 28u, true);
- bitv.set(act, 29u, true);
- bitv.set(act, 30u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(31u, false);
+ BitV.set(act, 24u, true);
+ BitV.set(act, 25u, true);
+ BitV.set(act, 26u, true);
+ BitV.set(act, 27u, true);
+ BitV.set(act, 28u, true);
+ BitV.set(act, 29u, true);
+ BitV.set(act, 30u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u)));
// mixed
- act = bitv.create(31u, false);
- bitv.set(act, 3u, true);
- bitv.set(act, 17u, true);
- bitv.set(act, 30u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
+ act = BitV.create(31u, false);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 17u, true);
+ BitV.set(act, 30u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 1u)));
@@ -136,71 +136,71 @@ fn test_32_elements() {
auto act;
// all 0
- act = bitv.create(32u, false);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(32u, false);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// all 1
- act = bitv.create(32u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
+ act = BitV.create(32u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
// mixed
- act = bitv.create(32u, false);
- bitv.set(act, 0u, true);
- bitv.set(act, 1u, true);
- bitv.set(act, 2u, true);
- bitv.set(act, 3u, true);
- bitv.set(act, 4u, true);
- bitv.set(act, 5u, true);
- bitv.set(act, 6u, true);
- bitv.set(act, 7u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
+ act = BitV.create(32u, false);
+ BitV.set(act, 0u, true);
+ BitV.set(act, 1u, true);
+ BitV.set(act, 2u, true);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 4u, true);
+ BitV.set(act, 5u, true);
+ BitV.set(act, 6u, true);
+ BitV.set(act, 7u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// mixed
- act = bitv.create(32u, false);
- bitv.set(act, 16u, true);
- bitv.set(act, 17u, true);
- bitv.set(act, 18u, true);
- bitv.set(act, 19u, true);
- bitv.set(act, 20u, true);
- bitv.set(act, 21u, true);
- bitv.set(act, 22u, true);
- bitv.set(act, 23u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(32u, false);
+ BitV.set(act, 16u, true);
+ BitV.set(act, 17u, true);
+ BitV.set(act, 18u, true);
+ BitV.set(act, 19u, true);
+ BitV.set(act, 20u, true);
+ BitV.set(act, 21u, true);
+ BitV.set(act, 22u, true);
+ BitV.set(act, 23u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
// mixed
- act = bitv.create(32u, false);
- bitv.set(act, 24u, true);
- bitv.set(act, 25u, true);
- bitv.set(act, 26u, true);
- bitv.set(act, 27u, true);
- bitv.set(act, 28u, true);
- bitv.set(act, 29u, true);
- bitv.set(act, 30u, true);
- bitv.set(act, 31u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(32u, false);
+ BitV.set(act, 24u, true);
+ BitV.set(act, 25u, true);
+ BitV.set(act, 26u, true);
+ BitV.set(act, 27u, true);
+ BitV.set(act, 28u, true);
+ BitV.set(act, 29u, true);
+ BitV.set(act, 30u, true);
+ BitV.set(act, 31u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
// mixed
- act = bitv.create(32u, false);
- bitv.set(act, 3u, true);
- bitv.set(act, 17u, true);
- bitv.set(act, 30u, true);
- bitv.set(act, 31u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
+ act = BitV.create(32u, false);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 17u, true);
+ BitV.set(act, 30u, true);
+ BitV.set(act, 31u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u)));
@@ -210,77 +210,77 @@ fn test_33_elements() {
auto act;
// all 0
- act = bitv.create(33u, false);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(33u, false);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u)));
// all 1
- act = bitv.create(33u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
+ act = BitV.create(33u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
1u)));
// mixed
- act = bitv.create(33u, false);
- bitv.set(act, 0u, true);
- bitv.set(act, 1u, true);
- bitv.set(act, 2u, true);
- bitv.set(act, 3u, true);
- bitv.set(act, 4u, true);
- bitv.set(act, 5u, true);
- bitv.set(act, 6u, true);
- bitv.set(act, 7u, true);
- assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
+ act = BitV.create(33u, false);
+ BitV.set(act, 0u, true);
+ BitV.set(act, 1u, true);
+ BitV.set(act, 2u, true);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 4u, true);
+ BitV.set(act, 5u, true);
+ BitV.set(act, 6u, true);
+ BitV.set(act, 7u, true);
+ assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u)));
// mixed
- act = bitv.create(33u, false);
- bitv.set(act, 16u, true);
- bitv.set(act, 17u, true);
- bitv.set(act, 18u, true);
- bitv.set(act, 19u, true);
- bitv.set(act, 20u, true);
- bitv.set(act, 21u, true);
- bitv.set(act, 22u, true);
- bitv.set(act, 23u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(33u, false);
+ BitV.set(act, 16u, true);
+ BitV.set(act, 17u, true);
+ BitV.set(act, 18u, true);
+ BitV.set(act, 19u, true);
+ BitV.set(act, 20u, true);
+ BitV.set(act, 21u, true);
+ BitV.set(act, 22u, true);
+ BitV.set(act, 23u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u)));
// mixed
- act = bitv.create(33u, false);
- bitv.set(act, 24u, true);
- bitv.set(act, 25u, true);
- bitv.set(act, 26u, true);
- bitv.set(act, 27u, true);
- bitv.set(act, 28u, true);
- bitv.set(act, 29u, true);
- bitv.set(act, 30u, true);
- bitv.set(act, 31u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ act = BitV.create(33u, false);
+ BitV.set(act, 24u, true);
+ BitV.set(act, 25u, true);
+ BitV.set(act, 26u, true);
+ BitV.set(act, 27u, true);
+ BitV.set(act, 28u, true);
+ BitV.set(act, 29u, true);
+ BitV.set(act, 30u, true);
+ BitV.set(act, 31u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
0u)));
// mixed
- act = bitv.create(33u, false);
- bitv.set(act, 3u, true);
- bitv.set(act, 17u, true);
- bitv.set(act, 30u, true);
- bitv.set(act, 31u, true);
- bitv.set(act, 32u, true);
- assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
+ act = BitV.create(33u, false);
+ BitV.set(act, 3u, true);
+ BitV.set(act, 17u, true);
+ BitV.set(act, 30u, true);
+ BitV.set(act, 31u, true);
+ BitV.set(act, 32u, true);
+ assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u,
diff --git a/src/test/run-pass/lib-deque.rs b/src/test/run-pass/lib-deque.rs
index 405ab72be203..9de238dc8f75 100644
--- a/src/test/run-pass/lib-deque.rs
+++ b/src/test/run-pass/lib-deque.rs
@@ -1,10 +1,10 @@
// -*- rust -*-
use std;
-import std.deque;
+import std.Deque;
fn test_simple() {
- let deque.t[int] d = deque.create[int]();
+ let Deque.t[int] d = Deque.create[int]();
assert (d.size() == 0u);
d.add_front(17);
d.add_front(42);
@@ -57,7 +57,7 @@ fn test_simple() {
}
fn test_boxes(@int a, @int b, @int c, @int d) {
- let deque.t[@int] deq = deque.create[@int]();
+ let Deque.t[@int] deq = Deque.create[@int]();
assert (deq.size() == 0u);
deq.add_front(a);
deq.add_front(b);
@@ -93,7 +93,7 @@ fn test_boxes(@int a, @int b, @int c, @int d) {
type eqfn[T] = fn(&T a, &T b) -> bool;
fn test_parameterized[T](eqfn[T] e, &T a, &T b, &T c, &T d) {
- let deque.t[T] deq = deque.create[T]();
+ let Deque.t[T] deq = Deque.create[T]();
assert (deq.size() == 0u);
deq.add_front(a);
deq.add_front(b);
diff --git a/src/test/run-pass/lib-int.rs b/src/test/run-pass/lib-int.rs
index e4e68351aabf..a5a9a2a10ce0 100644
--- a/src/test/run-pass/lib-int.rs
+++ b/src/test/run-pass/lib-int.rs
@@ -1,25 +1,25 @@
use std;
-import std._int;
-import std._str.eq;
+import std.Int;
+import std.Str.eq;
fn test_to_str() {
- assert (eq(_int.to_str(0, 10u), "0"));
- assert (eq(_int.to_str(1, 10u), "1"));
- assert (eq(_int.to_str(-1, 10u), "-1"));
- assert (eq(_int.to_str(255, 16u), "ff"));
- assert (eq(_int.to_str(100, 10u), "100"));
+ assert (eq(Int.to_str(0, 10u), "0"));
+ assert (eq(Int.to_str(1, 10u), "1"));
+ assert (eq(Int.to_str(-1, 10u), "-1"));
+ assert (eq(Int.to_str(255, 16u), "ff"));
+ assert (eq(Int.to_str(100, 10u), "100"));
}
fn test_pow() {
- assert (_int.pow(0, 0u) == 1);
- assert (_int.pow(0, 1u) == 0);
- assert (_int.pow(0, 2u) == 0);
- assert (_int.pow(-1, 0u) == -1);
- assert (_int.pow(1, 0u) == 1);
- assert (_int.pow(-3, 2u) == 9);
- assert (_int.pow(-3, 3u) == -27);
- assert (_int.pow(4, 9u) == 262144);
+ assert (Int.pow(0, 0u) == 1);
+ assert (Int.pow(0, 1u) == 0);
+ assert (Int.pow(0, 2u) == 0);
+ assert (Int.pow(-1, 0u) == -1);
+ assert (Int.pow(1, 0u) == 1);
+ assert (Int.pow(-3, 2u) == 9);
+ assert (Int.pow(-3, 3u) == -27);
+ assert (Int.pow(4, 9u) == 262144);
}
fn main() {
diff --git a/src/test/run-pass/lib-io.rs b/src/test/run-pass/lib-io.rs
index 5c97c2f05e86..e124cde3b22f 100644
--- a/src/test/run-pass/lib-io.rs
+++ b/src/test/run-pass/lib-io.rs
@@ -5,8 +5,8 @@
// -*- rust -*-
use std;
-import std.io;
-import std._str;
+import std.IO;
+import std.Str;
fn test_simple(str tmpfilebase) {
let str tmpfile = tmpfilebase + ".tmp";
@@ -15,14 +15,14 @@ fn test_simple(str tmpfilebase) {
log frood;
{
- let io.writer out = io.file_writer(tmpfile, vec(io.create));
+ let IO.writer out = IO.file_writer(tmpfile, vec(IO.create));
out.write_str(frood);
}
- let io.reader inp = io.file_reader(tmpfile);
+ let IO.reader inp = IO.file_reader(tmpfile);
let str frood2 = inp.read_c_str();
log frood2;
- assert (_str.eq(frood, frood2));
+ assert (Str.eq(frood, frood2));
}
fn main(vec[str] argv) {
diff --git a/src/test/run-pass/lib-map.rs b/src/test/run-pass/lib-map.rs
index abd2041e1513..1f9560558d96 100644
--- a/src/test/run-pass/lib-map.rs
+++ b/src/test/run-pass/lib-map.rs
@@ -1,31 +1,31 @@
// -*- rust -*-
use std;
-import std.map;
-import std._str;
-import std._uint;
-import std.util;
+import std.Map;
+import std.Str;
+import std.UInt;
+import std.Util;
fn test_simple() {
log "*** starting test_simple";
fn eq_uint(&uint x, &uint y) -> bool { ret x == y; }
fn hash_uint(&uint u) -> uint {
- // FIXME: can't use std.util.id since we'd be capturing a type param,
+ // FIXME: can't use std.Util.id since we'd be capturing a type param,
// and presently we can't close items over type params.
ret u;
}
- let map.hashfn[uint] hasher_uint = hash_uint;
- let map.eqfn[uint] eqer_uint = eq_uint;
+ let Map.hashfn[uint] hasher_uint = hash_uint;
+ let Map.eqfn[uint] eqer_uint = eq_uint;
- let map.hashfn[str] hasher_str = _str.hash;
- let map.eqfn[str] eqer_str = _str.eq;
+ let Map.hashfn[str] hasher_str = Str.hash;
+ let Map.eqfn[str] eqer_str = Str.eq;
log "uint -> uint";
- let map.hashmap[uint, uint] hm_uu = map.mk_hashmap[uint, uint](hasher_uint,
+ let Map.hashmap[uint, uint] hm_uu = Map.mk_hashmap[uint, uint](hasher_uint,
eqer_uint);
assert (hm_uu.insert(10u, 12u));
@@ -49,7 +49,7 @@ fn test_simple() {
log "str -> uint";
- let map.hashmap[str, uint] hm_su = map.mk_hashmap[str, uint](hasher_str,
+ let Map.hashmap[str, uint] hm_su = Map.mk_hashmap[str, uint](hasher_str,
eqer_str);
assert (hm_su.insert("ten", 12u));
assert (hm_su.insert(eleven, 13u));
@@ -70,42 +70,42 @@ fn test_simple() {
log "uint -> str";
- let map.hashmap[uint, str] hm_us = map.mk_hashmap[uint, str](hasher_uint,
+ let Map.hashmap[uint, str] hm_us = Map.mk_hashmap[uint, str](hasher_uint,
eqer_uint);
assert (hm_us.insert(10u, "twelve"));
assert (hm_us.insert(11u, "thirteen"));
assert (hm_us.insert(12u, "fourteen"));
- assert (_str.eq(hm_us.get(11u), "thirteen"));
- assert (_str.eq(hm_us.get(12u), "fourteen"));
- assert (_str.eq(hm_us.get(10u), "twelve"));
+ assert (Str.eq(hm_us.get(11u), "thirteen"));
+ assert (Str.eq(hm_us.get(12u), "fourteen"));
+ assert (Str.eq(hm_us.get(10u), "twelve"));
assert (!hm_us.insert(12u, "fourteen"));
- assert (_str.eq(hm_us.get(12u), "fourteen"));
+ assert (Str.eq(hm_us.get(12u), "fourteen"));
assert (!hm_us.insert(12u, "twelve"));
- assert (_str.eq(hm_us.get(12u), "twelve"));
+ assert (Str.eq(hm_us.get(12u), "twelve"));
log "str -> str";
- let map.hashmap[str, str] hm_ss = map.mk_hashmap[str, str](hasher_str,
+ let Map.hashmap[str, str] hm_ss = Map.mk_hashmap[str, str](hasher_str,
eqer_str);
assert (hm_ss.insert(ten, "twelve"));
assert (hm_ss.insert(eleven, "thirteen"));
assert (hm_ss.insert(twelve, "fourteen"));
- assert (_str.eq(hm_ss.get("eleven"), "thirteen"));
- assert (_str.eq(hm_ss.get("twelve"), "fourteen"));
- assert (_str.eq(hm_ss.get("ten"), "twelve"));
+ assert (Str.eq(hm_ss.get("eleven"), "thirteen"));
+ assert (Str.eq(hm_ss.get("twelve"), "fourteen"));
+ assert (Str.eq(hm_ss.get("ten"), "twelve"));
assert (!hm_ss.insert("twelve", "fourteen"));
- assert (_str.eq(hm_ss.get("twelve"), "fourteen"));
+ assert (Str.eq(hm_ss.get("twelve"), "fourteen"));
assert (!hm_ss.insert("twelve", "twelve"));
- assert (_str.eq(hm_ss.get("twelve"), "twelve"));
+ assert (Str.eq(hm_ss.get("twelve"), "twelve"));
log "*** finished test_simple";
}
@@ -120,7 +120,7 @@ fn test_growth() {
fn eq_uint(&uint x, &uint y) -> bool { ret x == y; }
fn hash_uint(&uint u) -> uint {
- // FIXME: can't use std.util.id since we'd be capturing a type param,
+ // FIXME: can't use std.Util.id since we'd be capturing a type param,
// and presently we can't close items over type params.
ret u;
}
@@ -128,16 +128,16 @@ fn test_growth() {
log "uint -> uint";
- let map.hashfn[uint] hasher_uint = hash_uint;
- let map.eqfn[uint] eqer_uint = eq_uint;
- let map.hashmap[uint, uint] hm_uu = map.mk_hashmap[uint, uint](hasher_uint,
+ let Map.hashfn[uint] hasher_uint = hash_uint;
+ let Map.eqfn[uint] eqer_uint = eq_uint;
+ let Map.hashmap[uint, uint] hm_uu = Map.mk_hashmap[uint, uint](hasher_uint,
eqer_uint);
let uint i = 0u;
while (i < num_to_insert) {
assert (hm_uu.insert(i, i * i));
- log "inserting " + _uint.to_str(i, 10u)
- + " -> " + _uint.to_str(i * i, 10u);
+ log "inserting " + UInt.to_str(i, 10u)
+ + " -> " + UInt.to_str(i * i, 10u);
i += 1u;
}
@@ -145,8 +145,8 @@ fn test_growth() {
i = 0u;
while (i < num_to_insert) {
- log "get(" + _uint.to_str(i, 10u) + ") = "
- + _uint.to_str(hm_uu.get(i), 10u);
+ log "get(" + UInt.to_str(i, 10u) + ") = "
+ + UInt.to_str(hm_uu.get(i), 10u);
assert (hm_uu.get(i) == i * i);
i += 1u;
}
@@ -160,8 +160,8 @@ fn test_growth() {
i = 0u;
while (i < num_to_insert) {
- log "get(" + _uint.to_str(i, 10u) + ") = "
- + _uint.to_str(hm_uu.get(i), 10u);
+ log "get(" + UInt.to_str(i, 10u) + ") = "
+ + UInt.to_str(hm_uu.get(i), 10u);
assert (hm_uu.get(i) == i * i);
i += 1u;
}
@@ -169,16 +169,16 @@ fn test_growth() {
log "str -> str";
- let map.hashfn[str] hasher_str = _str.hash;
- let map.eqfn[str] eqer_str = _str.eq;
- let map.hashmap[str, str] hm_ss = map.mk_hashmap[str, str](hasher_str,
+ let Map.hashfn[str] hasher_str = Str.hash;
+ let Map.eqfn[str] eqer_str = Str.eq;
+ let Map.hashmap[str, str] hm_ss = Map.mk_hashmap[str, str](hasher_str,
eqer_str);
i = 0u;
while (i < num_to_insert) {
- assert (hm_ss.insert(_uint.to_str(i, 2u), _uint.to_str(i * i, 2u)));
- log "inserting \"" + _uint.to_str(i, 2u)
- + "\" -> \"" + _uint.to_str(i * i, 2u) + "\"";
+ assert (hm_ss.insert(UInt.to_str(i, 2u), UInt.to_str(i * i, 2u)));
+ log "inserting \"" + UInt.to_str(i, 2u)
+ + "\" -> \"" + UInt.to_str(i * i, 2u) + "\"";
i += 1u;
}
@@ -187,20 +187,20 @@ fn test_growth() {
i = 0u;
while (i < num_to_insert) {
log "get(\""
- + _uint.to_str(i, 2u)
+ + UInt.to_str(i, 2u)
+ "\") = \""
- + hm_ss.get(_uint.to_str(i, 2u)) + "\"";
+ + hm_ss.get(UInt.to_str(i, 2u)) + "\"";
- assert (_str.eq(hm_ss.get(_uint.to_str(i, 2u)),
- _uint.to_str(i * i, 2u)));
+ assert (Str.eq(hm_ss.get(UInt.to_str(i, 2u)),
+ UInt.to_str(i * i, 2u)));
i += 1u;
}
- assert (hm_ss.insert(_uint.to_str(num_to_insert, 2u),
- _uint.to_str(17u, 2u)));
+ assert (hm_ss.insert(UInt.to_str(num_to_insert, 2u),
+ UInt.to_str(17u, 2u)));
- assert (_str.eq(hm_ss.get(_uint.to_str(num_to_insert, 2u)),
- _uint.to_str(17u, 2u)));
+ assert (Str.eq(hm_ss.get(UInt.to_str(num_to_insert, 2u)),
+ UInt.to_str(17u, 2u)));
log "-----";
@@ -208,10 +208,10 @@ fn test_growth() {
i = 0u;
while (i < num_to_insert) {
- log "get(\"" + _uint.to_str(i, 2u) + "\") = \""
- + hm_ss.get(_uint.to_str(i, 2u)) + "\"";
- assert (_str.eq(hm_ss.get(_uint.to_str(i, 2u)),
- _uint.to_str(i * i, 2u)));
+ log "get(\"" + UInt.to_str(i, 2u) + "\") = \""
+ + hm_ss.get(UInt.to_str(i, 2u)) + "\"";
+ assert (Str.eq(hm_ss.get(UInt.to_str(i, 2u)),
+ UInt.to_str(i * i, 2u)));
i += 1u;
}
@@ -234,15 +234,15 @@ fn test_removal() {
assert (hash(2u) == hash(3u));
assert (hash(0u) != hash(2u));
- let map.hashfn[uint] hasher = hash;
- let map.eqfn[uint] eqer = eq;
- let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
+ let Map.hashfn[uint] hasher = hash;
+ let Map.eqfn[uint] eqer = eq;
+ let Map.hashmap[uint, uint] hm = Map.mk_hashmap[uint, uint](hasher, eqer);
let uint i = 0u;
while (i < num_to_insert) {
assert (hm.insert(i, i * i));
- log "inserting " + _uint.to_str(i, 10u)
- + " -> " + _uint.to_str(i * i, 10u);
+ log "inserting " + UInt.to_str(i, 10u)
+ + " -> " + UInt.to_str(i * i, 10u);
i += 1u;
}
@@ -279,8 +279,8 @@ fn test_removal() {
i = 1u;
while (i < num_to_insert) {
- log "get(" + _uint.to_str(i, 10u) + ") = "
- + _uint.to_str(hm.get(i), 10u);
+ log "get(" + UInt.to_str(i, 10u) + ") = "
+ + UInt.to_str(hm.get(i), 10u);
assert (hm.get(i) == i * i);
i += 2u;
}
@@ -294,8 +294,8 @@ fn test_removal() {
i = 1u;
while (i < num_to_insert) {
- log "get(" + _uint.to_str(i, 10u) + ") = "
- + _uint.to_str(hm.get(i), 10u);
+ log "get(" + UInt.to_str(i, 10u) + ") = "
+ + UInt.to_str(hm.get(i), 10u);
assert (hm.get(i) == i * i);
i += 2u;
}
@@ -305,8 +305,8 @@ fn test_removal() {
i = 0u;
while (i < num_to_insert) {
assert (hm.insert(i, i * i));
- log "inserting " + _uint.to_str(i, 10u)
- + " -> " + _uint.to_str(i * i, 10u);
+ log "inserting " + UInt.to_str(i, 10u)
+ + " -> " + UInt.to_str(i * i, 10u);
i += 2u;
}
@@ -316,8 +316,8 @@ fn test_removal() {
i = 0u;
while (i < num_to_insert) {
- log "get(" + _uint.to_str(i, 10u) + ") = "
- + _uint.to_str(hm.get(i), 10u);
+ log "get(" + UInt.to_str(i, 10u) + ") = "
+ + UInt.to_str(hm.get(i), 10u);
assert (hm.get(i) == i * i);
i += 1u;
}
@@ -333,8 +333,8 @@ fn test_removal() {
i = 0u;
while (i < num_to_insert) {
- log "get(" + _uint.to_str(i, 10u) + ") = "
- + _uint.to_str(hm.get(i), 10u);
+ log "get(" + UInt.to_str(i, 10u) + ") = "
+ + UInt.to_str(hm.get(i), 10u);
assert (hm.get(i) == i * i);
i += 1u;
}
diff --git a/src/test/run-pass/lib-option.rs b/src/test/run-pass/lib-option.rs
index 922072e5759a..417ab482764f 100644
--- a/src/test/run-pass/lib-option.rs
+++ b/src/test/run-pass/lib-option.rs
@@ -1,5 +1,5 @@
use std;
fn main() {
- auto x = std.option.some[int](10);
+ auto x = std.Option.some[int](10);
}
diff --git a/src/test/run-pass/lib-qsort.rs b/src/test/run-pass/lib-qsort.rs
index f7f0f99782c2..aed5009dd24a 100644
--- a/src/test/run-pass/lib-qsort.rs
+++ b/src/test/run-pass/lib-qsort.rs
@@ -1,13 +1,13 @@
use std;
fn check_sort(vec[mutable int] v1, vec[mutable int] v2) {
- auto len = std._vec.len[int](v1);
+ auto len = std.Vec.len[int](v1);
fn ltequal(&int a, &int b) -> bool {
ret a <= b;
}
auto f = ltequal;
- std.sort.quick_sort[int](f, v1);
+ std.Sort.quick_sort[int](f, v1);
auto i = 0u;
while (i < len) {
log v2.(i);
diff --git a/src/test/run-pass/lib-rand.rs b/src/test/run-pass/lib-rand.rs
index 3ef949733f71..e423bcba53f4 100644
--- a/src/test/run-pass/lib-rand.rs
+++ b/src/test/run-pass/lib-rand.rs
@@ -4,14 +4,14 @@
// -*- rust -*-
use std;
-import std.rand;
+import std.Rand;
fn main() {
- let rand.rng r1 = rand.mk_rng();
+ let Rand.rng r1 = Rand.mk_rng();
log r1.next();
log r1.next();
{
- auto r2 = rand.mk_rng();
+ auto r2 = Rand.mk_rng();
log r1.next();
log r2.next();
log r1.next();
diff --git a/src/test/run-pass/lib-sha1.rs b/src/test/run-pass/lib-sha1.rs
index 7e8efb5eba74..2a7e8646a631 100644
--- a/src/test/run-pass/lib-sha1.rs
+++ b/src/test/run-pass/lib-sha1.rs
@@ -2,9 +2,9 @@
use std;
-import std.sha1;
-import std._vec;
-import std._str;
+import std.SHA1;
+import std.Vec;
+import std.Str;
fn main() {
@@ -69,8 +69,8 @@ fn main() {
auto tests = fips_180_1_tests + wikipedia_tests;
fn check_vec_eq(vec[u8] v0, vec[u8] v1) {
- assert (_vec.len[u8](v0) == _vec.len[u8](v1));
- auto len = _vec.len[u8](v0);
+ assert (Vec.len[u8](v0) == Vec.len[u8](v1));
+ auto len = Vec.len[u8](v0);
auto i = 0u;
while (i < len) {
auto a = v0.(i);
@@ -81,7 +81,7 @@ fn main() {
}
// Test that it works when accepting the message all at once
- auto sh = sha1.mk_sha1();
+ auto sh = SHA1.mk_sha1();
for (test t in tests) {
sh.input_str(t.input);
auto out = sh.result();
@@ -91,11 +91,11 @@ fn main() {
// Test that it works when accepting the message in pieces
for (test t in tests) {
- auto len = _str.byte_len(t.input);
+ auto len = Str.byte_len(t.input);
auto left = len;
while (left > 0u) {
auto take = (left + 1u) / 2u;
- sh.input_str(_str.substr(t.input, len - left, take));
+ sh.input_str(Str.substr(t.input, len - left, take));
left = left - take;
}
auto out = sh.result();
diff --git a/src/test/run-pass/lib-sort.rs b/src/test/run-pass/lib-sort.rs
index a342b24eb566..145d0175ddb9 100644
--- a/src/test/run-pass/lib-sort.rs
+++ b/src/test/run-pass/lib-sort.rs
@@ -1,12 +1,12 @@
use std;
fn check_sort(vec[int] v1, vec[int] v2) {
- auto len = std._vec.len[int](v1);
+ auto len = std.Vec.len[int](v1);
fn lteq(&int a, &int b) -> bool {
ret a <= b;
}
auto f = lteq;
- auto v3 = std.sort.merge_sort[int](f, v1);
+ auto v3 = std.Sort.merge_sort[int](f, v1);
auto i = 0u;
while (i < len) {
log v3.(i);
diff --git a/src/test/run-pass/lib-str-buf.rs b/src/test/run-pass/lib-str-buf.rs
index 1f25373a4a01..cd8ba9e9fd01 100644
--- a/src/test/run-pass/lib-str-buf.rs
+++ b/src/test/run-pass/lib-str-buf.rs
@@ -4,14 +4,14 @@
// -*- rust -*-
use std;
-import std._str;
+import std.Str;
fn main() {
auto s = "hello";
- auto sb = _str.rustrt.str_buf(s);
- auto s_cstr = _str.rustrt.str_from_cstr(sb);
- assert (_str.eq(s_cstr, s));
- auto s_buf = _str.rustrt.str_from_buf(sb, 5u);
- assert (_str.eq(s_buf, s));
+ auto sb = Str.rustrt.str_buf(s);
+ auto s_cstr = Str.rustrt.str_from_cstr(sb);
+ assert (Str.eq(s_cstr, s));
+ auto s_buf = Str.rustrt.str_from_buf(sb, 5u);
+ assert (Str.eq(s_buf, s));
}
diff --git a/src/test/run-pass/lib-str.rs b/src/test/run-pass/lib-str.rs
index 767177111b2b..58779f674e3f 100644
--- a/src/test/run-pass/lib-str.rs
+++ b/src/test/run-pass/lib-str.rs
@@ -1,36 +1,36 @@
use std;
-import std._str;
+import std.Str;
fn test_bytes_len() {
- assert (_str.byte_len("") == 0u);
- assert (_str.byte_len("hello world") == 11u);
- assert (_str.byte_len("\x63") == 1u);
- assert (_str.byte_len("\xa2") == 2u);
- assert (_str.byte_len("\u03c0") == 2u);
- assert (_str.byte_len("\u2620") == 3u);
- assert (_str.byte_len("\U0001d11e") == 4u);
+ assert (Str.byte_len("") == 0u);
+ assert (Str.byte_len("hello world") == 11u);
+ assert (Str.byte_len("\x63") == 1u);
+ assert (Str.byte_len("\xa2") == 2u);
+ assert (Str.byte_len("\u03c0") == 2u);
+ assert (Str.byte_len("\u2620") == 3u);
+ assert (Str.byte_len("\U0001d11e") == 4u);
}
fn test_index_and_rindex() {
- assert (_str.index("hello", 'e' as u8) == 1);
- assert (_str.index("hello", 'o' as u8) == 4);
- assert (_str.index("hello", 'z' as u8) == -1);
- assert (_str.rindex("hello", 'l' as u8) == 3);
- assert (_str.rindex("hello", 'h' as u8) == 0);
- assert (_str.rindex("hello", 'z' as u8) == -1);
+ assert (Str.index("hello", 'e' as u8) == 1);
+ assert (Str.index("hello", 'o' as u8) == 4);
+ assert (Str.index("hello", 'z' as u8) == -1);
+ assert (Str.rindex("hello", 'l' as u8) == 3);
+ assert (Str.rindex("hello", 'h' as u8) == 0);
+ assert (Str.rindex("hello", 'z' as u8) == -1);
}
fn test_split() {
fn t(&str s, char c, int i, &str k) {
log "splitting: " + s;
log i;
- auto v = _str.split(s, c as u8);
+ auto v = Str.split(s, c as u8);
log "split to: ";
for (str z in v) {
log z;
}
log "comparing: " + v.(i) + " vs. " + k;
- assert (_str.eq(v.(i), k));
+ assert (Str.eq(v.(i), k));
}
t("abc.hello.there", '.', 0, "abc");
t("abc.hello.there", '.', 1, "hello");
@@ -43,7 +43,7 @@ fn test_split() {
fn test_find() {
fn t(&str haystack, &str needle, int i) {
- let int j = _str.find(haystack,needle);
+ let int j = Str.find(haystack,needle);
log "searched for " + needle;
log j;
assert (i == j);
@@ -57,8 +57,8 @@ fn test_find() {
fn test_substr() {
fn t(&str a, &str b, int start) {
- assert (_str.eq(_str.substr(a, start as uint,
- _str.byte_len(b)), b));
+ assert (Str.eq(Str.substr(a, start as uint,
+ Str.byte_len(b)), b));
}
t("hello", "llo", 2);
@@ -68,7 +68,7 @@ fn test_substr() {
fn test_concat() {
fn t(&vec[str] v, &str s) {
- assert (_str.eq(_str.concat(v), s));
+ assert (Str.eq(Str.concat(v), s));
}
t(vec("you", "know", "I'm", "no", "good"), "youknowI'mnogood");
@@ -79,7 +79,7 @@ fn test_concat() {
fn test_connect() {
fn t(&vec[str] v, &str sep, &str s) {
- assert (_str.eq(_str.connect(v, sep), s));
+ assert (Str.eq(Str.connect(v, sep), s));
}
t(vec("you", "know", "I'm", "no", "good"), " ", "you know I'm no good");
@@ -94,8 +94,8 @@ fn test_to_upper() {
auto unicode = "\u65e5\u672c";
auto input = "abcDEF" + unicode + "xyz:.;";
auto expected = "ABCDEF" + unicode + "XYZ:.;";
- auto actual = _str.to_upper(input);
- assert (_str.eq(expected, actual));
+ auto actual = Str.to_upper(input);
+ assert (Str.eq(expected, actual));
}
diff --git a/src/test/run-pass/lib-task.rs b/src/test/run-pass/lib-task.rs
index 18499f4e5d03..8e07962ce9e4 100644
--- a/src/test/run-pass/lib-task.rs
+++ b/src/test/run-pass/lib-task.rs
@@ -1,6 +1,6 @@
use std;
-import std._task;
+import std.Task;
fn main() {
- _task.sleep(1000000u);
+ Task.sleep(1000000u);
}
\ No newline at end of file
diff --git a/src/test/run-pass/lib-uint.rs b/src/test/run-pass/lib-uint.rs
index 64d39619f0b7..4f7877450811 100644
--- a/src/test/run-pass/lib-uint.rs
+++ b/src/test/run-pass/lib-uint.rs
@@ -1,47 +1,47 @@
// -*- rust -*-
use std;
-import std._uint;
+import std.UInt;
fn main() {
- assert (_uint.next_power_of_two(0u) == 0u);
- assert (_uint.next_power_of_two(1u) == 1u);
- assert (_uint.next_power_of_two(2u) == 2u);
- assert (_uint.next_power_of_two(3u) == 4u);
- assert (_uint.next_power_of_two(4u) == 4u);
- assert (_uint.next_power_of_two(5u) == 8u);
- assert (_uint.next_power_of_two(6u) == 8u);
- assert (_uint.next_power_of_two(7u) == 8u);
- assert (_uint.next_power_of_two(8u) == 8u);
- assert (_uint.next_power_of_two(9u) == 16u);
- assert (_uint.next_power_of_two(10u) == 16u);
- assert (_uint.next_power_of_two(11u) == 16u);
- assert (_uint.next_power_of_two(12u) == 16u);
- assert (_uint.next_power_of_two(13u) == 16u);
- assert (_uint.next_power_of_two(14u) == 16u);
- assert (_uint.next_power_of_two(15u) == 16u);
- assert (_uint.next_power_of_two(16u) == 16u);
- assert (_uint.next_power_of_two(17u) == 32u);
- assert (_uint.next_power_of_two(18u) == 32u);
- assert (_uint.next_power_of_two(19u) == 32u);
- assert (_uint.next_power_of_two(20u) == 32u);
- assert (_uint.next_power_of_two(21u) == 32u);
- assert (_uint.next_power_of_two(22u) == 32u);
- assert (_uint.next_power_of_two(23u) == 32u);
- assert (_uint.next_power_of_two(24u) == 32u);
- assert (_uint.next_power_of_two(25u) == 32u);
- assert (_uint.next_power_of_two(26u) == 32u);
- assert (_uint.next_power_of_two(27u) == 32u);
- assert (_uint.next_power_of_two(28u) == 32u);
- assert (_uint.next_power_of_two(29u) == 32u);
- assert (_uint.next_power_of_two(30u) == 32u);
- assert (_uint.next_power_of_two(31u) == 32u);
- assert (_uint.next_power_of_two(32u) == 32u);
- assert (_uint.next_power_of_two(33u) == 64u);
- assert (_uint.next_power_of_two(34u) == 64u);
- assert (_uint.next_power_of_two(35u) == 64u);
- assert (_uint.next_power_of_two(36u) == 64u);
- assert (_uint.next_power_of_two(37u) == 64u);
- assert (_uint.next_power_of_two(38u) == 64u);
- assert (_uint.next_power_of_two(39u) == 64u);
+ assert (UInt.next_power_of_two(0u) == 0u);
+ assert (UInt.next_power_of_two(1u) == 1u);
+ assert (UInt.next_power_of_two(2u) == 2u);
+ assert (UInt.next_power_of_two(3u) == 4u);
+ assert (UInt.next_power_of_two(4u) == 4u);
+ assert (UInt.next_power_of_two(5u) == 8u);
+ assert (UInt.next_power_of_two(6u) == 8u);
+ assert (UInt.next_power_of_two(7u) == 8u);
+ assert (UInt.next_power_of_two(8u) == 8u);
+ assert (UInt.next_power_of_two(9u) == 16u);
+ assert (UInt.next_power_of_two(10u) == 16u);
+ assert (UInt.next_power_of_two(11u) == 16u);
+ assert (UInt.next_power_of_two(12u) == 16u);
+ assert (UInt.next_power_of_two(13u) == 16u);
+ assert (UInt.next_power_of_two(14u) == 16u);
+ assert (UInt.next_power_of_two(15u) == 16u);
+ assert (UInt.next_power_of_two(16u) == 16u);
+ assert (UInt.next_power_of_two(17u) == 32u);
+ assert (UInt.next_power_of_two(18u) == 32u);
+ assert (UInt.next_power_of_two(19u) == 32u);
+ assert (UInt.next_power_of_two(20u) == 32u);
+ assert (UInt.next_power_of_two(21u) == 32u);
+ assert (UInt.next_power_of_two(22u) == 32u);
+ assert (UInt.next_power_of_two(23u) == 32u);
+ assert (UInt.next_power_of_two(24u) == 32u);
+ assert (UInt.next_power_of_two(25u) == 32u);
+ assert (UInt.next_power_of_two(26u) == 32u);
+ assert (UInt.next_power_of_two(27u) == 32u);
+ assert (UInt.next_power_of_two(28u) == 32u);
+ assert (UInt.next_power_of_two(29u) == 32u);
+ assert (UInt.next_power_of_two(30u) == 32u);
+ assert (UInt.next_power_of_two(31u) == 32u);
+ assert (UInt.next_power_of_two(32u) == 32u);
+ assert (UInt.next_power_of_two(33u) == 64u);
+ assert (UInt.next_power_of_two(34u) == 64u);
+ assert (UInt.next_power_of_two(35u) == 64u);
+ assert (UInt.next_power_of_two(36u) == 64u);
+ assert (UInt.next_power_of_two(37u) == 64u);
+ assert (UInt.next_power_of_two(38u) == 64u);
+ assert (UInt.next_power_of_two(39u) == 64u);
}
diff --git a/src/test/run-pass/lib-vec-str-conversions.rs b/src/test/run-pass/lib-vec-str-conversions.rs
index 3724d627b498..cd8b64a889e2 100644
--- a/src/test/run-pass/lib-vec-str-conversions.rs
+++ b/src/test/run-pass/lib-vec-str-conversions.rs
@@ -1,8 +1,8 @@
// -*- rust -*-
use std;
-import std._str;
-import std._vec;
+import std.Str;
+import std.Vec;
fn test_simple() {
let str s1 = "All mimsy were the borogoves";
@@ -14,12 +14,12 @@ fn test_simple() {
* working, but we should implement is_utf8 before that happens.
*/
- let vec[u8] v = _str.bytes(s1);
- let str s2 = _str.from_bytes(v);
+ let vec[u8] v = Str.bytes(s1);
+ let str s2 = Str.from_bytes(v);
let uint i = 0u;
- let uint n1 = _str.byte_len(s1);
- let uint n2 = _vec.len[u8](v);
+ let uint n1 = Str.byte_len(s1);
+ let uint n2 = Vec.len[u8](v);
assert (n1 == n2);
@@ -33,7 +33,7 @@ fn test_simple() {
}
log "refcnt is";
- log _str.refcount(s1);
+ log Str.refcount(s1);
}
fn main() {
diff --git a/src/test/run-pass/lib-vec.rs b/src/test/run-pass/lib-vec.rs
index 51341039c691..0905652a5d00 100644
--- a/src/test/run-pass/lib-vec.rs
+++ b/src/test/run-pass/lib-vec.rs
@@ -1,8 +1,8 @@
use std;
fn test_init_elt() {
- let vec[uint] v = std._vec.init_elt[uint](5u, 3u);
- assert (std._vec.len[uint](v) == 3u);
+ let vec[uint] v = std.Vec.init_elt[uint](5u, 3u);
+ assert (std.Vec.len[uint](v) == 3u);
assert (v.(0) == 5u);
assert (v.(1) == 5u);
assert (v.(2) == 5u);
@@ -13,8 +13,8 @@ fn id(uint x) -> uint {
}
fn test_init_fn() {
let fn(uint)->uint op = id;
- let vec[uint] v = std._vec.init_fn[uint](op, 5u);
- assert (std._vec.len[uint](v) == 5u);
+ let vec[uint] v = std.Vec.init_fn[uint](op, 5u);
+ assert (std.Vec.len[uint](v) == 5u);
assert (v.(0) == 0u);
assert (v.(1) == 1u);
assert (v.(2) == 2u);
@@ -24,17 +24,17 @@ fn test_init_fn() {
fn test_slice() {
let vec[int] v = vec(1,2,3,4,5);
- auto v2 = std._vec.slice[int](v, 2u, 4u);
- assert (std._vec.len[int](v2) == 2u);
+ auto v2 = std.Vec.slice[int](v, 2u, 4u);
+ assert (std.Vec.len[int](v2) == 2u);
assert (v2.(0) == 3);
assert (v2.(1) == 4);
}
fn test_map() {
fn square(&int x) -> int { ret x * x; }
- let std.option.operator[int, int] op = square;
+ let std.Option.operator[int, int] op = square;
let vec[int] v = vec(1, 2, 3, 4, 5);
- let vec[int] s = std._vec.map[int, int](op, v);
+ let vec[int] s = std.Vec.map[int, int](op, v);
let int i = 0;
while (i < 5) {
assert (v.(i) * v.(i) == s.(i));
@@ -47,7 +47,7 @@ fn test_map2() {
auto f = times;
auto v0 = vec(1, 2, 3, 4, 5);
auto v1 = vec(5, 4, 3, 2, 1);
- auto u = std._vec.map2[int,int,int](f, v0, v1);
+ auto u = std.Vec.map2[int,int,int](f, v0, v1);
auto i = 0;
while (i < 5) {
diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs
index 7c41e4b56760..b5eff76f4dc2 100644
--- a/src/test/run-pass/mlist-cycle.rs
+++ b/src/test/run-pass/mlist-cycle.rs
@@ -16,6 +16,6 @@ fn main() {
let @cell first = @tup(mutable @nil());
let @cell second = @tup(mutable @link(first));
first._0 = @link(second);
- std.sys.rustrt.gc();
+ std.Sys.rustrt.gc();
let @cell third = @tup(mutable @nil());
}
diff --git a/src/test/run-pass/mutable-alias-vec.rs b/src/test/run-pass/mutable-alias-vec.rs
index 71d4dfe927d0..5919abdc5d4b 100644
--- a/src/test/run-pass/mutable-alias-vec.rs
+++ b/src/test/run-pass/mutable-alias-vec.rs
@@ -11,7 +11,7 @@ fn main() {
grow(v);
grow(v);
grow(v);
- auto len = std._vec.len[int](v);
+ auto len = std.Vec.len[int](v);
log len;
assert (len == (3 as uint));
}
diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs
index e59c2dd5a416..cb244cc8b100 100644
--- a/src/test/run-pass/nested-pattern.rs
+++ b/src/test/run-pass/nested-pattern.rs
@@ -1,13 +1,13 @@
// a bug was causing this to complain about leaked memory on exit
use std;
-import std.option;
-import std.option.some;
-import std.option.none;
+import std.Option;
+import std.Option.some;
+import std.Option.none;
tag t {
foo(int, uint);
- bar(int, option.t[int]);
+ bar(int, Option.t[int]);
}
fn nested(t o) {
diff --git a/src/test/run-pass/rt-circular-buffer.rs b/src/test/run-pass/rt-circular-buffer.rs
index cd808ad733de..b6c545b2782b 100644
--- a/src/test/run-pass/rt-circular-buffer.rs
+++ b/src/test/run-pass/rt-circular-buffer.rs
@@ -5,9 +5,9 @@
use std;
-import std.option;
-import std._uint;
-import std._vec;
+import std.Option;
+import std.UInt;
+import std.Vec;
// A 12-byte unit to send over the channel
type record = rec(u32 val1, u32 val2, u32 val3);
@@ -33,7 +33,7 @@ fn test_grow() {
let record val = rec(val1=0u32, val2=0u32, val3=0u32);
- for each (uint i in _uint.range(0u, 100u)) {
+ for each (uint i in UInt.range(0u, 100u)) {
mychan <| val;
}
}
@@ -53,11 +53,11 @@ fn test_shrink2() {
let record val = rec(val1=0u32, val2=0u32, val3=0u32);
- for each (uint i in _uint.range(0u, 100u)) {
+ for each (uint i in UInt.range(0u, 100u)) {
mychan <| val;
}
- for each (uint i in _uint.range(0u, 100u)) {
+ for each (uint i in UInt.range(0u, 100u)) {
auto x <- myport;
}
}
@@ -67,7 +67,7 @@ fn test_rotate() {
let port[record] myport = port();
auto mychan = chan(myport);
- for each (uint i in _uint.range(0u, 100u)) {
+ for each (uint i in UInt.range(0u, 100u)) {
auto val = rec(val1=i as u32,
val2=i as u32,
val3=i as u32);
@@ -86,15 +86,15 @@ fn test_rotate_grow() {
let port[record] myport = port();
auto mychan = chan(myport);
- for each (uint j in _uint.range(0u, 10u)) {
- for each (uint i in _uint.range(0u, 10u)) {
+ for each (uint j in UInt.range(0u, 10u)) {
+ for each (uint i in UInt.range(0u, 10u)) {
let record val = rec(val1=i as u32,
val2=i as u32,
val3=i as u32);
mychan <| val;
}
- for each (uint i in _uint.range(0u, 10u)) {
+ for each (uint i in UInt.range(0u, 10u)) {
auto x <- myport;
assert (x.val1 == i as u32);
assert (x.val2 == i as u32);
diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs
index abfbe938e223..afca72a8d1da 100644
--- a/src/test/run-pass/str-append.rs
+++ b/src/test/run-pass/str-append.rs
@@ -1,7 +1,7 @@
// -*- rust -*-
use std;
-import std._str;
+import std.Str;
fn test1() {
let str s = "hello";
@@ -20,8 +20,8 @@ fn test2() {
log a;
log b;
- assert (_str.eq(a, "abcABCabc"));
- assert (_str.eq(b, "ABCabcABC"));
+ assert (Str.eq(a, "abcABCabc"));
+ assert (Str.eq(b, "ABCabcABC"));
}
fn main() {
diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs
index bb0c851fe135..08a8c4996684 100644
--- a/src/test/run-pass/syntax-extension-fmt.rs
+++ b/src/test/run-pass/syntax-extension-fmt.rs
@@ -3,12 +3,12 @@
// xfail-stage1
// xfail-stage2
use std;
-import std._str;
+import std.Str;
fn test(str actual, str expected) {
log actual;
log expected;
- assert (_str.eq(actual, expected));
+ assert (Str.eq(actual, expected));
}
fn main() {
diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs
index 2f8ef9856887..d4a135c2a39e 100644
--- a/src/test/run-pass/task-comm-12.rs
+++ b/src/test/run-pass/task-comm-12.rs
@@ -3,7 +3,7 @@
// xfail-stage1
// xfail-stage2
use std;
-import std._task;
+import std.Task;
fn main() -> () {
test00();
@@ -18,7 +18,7 @@ fn test00() {
let task t = spawn thread "child" start(i);
// Sleep long enough for the task to finish.
- _task.sleep(10000u);
+ Task.sleep(10000u);
// Try joining tasks that have already finished.
join t;
diff --git a/src/test/run-pass/task-comm-13-thread.rs b/src/test/run-pass/task-comm-13-thread.rs
index e5e420105a07..fedc516bd59a 100644
--- a/src/test/run-pass/task-comm-13-thread.rs
+++ b/src/test/run-pass/task-comm-13-thread.rs
@@ -2,7 +2,7 @@
// xfail-stage1
// xfail-stage2
use std;
-import std._task;
+import std.Task;
fn start(chan[int] c, int start, int number_of_messages) {
let int i = 0;
diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs
index bcae26e54cd6..1bf5d1f56f63 100644
--- a/src/test/run-pass/task-comm-13.rs
+++ b/src/test/run-pass/task-comm-13.rs
@@ -2,7 +2,7 @@
// xfail-stage1
// xfail-stage2
use std;
-import std._task;
+import std.Task;
fn start(chan[int] c, int start, int number_of_messages) {
let int i = 0;
diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs
index e416e9b561a7..d39a2064828a 100644
--- a/src/test/run-pass/type-sizes.rs
+++ b/src/test/run-pass/type-sizes.rs
@@ -2,7 +2,7 @@
// xfail-stage1
// xfail-stage2
-import size_of = std.sys.rustrt.size_of;
+import size_of = std.Sys.rustrt.size_of;
use std;
diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs
index 37cfe0747c3f..3d1a6947f7cb 100644
--- a/src/test/run-pass/use.rs
+++ b/src/test/run-pass/use.rs
@@ -7,8 +7,8 @@ use zed(name = "std");
use bar(name = "std", ver = "0.0.1");
// FIXME: commented out since resolve doesn't know how to handle crates yet.
-// import std._str;
-// import x = std._str;
+// import std.Str;
+// import x = std.Str;
mod baz {
use std;
@@ -16,8 +16,8 @@ mod baz {
use zed(name = "std");
use bar(name = "std", ver = "0.0.1");
- // import std._str;
- // import x = std._str;
+ // import std.Str;
+ // import x = std.Str;
}
fn main() {
diff --git a/src/test/run-pass/user.rs b/src/test/run-pass/user.rs
index 679d3e485e04..877c416bbb35 100644
--- a/src/test/run-pass/user.rs
+++ b/src/test/run-pass/user.rs
@@ -8,10 +8,10 @@ use std (name = "std",
uuid = _, ver = _);
fn main() {
- auto s = std._str.alloc(10 as uint);
+ auto s = std.Str.alloc(10 as uint);
s += "hello ";
log s;
s += "there";
log s;
- auto z = std._vec.alloc[int](10 as uint);
+ auto z = std.Vec.alloc[int](10 as uint);
}
diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs
index e2df05dc7f02..95cbc64e0ab6 100644
--- a/src/test/run-pass/utf8_chars.rs
+++ b/src/test/run-pass/utf8_chars.rs
@@ -2,34 +2,34 @@
// xfail-stage1
// xfail-stage2
use std;
-import std._str;
-import std._vec;
-import std.io;
+import std.Str;
+import std.Vec;
+import std.IO;
fn main() {
// Chars of 1, 2, 3, and 4 bytes
let vec[char] chs = vec('e', 'é', '€', 0x10000 as char);
- let str s = _str.from_chars(chs);
+ let str s = Str.from_chars(chs);
- assert (_str.byte_len(s) == 10u);
- assert (_str.char_len(s) == 4u);
- assert (_vec.len[char](_str.to_chars(s)) == 4u);
- assert (_str.eq(_str.from_chars(_str.to_chars(s)), s));
- assert (_str.char_at(s, 0u) == 'e');
- assert (_str.char_at(s, 1u) == 'é');
+ assert (Str.byte_len(s) == 10u);
+ assert (Str.char_len(s) == 4u);
+ assert (Vec.len[char](Str.to_chars(s)) == 4u);
+ assert (Str.eq(Str.from_chars(Str.to_chars(s)), s));
+ assert (Str.char_at(s, 0u) == 'e');
+ assert (Str.char_at(s, 1u) == 'é');
- assert (_str.is_utf8(_str.bytes(s)));
- assert (!_str.is_utf8(vec(0x80_u8)));
- assert (!_str.is_utf8(vec(0xc0_u8)));
- assert (!_str.is_utf8(vec(0xc0_u8, 0x10_u8)));
+ assert (Str.is_utf8(Str.bytes(s)));
+ assert (!Str.is_utf8(vec(0x80_u8)));
+ assert (!Str.is_utf8(vec(0xc0_u8)));
+ assert (!Str.is_utf8(vec(0xc0_u8, 0x10_u8)));
auto stack = "a×c€";
- assert (_str.pop_char(stack) == '€');
- assert (_str.pop_char(stack) == 'c');
- _str.push_char(stack, 'u');
- assert (_str.eq(stack, "a×u"));
- assert (_str.shift_char(stack) == 'a');
- assert (_str.shift_char(stack) == '×');
- _str.unshift_char(stack, 'ß');
- assert (_str.eq(stack, "ßu"));
+ assert (Str.pop_char(stack) == '€');
+ assert (Str.pop_char(stack) == 'c');
+ Str.push_char(stack, 'u');
+ assert (Str.eq(stack, "a×u"));
+ assert (Str.shift_char(stack) == 'a');
+ assert (Str.shift_char(stack) == '×');
+ Str.unshift_char(stack, 'ß');
+ assert (Str.eq(stack, "ßu"));
}
diff --git a/src/test/run-pass/vec-alloc-append.rs b/src/test/run-pass/vec-alloc-append.rs
index 616823ae942d..4327e789cd57 100644
--- a/src/test/run-pass/vec-alloc-append.rs
+++ b/src/test/run-pass/vec-alloc-append.rs
@@ -6,7 +6,7 @@
use std;
fn slice[T](vec[T] e) {
- let vec[T] result = std._vec.alloc[T](1 as uint);
+ let vec[T] result = std.Vec.alloc[T](1 as uint);
log "alloced";
result += e;
log "appended";
diff --git a/src/test/run-pass/vec-append.rs b/src/test/run-pass/vec-append.rs
index e63b1d09d57a..cd87ec230cec 100644
--- a/src/test/run-pass/vec-append.rs
+++ b/src/test/run-pass/vec-append.rs
@@ -4,11 +4,11 @@
// -*- rust -*-
use std;
-import std._str;
-import std._vec;
+import std.Str;
+import std.Vec;
-// FIXME: import std.dbg.const_refcount. Currently
+// FIXME: import std.Dbg.const_refcount. Currently
// cross-crate const references don't work.
const uint const_refcount = 0x7bad_face_u;
@@ -53,30 +53,30 @@ fn slow_growth2_helper(str s) { // ref up: s
let vec[str] v = vec(mumble); // ref up: v, mumble
let acc a = acc(v); // ref up: a, v
- log _vec.refcount[str](v);
- assert (_vec.refcount[str](v) == 2u);
+ log Vec.refcount[str](v);
+ assert (Vec.refcount[str](v) == 2u);
a.add(s); // ref up: mumble, s. ref down: v
- log _vec.refcount[str](v);
- log _str.refcount(s);
- log _str.refcount(mumble);
+ log Vec.refcount[str](v);
+ log Str.refcount(s);
+ log Str.refcount(mumble);
- assert (_vec.refcount[str](v) == 1u);
- assert (_str.refcount(s) == const_refcount);
- assert (_str.refcount(mumble) == const_refcount);
+ assert (Vec.refcount[str](v) == 1u);
+ assert (Str.refcount(s) == const_refcount);
+ assert (Str.refcount(mumble) == const_refcount);
log v.(0);
- log _vec.len[str](v);
- assert (_str.eq(v.(0), mumble));
- assert (_vec.len[str](v) == 1u);
+ log Vec.len[str](v);
+ assert (Str.eq(v.(0), mumble));
+ assert (Vec.len[str](v) == 1u);
} // ref down: a, mumble, s, v
- log _str.refcount(s);
- log _str.refcount(mumble);
+ log Str.refcount(s);
+ log Str.refcount(mumble);
- assert (_str.refcount(s) == const_refcount);
- assert (_str.refcount(mumble) == const_refcount);
+ assert (Str.refcount(s) == const_refcount);
+ assert (Str.refcount(mumble) == const_refcount);
log mumble;
log ss;
@@ -85,8 +85,8 @@ fn slow_growth2_helper(str s) { // ref up: s
fn slow_growth2() {
let str s = "hi"; // ref up: s
slow_growth2_helper(s);
- log _str.refcount(s);
- assert (_str.refcount(s) == const_refcount);
+ log Str.refcount(s);
+ assert (Str.refcount(s) == const_refcount);
}
fn main() {
diff --git a/src/test/run-pass/vec-ref-count.rs b/src/test/run-pass/vec-ref-count.rs
index 45f28f9bff29..4534a86195a2 100644
--- a/src/test/run-pass/vec-ref-count.rs
+++ b/src/test/run-pass/vec-ref-count.rs
@@ -1,12 +1,12 @@
use std;
-import std._vec;
+import std.Vec;
fn main() {
auto v = vec(1, 2, 3);
- log_err _vec.refcount[int](v);
- log_err _vec.refcount[int](v);
- log_err _vec.refcount[int](v);
- assert (_vec.refcount[int](v) == 1u || _vec.refcount[int](v) == 2u);
- assert (_vec.refcount[int](v) == 1u || _vec.refcount[int](v) == 2u);
+ log_err Vec.refcount[int](v);
+ log_err Vec.refcount[int](v);
+ log_err Vec.refcount[int](v);
+ assert (Vec.refcount[int](v) == 1u || Vec.refcount[int](v) == 2u);
+ assert (Vec.refcount[int](v) == 1u || Vec.refcount[int](v) == 2u);
}