type provided_metas =
{name: option::t[str],
vers: option::t[str],
- cmh_items: (@ast::meta_item)[]};
+ cmh_items: [@ast::meta_item]};
fn provided_link_metas(sess: &session::session, c: &ast::crate) ->
provided_metas {
let name: option::t[str] = none;
let vers: option::t[str] = none;
- let cmh_items: (@ast::meta_item)[] = ~[];
+ let cmh_items: [@ast::meta_item] = ~[];
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess, linkage_metas);
for meta: @ast::meta_item in linkage_metas {
ret hash;
}
-fn mangle(ss: &str[]) -> str {
+fn mangle(ss: &[str]) -> str {
// Follow C++ namespace-mangling style
let n = "_ZN"; // Begin name-sequence.
ret n;
}
-fn exported_name(path: &str[], hash: &str, vers: &str) -> str {
+fn exported_name(path: &[str], hash: &str, vers: &str) -> str {
// FIXME: versioning isn't working yet
ret mangle(path + ~[hash]); // + "@" + vers;
}
-fn mangle_exported_name(ccx: &@crate_ctxt, path: &str[], t: &ty::t) -> str {
+fn mangle_exported_name(ccx: &@crate_ctxt, path: &[str], t: &ty::t) -> str {
let hash = get_symbol_hash(ccx, t);
ret exported_name(path, hash, ccx.link_meta.vers);
}
ret mangle(~[name, s, hash]);
}
-fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &str[],
+fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[str],
flav: &str) -> str {
ret mangle(path + ~[ccx.names.next(flav)]);
}
-fn mangle_internal_name_by_path(ccx: &@crate_ctxt, path: &str[]) -> str {
+fn mangle_internal_name_by_path(ccx: &@crate_ctxt, path: &[str]) -> str {
ret mangle(path);
}
fn declare_upcalls(tn: type_names, tydesc_type: TypeRef,
taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls {
- fn decl(tn: type_names, llmod: ModuleRef, name: str, tys: TypeRef[],
+ fn decl(tn: type_names, llmod: ModuleRef, name: str, tys: [TypeRef],
rv: TypeRef) -> ValueRef {
- let arg_tys: TypeRef[] = ~[];
+ let arg_tys: [TypeRef] = ~[];
for t: TypeRef in tys { arg_tys += ~[t]; }
let fn_ty = T_fn(arg_tys, rv);
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
let d = bind decl_with_taskptr(taskptr_type, tn, llmod, _, _, _);
let dr = bind decl(tn, llmod, _, _, _);
- let empty_vec: TypeRef[] = ~[];
+ let empty_vec: [TypeRef] = ~[];
ret @{grow_task: dv("grow_task", ~[T_size_t()]),
log_int: dv("log_int", ~[T_i32(), T_i32()]),
log_float: dv("log_float", ~[T_i32(), T_f32()]),
time_passes: bool,
time_llvm_passes: bool,
output_type: back::link::output_type,
- library_search_paths: str[],
+ library_search_paths: [str],
sysroot: str,
cfg: ast::crate_cfg,
test: bool,
no_trans: bool
};
-type crate_metadata = {name: str, data: u8[]};
+type crate_metadata = {name: str, data: [u8]};
obj session(targ_cfg: @config,
opts: @options,
// From a list of crate attributes get only the meta_items that impact crate
// linkage
-fn find_linkage_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] {
- let metas: (@ast::meta_item)[] = ~[];
+fn find_linkage_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] {
+ let metas: [@ast::meta_item] = ~[];
for attr: ast::attribute in find_attrs_by_name(attrs, "link") {
alt attr.node.value.node {
ast::meta_list(_, items) { metas += items; }
}
// Search a list of attributes and return only those with a specific name
-fn find_attrs_by_name(attrs: &ast::attribute[], name: ast::ident) ->
- ast::attribute[] {
+fn find_attrs_by_name(attrs: &[ast::attribute], name: ast::ident) ->
+ [ast::attribute] {
let filter =
bind fn (a: &ast::attribute, name: ast::ident) ->
option::t[ast::attribute] {
get_meta_item_name(@attr.node.value)
}
-fn find_meta_items_by_name(metas: &(@ast::meta_item)[], name: ast::ident) ->
- (@ast::meta_item)[] {
+fn find_meta_items_by_name(metas: &[@ast::meta_item], name: ast::ident) ->
+ [@ast::meta_item] {
let filter =
bind fn (m: &@ast::meta_item, name: ast::ident) ->
option::t[@ast::meta_item] {
fn attr_meta(attr: &ast::attribute) -> @ast::meta_item { @attr.node.value }
// Get the meta_items from inside a vector of attributes
-fn attr_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] {
+fn attr_metas(attrs: &[ast::attribute]) -> [@ast::meta_item] {
let mitems = ~[];
for a: ast::attribute in attrs { mitems += ~[attr_meta(a)]; }
ret mitems;
}
}
-fn contains(haystack: &(@ast::meta_item)[], needle: @ast::meta_item) -> bool {
+fn contains(haystack: &[@ast::meta_item], needle: @ast::meta_item) -> bool {
log #fmt("looking for %s",
syntax::print::pprust::meta_item_to_str(*needle));
for item: @ast::meta_item in haystack {
ret false;
}
-fn contains_name(metas: &(@ast::meta_item)[], name: ast::ident) -> bool {
+fn contains_name(metas: &[@ast::meta_item], name: ast::ident) -> bool {
let matches = find_meta_items_by_name(metas, name);
ret ivec::len(matches) > 0u;
}
// FIXME: This needs to sort by meta_item variant in addition to the item name
-fn sort_meta_items(items: &(@ast::meta_item)[]) -> (@ast::meta_item)[] {
+fn sort_meta_items(items: &[@ast::meta_item]) -> [@ast::meta_item] {
fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool {
fn key(m: &@ast::meta_item) -> ast::ident {
alt m.node {
}
// This is sort of stupid here, converting to a vec of mutables and back
- let v: (@ast::meta_item)[mutable ] = ~[mutable ];
+ let v: [mutable @ast::meta_item] = ~[mutable];
for mi: @ast::meta_item in items { v += ~[mutable mi]; }
std::sort::ivector::quick_sort(lteq, v);
- let v2: (@ast::meta_item)[] = ~[];
+ let v2: [@ast::meta_item] = ~[];
for mi: @ast::meta_item in v { v2 += ~[mi]; }
ret v2;
}
-fn remove_meta_items_by_name(items: &(@ast::meta_item)[], name: str) ->
- (@ast::meta_item)[] {
+fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) ->
+ [@ast::meta_item] {
let filter =
bind fn (item: &@ast::meta_item, name: str) ->
}
fn require_unique_names(sess: &session::session,
- metas: &(@ast::meta_item)[]) {
+ metas: &[@ast::meta_item]) {
let map = map::mk_hashmap[str, ()](str::hash, str::eq);
for meta: @ast::meta_item in metas {
let name = get_meta_item_name(meta);
ret @span(ast::meta_name_value(name, value));
}
-fn mk_list_item(name: ast::ident, items: &(@ast::meta_item)[]) ->
+fn mk_list_item(name: ast::ident, items: &[@ast::meta_item]) ->
@ast::meta_item {
ret @span(ast::meta_list(name, items));
}
// Determine if an item should be translated in the current crate
// configuration based on the item's attributes
-fn in_cfg(cfg: &ast::crate_cfg, attrs: &ast::attribute[]) -> bool {
+fn in_cfg(cfg: &ast::crate_cfg, attrs: &[ast::attribute]) -> bool {
// The "cfg" attributes on the item
let item_cfg_attrs = attr::find_attrs_by_name(attrs, "cfg");
// which the item is valid
let item_cfg_metas =
{
- fn extract_metas(inner_items: &(@ast::meta_item)[],
+ fn extract_metas(inner_items: &[@ast::meta_item],
cfg_item: &@ast::meta_item) ->
- (@ast::meta_item)[] {
+ [@ast::meta_item] {
alt cfg_item.node {
ast::meta_list(name, items) {
assert (name == "cfg");
type node_id_gen = @fn() -> ast::node_id ;
-type test = {path: ast::ident[], ignore: bool};
+type test = {path: [ast::ident], ignore: bool};
type test_ctxt =
@{next_node_id: node_id_gen,
- mutable path: ast::ident[],
- mutable testfns: test[]};
+ mutable path: [ast::ident],
+ mutable testfns: [test]};
// Traverse the crate, collecting all the test functions, eliding any
// existing main functions, and synthesizing a main test harness
std::test::test_main(args, tests())
}
- fn tests() -> std::test::test_desc[] {
+ fn tests() -> [std::test::test_desc] {
... the list of tests in the crate ...
}
}
ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs));
}
-// The ast::ty of std::test::test_desc[]
+// The ast::ty of [std::test::test_desc]
fn mk_test_desc_ivec_ty(cx: &test_ctxt) -> @ast::ty {
let test_desc_ty_path: ast::path =
nospan({global: false,
ret llvm::LLVMBuildRet(B, V);
}
- fn AggregateRet(RetVals: &ValueRef[]) -> ValueRef {
+ fn AggregateRet(RetVals: &[ValueRef]) -> ValueRef {
assert (!*terminated);
*terminated = true;
ret llvm::LLVMBuildAggregateRet(B, ivec::to_ptr(RetVals),
ret llvm::LLVMBuildIndirectBr(B, Addr, NumDests);
}
- fn Invoke(Fn: ValueRef, Args: &ValueRef[], Then: BasicBlockRef,
+ fn Invoke(Fn: ValueRef, Args: &[ValueRef], Then: BasicBlockRef,
Catch: BasicBlockRef) -> ValueRef {
assert (!*terminated);
*terminated = true;
ret llvm::LLVMBuildStore(B, Val, Ptr);
}
- fn GEP(Pointer: ValueRef, Indices: &ValueRef[]) -> ValueRef {
+ fn GEP(Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
assert (!*terminated);
ret llvm::LLVMBuildGEP(B, Pointer, ivec::to_ptr(Indices),
ivec::len(Indices), str::buf(""));
}
- fn InBoundsGEP(Pointer: ValueRef, Indices: &ValueRef[]) -> ValueRef {
+ fn InBoundsGEP(Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
assert (!*terminated);
ret llvm::LLVMBuildInBoundsGEP(B, Pointer, ivec::to_ptr(Indices),
ivec::len(Indices), str::buf(""));
/* Miscellaneous instructions */
- fn Phi(Ty: TypeRef, vals: &ValueRef[], bbs: &BasicBlockRef[]) ->
+ fn Phi(Ty: TypeRef, vals: &[ValueRef], bbs: &[BasicBlockRef]) ->
ValueRef {
assert (!*terminated);
let phi = llvm::LLVMBuildPhi(B, Ty, str::buf(""));
ret phi;
}
- fn AddIncomingToPhi(phi: ValueRef, vals: &ValueRef[],
- bbs: &BasicBlockRef[]) {
+ fn AddIncomingToPhi(phi: ValueRef, vals: &[ValueRef],
+ bbs: &[BasicBlockRef]) {
assert (ivec::len[ValueRef](vals) == ivec::len[BasicBlockRef](bbs));
llvm::LLVMAddIncoming(phi, ivec::to_ptr(vals), ivec::to_ptr(bbs),
ivec::len(vals));
}
- fn Call(Fn: ValueRef, Args: &ValueRef[]) -> ValueRef {
+ fn Call(Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
assert (!*terminated);
ret llvm::LLVMBuildCall(B, Fn, ivec::to_ptr(Args), ivec::len(Args),
str::buf(""));
}
- fn FastCall(Fn: ValueRef, Args: &ValueRef[]) -> ValueRef {
+ fn FastCall(Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
assert (!*terminated);
let v =
llvm::LLVMBuildCall(B, Fn, ivec::to_ptr(Args), ivec::len(Args),
ret v;
}
- fn CallWithConv(Fn: ValueRef, Args: &ValueRef[], Conv: uint) -> ValueRef {
+ fn CallWithConv(Fn: ValueRef, Args: &[ValueRef], Conv: uint) -> ValueRef {
assert (!*terminated);
let v =
llvm::LLVMBuildCall(B, Fn, ivec::to_ptr(Args), ivec::len(Args),
let T: ValueRef =
llvm::LLVMGetNamedFunction(M, str::buf("llvm.trap"));
assert (T as int != 0);
- let Args: ValueRef[] = ~[];
+ let Args: [ValueRef] = ~[];
ret llvm::LLVMBuildCall(B, T, ivec::to_ptr(Args), ivec::len(Args),
str::buf(""));
}
ret type_to_str_inner(names, ~[], ty);
}
-fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) ->
+fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
str {
if names.type_has_name(ty) { ret names.get_name(ty); }
let kind: int = llvm::LLVMGetTypeKind(ty);
- fn tys_str(names: type_names, outer: &TypeRef[], tys: &TypeRef[]) -> str {
+ fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str {
let s: str = "";
let first: bool = true;
for t: TypeRef in tys {
let s = "fn(";
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
let n_args: uint = llvm::LLVMCountParamTypes(ty);
- let args: TypeRef[] = ivec::init_elt[TypeRef](0 as TypeRef, n_args);
+ let args: [TypeRef] = ivec::init_elt[TypeRef](0 as TypeRef, n_args);
llvm::LLVMGetParamTypes(ty, ivec::to_ptr(args));
s += tys_str(names, outer, args);
s += ") -> ";
9 {
let s: str = "{";
let n_elts: uint = llvm::LLVMCountStructElementTypes(ty);
- let elts: TypeRef[] = ivec::init_elt[TypeRef](0 as TypeRef, n_elts);
+ let elts: [TypeRef] = ivec::init_elt[TypeRef](0 as TypeRef, n_elts);
llvm::LLVMGetStructElementTypes(ty, ivec::to_ptr(elts));
s += tys_str(names, outer, elts);
s += "}";
};
}
-fn fn_ty_param_tys(fn_ty: TypeRef) -> TypeRef[] {
+fn fn_ty_param_tys(fn_ty: TypeRef) -> [TypeRef] {
let args = ivec::init_elt(0 as TypeRef, llvm::LLVMCountParamTypes(fn_ty));
llvm::LLVMGetParamTypes(fn_ty, ivec::to_ptr(args));
ret args;
type env =
@{sess: session::session,
crate_cache: @hashmap[str, int],
- library_search_paths: str[],
+ library_search_paths: [str],
mutable next_crate_num: ast::crate_num};
fn visit_view_item(e: env, i: &@ast::view_item) {
}
}
-fn metadata_matches(crate_data: &@u8[], metas: &(@ast::meta_item)[]) -> bool {
+fn metadata_matches(crate_data: &@[u8], metas: &[@ast::meta_item]) -> bool {
let attrs = decoder::get_crate_attributes(crate_data);
let linkage_metas = attr::find_linkage_metas(attrs);
}
fn find_library_crate(sess: &session::session, ident: &ast::ident,
- metas: &(@ast::meta_item)[],
- library_search_paths: &str[]) ->
- option::t[{ident: str, data: @u8[]}] {
+ metas: &[@ast::meta_item],
+ library_search_paths: &[str]) ->
+ option::t[{ident: str, data: @[u8]}] {
attr::require_unique_names(sess, metas);
}
fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
- metas: &(@ast::meta_item)[],
- library_search_paths: &str[]) ->
- option::t[{ident: str, data: @u8[]}] {
+ metas: &[@ast::meta_item],
+ library_search_paths: &[str]) ->
+ option::t[{ident: str, data: @[u8]}] {
let prefix: str = nn.prefix + crate_name;
// FIXME: we could probably use a 'glob' function in std::fs but it will
// be much easier to write once the unsafe module knows more about FFI
ret none;
}
-fn get_metadata_section(filename: str) -> option::t[@u8[]] {
+fn get_metadata_section(filename: str) -> option::t[@[u8]] {
let b = str::buf(filename);
let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(b);
- if mb as int == 0 { ret option::none[@u8[]]; }
+ if mb as int == 0 { ret option::none[@[u8]]; }
let of = mk_object_file(mb);
let si = mk_section_iter(of.llof);
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
let csz = llvm::LLVMGetSectionSize(si.llsi);
let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf);
- ret option::some[@u8[]](@ivec::unsafe::from_buf(cvbuf, csz));
+ ret option::some[@[u8]](@ivec::unsafe::from_buf(cvbuf, csz));
}
llvm::LLVMMoveToNextSection(si.llsi);
}
- ret option::none[@u8[]];
+ ret option::none[@[u8]];
}
fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
- metas: &(@ast::meta_item)[],
- library_search_paths: &str[]) ->
- {ident: str, data: @u8[]} {
+ metas: &[@ast::meta_item],
+ library_search_paths: &[str]) ->
+ {ident: str, data: @[u8]} {
alt find_library_crate(sess, ident, metas, library_search_paths) {
}
}
-fn resolve_crate(e: env, ident: ast::ident, metas: (@ast::meta_item)[],
+fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
span: span) -> ast::crate_num {
if !e.crate_cache.contains_key(ident) {
let cinfo =
}
// Go through the crate metadata and load any crates that it references
-fn resolve_crate_deps(e: env, cdata: &@u8[]) -> cstore::cnum_map {
+fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
log "resolving deps of external crate";
// The map from crate numbers in the crate we're resolving to local crate
// numbers
}
fn lookup_defs(cstore: &cstore::cstore, cnum: ast::crate_num,
- path: &ast::ident[]) -> ast::def[] {
+ path: &[ast::ident]) -> [ast::def] {
let cdata = cstore::get_crate_data(cstore, cnum).data;
ret decoder::lookup_defs(cdata, cnum, path);
}
-fn get_tag_variants(tcx: ty::ctxt, def: ast::def_id) -> ty::variant_info[] {
+fn get_tag_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {
let cstore = tcx.sess.get_cstore();
let cnum = def.crate;
let cdata = cstore::get_crate_data(cstore, cnum).data;
// own crate numbers.
type cnum_map = map::hashmap[ast::crate_num, ast::crate_num];
-type crate_metadata = {name: str, data: @u8[], cnum_map: cnum_map};
+type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map};
// This is a bit of an experiment at encapsulating the data in cstore. By
// keeping all the data in a non-exported tag variant, it's impossible for
type cstore_private =
@{metas: map::hashmap[ast::crate_num, crate_metadata],
use_crate_map: use_crate_map,
- mutable used_crate_files: str[],
- mutable used_libraries: str[],
- mutable used_link_args: str[]};
+ mutable used_crate_files: [str],
+ mutable used_libraries: [str],
+ mutable used_link_args: [str]};
// Map from node_id's of local use statements to crate numbers
type use_crate_map = map::hashmap[ast::node_id, ast::crate_num];
}
}
-fn get_used_crate_files(cstore: &cstore) -> str[] {
+fn get_used_crate_files(cstore: &cstore) -> [str] {
ret p(cstore).used_crate_files;
}
ret true;
}
-fn get_used_libraries(cstore: &cstore) -> str[] {
+fn get_used_libraries(cstore: &cstore) -> [str] {
ret p(cstore).used_libraries;
}
}
}
-fn get_used_link_args(cstore: &cstore) -> str[] {
+fn get_used_link_args(cstore: &cstore) -> [str] {
ret p(cstore).used_link_args;
}
// build.
type external_resolver = fn(&ast::def_id) -> ast::def_id ;
-fn lookup_hash(d: &ebmlivec::doc, eq_fn: fn(&u8[]) -> bool , hash: uint) ->
- ebmlivec::doc[] {
+fn lookup_hash(d: &ebmlivec::doc, eq_fn: fn(&[u8]) -> bool , hash: uint) ->
+ [ebmlivec::doc] {
let index = ebmlivec::get_doc(d, tag_index);
let table = ebmlivec::get_doc(index, tag_index_table);
let hash_pos = table.start + hash % 256u * 4u;
let bucket = ebmlivec::doc_at(d.data, pos);
// Awkward logic because we can't ret from foreach yet
- let result: ebmlivec::doc[] = ~[];
+ let result: [ebmlivec::doc] = ~[];
let belt = tag_index_buckets_bucket_elt;
for each elt: ebmlivec::doc in ebmlivec::tagged_docs(bucket, belt) {
let pos = ebmlivec::be_uint_from_bytes(elt.data, elt.start, 4u);
fn maybe_find_item(item_id: int, items: &ebmlivec::doc) ->
option::t[ebmlivec::doc] {
- fn eq_item(bytes: &u8[], item_id: int) -> bool {
+ fn eq_item(bytes: &[u8], item_id: int) -> bool {
ret ebmlivec::be_uint_from_bytes(@bytes, 0u, 4u) as int == item_id;
}
let eqer = bind eq_item(_, item_id);
// Looks up an item in the given metadata and returns an ebmlivec doc pointing
// to the item data.
-fn lookup_item(item_id: int, data: &@u8[]) -> ebmlivec::doc {
+fn lookup_item(item_id: int, data: &@[u8]) -> ebmlivec::doc {
let items = ebmlivec::get_doc(ebmlivec::new_doc(data), tag_items);
ret find_item(item_id, items);
}
def_parser, tcx);
}
-fn item_ty_param_kinds(item: &ebmlivec::doc) -> ast::kind[] {
- let ks: ast::kind[] = ~[];
+fn item_ty_param_kinds(item: &ebmlivec::doc) -> [ast::kind] {
+ let ks: [ast::kind] = ~[];
let tp = tag_items_data_item_ty_param_kinds;
for each p: ebmlivec::doc in ebmlivec::tagged_docs(item, tp) {
- let dat : u8[] = ebmlivec::doc_data(p);
+ let dat : [u8] = ebmlivec::doc_data(p);
let vi = ebmlivec::vint_at(dat, 0u);
let i = 0u;
while i < vi.val {
}
fn tag_variant_ids(item: &ebmlivec::doc, this_cnum: ast::crate_num) ->
- ast::def_id[] {
- let ids: ast::def_id[] = ~[];
+ [ast::def_id] {
+ let ids: [ast::def_id] = ~[];
let v = tag_items_data_item_variant;
for each p: ebmlivec::doc in ebmlivec::tagged_docs(item, v) {
let ext = parse_def_id(ebmlivec::doc_data(p));
// Given a path and serialized crate metadata, returns the ID of the
// definition the path refers to.
-fn resolve_path(path: &ast::ident[], data: @u8[]) -> ast::def_id[] {
- fn eq_item(data: &u8[], s: str) -> bool {
+fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
+ fn eq_item(data: &[u8], s: str) -> bool {
ret str::eq(str::unsafe_from_bytes_ivec(data), s);
}
let s = str::connect_ivec(path, "::");
let md = ebmlivec::new_doc(data);
let paths = ebmlivec::get_doc(md, tag_paths);
let eqer = bind eq_item(_, s);
- let result: ast::def_id[] = ~[];
+ let result: [ast::def_id] = ~[];
for doc: ebmlivec::doc in lookup_hash(paths, eqer, hash_path(s)) {
let did_doc = ebmlivec::get_doc(doc, tag_def_id);
result += ~[parse_def_id(ebmlivec::doc_data(did_doc))];
}
// Crate metadata queries
-fn lookup_defs(data: &@u8[], cnum: ast::crate_num, path: &ast::ident[]) ->
- ast::def[] {
+fn lookup_defs(data: &@[u8], cnum: ast::crate_num, path: &[ast::ident]) ->
+ [ast::def] {
ret ivec::map(bind lookup_def(cnum, data, _), resolve_path(path, data));
}
// FIXME doesn't yet handle re-exported externals
-fn lookup_def(cnum: ast::crate_num, data: @u8[], did_: &ast::def_id) ->
+fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: &ast::def_id) ->
ast::def {
let item = lookup_item(did_.node, data);
let fam_ch = item_family(item);
ret def;
}
-fn get_type(data: @u8[], def: ast::def_id, tcx: &ty::ctxt,
+fn get_type(data: @[u8], def: ast::def_id, tcx: &ty::ctxt,
extres: &external_resolver) -> ty::ty_param_kinds_and_ty {
let this_cnum = def.crate;
let node_id = def.node;
let item = lookup_item(node_id, data);
let t = item_type(item, this_cnum, tcx, extres);
- let tp_kinds : ast::kind[];
+ let tp_kinds : [ast::kind];
let fam_ch = item_family(item);
let has_ty_params = family_has_type_params(fam_ch);
if has_ty_params {
ret {kinds: tp_kinds, ty: t};
}
-fn get_type_param_count(data: @u8[], id: ast::node_id) -> uint {
+fn get_type_param_count(data: @[u8], id: ast::node_id) -> uint {
ret ivec::len(get_type_param_kinds(data, id));
}
-fn get_type_param_kinds(data: @u8[], id: ast::node_id) -> ast::kind[] {
+fn get_type_param_kinds(data: @[u8], id: ast::node_id) -> [ast::kind] {
ret item_ty_param_kinds(lookup_item(id, data));
}
-fn get_symbol(data: @u8[], id: ast::node_id) -> str {
+fn get_symbol(data: @[u8], id: ast::node_id) -> str {
ret item_symbol(lookup_item(id, data));
}
-fn get_tag_variants(data: &@u8[], def: ast::def_id, tcx: &ty::ctxt,
- extres: &external_resolver) -> ty::variant_info[] {
+fn get_tag_variants(data: &@[u8], def: ast::def_id, tcx: &ty::ctxt,
+ extres: &external_resolver) -> [ty::variant_info] {
let external_crate_id = def.crate;
let data =
cstore::get_crate_data(tcx.sess.get_cstore(), external_crate_id).data;
let items = ebmlivec::get_doc(ebmlivec::new_doc(data), tag_items);
let item = find_item(def.node, items);
- let infos: ty::variant_info[] = ~[];
+ let infos: [ty::variant_info] = ~[];
let variant_ids = tag_variant_ids(item, external_crate_id);
for did: ast::def_id in variant_ids {
let item = find_item(did.node, items);
let ctor_ty = item_type(item, external_crate_id, tcx, extres);
- let arg_tys: ty::t[] = ~[];
+ let arg_tys: [ty::t] = ~[];
alt ty::struct(tcx, ctor_ty) {
ty::ty_fn(_, args, _, _, _) {
for a: ty::arg in args { arg_tys += ~[a.ty]; }
}
}
-fn get_meta_items(md: &ebmlivec::doc) -> (@ast::meta_item)[] {
- let items: (@ast::meta_item)[] = ~[];
+fn get_meta_items(md: &ebmlivec::doc) -> [@ast::meta_item] {
+ let items: [@ast::meta_item] = ~[];
for each meta_item_doc: ebmlivec::doc in
ebmlivec::tagged_docs(md, tag_meta_item_word) {
let nd = ebmlivec::get_doc(meta_item_doc, tag_meta_item_name);
ret items;
}
-fn get_attributes(md: &ebmlivec::doc) -> ast::attribute[] {
- let attrs: ast::attribute[] = ~[];
+fn get_attributes(md: &ebmlivec::doc) -> [ast::attribute] {
+ let attrs: [ast::attribute] = ~[];
alt ebmlivec::maybe_get_doc(md, tag_attributes) {
option::some(attrs_d) {
for each attr_doc: ebmlivec::doc in
out.write_str("\n\n");
}
-fn get_crate_attributes(data: @u8[]) -> ast::attribute[] {
+fn get_crate_attributes(data: @[u8]) -> [ast::attribute] {
ret get_attributes(ebmlivec::new_doc(data));
}
type crate_dep = {cnum: ast::crate_num, ident: str};
-fn get_crate_deps(data: @u8[]) -> crate_dep[] {
- let deps: crate_dep[] = ~[];
+fn get_crate_deps(data: @[u8]) -> [crate_dep] {
+ let deps: [crate_dep] = ~[];
let cratedoc = ebmlivec::new_doc(data);
let depsdoc = ebmlivec::get_doc(cratedoc, tag_crate_deps);
let crate_num = 1;
ret deps;
}
-fn list_crate_deps(data: @u8[], out: ioivec::writer) {
+fn list_crate_deps(data: @[u8], out: ioivec::writer) {
out.write_str("=External Dependencies=\n");
for dep: crate_dep in get_crate_deps(data) {
out.write_str("\n");
}
-fn list_crate_items(bytes: &@u8[], md: &ebmlivec::doc, out: ioivec::writer) {
+fn list_crate_items(bytes: &@[u8], md: &ebmlivec::doc, out: ioivec::writer) {
out.write_str("=Items=\n");
let paths = ebmlivec::get_doc(md, tag_paths);
let items = ebmlivec::get_doc(md, tag_items);
out.write_str("\n");
}
-fn list_crate_metadata(bytes: &@u8[], out: ioivec::writer) {
+fn list_crate_metadata(bytes: &@[u8], out: ioivec::writer) {
let md = ebmlivec::new_doc(bytes);
list_crate_attributes(md, out);
list_crate_deps(bytes, out);
type entry[T] = {val: T, pos: uint};
-fn encode_tag_variant_paths(ebml_w: &ebmlivec::writer, variants: &variant[],
- path: &str[], index: &mutable (entry[str])[]) {
+fn encode_tag_variant_paths(ebml_w: &ebmlivec::writer, variants: &[variant],
+ path: &[str], index: &mutable [entry[str]]) {
for variant: variant in variants {
add_to_index(ebml_w, path, index, variant.node.name);
ebmlivec::start_tag(ebml_w, tag_paths_data_item);
}
}
-fn add_to_index(ebml_w: &ebmlivec::writer, path: &str[],
- index: &mutable (entry[str])[], name: &str) {
+fn add_to_index(ebml_w: &ebmlivec::writer, path: &[str],
+ index: &mutable [entry[str]], name: &str) {
let full_path = path + ~[name];
index +=
~[{val: str::connect_ivec(full_path, "::"),
}
fn encode_native_module_item_paths(ebml_w: &ebmlivec::writer,
- nmod: &native_mod, path: &str[],
- index: &mutable (entry[str])[]) {
+ nmod: &native_mod, path: &[str],
+ index: &mutable [entry[str]]) {
for nitem: @native_item in nmod.items {
add_to_index(ebml_w, path, index, nitem.ident);
ebmlivec::start_tag(ebml_w, tag_paths_data_item);
}
fn encode_module_item_paths(ebml_w: &ebmlivec::writer, module: &_mod,
- path: &str[], index: &mutable (entry[str])[]) {
+ path: &[str], index: &mutable [entry[str]]) {
for it: @item in module.items {
if !is_exported(it.ident, module) { cont; }
alt it.node {
}
fn encode_item_paths(ebml_w: &ebmlivec::writer, crate: &@crate) ->
- (entry[str])[] {
- let index: (entry[str])[] = ~[];
- let path: str[] = ~[];
+ [entry[str]] {
+ let index: [entry[str]] = ~[];
+ let path: [str] = ~[];
ebmlivec::start_tag(ebml_w, tag_paths);
encode_module_item_paths(ebml_w, crate.node.module, path, index);
ebmlivec::end_tag(ebml_w);
fn def_to_str(did: &def_id) -> str { ret #fmt("%d:%d", did.crate, did.node); }
-fn encode_type_param_kinds(ebml_w: &ebmlivec::writer, tps: &ty_param[]) {
+fn encode_type_param_kinds(ebml_w: &ebmlivec::writer, tps: &[ty_param]) {
ebmlivec::start_tag(ebml_w, tag_items_data_item_ty_param_kinds);
ebmlivec::write_vint(ebml_w.writer, ivec::len[ty_param](tps));
for tp: ty_param in tps {
}
fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer,
- id: node_id, variants: &variant[],
- index: &mutable (entry[int])[],
- ty_params: &ty_param[]) {
+ id: node_id, variants: &[variant],
+ index: &mutable [entry[int]],
+ ty_params: &[ty_param]) {
for variant: variant in variants {
index += ~[{val: variant.node.id, pos: ebml_w.writer.tell()}];
ebmlivec::start_tag(ebml_w, tag_items_data_item);
}
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: &ebmlivec::writer,
- item: @item, index: &mutable (entry[int])[]) {
+ item: @item, index: &mutable [entry[int]]) {
alt item.node {
item_const(_, _) {
ebmlivec::start_tag(ebml_w, tag_items_data_item);
}
fn encode_info_for_items(ecx: &@encode_ctxt, ebml_w: &ebmlivec::writer) ->
- (entry[int])[] {
- let index: (entry[int])[] = ~[];
+ [entry[int]] {
+ let index: [entry[int]] = ~[];
ebmlivec::start_tag(ebml_w, tag_items_data);
for each kvp: @{key: node_id, val: middle::ast_map::ast_node} in
ecx.ccx.ast_map.items() {
// Path and definition ID indexing
-fn create_index[T](index: &(entry[T])[], hash_fn: fn(&T) -> uint ) ->
- (@(entry[T])[])[] {
- let buckets: (@mutable (entry[T])[])[] = ~[];
+fn create_index[T](index: &[entry[T]], hash_fn: fn(&T) -> uint ) ->
+ [@[entry[T]]] {
+ let buckets: [@mutable [entry[T]]] = ~[];
for each i: uint in uint::range(0u, 256u) { buckets += ~[@mutable ~[]]; }
for elt: entry[T] in index {
let h = hash_fn(elt.val);
}
let buckets_frozen = ~[];
- for bucket: @mutable (entry[T])[] in buckets {
+ for bucket: @mutable [entry[T]] in buckets {
buckets_frozen += ~[@*bucket];
}
ret buckets_frozen;
}
-fn encode_index[T](ebml_w: &ebmlivec::writer, buckets: &(@(entry[T])[])[],
+fn encode_index[T](ebml_w: &ebmlivec::writer, buckets: &[@[entry[T]]],
write_fn: fn(&ioivec::writer, &T) ) {
let writer = ioivec::new_writer_(ebml_w.writer);
ebmlivec::start_tag(ebml_w, tag_index);
- let bucket_locs: uint[] = ~[];
+ let bucket_locs: [uint] = ~[];
ebmlivec::start_tag(ebml_w, tag_index_buckets);
- for bucket: @(entry[T])[] in buckets {
+ for bucket: @[entry[T]] in buckets {
bucket_locs += ~[ebml_w.writer.tell()];
ebmlivec::start_tag(ebml_w, tag_index_buckets_bucket);
for elt: entry[T] in *bucket {
}
}
-fn encode_attributes(ebml_w: &ebmlivec::writer, attrs: &attribute[]) {
+fn encode_attributes(ebml_w: &ebmlivec::writer, attrs: &[attribute]) {
ebmlivec::start_tag(ebml_w, tag_attributes);
for attr: attribute in attrs {
ebmlivec::start_tag(ebml_w, tag_attribute);
// metadata that Rust cares about for linking crates. This attribute requires
// 'name' and 'vers' items, so if the user didn't provide them we will throw
// them in anyway with default values.
-fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> attribute[] {
+fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] {
- fn synthesize_link_attr(ecx: &@encode_ctxt, items: &(@meta_item)[]) ->
+ fn synthesize_link_attr(ecx: &@encode_ctxt, items: &[@meta_item]) ->
attribute {
assert (ecx.ccx.link_meta.name != "");
ret attr::mk_attr(link_item);
}
- let attrs: attribute[] = ~[];
+ let attrs: [attribute] = ~[];
let found_link_attr = false;
for attr: attribute in crate.node.attrs {
attrs +=
fn encode_crate_deps(ebml_w: &ebmlivec::writer, cstore: &cstore::cstore) {
- fn get_ordered_names(cstore: &cstore::cstore) -> str[] {
+ fn get_ordered_names(cstore: &cstore::cstore) -> [str] {
type hashkv = @{key: crate_num, val: cstore::crate_metadata};
type numname = {crate: crate_num, ident: str};
// Pull the cnums and names out of cstore
- let pairs: numname[mutable ] = ~[mutable ];
+ let pairs: [mutable numname] = ~[mutable];
for each hashkv: hashkv in cstore::iter_crate_data(cstore) {
pairs += ~[mutable {crate: hashkv.key, ident: hashkv.val.name}];
}
type str_def = fn(str) -> ast::def_id ;
type pstate =
- {data: @u8[], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt};
+ {data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt};
tag ty_or_bang { a_ty(ty::t); a_bang; }
}
-fn parse_ty_data(data: @u8[], crate_num: int, pos: uint, len: uint,
+fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, len: uint,
sd: str_def, tcx: ty::ctxt) -> ty::t {
let st =
@{data: data, crate: crate_num, mutable pos: pos, len: len, tcx: tcx};
}
}
-fn parse_constrs(st: @pstate, sd: str_def) -> (@ty::constr)[] {
- let rslt: (@ty::constr)[] = ~[];
+fn parse_constrs(st: @pstate, sd: str_def) -> [@ty::constr] {
+ let rslt: [@ty::constr] = ~[];
alt peek(st) as char {
':' {
do {
}
// FIXME less copy-and-paste
-fn parse_ty_constrs(st: @pstate, sd: str_def) -> (@ty::type_constr)[] {
- let rslt: (@ty::type_constr)[] = ~[];
+fn parse_ty_constrs(st: @pstate, sd: str_def) -> [@ty::type_constr] {
+ let rslt: [@ty::type_constr] = ~[];
alt peek(st) as char {
':' {
do {
}
fn parse_path(st: @pstate, sd: str_def) -> ast::path {
- let idents: ast::ident[] = ~[];
+ let idents: [ast::ident] = ~[];
fn is_last(c: char) -> bool { ret c == '(' || c == ':'; }
idents += ~[parse_ident_(st, sd, is_last)];
while true {
fn parse_constr[@T](st: @pstate, sd: str_def, pser: arg_parser[T]) ->
@ty::constr_general[T] {
let sp = {lo: 0u, hi: 0u}; // FIXME: use a real span
- let args: (@sp_constr_arg[T])[] = ~[];
+ let args: [@sp_constr_arg[T]] = ~[];
let pth: path = parse_path(st, sd);
let ignore: char = next(st) as char;
assert (ignore as char == '(');
't' {
assert (next(st) as char == '[');
let def = parse_def(st, sd);
- let params: ty::t[] = ~[];
+ let params: [ty::t] = ~[];
while peek(st) as char != ']' { params += ~[parse_ty(st, sd)]; }
st.pos = st.pos + 1u;
ret ty::mk_tag(st.tcx, def, params);
'C' { ret ty::mk_chan(st.tcx, parse_ty(st, sd)); }
'R' {
assert (next(st) as char == '[');
- let fields: ty::field[] = ~[];
+ let fields: [ty::field] = ~[];
while peek(st) as char != ']' {
let name = "";
while peek(st) as char != '=' {
}
'O' {
assert (next(st) as char == '[');
- let methods: ty::method[] = ~[];
+ let methods: [ty::method] = ~[];
while peek(st) as char != ']' {
let proto;
alt next(st) as char {
assert (next(st) as char == '[');
let def = parse_def(st, sd);
let inner = parse_ty(st, sd);
- let params: ty::t[] = ~[];
+ let params: [ty::t] = ~[];
while peek(st) as char != ']' { params += ~[parse_ty(st, sd)]; }
st.pos = st.pos + 1u;
ret ty::mk_res(st.tcx, def, inner, params);
}
fn parse_ty_fn(st: @pstate, sd: str_def) ->
- {args: ty::arg[], ty: ty::t, cf: ast::controlflow, cs: (@ty::constr)[]} {
+ {args: [ty::arg], ty: ty::t, cf: ast::controlflow, cs: [@ty::constr]} {
assert (next(st) as char == '[');
- let inputs: ty::arg[] = ~[];
+ let inputs: [ty::arg] = ~[];
while peek(st) as char != ']' {
let mode = ty::mo_val;
if peek(st) as char == '&' {
// Rust metadata parsing
-fn parse_def_id(buf: &u8[]) -> ast::def_id {
+fn parse_def_id(buf: &[u8]) -> ast::def_id {
let colon_idx = 0u;
let len = ivec::len[u8](buf);
while colon_idx < len && buf.(colon_idx) != ':' as u8 { colon_idx += 1u; }
}
}
-fn enc_ty_fn(w: &ioivec::writer, cx: &@ctxt, args: &ty::arg[], out: &ty::t,
- cf: &controlflow, constrs: &(@ty::constr)[]) {
+fn enc_ty_fn(w: &ioivec::writer, cx: &@ctxt, args: &[ty::arg], out: &ty::t,
+ cf: &controlflow, constrs: &[@ty::constr]) {
w.write_char('[');
for arg: ty::arg in args {
alt arg.mode {
tag valid { valid; overwritten(span, ast::path); val_taken(span, ast::path); }
type restrict =
- @{root_vars: node_id[],
+ @{root_vars: [node_id],
block_defnum: node_id,
- bindings: node_id[],
- tys: ty::t[],
- depends_on: uint[],
+ bindings: [node_id],
+ tys: [ty::t],
+ depends_on: [uint],
mutable ok: valid};
-type scope = @restrict[];
+type scope = @[restrict];
tag local_info { arg(ast::mode); objfield(ast::mutability); }
tcx.sess.abort_if_errors();
}
-fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &ast::ty_param[], sp: &span,
+fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
name: &fn_ident, id: ast::node_id, sc: &scope, v: &vt[scope]) {
visit::visit_fn_decl(f.decl, sc, v);
for arg_: ast::arg in f.decl.inputs {
}
}
-fn check_call(cx: &ctx, f: &@ast::expr, args: &(@ast::expr)[], sc: &scope) ->
- {root_vars: node_id[], unsafe_ts: ty::t[]} {
+fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope) ->
+ {root_vars: [node_id], unsafe_ts: [ty::t]} {
let fty = ty::expr_ty(cx.tcx, f);
let arg_ts = fty_args(cx, fty);
- let roots: node_id[] = ~[];
- let mut_roots: {arg: uint, node: node_id}[] = ~[];
- let unsafe_ts: ty::t[] = ~[];
- let unsafe_t_offsets: uint[] = ~[];
+ let roots: [node_id] = ~[];
+ let mut_roots: [{arg: uint, node: node_id}] = ~[];
+ let unsafe_ts: [ty::t] = ~[];
+ let unsafe_t_offsets: [uint] = ~[];
let i = 0u;
for arg_t: ty::arg in arg_ts {
if arg_t.mode != ty::mo_val {
}
}
-fn check_alt(cx: &ctx, input: &@ast::expr, arms: &ast::arm[], sc: &scope,
+fn check_alt(cx: &ctx, input: &@ast::expr, arms: &[ast::arm], sc: &scope,
v: &vt[scope]) {
visit::visit_expr(input, sc, v);
let root = expr_root(cx, input, true);
let roots =
alt path_def_id(cx, root.ex) { some(did) { ~[did.node] } _ { ~[] } };
- let forbidden_tp: ty::t[] =
+ let forbidden_tp: [ty::t] =
alt inner_mut(root.ds) { some(t) { ~[t] } _ { ~[] } };
for a: ast::arm in arms {
let dnums = arm_defnums(a);
}
}
-fn arm_defnums(arm: &ast::arm) -> node_id[] {
+fn arm_defnums(arm: &ast::arm) -> [node_id] {
ret ast::pat_binding_ids(arm.pats.(0));
}
}
}
-fn deps(sc: &scope, roots: &node_id[]) -> uint[] {
+fn deps(sc: &scope, roots: &[node_id]) -> [uint] {
let i = 0u;
let result = ~[];
for r: restrict in *sc {
// the inner derefs come in front, so foo.bar.baz becomes rec(ex=foo,
// ds=[field(baz),field(bar)])
fn expr_root(cx: &ctx, ex: @ast::expr, autoderef: bool) ->
- {ex: @ast::expr, ds: @deref[]} {
- fn maybe_auto_unbox(cx: &ctx, t: ty::t) -> {t: ty::t, ds: deref[]} {
+ {ex: @ast::expr, ds: @[deref]} {
+ fn maybe_auto_unbox(cx: &ctx, t: ty::t) -> {t: ty::t, ds: [deref]} {
let ds = ~[];
while true {
alt ty::struct(cx.tcx, t) {
}
ret {t: t, ds: ds};
}
- let ds: deref[] = ~[];
+ let ds: [deref] = ~[];
while true {
alt { ex.node } {
ast::expr_field(base, ident) {
ret {ex: ex, ds: @ds};
}
-fn mut_field(ds: &@deref[]) -> bool {
+fn mut_field(ds: &@[deref]) -> bool {
for d: deref in *ds { if d.mut { ret true; } }
ret false;
}
-fn inner_mut(ds: &@deref[]) -> option::t[ty::t] {
+fn inner_mut(ds: &@[deref]) -> option::t[ty::t] {
for d: deref in *ds { if d.mut { ret some(d.outer_t); } }
ret none;
}
};
}
-fn fty_args(cx: &ctx, fty: ty::t) -> ty::arg[] {
+fn fty_args(cx: &ctx, fty: ty::t) -> [ty::arg] {
ret alt ty::struct(cx.tcx, ty::type_autoderef(cx.tcx, fty)) {
ty::ty_fn(_, args, _, _, _) | ty::ty_native_fn(_, args, _) { args }
};
alt ex.node { expr_alt(_, arms) { check_arms(tcx, arms); } _ { } }
}
-fn check_arms(tcx: &ty::ctxt, arms: &arm[]) {
+fn check_arms(tcx: &ty::ctxt, arms: &[arm]) {
let i = 0;
for arm: arm in arms {
for arm_pat: @pat in arm.pats {
}
fn pattern_supersedes(tcx: &ty::ctxt, a: &@pat, b: &@pat) -> bool {
- fn patterns_supersede(tcx: &ty::ctxt, as: &(@pat)[], bs: &(@pat)[]) ->
+ fn patterns_supersede(tcx: &ty::ctxt, as: &[@pat], bs: &[@pat]) ->
bool {
let i = 0;
for a: @pat in as {
}
ret true;
}
- fn field_patterns_supersede(tcx: &ty::ctxt, fas: &field_pat[],
- fbs: &field_pat[]) -> bool {
+ fn field_patterns_supersede(tcx: &ty::ctxt, fas: &[field_pat],
+ fbs: &[field_pat]) -> bool {
let wild = @{id: 0, node: pat_wild, span: {lo: 0u, hi: 0u}};
for fa: field_pat in fas {
let pb = wild;
// testing membership, the list of referencing sites is what you want for most
// other things.
type freevar_set = hashset[ast::node_id];
-type freevar_info = {defs: freevar_set, refs: @ast::node_id[]};
+type freevar_info = {defs: freevar_set, refs: @[ast::node_id]};
type freevar_map = hashmap[ast::node_id, freevar_info];
// Searches through part of the AST for all references to locals or
// in order to start the search.
fn collect_freevars(def_map: &resolve::def_map, sess: &session::session,
walker: &fn(&visit::vt[()]) ,
- initial_decls: ast::node_id[]) -> freevar_info {
+ initial_decls: [ast::node_id]) -> freevar_info {
let decls = new_int_hash();
for decl: ast::node_id in initial_decls { set_add(decls, decl); }
let refs = @mutable ~[];
- let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], sp: &span,
+ let walk_fn = lambda(f: &ast::_fn, tps: &[ast::ty_param], sp: &span,
i: &ast::fn_ident, nid: ast::node_id) {
for a: ast::arg in f.decl.inputs { set_add(decls, a.id); }
};
crate: &@ast::crate) -> freevar_map {
let freevars = new_int_hash();
- let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], sp: &span,
+ let walk_fn = lambda(f: &ast::_fn, tps: &[ast::ty_param], sp: &span,
i: &ast::fn_ident, nid: ast::node_id) {
let start_walk = lambda(v: &visit::vt[()]) {
v.visit_fn(f, tps, sp, i, nid, (), v);
fn get_freevar_defs(tcx: &ty::ctxt, fid: ast::node_id) -> freevar_set {
ret get_freevar_info(tcx, fid).defs;
}
-fn get_freevars(tcx: &ty::ctxt, fid: ast::node_id) -> @ast::node_id[] {
+fn get_freevars(tcx: &ty::ctxt, fid: ast::node_id) -> @[ast::node_id] {
ret get_freevar_info(tcx, fid).refs;
}
fn has_freevars(tcx: &ty::ctxt, fid: ast::node_id) -> bool {
tag scope {
scope_crate;
scope_item(@ast::item);
- scope_fn(ast::fn_decl, ast::proto, ast::ty_param[]);
+ scope_fn(ast::fn_decl, ast::proto, [ast::ty_param]);
scope_native_item(@ast::native_item);
scope_loop(@ast::local); // there's only 1 decl per loop.
type indexed_mod =
{m: option::t[ast::_mod],
index: mod_index,
- mutable glob_imports: glob_imp_def[],
+ mutable glob_imports: [glob_imp_def],
glob_imported_names: hashmap[str, import_state]};
ast_map: ast_map::map,
imports: hashmap[ast::node_id, import_state],
mod_map: hashmap[ast::node_id, @indexed_mod],
- ext_map: hashmap[def_id, ident[]],
+ ext_map: hashmap[def_id, [ident]],
ext_cache: ext_hash,
- mutable reported: {ident: str, sc: scope}[],
+ mutable reported: [{ident: str, sc: scope}],
sess: session};
ast_map: amap,
imports: new_int_hash[import_state](),
mod_map: new_int_hash[@indexed_mod](),
- ext_map: new_def_hash[ident[]](),
+ ext_map: new_def_hash[[ident]](),
ext_cache: new_ext_hash(),
mutable reported: ~[],
sess: sess};
visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v);
}
-fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &ast::ty_param[],
+fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &[ast::ty_param],
sp: &span, name: &fn_ident, id: node_id, sc: &scopes,
v: &vt[scopes]) {
// is this a main fn declaration?
}
}
-fn follow_import(e: &env, sc: &scopes, path: &ident[], sp: &span) ->
+fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) ->
option::t[def] {
let path_len = ivec::len(path);
let dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module);
}
-fn lookup_in_ty_params(name: &ident, ty_params: &ast::ty_param[]) ->
+fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) ->
option::t[def] {
let i = 0u;
for tp: ast::ty_param in ty_params {
}
fn lookup_in_fn(name: &ident, decl: &ast::fn_decl,
- ty_params: &ast::ty_param[], ns: namespace) ->
+ ty_params: &[ast::ty_param], ns: namespace) ->
option::t[def] {
alt ns {
ns_value. {
}
}
-fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &ast::ty_param[],
+fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param],
ns: namespace) -> option::t[def] {
alt ns {
ns_value. {
};
}
-fn lookup_external(e: &env, cnum: int, ids: &ident[], ns: namespace) ->
+fn lookup_external(e: &env, cnum: int, ids: &[ident], ns: namespace) ->
option::t[def] {
for d: def in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids) {
e.ext_map.insert(ast::def_id_of_def(d), ids);
}
fn check_item(e: &@env, i: &@ast::item, x: &(), v: &vt[()]) {
- fn typaram_names(tps: &ast::ty_param[]) -> ident[] {
- let x: ast::ident[] = ~[];
+ fn typaram_names(tps: &[ast::ty_param]) -> [ident] {
+ let x: [ast::ident] = ~[];
for tp: ast::ty_param in tps { x += ~[tp.ident] }
ret x;
}
visit::visit_ty(ty, x, v);
}
-type checker = @{mutable seen: ident[], kind: str, sess: session};
+type checker = @{mutable seen: [ident], kind: str, sess: session};
fn checker(e: &env, kind: str) -> checker {
- let seen: ident[] = ~[];
+ let seen: [ident] = ~[];
ret @{mutable seen: seen, kind: kind, sess: e.sess};
}
fn ident_id(i: &ident) -> ident { ret i; }
-fn ensure_unique[T](e: &env, sp: &span, elts: &T[], id: fn(&T) -> ident ,
+fn ensure_unique[T](e: &env, sp: &span, elts: &[T], id: fn(&T) -> ident ,
kind: &str) {
let ch = checker(e, kind);
for elt: T in elts { add_name(ch, sp, id(elt)); }
mutable next_tag_id: u16,
pad: u16,
tag_id_to_index: hashmap[ast::def_id,u16],
- mutable tag_order: ast::def_id[],
+ mutable tag_order: [ast::def_id],
resources: interner::interner[res_info],
llshapetablesty: TypeRef,
llshapetables: ValueRef
//
// TODO: Use this in dynamic_size_of() as well.
-fn largest_variants(ccx : &@crate_ctxt, tag_id : &ast::def_id) -> uint[] {
+fn largest_variants(ccx : &@crate_ctxt, tag_id : &ast::def_id) -> [uint] {
// Compute the minimum and maximum size and alignment for each variant.
//
// TODO: We could do better here; e.g. we know that any variant that
type size_align = { size: u16, align: u8 };
-fn compute_static_tag_size(ccx : &@crate_ctxt, largest_variants : &uint[],
+fn compute_static_tag_size(ccx : &@crate_ctxt, largest_variants : &[uint],
did : &ast::def_id) -> size_align {
let max_size = 0u16; let max_align = 1u8;
let variants = ty::tag_variants(ccx.tcx, did);
};
}
-fn add_bool(dest : &mutable u8[], val : bool) {
+fn add_bool(dest : &mutable [u8], val : bool) {
dest += ~[if val { 1u8 } else { 0u8 }];
}
-fn add_u16(dest : &mutable u8[], val : u16) {
+fn add_u16(dest : &mutable [u8], val : u16) {
dest += ~[(val & 0xffu16) as u8, (val >> 8u16) as u8];
}
-fn add_substr(dest : &mutable u8[], src : &u8[]) {
+fn add_substr(dest : &mutable [u8], src : &[u8]) {
add_u16(dest, ivec::len(src) as u16);
dest += src;
}
-fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> u8[] {
+fn shape_of(ccx : &@crate_ctxt, t : ty::t) -> [u8] {
let s = ~[];
alt ty::struct(ccx.tcx, t) {
ret s;
}
-fn add_size_hint(ccx : &@crate_ctxt, s : &mutable u8[], typ : ty::t) {
+fn add_size_hint(ccx : &@crate_ctxt, s : &mutable [u8], typ : ty::t) {
if (ty::type_has_dynamic_size(ccx.tcx, typ)) {
s += ~[ 0u8, 0u8, 0u8 ];
ret;
}
// FIXME: We might discover other variants as we traverse these. Handle this.
-fn shape_of_variant(ccx : &@crate_ctxt, v : &ty::variant_info) -> u8[] {
+fn shape_of_variant(ccx : &@crate_ctxt, v : &ty::variant_info) -> [u8] {
let s = ~[];
for t : ty::t in v.args { s += shape_of(ccx, t); }
ret s;
ret type_of_inner(cx, sp, t);
}
-fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &ty::arg[]) ->
- TypeRef[] {
- let atys: TypeRef[] = ~[];
+fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &[ty::arg]) ->
+ [TypeRef] {
+ let atys: [TypeRef] = ~[];
for arg: ty::arg in inputs {
let t: TypeRef = type_of_inner(cx, sp, arg.ty);
t = alt arg.mode {
// - new_fn_ctxt
// - trans_args
fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto,
- is_method: bool, inputs: &ty::arg[], output: &ty::t,
+ is_method: bool, inputs: &[ty::arg], output: &ty::t,
ty_param_count: uint) -> TypeRef {
- let atys: TypeRef[] = ~[];
+ let atys: [TypeRef] = ~[];
// Arg 0: Output pointer.
atys += ~[T_ptr(type_of_inner(cx, sp, output))];
}
fn type_of_fn(cx: &@crate_ctxt, sp: &span, proto: ast::proto,
- inputs: &ty::arg[], output: &ty::t, ty_param_count: uint) ->
+ inputs: &[ty::arg], output: &ty::t, ty_param_count: uint) ->
TypeRef {
ret type_of_fn_full(cx, sp, proto, false, inputs, output, ty_param_count);
}
}
fn type_of_native_fn(cx: &@crate_ctxt, sp: &span, abi: ast::native_abi,
- inputs: &ty::arg[], output: &ty::t, ty_param_count: uint)
+ inputs: &[ty::arg], output: &ty::t, ty_param_count: uint)
-> TypeRef {
- let atys: TypeRef[] = ~[];
+ let atys: [TypeRef] = ~[];
if abi == ast::native_abi_rust {
atys += ~[T_taskptr(*cx)];
let i = 0u;
ty::ty_chan(t) { llty = T_ptr(T_chan(type_of_inner(cx, sp, t))); }
ty::ty_task. { llty = T_taskptr(*cx); }
ty::ty_rec(fields) {
- let tys: TypeRef[] = ~[];
+ let tys: [TypeRef] = ~[];
for f: ty::field in fields {
tys += ~[type_of_inner(cx, sp, f.mt.ty)];
}
fn trans_native_call(b: &builder, glues: @glue_fns, lltaskptr: ValueRef,
externs: &hashmap[str, ValueRef], tn: &type_names,
llmod: ModuleRef, name: &str, pass_task: bool,
- args: &ValueRef[]) -> ValueRef {
+ args: &[ValueRef]) -> ValueRef {
let n: int = std::ivec::len[ValueRef](args) as int;
let llnative: ValueRef = get_simple_extern_fn(externs, llmod, name, n);
- let call_args: ValueRef[] = ~[];
+ let call_args: [ValueRef] = ~[];
for a: ValueRef in args { call_args += ~[b.ZExtOrBitCast(a, T_int())]; }
ret b.Call(llnative, call_args);
}
}
fn dynamic_size_of(cx: &@block_ctxt, t: ty::t) -> result {
- fn align_elements(cx: &@block_ctxt, elts: &ty::t[]) -> result {
+ fn align_elements(cx: &@block_ctxt, elts: &[ty::t]) -> result {
//
// C padding rules:
//
ret rslt(szptr.bcx, szptr.bcx.build.Load(szptr.val));
}
ty::ty_rec(flds) {
- let tys: ty::t[] = ~[];
+ let tys: [ty::t] = ~[];
for f: ty::field in flds { tys += ~[f.mt.ty]; }
ret align_elements(cx, tys);
}
for variant: ty::variant_info in variants {
// Perform type substitution on the raw argument types.
- let raw_tys: ty::t[] = variant.args;
- let tys: ty::t[] = ~[];
+ let raw_tys: [ty::t] = variant.args;
+ let tys: [ty::t] = ~[];
for raw_ty: ty::t in raw_tys {
let t = ty::substitute_type_params(bcx_tcx(cx), tps, raw_ty);
tys += ~[t];
// Simple wrapper around GEP that takes an array of ints and wraps them
// in C_int()
-fn GEPi(cx: &@block_ctxt, base: ValueRef, ixs: &int[]) -> ValueRef {
- let v: ValueRef[] = ~[];
+fn GEPi(cx: &@block_ctxt, base: ValueRef, ixs: &[int]) -> ValueRef {
+ let v: [ValueRef] = ~[];
for i: int in ixs { v += ~[C_int(i)]; }
ret cx.build.GEP(base, v);
}
// ty::struct and knows what to do when it runs into a ty_param stuck in the
// middle of the thing it's GEP'ing into. Much like size_of and align_of,
// above.
-fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &int[]) ->
+fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &[int]) ->
result {
assert (ty::type_is_tup_like(bcx_tcx(cx), t));
// It might be a static-known type. Handle this.
// elements of the type and splitting the Xth off. Return the prefix as
// well as the innermost Xth type.
- fn split_type(ccx: &@crate_ctxt, t: &ty::t, ixs: &int[], n: uint) ->
- {prefix: ty::t[], target: ty::t} {
+ fn split_type(ccx: &@crate_ctxt, t: &ty::t, ixs: &[int], n: uint) ->
+ {prefix: [ty::t], target: ty::t} {
let len: uint = std::ivec::len[int](ixs);
// We don't support 0-index or 1-index GEPs: The former is nonsense
// and the latter would only be meaningful if we supported non-0
}
assert (n < len);
let ix: int = ixs.(n);
- let prefix: ty::t[] = ~[];
+ let prefix: [ty::t] = ~[];
let i: int = 0;
while i < ix {
prefix += ~[ty::get_element_type(ccx.tcx, t, i as uint)];
// appropriate. @llblobptr is the data part of a tag value; its actual type is
// meaningless, as it will be cast away.
fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: &ast::def_id,
- variant_id: &ast::def_id, ty_substs: &ty::t[], ix: int) -> result {
+ variant_id: &ast::def_id, ty_substs: &[ty::t], ix: int) -> result {
let variant = ty::tag_variant_with_id(bcx_tcx(cx), tag_id, variant_id);
// Synthesize a tuple type so that GEP_tup_like() can work its magic.
// Separately, store the type of the element we're interested in.
let elem_ty = ty::mk_nil(bcx_tcx(cx)); // typestate infelicity
let i = 0;
- let true_arg_tys: ty::t[] = ~[];
+ let true_arg_tys: [ty::t] = ~[];
for aty: ty::t in arg_tys {
let arg_ty = ty::substitute_type_params(bcx_tcx(cx), ty_substs, aty);
true_arg_tys += ~[arg_ty];
// indices of the ty params present in the type. This is used solely for
// constructing derived tydescs.
fn linearize_ty_params(cx: &@block_ctxt, t: &ty::t) ->
- {params: uint[], descs: ValueRef[]} {
- let param_vals: ValueRef[] = ~[];
- let param_defs: uint[] = ~[];
+ {params: [uint], descs: [ValueRef]} {
+ let param_vals: [ValueRef] = ~[];
+ let param_defs: [uint] = ~[];
type rr =
- {cx: @block_ctxt, mutable vals: ValueRef[], mutable defs: uint[]};
+ {cx: @block_ctxt, mutable vals: [ValueRef], mutable defs: [uint]};
fn linearizer(r: @rr, t: ty::t) {
alt ty::struct(bcx_tcx(r.cx), t) {
ret rslt(cx, info.tydesc);
}
-fn get_static_tydesc(cx: &@block_ctxt, orig_t: &ty::t, ty_params: &uint[]) ->
+fn get_static_tydesc(cx: &@block_ctxt, orig_t: &ty::t, ty_params: &[uint]) ->
@tydesc_info {
let t = ty::strip_cname(bcx_tcx(cx), orig_t);
// Generates the declaration for (but doesn't emit) a type descriptor.
-fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &uint[])
+fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &[uint])
-> @tydesc_info {
log "+++ declare_tydesc " + ty_to_str(cx.ccx.tcx, t);
let ccx = cx.ccx;
fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t,
llfn: ValueRef,
helper: &make_generic_glue_helper_fn,
- ty_params: &uint[]) -> ValueRef {
+ ty_params: &[uint]) -> ValueRef {
let fcx = new_fn_ctxt(cx, sp, llfn);
llvm::LLVMSetLinkage(llfn,
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
let ty_param_count = std::ivec::len[uint](ty_params);
let lltyparams = llvm::LLVMGetParam(llfn, 3u);
let copy_args_bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
- let lltydescs = ~[mutable ];
+ let lltydescs = ~[mutable];
let p = 0u;
while p < ty_param_count {
let llparam = copy_args_bcx.build.GEP(lltyparams, ~[C_int(p as int)]);
}
fn make_generic_glue(cx: &@local_ctxt, sp: &span, t: &ty::t, llfn: ValueRef,
- helper: &make_generic_glue_helper_fn, ty_params: &uint[],
+ helper: &make_generic_glue_helper_fn, ty_params: &[uint],
name: &str) -> ValueRef {
if !cx.ccx.sess.get_opts().stats {
ret make_generic_glue_inner(cx, sp, t, llfn, helper, ty_params);
}
fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
- inner_t: ty::t, tps: &ty::t[]) -> result {
+ inner_t: ty::t, tps: &[ty::t]) -> result {
let ccx = bcx_ccx(cx);
let inner_t_s = ty::substitute_type_params(ccx.tcx, tps, inner_t);
let tup_ty = ty::mk_imm_tup(ccx.tcx, ~[ty::mk_int(ccx.tcx), inner_t_s]);
if load_inner {
// If `load_inner` is true, then the pointer type will always
// be i8, because the data part of a vector always has type
- // i8[]. So we need to cast it to the proper type.
+ // [i8]. So we need to cast it to the proper type.
if !ty::type_has_dynamic_size(bcx_tcx(last_cx), t) {
let llelemty =
ret iter_structural_ty_full(cx, v, v, t, bind adaptor_fn(f, _, _, _, _));
}
-fn load_inbounds(cx: &@block_ctxt, p: ValueRef, idxs: &ValueRef[]) ->
+fn load_inbounds(cx: &@block_ctxt, p: ValueRef, idxs: &[ValueRef]) ->
ValueRef {
ret cx.build.Load(cx.build.InBoundsGEP(p, idxs));
}
fn store_inbounds(cx: &@block_ctxt, v: ValueRef, p: ValueRef,
- idxs: &ValueRef[]) {
+ idxs: &[ValueRef]) {
cx.build.Store(v, cx.build.InBoundsGEP(p, idxs));
}
}
fn iter_variant(cx: @block_ctxt, a_tup: ValueRef, b_tup: ValueRef,
- variant: &ty::variant_info, tps: &ty::t[],
+ variant: &ty::variant_info, tps: &[ty::t],
tid: &ast::def_id, f: &val_pair_and_ty_fn) -> result {
if std::ivec::len[ty::t](variant.args) == 0u {
ret rslt(cx, C_nil());
}
let llcmpresultptr = alloca(r.bcx, T_i1());
- let llargs: ValueRef[] =
+ let llargs: [ValueRef] =
~[llcmpresultptr, r.bcx.fcx.lltaskptr, lltydesc,
lltydescs, llrawlhsptr, llrawrhsptr, llop];
r.bcx.build.Call(llfn, llargs);
}
}
-fn join_results(parent_cx: &@block_ctxt, t: TypeRef, ins: &result[]) ->
+fn join_results(parent_cx: &@block_ctxt, t: TypeRef, ins: &[result]) ->
result {
- let live: result[] = ~[];
- let vals: ValueRef[] = ~[];
- let bbs: BasicBlockRef[] = ~[];
+ let live: [result] = ~[];
+ let vals: [ValueRef] = ~[];
+ let bbs: [BasicBlockRef] = ~[];
for r: result in ins {
if !is_terminated(r.bcx) {
live += ~[r];
ret rslt(join_cx, phi);
}
-fn join_branches(parent_cx: &@block_ctxt, ins: &result[]) -> @block_ctxt {
+fn join_branches(parent_cx: &@block_ctxt, ins: &[result]) -> @block_ctxt {
let out = new_sub_block_ctxt(parent_cx, "join");
for r: result in ins {
if !is_terminated(r.bcx) { r.bcx.build.Br(out.llbb); }
// construct a closure out of them. If copying is true, it is a
// heap allocated closure that copies the upvars into environment.
// Otherwise, it is stack allocated and copies pointers to the upvars.
-fn build_environment(bcx: @block_ctxt, lltydescs: ValueRef[],
- bound_tys: ty::t[], bound_vals: lval_result[],
+fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
+ bound_tys: [ty::t], bound_vals: [lval_result],
copying: bool)
-> {ptr: ValueRef, ptrty: ty::t, bcx: @block_ctxt} {
// Synthesize a closure type.
// (We'll need room for that many tydescs in the closure.)
let ty_param_count = std::ivec::len(lltydescs);
let tydesc_ty: ty::t = ty::mk_type(bcx_tcx(bcx));
- let captured_tys: ty::t[] =
+ let captured_tys: [ty::t] =
std::ivec::init_elt(tydesc_ty, ty_param_count);
// Get all the types we've got (some of which we synthesized
// closure_tys = [tydesc_ty, [bound_ty1, bound_ty2, ...], [tydesc_ty,
// tydesc_ty, ...]]
- let closure_tys: ty::t[] =
+ let closure_tys: [ty::t] =
~[tydesc_ty, bindings_ty, ty::mk_imm_tup(bcx_tcx(bcx), captured_tys)];
// Finally, synthesize a type for that whole vector.
// Given a context and a list of upvars, build a closure. This just
// collects the upvars and packages them up for build_environment.
-fn build_closure(cx: &@block_ctxt, upvars: &@ast::node_id[], copying: bool)
+fn build_closure(cx: &@block_ctxt, upvars: &@[ast::node_id], copying: bool)
-> {ptr: ValueRef, ptrty: ty::t, bcx: @block_ctxt} {
- let closure_vals: lval_result[] = ~[];
- let closure_tys: ty::t[] = ~[];
+ let closure_vals: [lval_result] = ~[];
+ let closure_tys: [ty::t] = ~[];
// If we need to, package up the iterator body to call
if !copying && !option::is_none(cx.fcx.lliterbody) {
closure_vals += ~[lval_mem(cx, option::get(cx.fcx.lliterbody))];
// and a list of upvars, generate code to load and populate the environment
// with the upvars and type descriptors.
fn load_environment(enclosing_cx: &@block_ctxt, fcx: &@fn_ctxt,
- envty: &ty::t, upvars: &@ast::node_id[],
+ envty: &ty::t, upvars: &@[ast::node_id],
copying: bool) {
let bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
type generic_info =
{item_type: ty::t,
- static_tis: (option::t[@tydesc_info])[],
- tydescs: ValueRef[]};
+ static_tis: [option::t[@tydesc_info]],
+ tydescs: [ValueRef]};
type lval_result =
{res: result,
let tys = ty::node_id_to_type_params(bcx_tcx(cx), id);
if std::ivec::len[ty::t](tys) != 0u {
let bcx = lv.res.bcx;
- let tydescs: ValueRef[] = ~[];
- let tis: (option::t[@tydesc_info])[] = ~[];
+ let tydescs: [ValueRef] = ~[];
+ let tis: [option::t[@tydesc_info]] = ~[];
for t: ty::t in tys {
// TODO: Doesn't always escape.
ret lval_mem(cx, ccx.consts.get(did.node));
} else {
let tp = ty::node_id_to_monotype(ccx.tcx, id);
- let k: ast::kind[] = ~[];
+ let k: [ast::kind] = ~[];
ret lval_val(cx,
load_if_immediate(cx,
trans_external_path(cx, did,
}
fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
- outgoing_fty: &ty::t, args: &(option::t[@ast::expr])[],
- env_ty: &ty::t, bound_tys: &ty::t[],
+ outgoing_fty: &ty::t, args: &[option::t[@ast::expr]],
+ env_ty: &ty::t, bound_tys: &[ty::t],
ty_param_count: uint) -> {val: ValueRef, ty: TypeRef} {
// Here we're not necessarily constructing a thunk in the sense of
}
// Set up the three implicit arguments to the thunk.
- let llargs: ValueRef[] = ~[llretptr, fcx.lltaskptr, lltargetclosure];
+ let llargs: [ValueRef] = ~[llretptr, fcx.lltaskptr, lltargetclosure];
// Copy in the type parameters.
let i: uint = 0u;
let a: uint = 3u; // retptr, task ptr, env come first
let b: int = 1;
let outgoing_arg_index: uint = 0u;
- let llout_arg_tys: TypeRef[] =
+ let llout_arg_tys: [TypeRef] =
type_of_explicit_args(cx.ccx, sp, outgoing_args);
for arg: option::t[@ast::expr] in args {
let out_arg = outgoing_args.(outgoing_arg_index);
}
fn trans_bind(cx: &@block_ctxt, f: &@ast::expr,
- args: &(option::t[@ast::expr])[], id: ast::node_id) -> result {
+ args: &[option::t[@ast::expr]], id: ast::node_id) -> result {
let f_res = trans_lval_gen(cx, f);
ret trans_bind_1(cx, f, f_res, args, id);
}
fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
- args: &(option::t[@ast::expr])[], id: ast::node_id) ->
+ args: &[option::t[@ast::expr]], id: ast::node_id) ->
result {
- let bound: (@ast::expr)[] = ~[];
+ let bound: [@ast::expr] = ~[];
for argopt: option::t[@ast::expr] in args {
alt argopt { none. { } some(e) { bound += ~[e]; } }
}
// Figure out which tydescs we need to pass, if any.
let outgoing_fty: ty::t = ty::expr_ty(bcx_tcx(cx), f);
let outgoing_fty_real; // the type with typarams still in it
- let lltydescs: ValueRef[];
+ let lltydescs: [ValueRef];
alt f_res.generic {
none. { outgoing_fty_real = outgoing_fty; lltydescs = ~[]; }
some(ginfo) {
let bound_f = {res: {bcx: bcx, val: src_loc} with f_res};
// Arrange for the bound function to live in the first binding spot.
- let bound_tys: ty::t[] = ~[outgoing_fty];
- let bound_vals: lval_result[] = ~[bound_f];
+ let bound_tys: [ty::t] = ~[outgoing_fty];
+ let bound_vals: [lval_result] = ~[bound_f];
// Translate the bound expressions.
for e: @ast::expr in bound {
let lv = trans_lval(bcx, e);
// - trans_args
fn trans_args(cx: &@block_ctxt, llenv: ValueRef,
gen: &option::t[generic_info], lliterbody: &option::t[ValueRef],
- es: &(@ast::expr)[], fn_ty: &ty::t) ->
- {bcx: @block_ctxt, args: ValueRef[], retslot: ValueRef} {
- let args: ty::arg[] = ty::ty_fn_args(bcx_tcx(cx), fn_ty);
- let llargs: ValueRef[] = ~[];
- let lltydescs: ValueRef[] = ~[];
+ es: &[@ast::expr], fn_ty: &ty::t) ->
+ {bcx: @block_ctxt, args: [ValueRef], retslot: ValueRef} {
+ let args: [ty::arg] = ty::ty_fn_args(bcx_tcx(cx), fn_ty);
+ let llargs: [ValueRef] = ~[];
+ let lltydescs: [ValueRef] = ~[];
let bcx: @block_ctxt = cx;
// Arg 0: Output pointer.
}
fn trans_call(cx: &@block_ctxt, f: &@ast::expr,
- lliterbody: &option::t[ValueRef], args: &(@ast::expr)[],
+ lliterbody: &option::t[ValueRef], args: &[@ast::expr],
id: ast::node_id) -> result {
// NB: 'f' isn't necessarily a function; it might be an entire self-call
// expression because of the hack that allows us to process self-calls
ret rslt(bcx, retval);
}
-fn trans_vec(cx: &@block_ctxt, args: &(@ast::expr)[], id: ast::node_id) ->
+fn trans_vec(cx: &@block_ctxt, args: &[@ast::expr], id: ast::node_id) ->
result {
let t = node_id_type(bcx_ccx(cx), id);
let unit_ty = t;
// TODO: Move me to ivec::
-fn trans_ivec(bcx: @block_ctxt, args: &(@ast::expr)[], id: ast::node_id) ->
+fn trans_ivec(bcx: @block_ctxt, args: &[@ast::expr], id: ast::node_id) ->
result {
let typ = node_id_type(bcx_ccx(bcx), id);
let unit_ty;
ret rslt(bcx, llvecptr);
}
-fn trans_rec(cx: &@block_ctxt, fields: &ast::field[],
+fn trans_rec(cx: &@block_ctxt, fields: &[ast::field],
base: &option::t[@ast::expr], id: ast::node_id) -> result {
let bcx = cx;
let t = node_id_type(bcx_ccx(bcx), id);
base_val = base_res.val;
}
}
- let ty_fields: ty::field[] = ~[];
+ let ty_fields: [ty::field] = ~[];
alt ty::struct(bcx_tcx(cx), t) { ty::ty_rec(flds) { ty_fields = flds; } }
for tf: ty::field in ty_fields {
let e_ty = tf.mt.ty;
}
let bcx = cx;
let dummy_retslot = alloca(bcx, T_nil());
- let llargs: ValueRef[] = ~[dummy_retslot, cx.fcx.lltaskptr, llenv];
+ let llargs: [ValueRef] = ~[dummy_retslot, cx.fcx.lltaskptr, llenv];
alt e {
none. { }
some(x) {
// Fields.
// FIXME (part of issue #538): Where do we fill in the field *values* from
// the outer object?
- let additional_fields: ast::anon_obj_field[] = ~[];
- let additional_field_vals: result[] = ~[];
- let additional_field_tys: ty::t[] = ~[];
+ let additional_fields: [ast::anon_obj_field] = ~[];
+ let additional_field_vals: [result] = ~[];
+ let additional_field_tys: [ty::t] = ~[];
alt anon_obj.fields {
none. { }
some(fields) {
// next three functions instead.
fn new_block_ctxt(cx: &@fn_ctxt, parent: &block_parent, kind: block_kind,
name: &str) -> @block_ctxt {
- let cleanups: cleanup[] = ~[];
+ let cleanups: [cleanup] = ~[];
let s = str::buf("");
let held_name; //HACK for str::buf, which doesn't keep its value alive
if cx.lcx.ccx.sess.get_opts().save_temps ||
}
fn new_raw_block_ctxt(fcx: &@fn_ctxt, llbb: BasicBlockRef) -> @block_ctxt {
- let cleanups: cleanup[] = ~[];
+ let cleanups: [cleanup] = ~[];
ret @{llbb: llbb,
build: new_builder(llbb),
parent: parent_none,
}
fn llstaticallocas_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt {
- let cleanups: cleanup[] = ~[];
+ let cleanups: [cleanup] = ~[];
ret @{llbb: fcx.llstaticallocas,
build: new_builder(fcx.llstaticallocas),
parent: parent_none,
}
fn llderivedtydescs_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt {
- let cleanups: cleanup[] = ~[];
+ let cleanups: [cleanup] = ~[];
ret @{llbb: fcx.llderivedtydescs,
build: new_builder(fcx.llderivedtydescs),
parent: parent_none,
}
fn lldynamicallocas_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt {
- let cleanups: cleanup[] = ~[];
+ let cleanups: [cleanup] = ~[];
ret @{llbb: fcx.lldynamicallocas,
build: new_builder(fcx.lldynamicallocas),
parent: parent_none,
}
fn new_local_ctxt(ccx: &@crate_ctxt) -> @local_ctxt {
- let pth: str[] = ~[];
+ let pth: [str] = ~[];
ret @{path: pth,
module_path: ~[ccx.link_meta.name],
obj_typarams: ~[],
// field of the fn_ctxt with
fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto,
ty_self: option::t[ty::t], ret_ty: ty::t,
- args: &ast::arg[], ty_params: &ast::ty_param[]) {
+ args: &[ast::arg], ty_params: &[ast::ty_param]) {
// Skip the implicit arguments 0, 1, and 2. TODO: Pull out 3u and define
// it as a constant, since we're using it in several places in trans this
// way.
}
}
-fn copy_args_to_allocas(fcx: @fn_ctxt, args: &ast::arg[],
- arg_tys: &ty::arg[]) {
+fn copy_args_to_allocas(fcx: @fn_ctxt, args: &[ast::arg],
+ arg_tys: &[ty::arg]) {
let bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
let arg_n: uint = 0u;
for aarg: ast::arg in args {
}
}
-fn add_cleanups_for_args(bcx: &@block_ctxt, args: &ast::arg[],
- arg_tys: &ty::arg[]) {
+fn add_cleanups_for_args(bcx: &@block_ctxt, args: &[ast::arg],
+ arg_tys: &[ty::arg]) {
let arg_n: uint = 0u;
for aarg: ast::arg in args {
if aarg.mode == ast::val {
ret llvm::LLVMIsATerminatorInst(inst) as int != 0;
}
-fn arg_tys_of_fn(ccx: &@crate_ctxt, id: ast::node_id) -> ty::arg[] {
+fn arg_tys_of_fn(ccx: &@crate_ctxt, id: ast::node_id) -> [ty::arg] {
alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id)) {
ty::ty_fn(_, arg_tys, _, _, _) { ret arg_tys; }
}
fn populate_fn_ctxt_from_llself(fcx: @fn_ctxt, llself: val_self_pair) {
let bcx = llstaticallocas_block_ctxt(fcx);
- let field_tys: ty::t[] = ~[];
+ let field_tys: [ty::t] = ~[];
for f: ast::obj_field in bcx.fcx.lcx.obj_fields {
field_tys += ~[node_id_type(bcx_ccx(bcx), f.id)];
}
fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
llfnty: &option::t[TypeRef], cx: @local_ctxt, sp: &span,
f: &ast::_fn, llfndecl: ValueRef, ty_self: option::t[ty::t],
- ty_params: &ast::ty_param[], id: ast::node_id)
+ ty_params: &[ast::ty_param], id: ast::node_id)
-> option::t[{fn_pair: ValueRef, bcx: @block_ctxt}] {
set_uwtable(llfndecl);
fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn,
llfndecl: ValueRef, ty_self: option::t[ty::t],
- ty_params: &ast::ty_param[], id: ast::node_id) {
+ ty_params: &[ast::ty_param], id: ast::node_id) {
trans_closure(none, none, cx, sp, f, llfndecl, ty_self, ty_params, id);
}
// trans_fn: creates an LLVM function corresponding to a source language
// function.
fn trans_fn(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef,
- ty_self: option::t[ty::t], ty_params: &ast::ty_param[],
+ ty_self: option::t[ty::t], ty_params: &[ast::ty_param],
id: ast::node_id) {
if !cx.ccx.sess.get_opts().stats {
trans_fn_inner(cx, sp, f, llfndecl, ty_self, ty_params, id);
// the corresponding method on inner does, calls that method on outer, and
// returns the value returned from that call.
fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
- ty_params: &ast::ty_param[], outer_obj_ty: ty::t,
- additional_field_tys: &ty::t[]) -> ValueRef {
+ ty_params: &[ast::ty_param], outer_obj_ty: ty::t,
+ additional_field_tys: &[ty::t]) -> ValueRef {
// Create a local context that's aware of the name of the method we're
// creating.
// Set up the three implicit arguments to the outer method we'll need
// to call.
let self_arg = llself_obj_ptr;
- let llouter_mthd_args: ValueRef[] = ~[llretptr, fcx.lltaskptr, self_arg];
+ let llouter_mthd_args: [ValueRef] = ~[llretptr, fcx.lltaskptr, self_arg];
// Copy the explicit arguments that are being passed into the forwarding
// function (they're in fcx.llargs) to llouter_mthd_args.
// from that call. (The inner object won't exist until run-time, but we know
// its type statically.)
fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
- ty_params: &ast::ty_param[], inner_obj_ty: ty::t,
+ ty_params: &[ast::ty_param], inner_obj_ty: ty::t,
backwarding_vtbl: ValueRef,
- additional_field_tys: &ty::t[]) -> ValueRef {
+ additional_field_tys: &[ty::t]) -> ValueRef {
// Create a local context that's aware of the name of the method we're
// creating.
// Set up the three implicit arguments to the original method we'll need
// to call.
- let llorig_mthd_args: ValueRef[] = ~[llretptr, fcx.lltaskptr, self_stack];
+ let llorig_mthd_args: [ValueRef] = ~[llretptr, fcx.lltaskptr, self_stack];
// Copy the explicit arguments that are being passed into the forwarding
// function (they're in fcx.llargs) to llorig_mthd_args.
// process_normal_mthd: Create the contents of a normal vtable slot. A helper
// function for create_vtbl.
fn process_normal_mthd(cx: @local_ctxt, m: @ast::method, self_ty: ty::t,
- ty_params: &ast::ty_param[]) -> ValueRef {
+ ty_params: &[ast::ty_param]) -> ValueRef {
let llfnty = T_nil();
alt ty::struct(cx.ccx.tcx, node_id_type(cx.ccx, m.node.id)) {
// Create a vtable for an object being translated. Returns a pointer into
// read-only memory.
fn create_vtbl(cx: @local_ctxt, sp: &span, outer_obj_ty: ty::t,
- ob: &ast::_obj, ty_params: &ast::ty_param[],
+ ob: &ast::_obj, ty_params: &[ast::ty_param],
inner_obj_ty: option::t[ty::t],
- additional_field_tys: &ty::t[]) -> ValueRef {
+ additional_field_tys: &[ty::t]) -> ValueRef {
- let llmethods: ValueRef[] = ~[];
+ let llmethods: [ValueRef] = ~[];
alt inner_obj_ty {
none. {
// original methods onto the list of methods we need forwarding
// methods for.
- let meths: vtbl_mthd[] = ~[];
+ let meths: [vtbl_mthd] = ~[];
// Gather up methods on the original object in 'meths'.
alt ty::struct(cx.ccx.tcx, inner_obj_ty) {
// object, and it needs to forward them to the corresponding slots on the
// outer object. All we know about either one are their types.
- let llmethods: ValueRef[] = ~[];
- let meths: ty::method[]= ~[];
+ let llmethods: [ValueRef] = ~[];
+ let meths: [ty::method]= ~[];
// Gather up methods on the inner object.
alt ty::struct(cx.ccx.tcx, inner_obj_ty) {
// trans_obj: creates an LLVM function that is the object constructor for the
// object being translated.
fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj,
- ctor_id: ast::node_id, ty_params: &ast::ty_param[]) {
+ ctor_id: ast::node_id, ty_params: &[ast::ty_param]) {
// To make a function, we have to create a function context and, inside
// that, a number of block contexts for which code is generated.
// The fields of our object will become the arguments to the function
// we're creating.
- let fn_args: ast::arg[] = ~[];
+ let fn_args: [ast::arg] = ~[];
for f: ast::obj_field in ob.fields {
fn_args +=
~[{mode: ast::alias(false), ty: f.ty, ident: f.ident, id: f.id}];
create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty::t],
ty::ret_ty_of_fn(ccx.tcx, ctor_id), fn_args,
ty_params);
- let arg_tys: ty::arg[] = arg_tys_of_fn(ccx, ctor_id);
+ let arg_tys: [ty::arg] = arg_tys_of_fn(ccx, ctor_id);
copy_args_to_allocas(fcx, fn_args, arg_tys);
// Create the first block context in the function and keep a handle on it
} else {
// Otherwise, we have to synthesize a big structural type for the
// object body.
- let obj_fields: ty::t[] = ~[];
+ let obj_fields: [ty::t] = ~[];
for a: ty::arg in arg_tys { obj_fields += ~[a.ty]; }
// Tuple type for fields: [field, ...]
let fields_ty: ty::t = ty::mk_imm_tup(ccx.tcx, obj_fields);
let tydesc_ty = ty::mk_type(ccx.tcx);
- let tps: ty::t[] = ~[];
+ let tps: [ty::t] = ~[];
for tp: ast::ty_param in ty_params { tps += ~[tydesc_ty]; }
// Tuple type for typarams: [typaram, ...]
}
fn trans_res_ctor(cx: @local_ctxt, sp: &span, dtor: &ast::_fn,
- ctor_id: ast::node_id, ty_params: &ast::ty_param[]) {
+ ctor_id: ast::node_id, ty_params: &[ast::ty_param]) {
// Create a function for the constructor
let llctor_decl;
alt cx.ccx.item_ids.find(ctor_id) {
fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
variant: &ast::variant, index: int, is_degen: bool,
- ty_params: &ast::ty_param[]) {
+ ty_params: &[ast::ty_param]) {
if std::ivec::len[ast::variant_arg](variant.node.args) == 0u {
ret; // nullary constructors are just constants
}
// Translate variant arguments to function arguments.
- let fn_args: ast::arg[] = ~[];
+ let fn_args: [ast::arg] = ~[];
let i = 0u;
for varg: ast::variant_arg in variant.node.args {
fn_args +=
create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty::t],
ty::ret_ty_of_fn(cx.ccx.tcx, variant.node.id),
fn_args, ty_params);
- let ty_param_substs: ty::t[] = ~[];
+ let ty_param_substs: [ty::t] = ~[];
i = 0u;
for tp: ast::ty_param in ty_params {
ty_param_substs += ~[ty::mk_param(cx.ccx.tcx, i, tp.kind)];
ret struct_elt(llpairty, 0u);
}
-fn decl_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[], flav: str,
- ty_params: &ast::ty_param[], node_id: ast::node_id) {
+fn decl_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str], flav: str,
+ ty_params: &[ast::ty_param], node_id: ast::node_id) {
decl_fn_and_pair_full(ccx, sp, path, flav, ty_params, node_id,
node_id_type(ccx, node_id));
}
-fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &str[],
- flav: str, ty_params: &ast::ty_param[],
+fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &[str],
+ flav: str, ty_params: &[ast::ty_param],
node_id: ast::node_id, node_type: ty::t) {
let llfty = type_of_fn_from_ty(ccx, sp, node_type,
std::ivec::len(ty_params));
}
}
-fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &str[],
+fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str],
name: str, id: ast::node_id) {
let num_ty_param = native_fn_ty_param_count(ccx, id);
// Declare the wrapper.
lltaskptr = vp2i(bcx, fcx.lltaskptr);
} else { lltaskptr = fcx.lltaskptr; }
- let call_args: ValueRef[] = ~[];
+ let call_args: [ValueRef] = ~[];
if pass_task { call_args += ~[lltaskptr]; }
if uses_retptr { call_args += ~[bcx.fcx.llretptr]; }
}
fn trans_simple_native_abi(bcx: &@block_ctxt, name: str,
- call_args: &mutable ValueRef[], fn_type: ty::t,
+ call_args: &mutable [ValueRef], fn_type: ty::t,
first_arg_n: uint, uses_retptr: bool, cc: uint)
-> {val: ValueRef, rptr: ValueRef} {
- let call_arg_tys: TypeRef[] = ~[];
+ let call_arg_tys: [TypeRef] = ~[];
for arg: ValueRef in call_args { call_arg_tys += ~[val_ty(arg)]; }
let llnativefnty;
let args = ty::ty_fn_args(ccx.tcx, fn_type);
// Build up the list of arguments.
- let drop_args: {val: ValueRef, ty: ty::t}[] = ~[];
+ let drop_args: [{val: ValueRef, ty: ty::t}] = ~[];
let i = arg_n;
for arg: ty::arg in args {
let llarg = llvm::LLVMGetParam(fcx.llfn, i);
finish_fn(fcx, lltop);
}
-fn item_path(item: &@ast::item) -> str[] { ret ~[item.ident]; }
+fn item_path(item: &@ast::item) -> [str] { ret ~[item.ident]; }
-fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &str[],
- v: &vt[str[]]) {
+fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &[str],
+ v: &vt[[str]]) {
alt i.node {
ast::native_item_fn(_, _, _) {
if !ccx.obj_methods.contains_key(i.id) {
}
}
-fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &str[],
- v: &vt[str[]]) {
+fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str],
+ v: &vt[[str]]) {
visit::visit_item(i, pt + item_path(i), v);
alt i.node {
ast::item_const(_, _) {
}
}
-fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &str[],
- v: &vt[str[]]) {
+fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &[str],
+ v: &vt[[str]]) {
let new_pt = pt + item_path(i);
visit::visit_item(i, new_pt, v);
alt i.node {
visit::visit_crate(*crate, ~[], visit::mk_vt(visitor2));
}
-fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &str[],
- v: &vt[str[]]) {
+fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &[str],
+ v: &vt[[str]]) {
let new_pt = pt + item_path(i);
visit::visit_item(i, new_pt, v);
alt i.node {
// The constant translation pass.
-fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &str[],
- v: &vt[str[]]) {
+fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[str],
+ v: &vt[[str]]) {
let new_pt = pt + item_path(it);
visit::visit_item(it, new_pt, v);
alt it.node {
}
fn declare_intrinsics(llmod: ModuleRef) -> hashmap[str, ValueRef] {
- let T_memmove32_args: TypeRef[] =
+ let T_memmove32_args: [TypeRef] =
~[T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()];
- let T_memmove64_args: TypeRef[] =
+ let T_memmove64_args: [TypeRef] =
~[T_ptr(T_i8()), T_ptr(T_i8()), T_i64(), T_i32(), T_i1()];
- let T_memset32_args: TypeRef[] =
+ let T_memset32_args: [TypeRef] =
~[T_ptr(T_i8()), T_i8(), T_i32(), T_i32(), T_i1()];
- let T_memset64_args: TypeRef[] =
+ let T_memset64_args: [TypeRef] =
~[T_ptr(T_i8()), T_i8(), T_i64(), T_i32(), T_i1()];
- let T_trap_args: TypeRef[] = ~[];
+ let T_trap_args: [TypeRef] = ~[];
let memmove32 =
decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i32",
T_fn(T_memmove32_args, T_void()));
}
fn trap(bcx: &@block_ctxt) {
- let v: ValueRef[] = ~[];
+ let v: [ValueRef] = ~[];
alt bcx_ccx(bcx).intrinsics.find("llvm.trap") {
some(x) { bcx.build.Call(x, v); }
_ { bcx_ccx(bcx).sess.bug("unbound llvm.trap in trap"); }
llvm::LLVMAddGlobal(ccx.llmod, maptype, str::buf("_rust_mod_map"));
llvm::LLVMSetLinkage(map,
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
- let elts: ValueRef[] = ~[];
+ let elts: [ValueRef] = ~[];
for each item: @{key: str, val: ValueRef} in ccx.module_data.items() {
let elt = C_struct(~[p2i(C_cstr(ccx, item.key)), p2i(item.val)]);
elts += ~[elt];
// FIXME use hashed metadata instead of crate names once we have that
fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef {
- let subcrates: ValueRef[] = ~[];
+ let subcrates: [ValueRef] = ~[];
let i = 1;
let cstore = ccx.sess.get_cstore();
while cstore::have_crate_data(cstore, i) {
fail;
}
-type bind_map = {ident: ast::ident, val: ValueRef}[];
+type bind_map = [{ident: ast::ident, val: ValueRef}];
type match_branch =
- @{pats: (@ast::pat)[], body: BasicBlockRef, mutable bound: bind_map};
-type match = match_branch[];
+ @{pats: [@ast::pat], body: BasicBlockRef, mutable bound: bind_map};
+type match = [match_branch];
fn matches_always(p: &@ast::pat) -> bool {
ret alt p.node {
}
}
-type enter_pat = fn(&@ast::pat) -> option::t[(@ast::pat)[]] ;
+type enter_pat = fn(&@ast::pat) -> option::t[[@ast::pat]] ;
fn enter_match(m: &match, col: uint, val: ValueRef, e: &enter_pat) -> match {
let result = ~[];
}
fn enter_default(m: &match, col: uint, val: ValueRef) -> match {
- fn e(p: &@ast::pat) -> option::t[(@ast::pat)[]] {
+ fn e(p: &@ast::pat) -> option::t[[@ast::pat]] {
ret if matches_always(p) { some(~[]) } else { none };
}
ret enter_match(m, col, val, e);
tag_size: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
fn e(ccx: &@crate_ctxt, dummy: &@ast::pat, opt: &opt, size: uint,
- p: &@ast::pat) -> option::t[(@ast::pat)[]] {
+ p: &@ast::pat) -> option::t[[@ast::pat]] {
alt p.node {
ast::pat_tag(ctor, subpats) {
ret if opt_eq(variant_opt(ccx, p.id), opt) {
ret enter_match(m, col, val, bind e(ccx, dummy, opt, tag_size, _));
}
-fn enter_rec(m: &match, col: uint, fields: &ast::ident[], val: ValueRef) ->
+fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
match {
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
- fn e(dummy: &@ast::pat, fields: &ast::ident[], p: &@ast::pat) ->
- option::t[(@ast::pat)[]] {
+ fn e(dummy: &@ast::pat, fields: &[ast::ident], p: &@ast::pat) ->
+ option::t[[@ast::pat]] {
alt p.node {
ast::pat_rec(fpats, _) {
let pats = ~[];
fn enter_box(m: &match, col: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
- fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t[(@ast::pat)[]] {
+ fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t[[@ast::pat]] {
alt p.node {
ast::pat_box(sub) { ret some(~[sub]); }
_ { ret some(~[dummy]); }
ret enter_match(m, col, val, bind e(dummy, _));
}
-fn get_options(ccx: &@crate_ctxt, m: &match, col: uint) -> opt[] {
- fn add_to_set(set: &mutable opt[], val: &opt) {
+fn get_options(ccx: &@crate_ctxt, m: &match, col: uint) -> [opt] {
+ fn add_to_set(set: &mutable [opt], val: &opt) {
for l: opt in set { if opt_eq(l, val) { ret; } }
set += ~[val];
}
fn extract_variant_args(bcx: @block_ctxt, pat_id: ast::node_id,
vdefs: &{tg: def_id, var: def_id}, val: ValueRef)
- -> {vals: ValueRef[], bcx: @block_ctxt} {
+ -> {vals: [ValueRef], bcx: @block_ctxt} {
let ccx = bcx.fcx.lcx.ccx;
let ty_param_substs = ty::node_id_to_type_params(ccx.tcx, pat_id);
let blobptr = val;
ret {vals: args, bcx: bcx};
}
-fn collect_record_fields(m: &match, col: uint) -> ast::ident[] {
+fn collect_record_fields(m: &match, col: uint) -> [ast::ident] {
let fields = ~[];
for br: match_branch in m {
alt br.pats.(col).node {
ret best_col;
}
-fn compile_submatch(bcx: @block_ctxt, m: &match, vals: ValueRef[],
- f: &mk_fail, exits: &mutable exit_node[]) {
+fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
+ f: &mk_fail, exits: &mutable [exit_node]) {
if ivec::len(m) == 0u { bcx.build.Br(f()); ret; }
if ivec::len(m.(0).pats) == 0u {
exits += ~[{bound: m.(0).bound, from: bcx.llbb, to: m.(0).body}];
}
// Returns false for unreachable blocks
-fn make_phi_bindings(bcx: &@block_ctxt, map: &exit_node[],
+fn make_phi_bindings(bcx: &@block_ctxt, map: &[exit_node],
ids: &ast::pat_id_map) -> bool {
fn assoc(key: str, list: &bind_map) -> option::t[ValueRef] {
for elt: {ident: ast::ident, val: ValueRef} in list {
ret success;
}
-fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &ast::arm[],
+fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &[ast::arm],
id: ast::node_id, output: &trans::out_method) -> result {
let bodies = ~[];
let match: match = ~[];
}
fn trans_spawn(cx: &@block_ctxt, dom: &ast::spawn_dom, name: &option::t[str],
- func: &@ast::expr, args: &(@ast::expr)[], id: ast::node_id) ->
+ func: &@ast::expr, args: &[@ast::expr], id: ast::node_id) ->
result {
let bcx = cx;
// Make the task name
// Translate the arguments, remembering their types and where the values
// ended up.
- let arg_tys: ty::t[] = ~[];
- let arg_vals: ValueRef[] = ~[];
+ let arg_tys: [ty::t] = ~[];
+ let arg_vals: [ValueRef] = ~[];
for e: @ast::expr in args {
let e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
let arg = trans_expr(bcx, e);
// 3u to skip the three implicit args
let arg: ValueRef = llvm::LLVMGetParam(fcx.llfn, 3u);
- let child_args: ValueRef[] =
+ let child_args: [ValueRef] =
~[llvm::LLVMGetParam(fcx.llfn, 0u), llvm::LLVMGetParam(fcx.llfn, 1u),
llvm::LLVMGetParam(fcx.llfn, 2u)];
// unpack the arguments
mutable drop_glue: option::t[ValueRef],
mutable free_glue: option::t[ValueRef],
mutable cmp_glue: option::t[ValueRef],
- ty_params: uint[]};
+ ty_params: [uint]};
/*
* A note on nomenclature of linking: "upcall", "extern" and "native".
mutable n_glues_created: uint,
mutable n_null_glues: uint,
mutable n_real_glues: uint,
- fn_times: @mutable {ident: str, time: int}[]};
+ fn_times: @mutable [{ident: str, time: int}]};
// Crate context. Every crate we compile has one of these.
type crate_ctxt = {
};
type local_ctxt =
- {path: str[],
- module_path: str[],
- obj_typarams: ast::ty_param[],
- obj_fields: ast::obj_field[],
+ {path: [str],
+ module_path: [str],
+ obj_typarams: [ast::ty_param],
+ obj_fields: [ast::obj_field],
ccx: @crate_ctxt};
// Types used for llself.
// this functions type parameters, fetched via llvm::LLVMGetParam.
// For example, for a function foo[A, B, C](), lltydescs contains
// the ValueRefs for the tydescs for A, B, and C.
- mutable lltydescs: ValueRef[],
+ mutable lltydescs: [ValueRef],
// Derived tydescs are tydescs created at runtime, for types that
// involve type parameters inside type constructors. For example,
// A list of functions that run at the end of translating this
// block, cleaning up any variables that were introduced in the
// block and need to go out of scope at the end of it.
- mutable cleanups: cleanup[],
+ mutable cleanups: [cleanup],
// The source span where this block comes from, for error
// reporting.
ret T_i32();
}
-fn T_fn(inputs: &TypeRef[], output: TypeRef) -> TypeRef {
+fn T_fn(inputs: &[TypeRef], output: TypeRef) -> TypeRef {
ret llvm::LLVMFunctionType(output, std::ivec::to_ptr(inputs),
std::ivec::len[TypeRef](inputs), False);
}
fn T_ptr(t: TypeRef) -> TypeRef { ret llvm::LLVMPointerType(t, 0u); }
-fn T_struct(elts: &TypeRef[]) -> TypeRef {
+fn T_struct(elts: &[TypeRef]) -> TypeRef {
ret llvm::LLVMStructType(std::ivec::to_ptr(elts), std::ivec::len(elts),
False);
}
ret llvm::LLVMStructCreateNamed(c, str::buf(name));
}
-fn set_struct_body(t: TypeRef, elts: &TypeRef[]) {
+fn set_struct_body(t: TypeRef, elts: &[TypeRef]) {
llvm::LLVMStructSetBody(t, std::ivec::to_ptr(elts), std::ivec::len(elts),
False);
}
fn T_tydesc_field(cx: &crate_ctxt, field: int) -> TypeRef {
// Bit of a kludge: pick the fn typeref out of the tydesc..
- let tydesc_elts: TypeRef[] =
+ let tydesc_elts: [TypeRef] =
std::ivec::init_elt[TypeRef](T_nil(), abi::n_tydesc_fields as uint);
llvm::LLVMGetStructElementTypes(cx.tydesc_type,
std::ivec::to_ptr[TypeRef](tydesc_elts));
fn C_zero_byte_arr(size: uint) -> ValueRef {
let i = 0u;
- let elts: ValueRef[] = ~[];
+ let elts: [ValueRef] = ~[];
while i < size { elts += ~[C_u8(0u)]; i += 1u; }
ret llvm::LLVMConstArray(T_i8(), std::ivec::to_ptr(elts),
std::ivec::len(elts));
}
-fn C_struct(elts: &ValueRef[]) -> ValueRef {
+fn C_struct(elts: &[ValueRef]) -> ValueRef {
ret llvm::LLVMConstStruct(std::ivec::to_ptr(elts), std::ivec::len(elts),
False);
}
-fn C_named_struct(T: TypeRef, elts: &ValueRef[]) -> ValueRef {
+fn C_named_struct(T: TypeRef, elts: &[ValueRef]) -> ValueRef {
ret llvm::LLVMConstNamedStruct(T, std::ivec::to_ptr(elts),
std::ivec::len(elts));
}
-fn C_array(ty: TypeRef, elts: &ValueRef[]) -> ValueRef {
+fn C_array(ty: TypeRef, elts: &[ValueRef]) -> ValueRef {
ret llvm::LLVMConstArray(ty, std::ivec::to_ptr(elts),
std::ivec::len(elts));
}
-fn C_bytes(bytes : &u8[]) -> ValueRef {
+fn C_bytes(bytes : &[u8]) -> ValueRef {
ret llvm::LLVMConstString(unsafe::reinterpret_cast(ivec::to_ptr(bytes)),
ivec::len(bytes), False);
}
-fn C_shape(ccx : &@crate_ctxt, bytes : &u8[]) -> ValueRef {
+fn C_shape(ccx : &@crate_ctxt, bytes : &[u8]) -> ValueRef {
let llshape = C_bytes(bytes);
let llglobal = llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape),
str::buf(ccx.names.next("shape")));
import aux::add_node;
import middle::tstate::ann::empty_ann;
-fn collect_ids_expr(e: &@expr, rs: @mutable node_id[]) { *rs += ~[e.id]; }
+fn collect_ids_expr(e: &@expr, rs: @mutable [node_id]) { *rs += ~[e.id]; }
-fn collect_ids_block(b: &blk, rs: @mutable node_id[]) { *rs += ~[b.node.id]; }
+fn collect_ids_block(b: &blk, rs: @mutable [node_id]) { *rs += ~[b.node.id]; }
-fn collect_ids_stmt(s: &@stmt, rs: @mutable node_id[]) {
+fn collect_ids_stmt(s: &@stmt, rs: @mutable [node_id]) {
alt s.node {
stmt_decl(_, id) {
log "node_id " + int::str(id);
}
}
-fn collect_ids_local(l: &@local, rs: @mutable node_id[]) {
+fn collect_ids_local(l: &@local, rs: @mutable [node_id]) {
*rs += pat_binding_ids(l.node.pat);
}
-fn node_ids_in_fn(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident,
- id: node_id, rs: @mutable node_id[]) {
+fn node_ids_in_fn(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident,
+ id: node_id, rs: @mutable [node_id]) {
let collect_ids =
visit::mk_simple_visitor(@{visit_expr: bind collect_ids_expr(_, rs),
visit_block: bind collect_ids_block(_, rs),
visit::visit_fn(f, tps, sp, i, id, (), collect_ids);
}
-fn init_vecs(ccx: &crate_ctxt, node_ids: &node_id[], len: uint) {
+fn init_vecs(ccx: &crate_ctxt, node_ids: &[node_id], len: uint) {
for i: node_id in node_ids {
log int::str(i) + " |-> " + uint::str(len);
add_node(ccx, i, empty_ann(len));
}
fn visit_fn(ccx: &crate_ctxt, num_constraints: uint, f: &_fn,
- tps: &ty_param[], sp: &span, i: &fn_ident, id: node_id) {
- let node_ids: @mutable node_id[] = @mutable ~[];
+ tps: &[ty_param], sp: &span, i: &fn_ident, id: node_id) {
+ let node_ids: @mutable [node_id] = @mutable ~[];
node_ids_in_fn(f, tps, sp, i, id, node_ids);
let node_id_vec = *node_ids;
init_vecs(ccx, node_id_vec, num_constraints);
}
-fn annotate_in_fn(ccx: &crate_ctxt, f: &_fn, tps: &ty_param[], sp: &span,
+fn annotate_in_fn(ccx: &crate_ctxt, f: &_fn, tps: &[ty_param], sp: &span,
i: &fn_ident, id: node_id) {
let f_info = get_fn_info(ccx, id);
visit_fn(ccx, num_constraints(f_info), f, tps, sp, i, id);
ret int::str(d.crate) + "," + int::str(d.node);
}
-fn comma_str(args: &(@constr_arg_use)[]) -> str {
+fn comma_str(args: &[@constr_arg_use]) -> str {
let rslt = "";
let comma = false;
for a: @constr_arg_use in args {
fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { log_err tritv_to_str(fcx, v); }
-fn tos(v: &uint[]) -> str {
+fn tos(v: &[uint]) -> str {
let rslt = "";
for i: uint in v {
if i == 0u {
ret rslt;
}
-fn log_cond(v: &uint[]) { log tos(v); }
+fn log_cond(v: &[uint]) { log tos(v); }
-fn log_cond_err(v: &uint[]) { log_err tos(v); }
+fn log_cond_err(v: &[uint]) { log_err tos(v); }
fn log_pp(pp: &pre_and_post) {
let p1 = tritv::to_vec(pp.precondition);
fn print_ident(i: &ident) { log " " + i + " "; }
-fn print_idents(idents: &mutable ident[]) {
+fn print_idents(idents: &mutable [ident]) {
if ivec::len[ident](idents) == 0u { ret; }
log "an ident: " + ivec::pop[ident](idents);
print_idents(idents);
Both types store an ident and span, for error-logging purposes.
*/
-type pred_args_ = {args: (@constr_arg_use)[], bit_num: uint};
+type pred_args_ = {args: [@constr_arg_use], bit_num: uint};
type pred_args = spanned[pred_args_];
// FIXME: really only want it to be mutable during collect_locals.
// freeze it after that.
- cpred(path, @mutable pred_args[]);
+ cpred(path, @mutable [pred_args]);
}
// An ninit variant has a node_id because it refers to a local var.
// and give ninit a constraint saying it's local.
tag tsconstr {
ninit(node_id, ident);
- npred(path, def_id, (@constr_arg_use)[]);
+ npred(path, def_id, [@constr_arg_use]);
}
type sp_constr = spanned[tsconstr];
computation, of all local variables that may be
used */
// Doesn't seem to work without the @ -- bug
- used_vars: @mutable node_id[]};
+ used_vars: @mutable [node_id]};
fn tsconstr_to_def_id(t: &tsconstr) -> def_id {
alt t { ninit(id, _) { local_def(id) } npred(_, id, _) { id } }
}
/* mapping from node ID to typestate annotation */
-type node_ann_table = @mutable ts_ann[mutable ];
+type node_ann_table = @mutable [mutable ts_ann];
/* mapping from function name to fn_info map */
fn num_constraints(m: fn_info) -> uint { ret m.num_constraints; }
fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
- let na: ts_ann[mutable ] = ~[mutable ];
+ let na: [mutable ts_ann] = ~[mutable];
ret {tcx: cx, node_anns: @mutable na, fm: @new_int_hash[fn_info]()};
}
}
}
-fn constraints_expr(cx: &ty::ctxt, e: @expr) -> (@ty::constr)[] {
+fn constraints_expr(cx: &ty::ctxt, e: @expr) -> [@ty::constr] {
alt ty::struct(cx, ty::node_id_to_type(cx, e.id)) {
ty::ty_fn(_, _, _, _, cs) { ret cs; }
_ { ret ~[]; }
ret freevars::def_lookup(cx.ccx.tcx, cx.id, id);
}
-fn norm_a_constraint(id: def_id, c: &constraint) -> norm_constraint[] {
+fn norm_a_constraint(id: def_id, c: &constraint) -> [norm_constraint] {
alt c {
cinit(n, sp, i) {
ret ~[{bit_num: n, c: respan(sp, ninit(id.node, i))}];
}
cpred(p, descs) {
- let rslt: norm_constraint[] = ~[];
+ let rslt: [norm_constraint] = ~[];
for pd: pred_args in *descs {
rslt +=
~[{bit_num: pd.node.bit_num,
// Tried to write this as an iterator, but I got a
// non-exhaustive match in trans.
-fn constraints(fcx: &fn_ctxt) -> norm_constraint[] {
- let rslt: norm_constraint[] = ~[];
+fn constraints(fcx: &fn_ctxt) -> [norm_constraint] {
+ let rslt: [norm_constraint] = ~[];
for each p: @{key: def_id, val: constraint} in
fcx.enclosing.constrs.items() {
rslt += norm_a_constraint(p.key, p.val);
// FIXME
// Would rather take an immutable vec as an argument,
// should freeze it at some earlier point.
-fn match_args(fcx: &fn_ctxt, occs: &@mutable pred_args[],
- occ: &(@constr_arg_use)[]) -> uint {
+fn match_args(fcx: &fn_ctxt, occs: &@mutable [pred_args],
+ occ: &[@constr_arg_use]) -> uint {
log "match_args: looking at " +
constr_args_to_str(fn (i: &inst) -> str { ret i.ident; }, occ);
for pd: pred_args in *occs {
}
}
-fn exprs_to_constr_args(tcx: ty::ctxt, args: &(@expr)[]) ->
- (@constr_arg_use)[] {
+fn exprs_to_constr_args(tcx: ty::ctxt, args: &[@expr]) ->
+ [@constr_arg_use] {
let f = bind expr_to_constr_arg(tcx, _);
- let rslt: (@constr_arg_use)[] = ~[];
+ let rslt: [@constr_arg_use] = ~[];
for e: @expr in args { rslt += ~[f(e)]; }
rslt
}
+ ">"
}
-fn substitute_constr_args(cx: &ty::ctxt, actuals: &(@expr)[], c: &@ty::constr)
+fn substitute_constr_args(cx: &ty::ctxt, actuals: &[@expr], c: &@ty::constr)
-> tsconstr {
- let rslt: (@constr_arg_use)[] = ~[];
+ let rslt: [@constr_arg_use] = ~[];
for a: @constr_arg in c.node.args {
rslt += ~[substitute_arg(cx, actuals, a)];
}
ret npred(c.node.path, c.node.id, rslt);
}
-fn substitute_arg(cx: &ty::ctxt, actuals: &(@expr)[], a: @constr_arg) ->
+fn substitute_arg(cx: &ty::ctxt, actuals: &[@expr], a: @constr_arg) ->
@constr_arg_use {
let num_actuals = ivec::len(actuals);
alt a.node {
}
}
-fn pred_args_matches(pattern: &(constr_arg_general_[inst])[],
+fn pred_args_matches(pattern: &[constr_arg_general_[inst]],
desc: &pred_args) -> bool {
let i = 0u;
for c: @constr_arg_use in desc.node.args {
ret true;
}
-fn find_instance_(pattern: &(constr_arg_general_[inst])[],
- descs: &pred_args[]) -> option::t[uint] {
+fn find_instance_(pattern: &[constr_arg_general_[inst]],
+ descs: &[pred_args]) -> option::t[uint] {
for d: pred_args in descs {
if pred_args_matches(pattern, d) { ret some(d.node.bit_num); }
}
}
type inst = {ident: ident, node: node_id};
-type subst = {from: inst, to: inst}[];
+type subst = [{from: inst, to: inst}];
fn find_instances(fcx: &fn_ctxt, subst: &subst, c: &constraint) ->
- {from: uint, to: uint}[] {
+ [{from: uint, to: uint}] {
let rslt = ~[];
if ivec::len(subst) == 0u { ret rslt; }
is_some(find_in_subst(id, s))
}
-fn insts_to_str(stuff: &(constr_arg_general_[inst])[]) -> str {
+fn insts_to_str(stuff: &[constr_arg_general_[inst]]) -> str {
let rslt = "<";
for i: constr_arg_general_[inst] in stuff {
rslt +=
rslt
}
-fn replace(subst: subst, d: pred_args) -> (constr_arg_general_[inst])[] {
- let rslt: (constr_arg_general_[inst])[] = ~[];
+fn replace(subst: subst, d: pred_args) -> [constr_arg_general_[inst]] {
+ let rslt: [constr_arg_general_[inst]] = ~[];
for c: @constr_arg_use in d.node.args {
alt c.node {
carg_ident(p) {
ret changed;
}
-fn any_eq(v: &node_id[], d: node_id) -> bool {
+fn any_eq(v: &[node_id], d: node_id) -> bool {
for i: node_id in v { if i == d { ret true; } }
false
}
};
}
-fn args_mention[T](args: &(@constr_arg_use)[], q: fn(&T[], node_id) -> bool ,
- s: &T[]) -> bool {
+fn args_mention[T](args: &[@constr_arg_use], q: fn(&[T], node_id) -> bool ,
+ s: &[T]) -> bool {
/*
FIXME
The following version causes an assertion in trans to fail
(something about type_is_tup_like)
- fn mentions[T](&(T)[] s, &fn(&(T)[], def_id) -> bool q,
+ fn mentions[T](&[T] s, &fn(&[T], def_id) -> bool q,
&@constr_arg_use a) -> bool {
alt (a.node) {
case (carg_ident(?p1)) {
fn use_var(fcx: &fn_ctxt, v: &node_id) { *fcx.enclosing.used_vars += ~[v]; }
// FIXME: This should be a function in std::ivec::.
-fn vec_contains(v: &@mutable node_id[], i: &node_id) -> bool {
+fn vec_contains(v: &@mutable [node_id], i: &node_id) -> bool {
for d: node_id in *v { if d == i { ret true; } }
ret false;
}
}
// default function visitor
-fn do_nothing[T](f: &_fn, tp: &ty_param[], sp: &span, i: &fn_ident,
+fn do_nothing[T](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident,
iid: node_id, cx: &T, v: &visit::vt[T]) {
}
-fn args_to_constr_args(sp: &span, args: &arg[]) -> (@constr_arg_use)[] {
- let actuals: (@constr_arg_use)[] = ~[];
+fn args_to_constr_args(sp: &span, args: &[arg]) -> [@constr_arg_use] {
+ let actuals: [@constr_arg_use] = ~[];
for a: arg in args {
actuals += ~[@respan(sp, carg_ident({ident: a.ident, node: a.id}))];
}
ret actuals;
}
-fn ast_constr_to_ts_constr(tcx: &ty::ctxt, args: &arg[], c: &@constr) ->
+fn ast_constr_to_ts_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) ->
tsconstr {
let tconstr = ty::ast_constr_to_constr(tcx, c);
ret npred(tconstr.node.path, tconstr.node.id,
args_to_constr_args(tconstr.span, args));
}
-fn ast_constr_to_sp_constr(tcx: &ty::ctxt, args: &arg[], c: &@constr) ->
+fn ast_constr_to_sp_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) ->
sp_constr {
let tconstr = ast_constr_to_ts_constr(tcx, args, c);
ret respan(c.span, tconstr);
}
-type binding = {lhs: inst[], rhs: option::t[initializer]};
+type binding = {lhs: [inst], rhs: option::t[initializer]};
fn local_to_bindings(loc : &@local) -> binding {
let lhs = ~[];
rhs: loc.node.init}
}
-fn locals_to_bindings(locals : &(@local)[]) -> binding[] {
+fn locals_to_bindings(locals : &[@local]) -> [binding] {
ivec::map(local_to_bindings, locals)
}
-fn callee_modes(fcx: &fn_ctxt, callee: node_id) -> ty::mode[] {
+fn callee_modes(fcx: &fn_ctxt, callee: node_id) -> [ty::mode] {
let ty = ty::type_autoderef(fcx.ccx.tcx,
ty::node_id_to_type(fcx.ccx.tcx, callee));
alt ty::struct(fcx.ccx.tcx, ty) {
}
}
-fn callee_arg_init_ops(fcx: &fn_ctxt, callee: node_id) -> init_op[] {
+fn callee_arg_init_ops(fcx: &fn_ctxt, callee: node_id) -> [init_op] {
fn mode_to_op(m: &ty::mode) -> init_op {
alt m {
ty::mo_move. { init_move }
ivec::map(mode_to_op, callee_modes(fcx, callee))
}
-fn anon_bindings(ops: &init_op[], es : &(@expr)[]) -> binding[] {
- let bindings: binding[] = ~[];
+fn anon_bindings(ops: &[init_op], es : &[@expr]) -> [binding] {
+ let bindings: [binding] = ~[];
let i = 0;
for op: init_op in ops {
bindings += ~[{lhs: ~[],
}
}
-fn seq_postconds(fcx: &fn_ctxt, ps: &postcond[]) -> postcond {
+fn seq_postconds(fcx: &fn_ctxt, ps: &[postcond]) -> postcond {
let sz = ivec::len(ps);
if sz >= 1u {
let prev = tritv_clone(ps.(0));
// return the precondition for evaluating each expr in order.
// So, if e0's post is {x} and e1's pre is {x, y, z}, the entire
// precondition shouldn't include x.
-fn seq_preconds(fcx: &fn_ctxt, pps: &pre_and_post[]) -> precond {
+fn seq_preconds(fcx: &fn_ctxt, pps: &[pre_and_post]) -> precond {
let sz: uint = ivec::len(pps);
let num_vars: uint = num_constraints(fcx.enclosing);
- fn seq_preconds_go(fcx: &fn_ctxt, pps: &pre_and_post[],
+ fn seq_preconds_go(fcx: &fn_ctxt, pps: &[pre_and_post],
first: &pre_and_post) -> precond {
let sz: uint = ivec::len(pps);
if sz >= 1u {
}
fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
- tps: &ast::ty_param[], id: node_id,
+ tps: &[ast::ty_param], id: node_id,
sp: &span, i: &fn_ident) {
/* Postorder traversal instead of pre is important
because we want the smallest possible erroneous statement
check_unused_vars(fcx);
}
-fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &ast::ty_param[], id: node_id,
+fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &[ast::ty_param], id: node_id,
sp: &span, i: &fn_ident) {
/* Compute the pre- and post-states for this function */
check_states_against_conditions(fcx, f, tps, id, sp, i);
}
-fn fn_states(f: &_fn, tps: &ast::ty_param[], sp: &span, i: &fn_ident,
+fn fn_states(f: &_fn, tps: &[ast::ty_param], sp: &span, i: &fn_ident,
id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) {
visit::visit_fn(f, tps, sp, i, id, ccx, v);
/* Look up the var-to-bit-num map for this function */
import syntax::codemap::span;
import syntax::ast::respan;
-type ctxt = {cs: @mutable sp_constr[], tcx: ty::ctxt};
+type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt};
fn collect_local(loc: &@local, cx: &ctxt, v: &visit::vt[ctxt]) {
for each p: @pat in pat_bindings(loc.node.pat) {
visit::visit_expr(e, cx, v);
}
-fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &ty_param[], sp: &span,
+fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &[ty_param], sp: &span,
i: &fn_ident, id: node_id) -> ctxt {
let cx: ctxt = {cs: @mutable ~[], tcx: tcx};
let visitor = visit::default_visitor[ctxt]();
}
}
none. {
- let rslt: @mutable pred_args[] =
+ let rslt: @mutable [pred_args] =
@mutable ~[respan(c.span, {args: args, bit_num: next})];
tbl.insert(d_id, cpred(p, rslt));
}
/* builds a table mapping each local var defined in f
to a bit number in the precondition/postcondition vectors */
-fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &ty_param[], f_sp: &span,
+fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &[ty_param], f_sp: &span,
f_name: &fn_ident, id: node_id) {
let name = fn_ident_to_string(id, f_name);
let res_map = @new_def_hash[constraint]();
add_constraint(cx.tcx, respan(f_sp, ninit(diverges_id, diverges_name)),
next, res_map);
- let v: @mutable node_id[] = @mutable ~[];
+ let v: @mutable [node_id] = @mutable ~[];
let rslt =
{constrs: res_map,
num_constraints:
alt i.node {
item_const(_, e) {
// make a fake fcx
- let v: @mutable node_id[] = @mutable ~[];
+ let v: @mutable [node_id] = @mutable ~[];
let fake_fcx =
{enclosing:
{constrs: @new_def_hash[constraint](),
sets the precondition in a to be the result of combining
the preconditions for <args>, and the postcondition in a to
be the union of all postconditions for <args> */
-fn find_pre_post_exprs(fcx: &fn_ctxt, args: &(@expr)[], id: node_id) {
+fn find_pre_post_exprs(fcx: &fn_ctxt, args: &[@expr], id: node_id) {
if ivec::len[@expr](args) > 0u {
log "find_pre_post_exprs: oper =";
log_expr(*args.(0));
let do_inner = bind do_inner_(fcx, _);
option::map[@expr, ()](do_inner, b.node.expr);
- let pps: pre_and_post[] = ~[];
+ let pps: [pre_and_post] = ~[];
for s: @stmt in b.node.stmts { pps += ~[stmt_pp(fcx.ccx, *s)]; }
alt b.node.expr {
none. {/* no-op */ }
}
}
-fn fn_pre_post(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident,
+fn fn_pre_post(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident,
id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) {
visit::visit_fn(f, tps, sp, i, id, ccx, v);
assert (ccx.fm.contains_key(id));
}
}
-fn seq_states(fcx: &fn_ctxt, pres: &prestate, bindings: &binding[])
+fn seq_states(fcx: &fn_ctxt, pres: &prestate, bindings: &[binding])
-> {changed: bool, post: poststate} {
let changed = false;
let post = tritv_clone(pres);
}
fn find_pre_post_state_call(fcx: &fn_ctxt, pres: &prestate, a: &@expr,
- id: node_id, ops: &init_op[], bs: &(@expr)[],
+ id: node_id, ops: &[init_op], bs: &[@expr],
cf: controlflow) -> bool {
let changed = find_pre_post_state_expr(fcx, pres, a);
if ivec::len(bs) != ivec::len(ops) {
}
fn find_pre_post_state_exprs(fcx: &fn_ctxt, pres: &prestate, id: node_id,
- ops: &init_op[], es: &(@expr)[],
+ ops: &[init_op], es: &[@expr],
cf: controlflow) -> bool {
let rs = seq_states(fcx, pres, anon_bindings(ops, es));
let changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres);
ret true;
}
-fn to_vec(v: &t) -> uint[] {
+fn to_vec(v: &t) -> [uint] {
let i: uint = 0u;
- let rslt: uint[] = ~[];
+ let rslt: [uint] = ~[];
while i < v.nbits {
rslt +=
~[alt tritv_get(v, i) {
type method =
{proto: ast::proto,
ident: ast::ident,
- inputs: arg[],
+ inputs: [arg],
output: t,
cf: controlflow,
- constrs: (@constr)[]};
+ constrs: [@constr]};
-type constr_table = hashmap[ast::node_id, constr[]];
+type constr_table = hashmap[ast::node_id, [constr]];
type mt = {ty: t, mut: ast::mutability};
ty_char;
ty_str;
ty_istr;
- ty_tag(def_id, t[]);
+ ty_tag(def_id, [t]);
ty_box(mt);
ty_vec(mt);
ty_ivec(mt);
ty_port(t);
ty_chan(t);
ty_task;
- ty_rec(field[]);
- ty_fn(ast::proto, arg[], t, controlflow, (@constr)[]);
- ty_native_fn(ast::native_abi, arg[], t);
- ty_obj(method[]);
- ty_res(def_id, t, t[]);
+ ty_rec([field]);
+ ty_fn(ast::proto, [arg], t, controlflow, [@constr]);
+ ty_native_fn(ast::native_abi, [arg], t);
+ ty_obj([method]);
+ ty_res(def_id, t, [t]);
ty_var(int); // type variable
ty_param(uint, ast::kind); // fn/tag type param
ty_type;
ty_native(def_id);
- ty_constr(t, (@type_constr)[]);
+ ty_constr(t, [@type_constr]);
// TODO: ty_fn_arg(t), for a possibly-aliased function argument
}
terr_constr_mismatch(@type_constr, @type_constr);
}
-type ty_param_kinds_and_ty = {kinds: ast::kind[], ty: t};
+type ty_param_kinds_and_ty = {kinds: [ast::kind], ty: t};
type type_cache = hashmap[ast::def_id, ty_param_kinds_and_ty];
type type_store = interner::interner[@raw_t];
-type ty_param_substs_opt_and_ty = {substs: option::t[ty::t[]], ty: ty::t};
+type ty_param_substs_opt_and_ty = {substs: option::t[[ty::t]], ty: ty::t};
type node_type_table =
@smallintmap::smallintmap[ty::ty_param_substs_opt_and_ty];
derive_flags_t(cx, has_params, has_vars, a.ty);
}
fn derive_flags_sig(cx: &ctxt, has_params: &mutable bool,
- has_vars: &mutable bool, args: &arg[], tt: &t) {
+ has_vars: &mutable bool, args: &[arg], tt: &t) {
for a: arg in args { derive_flags_arg(cx, has_params, has_vars, a); }
derive_flags_t(cx, has_params, has_vars, tt);
}
fn mk_istr(cx: &ctxt) -> t { ret idx_istr; }
-fn mk_tag(cx: &ctxt, did: &ast::def_id, tys: &t[]) -> t {
+fn mk_tag(cx: &ctxt, did: &ast::def_id, tys: &[t]) -> t {
ret gen_ty(cx, ty_tag(did, tys));
}
fn mk_task(cx: &ctxt) -> t { ret gen_ty(cx, ty_task); }
-fn mk_rec(cx: &ctxt, fs: &field[]) -> t { ret gen_ty(cx, ty_rec(fs)); }
+fn mk_rec(cx: &ctxt, fs: &[field]) -> t { ret gen_ty(cx, ty_rec(fs)); }
-fn mk_imm_tup(cx: &ctxt, tys: &t[]) -> t {
+fn mk_imm_tup(cx: &ctxt, tys: &[t]) -> t {
let fields = ~[];
let i = 0u;
for typ: t in tys {
ret gen_ty(cx, ty_rec(fields));
}
-fn mk_constr(cx: &ctxt, t: &t, cs: &(@type_constr)[]) -> t {
+fn mk_constr(cx: &ctxt, t: &t, cs: &[@type_constr]) -> t {
ret gen_ty(cx, ty_constr(t, cs));
}
-fn mk_fn(cx: &ctxt, proto: &ast::proto, args: &arg[], ty: &t,
- cf: &controlflow, constrs: &(@constr)[]) -> t {
+fn mk_fn(cx: &ctxt, proto: &ast::proto, args: &[arg], ty: &t,
+ cf: &controlflow, constrs: &[@constr]) -> t {
ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs));
}
-fn mk_native_fn(cx: &ctxt, abi: &ast::native_abi, args: &arg[], ty: &t) -> t {
+fn mk_native_fn(cx: &ctxt, abi: &ast::native_abi, args: &[arg], ty: &t) -> t {
ret gen_ty(cx, ty_native_fn(abi, args, ty));
}
-fn mk_obj(cx: &ctxt, meths: &method[]) -> t { ret gen_ty(cx, ty_obj(meths)); }
+fn mk_obj(cx: &ctxt, meths: &[method]) -> t { ret gen_ty(cx, ty_obj(meths)); }
-fn mk_res(cx: &ctxt, did: &ast::def_id, inner: &t, tps: &t[]) -> t {
+fn mk_res(cx: &ctxt, did: &ast::def_id, inner: &t, tps: &[t]) -> t {
ret gen_ty(cx, ty_res(did, inner, tps));
}
ty = copy_cname(cx, mk_chan(cx, fold_ty(cx, fld, subty)), ty);
}
ty_tag(tid, subtys) {
- let new_subtys: t[] = ~[];
+ let new_subtys: [t] = ~[];
for subty: t in subtys { new_subtys += ~[fold_ty(cx, fld, subty)]; }
ty = copy_cname(cx, mk_tag(cx, tid, new_subtys), ty);
}
ty_rec(fields) {
- let new_fields: field[] = ~[];
+ let new_fields: [field] = ~[];
for fl: field in fields {
let new_ty = fold_ty(cx, fld, fl.mt.ty);
let new_mt = {ty: new_ty, mut: fl.mt.mut};
ty = copy_cname(cx, mk_rec(cx, new_fields), ty);
}
ty_fn(proto, args, ret_ty, cf, constrs) {
- let new_args: arg[] = ~[];
+ let new_args: [arg] = ~[];
for a: arg in args {
let new_ty = fold_ty(cx, fld, a.ty);
new_args += ~[{mode: a.mode, ty: new_ty}];
cf, constrs), ty);
}
ty_native_fn(abi, args, ret_ty) {
- let new_args: arg[] = ~[];
+ let new_args: [arg] = ~[];
for a: arg in args {
let new_ty = fold_ty(cx, fld, a.ty);
new_args += ~[{mode: a.mode, ty: new_ty}];
fold_ty(cx, fld, ret_ty)), ty);
}
ty_obj(methods) {
- let new_methods: method[] = ~[];
+ let new_methods: [method] = ~[];
for m: method in methods {
- let new_args: arg[] = ~[];
+ let new_args: [arg] = ~[];
for a: arg in m.inputs {
new_args += ~[{mode: a.mode, ty: fold_ty(cx, fld, a.ty)}];
}
// Returns an ivec of all the type variables
// occurring in t. It may contain duplicates.
-fn vars_in_type(cx:&ctxt, ty: &t) -> int[] {
- fn collect_var(cx:&ctxt, vars: &@mutable int[], ty: t) {
+fn vars_in_type(cx:&ctxt, ty: &t) -> [int] {
+ fn collect_var(cx:&ctxt, vars: &@mutable [int], ty: t) {
alt struct(cx, ty) {
ty_var(v) {
*vars += ~[v];
_ {}
}
}
- let rslt: @mutable int[] = @mutable (~[]);
+ let rslt: @mutable [int] = @mutable (~[]);
walk_ty(cx, bind collect_var(cx, rslt, _), ty);
// Works because of a "convenient" bug that lets us
// return a mutable ivec as if it's immutable
h += h << 5u + hash_def(h, c.node.id);
ret hash_type_constr_args(h, c.node.args);
}
- fn hash_type_constr_args(id: uint, args: (@ty_constr_arg)[]) -> uint {
+ fn hash_type_constr_args(id: uint, args: [@ty_constr_arg]) -> uint {
let h = id;
for a: @ty_constr_arg in args {
alt a.node {
}
- fn hash_fn(id: uint, args: &arg[], rty: &t) -> uint {
+ fn hash_fn(id: uint, args: &[arg], rty: &t) -> uint {
let h = id;
for a: arg in args { h += h << 5u + hash_ty(a.ty); }
h += h << 5u + hash_ty(rty);
}
}
-fn args_eq[T](eq: fn(&T, &T) -> bool , a: &(@sp_constr_arg[T])[],
- b: &(@sp_constr_arg[T])[]) -> bool {
+fn args_eq[T](eq: fn(&T, &T) -> bool , a: &[@sp_constr_arg[T]],
+ b: &[@sp_constr_arg[T]]) -> bool {
let i: uint = 0u;
for arg: @sp_constr_arg[T] in a {
if !arg_eq(eq, arg, b.(i)) { ret false; }
args_eq(eq_int, c.node.args, d.node.args);
}
-fn constrs_eq(cs: &(@constr)[], ds: &(@constr)[]) -> bool {
+fn constrs_eq(cs: &[@constr], ds: &[@constr]) -> bool {
if ivec::len(cs) != ivec::len(ds) { ret false; }
let i = 0u;
for c: @constr in cs { if !constr_eq(c, ds.(i)) { ret false; } i += 1u; }
fn equal_mt(a: &mt, b: &mt) -> bool {
ret a.mut == b.mut && eq_ty(a.ty, b.ty);
}
- fn equal_fn(args_a: &arg[], rty_a: &t, args_b: &arg[], rty_b: &t) ->
+ fn equal_fn(args_a: &[arg], rty_a: &t, args_b: &[arg], rty_b: &t) ->
bool {
if !eq_ty(rty_a, rty_b) { ret false; }
let len = ivec::len[arg](args_a);
ret node_id_to_ty_param_substs_opt_and_ty(cx, id).ty;
}
-fn node_id_to_type_params(cx: &ctxt, id: &ast::node_id) -> t[] {
+fn node_id_to_type_params(cx: &ctxt, id: &ast::node_id) -> [t] {
alt node_id_to_ty_param_substs_opt_and_ty(cx, id).substs {
none. { ret ~[]; }
some(tps) { ret tps; }
// Returns the number of distinct type parameters in the given type.
fn count_ty_params(cx: &ctxt, ty: t) -> uint {
- fn counter(cx: &ctxt, param_indices: @mutable uint[], ty: t) {
+ fn counter(cx: &ctxt, param_indices: @mutable [uint], ty: t) {
alt struct(cx, ty) {
ty_param(param_idx,_) {
let seen = false;
_ {/* fall through */ }
}
}
- let param_indices: @mutable uint[] = @mutable ~[];
+ let param_indices: @mutable [uint] = @mutable ~[];
let f = bind counter(cx, param_indices, _);
walk_ty(cx, f, ty);
ret ivec::len[uint](*param_indices);
// Type accessors for substructures of types
-fn ty_fn_args(cx: &ctxt, fty: &t) -> arg[] {
+fn ty_fn_args(cx: &ctxt, fty: &t) -> [arg] {
alt struct(cx, fty) {
ty::ty_fn(_, a, _, _, _) { ret a; }
ty::ty_native_fn(_, a, _) { ret a; }
}
fn expr_ty_params_and_ty(cx: &ctxt, expr: &@ast::expr) ->
- {params: t[], ty: t} {
+ {params: [t], ty: t} {
ret {params: node_id_to_type_params(cx, expr.id),
ty: node_id_to_type(cx, expr.id)};
}
}
fn field_idx(sess: &session::session, sp: &span, id: &ast::ident,
- fields: &field[]) -> uint {
+ fields: &[field]) -> uint {
let i: uint = 0u;
for f: field in fields { if str::eq(f.ident, id) { ret i; } i += 1u; }
sess.span_fatal(sp, "unknown field '" + id + "' of record");
}
fn method_idx(sess: &session::session, sp: &span, id: &ast::ident,
- meths: &method[]) -> uint {
+ meths: &[method]) -> uint {
let i: uint = 0u;
for m: method in meths { if str::eq(m.ident, id) { ret i; } i += 1u; }
sess.span_fatal(sp, "unknown method '" + id + "' of obj");
}
-fn sort_methods(meths: &method[]) -> method[] {
+fn sort_methods(meths: &[method]) -> [method] {
fn method_lteq(a: &method, b: &method) -> bool {
ret str::lteq(a.ident, b.ident);
}
// Right now this just checks that the lists of constraints are
// pairwise equal.
- fn unify_constrs(base_t: &t, expected: (@type_constr)[],
- actual: &(@type_constr)[]) -> result {
+ fn unify_constrs(base_t: &t, expected: [@type_constr],
+ actual: &[@type_constr]) -> result {
let expected_len = ivec::len(expected);
let actual_len = ivec::len(actual);
}
tag fn_common_res {
fn_common_res_err(result);
- fn_common_res_ok(arg[], t);
+ fn_common_res_ok([arg], t);
}
fn unify_fn_common(cx: &@ctxt, expected: &t, actual: &t,
- expected_inputs: &arg[], expected_output: &t,
- actual_inputs: &arg[], actual_output: &t) ->
+ expected_inputs: &[arg], expected_output: &t,
+ actual_inputs: &[arg], actual_output: &t) ->
fn_common_res {
let expected_len = ivec::len[arg](expected_inputs);
let actual_len = ivec::len[arg](actual_inputs);
}
// TODO: as above, we should have an iter2 iterator.
- let result_ins: arg[] = ~[];
+ let result_ins: [arg] = ~[];
let i = 0u;
while i < expected_len {
let expected_input = expected_inputs.(i);
}
}
fn unify_fn(cx: &@ctxt, e_proto: &ast::proto, a_proto: &ast::proto,
- expected: &t, actual: &t, expected_inputs: &arg[],
- expected_output: &t, actual_inputs: &arg[], actual_output: &t,
+ expected: &t, actual: &t, expected_inputs: &[arg],
+ expected_output: &t, actual_inputs: &[arg], actual_output: &t,
expected_cf: &controlflow, actual_cf: &controlflow,
- expected_constrs: &(@constr)[], actual_constrs: &(@constr)[])
+ expected_constrs: &[@constr], actual_constrs: &[@constr])
-> result {
if e_proto != a_proto { ret ures_err(terr_mismatch); }
alt expected_cf {
}
fn unify_native_fn(cx: &@ctxt, e_abi: &ast::native_abi,
a_abi: &ast::native_abi, expected: &t, actual: &t,
- expected_inputs: &arg[], expected_output: &t,
- actual_inputs: &arg[], actual_output: &t) -> result {
+ expected_inputs: &[arg], expected_output: &t,
+ actual_inputs: &[arg], actual_output: &t) -> result {
if e_abi != a_abi { ret ures_err(terr_mismatch); }
let t =
unify_fn_common(cx, expected, actual, expected_inputs,
}
}
fn unify_obj(cx: &@ctxt, expected: &t, actual: &t,
- expected_meths: &method[], actual_meths: &method[]) ->
+ expected_meths: &[method], actual_meths: &[method]) ->
result {
- let result_meths: method[] = ~[];
+ let result_meths: [method] = ~[];
let i: uint = 0u;
let expected_len: uint = ivec::len[method](expected_meths);
let actual_len: uint = ivec::len[method](actual_meths);
ret ures_err(terr_mismatch);
}
// TODO: factor this cruft out
- let result_tps: t[] = ~[];
+ let result_tps: [t] = ~[];
let i = 0u;
let expected_len = ivec::len[t](expected_tps);
while i < expected_len {
// TODO: implement an iterator that can iterate over
// two arrays simultaneously.
- let result_fields: field[] = ~[];
+ let result_fields: [field] = ~[];
let i = 0u;
while i < expected_len {
let expected_field = expected_fields.(i);
// Converts type parameters in a type to type variables and returns the
// resulting type along with a list of type variable IDs.
fn bind_params_in_type(sp: &span, cx: &ctxt, next_ty_var: fn() -> int ,
- typ: t, ty_param_count: uint) -> {ids: int[], ty: t} {
- let param_var_ids: @mutable int[] = @mutable ~[];
+ typ: t, ty_param_count: uint) -> {ids: [int], ty: t} {
+ let param_var_ids: @mutable [int] = @mutable ~[];
let i = 0u;
while i < ty_param_count { *param_var_ids += ~[next_ty_var()]; i += 1u; }
- fn binder(sp: span, cx: ctxt, param_var_ids: @mutable int[],
+ fn binder(sp: span, cx: ctxt, param_var_ids: @mutable [int],
next_ty_var: fn() -> int , index: uint, kind: ast::kind) -> t {
if index < ivec::len(*param_var_ids) {
ret mk_var(cx, param_var_ids.(index));
// Replaces type parameters in the given type using the given list of
// substitions.
-fn substitute_type_params(cx: &ctxt, substs: &ty::t[], typ: t) -> t {
+fn substitute_type_params(cx: &ctxt, substs: &[ty::t], typ: t) -> t {
if !type_contains_params(cx, typ) { ret typ; }
- fn substituter(cx: ctxt, substs: @ty::t[], idx: uint,
+ fn substituter(cx: ctxt, substs: @[ty::t], idx: uint,
kind: ast::kind) -> t {
// FIXME: bounds check can fail
ret substs.(idx);
// Tag information
-type variant_info = {args: ty::t[], ctor_ty: ty::t, id: ast::def_id};
+type variant_info = {args: [ty::t], ctor_ty: ty::t, id: ast::def_id};
-fn tag_variants(cx: &ctxt, id: &ast::def_id) -> variant_info[] {
+fn tag_variants(cx: &ctxt, id: &ast::def_id) -> [variant_info] {
if ast::local_crate != id.crate { ret csearch::get_tag_variants(cx, id); }
let item =
alt cx.items.find(id.node) {
ast_map::node_item(item) {
alt item.node {
ast::item_tag(variants, _) {
- let result: variant_info[] = ~[];
+ let result: [variant_info] = ~[];
for variant: ast::variant in variants {
let ctor_ty = node_id_to_monotype(cx, variant.node.id);
- let arg_tys: t[] = ~[];
+ let arg_tys: [t] = ~[];
if std::ivec::len(variant.node.args) > 0u {
for a: arg in ty_fn_args(cx, ctor_ty) {
arg_tys += ~[a.ty];
// Used for typechecking the methods of an object.
tag obj_info {
// Regular objects have a node_id at compile time.
- regular_obj(ast::obj_field[], ast::node_id);
+ regular_obj([ast::obj_field], ast::node_id);
// Anonymous objects only have a type at compile time. It's optional
// because not all anonymous objects have a inner_obj to attach to.
- anon_obj(ast::obj_field[], option::t[ty::sty]);
+ anon_obj([ast::obj_field], option::t[ty::sty]);
}
-type crate_ctxt = {mutable obj_infos: obj_info[], tcx: ty::ctxt};
+type crate_ctxt = {mutable obj_infos: [obj_info], tcx: ty::ctxt};
type fn_ctxt =
// var_bindings, locals, local_names, and next_var_id are shared
locals: hashmap[ast::node_id, int],
local_names: hashmap[ast::node_id, ast::ident],
next_var_id: @mutable int,
- mutable fixups: ast::node_id[],
+ mutable fixups: [ast::node_id],
ccx: @crate_ctxt};
// Returns the type parameter count and the type for the given definition.
fn ty_param_kinds_and_ty_for_def(fcx: &@fn_ctxt, sp: &span, defn: &ast::def)
-> ty_param_kinds_and_ty {
- let no_kinds: ast::kind[] = ~[];
+ let no_kinds: [ast::kind] = ~[];
alt defn {
ast::def_arg(id) {
assert (fcx.locals.contains_key(id.node));
fcx.ccx.tcx.sess.span_fatal
(sp, "not enough type parameters provided for this item");
}
- let ty_substs: ty::t[] = ~[];
+ let ty_substs: [ty::t] = ~[];
let i = 0u;
while i < ty_substs_len {
let ty_var = ty::mk_var(fcx.ccx.tcx, ty_param_vars.(i));
ty_substs += ~[res_ty];
i += 1u;
}
- ty_substs_opt = some[ty::t[]](ty_substs);
+ ty_substs_opt = some[[ty::t]](ty_substs);
if ty_param_count == 0u {
fcx.ccx.tcx.sess.span_fatal(sp,
"this item does not take type \
}
} else {
// We will acquire the type parameters through unification.
- let ty_substs: ty::t[] = ~[];
+ let ty_substs: [ty::t] = ~[];
let i = 0u;
while i < ty_param_count {
ty_substs += ~[ty::mk_var(fcx.ccx.tcx, ty_param_vars.(i))];
i += 1u;
}
- ty_substs_opt = some[ty::t[]](ty_substs);
+ ty_substs_opt = some[[ty::t]](ty_substs);
}
ret {substs: ty_substs_opt, ty: tpt.ty};
}
ret {ty: ast_ty_to_ty(tcx, getter, mt.ty), mut: mt.mut};
}
fn instantiate(tcx: &ty::ctxt, sp: &span, getter: &ty_getter,
- id: &ast::def_id, args: &(@ast::ty)[]) -> ty::t {
+ id: &ast::def_id, args: &[@ast::ty]) -> ty::t {
// TODO: maybe record cname chains so we can do
// "foo = int" like OCaml?
// The typedef is type-parametric. Do the type substitution.
//
- let param_bindings: ty::t[] = ~[];
+ let param_bindings: [ty::t] = ~[];
for ast_ty: @ast::ty in args {
param_bindings += ~[ast_ty_to_ty(tcx, getter, ast_ty)];
}
typ = ty::mk_chan(tcx, ast_ty_to_ty(tcx, getter, t));
}
ast::ty_rec(fields) {
- let flds: field[] = ~[];
+ let flds: [field] = ~[];
for f: ast::ty_field in fields {
let tm = ast_mt_to_mt(tcx, getter, f.node.mt);
flds += ~[{ident: f.node.ident, mt: tm}];
cname = some(path_to_str(path));
}
ast::ty_obj(meths) {
- let tmeths: ty::method[] = ~[];
+ let tmeths: [ty::method] = ~[];
for m: ast::ty_method in meths {
let ins = ~[];
for ta: ast::ty_arg in m.node.inputs {
// Writes a type with no type parameters into the node type table.
fn ty_only(tcx: &ty::ctxt, node_id: ast::node_id, typ: ty::t) {
- ty(tcx, node_id, {substs: none[ty::t[]], ty: typ});
+ ty(tcx, node_id, {substs: none[[ty::t]], ty: typ});
}
// Writes a type with no type parameters into the node type table. This
// function allows for the possibility of type variables.
fn ty_only_fixup(fcx: @fn_ctxt, node_id: ast::node_id, typ: ty::t) {
- ret ty_fixup(fcx, node_id, {substs: none[ty::t[]], ty: typ});
+ ret ty_fixup(fcx, node_id, {substs: none[[ty::t]], ty: typ});
}
// Writes a nil type into the node type table.
fn nil_ty(tcx: &ty::ctxt, node_id: ast::node_id) {
- ret ty(tcx, node_id, {substs: none[ty::t[]], ty: ty::mk_nil(tcx)});
+ ret ty(tcx, node_id, {substs: none[[ty::t]], ty: ty::mk_nil(tcx)});
}
// Writes the bottom type into the node type table.
fn bot_ty(tcx: &ty::ctxt, node_id: ast::node_id) {
- ret ty(tcx, node_id, {substs: none[ty::t[]], ty: ty::mk_bot(tcx)});
+ ret ty(tcx, node_id, {substs: none[[ty::t]], ty: ty::mk_bot(tcx)});
}
}
mod collect {
type ctxt = {tcx: ty::ctxt};
- fn mk_ty_params(cx: &@ctxt, atps: &ast::ty_param[]) -> ty::t[] {
+ fn mk_ty_params(cx: &@ctxt, atps: &[ast::ty_param]) -> [ty::t] {
let tps = ~[];
let i = 0u;
for atp: ast::ty_param in atps {
ret tps;
}
- fn ty_param_kinds(tps: &ast::ty_param[]) -> ast::kind[] {
- let k: ast::kind[] = ~[];
+ fn ty_param_kinds(tps: &[ast::ty_param]) -> [ast::kind] {
+ let k: [ast::kind] = ~[];
for p: ast::ty_param in tps {
k += ~[p.kind]
}
fn ty_of_fn_decl(cx: &@ctxt, convert: &fn(&@ast::ty) -> ty::t ,
ty_of_arg: &fn(&ast::arg) -> arg , decl: &ast::fn_decl,
- proto: ast::proto, ty_params: &ast::ty_param[],
+ proto: ast::proto, ty_params: &[ast::ty_param],
def_id: &option::t[ast::def_id]) ->
ty::ty_param_kinds_and_ty {
let input_tys = ~[];
fn ty_of_native_fn_decl(cx: &@ctxt, convert: &fn(&@ast::ty) -> ty::t ,
ty_of_arg: &fn(&ast::arg) -> arg ,
decl: &ast::fn_decl, abi: ast::native_abi,
- ty_params: &ast::ty_param[], def_id: &ast::def_id)
+ ty_params: &[ast::ty_param], def_id: &ast::def_id)
-> ty::ty_param_kinds_and_ty {
let input_tys = ~[];
for a: ast::arg in decl.inputs { input_tys += ~[ty_of_arg(a)]; }
constrs: out_constrs};
}
fn ty_of_obj(cx: @ctxt, id: &ast::ident, ob: &ast::_obj,
- ty_params: &ast::ty_param[]) -> ty::ty_param_kinds_and_ty {
+ ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty {
let methods = get_obj_method_types(cx, ob);
let t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods));
t_obj = ty::rename(cx.tcx, t_obj, id);
ret {kinds: ty_param_kinds(ty_params), ty: t_obj};
}
fn ty_of_obj_ctor(cx: @ctxt, id: &ast::ident, ob: &ast::_obj,
- ctor_id: ast::node_id, ty_params: &ast::ty_param[]) ->
+ ctor_id: ast::node_id, ty_params: &[ast::ty_param]) ->
ty::ty_param_kinds_and_ty {
let t_obj = ty_of_obj(cx, id, ob, ty_params);
- let t_inputs: arg[] = ~[];
+ let t_inputs: [arg] = ~[];
for f: ast::obj_field in ob.fields {
let g = bind getter(cx, _);
let t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
fn ty_of_item(cx: &@ctxt, it: &@ast::item) -> ty::ty_param_kinds_and_ty {
let get = bind getter(cx, _);
let convert = bind ast_ty_to_ty(cx.tcx, get, _);
- let no_kinds: ast::kind[] = ~[];
+ let no_kinds: [ast::kind] = ~[];
alt it.node {
ast::item_const(t, _) {
let typ = convert(t);
}
ast::item_tag(_, tps) {
// Create a new generic polytype.
- let subtys: ty::t[] = mk_ty_params(cx, tps);
+ let subtys: [ty::t] = mk_ty_params(cx, tps);
let t = ty::mk_tag(cx.tcx, local_def(it.id), subtys);
let tpt = {kinds: ty_param_kinds(tps), ty: t};
cx.tcx.tcache.insert(local_def(it.id), tpt);
}
fn ty_of_native_item(cx: &@ctxt, it: &@ast::native_item,
abi: ast::native_abi) -> ty::ty_param_kinds_and_ty {
- let no_kinds: ast::kind[] = ~[];
+ let no_kinds: [ast::kind] = ~[];
alt it.node {
ast::native_item_fn(_, fn_decl, params) {
let get = bind getter(cx, _);
}
}
fn get_tag_variant_types(cx: &@ctxt, tag_id: &ast::def_id,
- variants: &ast::variant[],
- ty_params: &ast::ty_param[]) {
+ variants: &[ast::variant],
+ ty_params: &[ast::ty_param]) {
// Create a set of parameter types shared among all the variants.
- let ty_param_tys: ty::t[] = mk_ty_params(cx, ty_params);
+ let ty_param_tys: [ty::t] = mk_ty_params(cx, ty_params);
for variant: ast::variant in variants {
// Nullary tag constructors get turned into constants; n-ary tag
// constructors get turned into functions.
// should be called to resolve named types.
let f = bind getter(cx, _);
- let args: arg[] = ~[];
+ let args: [arg] = ~[];
for va: ast::variant_arg in variant.node.args {
let arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
args += ~[{mode: ty::mo_alias(false), ty: arg_ty}];
write::ty_only(cx.tcx, variant.node.id, result_ty);
}
}
- fn get_obj_method_types(cx: &@ctxt, object: &ast::_obj) -> ty::method[] {
+ fn get_obj_method_types(cx: &@ctxt, object: &ast::_obj) -> [ty::method] {
let meths = ~[];
for m: @ast::method in object.methods {
meths += ~[ty_of_method(cx, m)];
// Demands - procedures that require that two types unify and emit an error
// message if they don't.
-type ty_param_substs_and_ty = {substs: ty::t[], ty: ty::t};
+type ty_param_substs_and_ty = {substs: [ty::t], ty: ty::t};
mod demand {
fn simple(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, actual: &ty::t) ->
// Requires that the two types unify, and prints an error message if they
// don't. Returns the unified type and the type parameter substitutions.
fn full(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, actual: &ty::t,
- ty_param_substs_0: &ty::t[], adk: autoderef_kind) ->
+ ty_param_substs_0: &[ty::t], adk: autoderef_kind) ->
ty_param_substs_and_ty {
let expected_1 = expected;
let actual_1 = actual;
} else if (adk == AUTODEREF_BLOCK_COERCE) {
actual_1 = do_fn_block_coerce(fcx, sp, actual, expected);
}
- let ty_param_substs: ty::t[mutable ] = ~[mutable ];
- let ty_param_subst_var_ids: int[] = ~[];
+ let ty_param_substs: [mutable ty::t] = ~[mutable];
+ let ty_param_subst_var_ids: [int] = ~[];
for ty_param_subst: ty::t in ty_param_substs_0 {
// Generate a type variable and unify it with the type parameter
// substitution. We will then pull out these type variables.
}
fn mk_result(fcx: &@fn_ctxt, result_ty: &ty::t,
- ty_param_subst_var_ids: &int[], implicit_boxes: uint) ->
+ ty_param_subst_var_ids: &[int], implicit_boxes: uint) ->
ty_param_substs_and_ty {
- let result_ty_param_substs: ty::t[] = ~[];
+ let result_ty_param_substs: [ty::t] = ~[];
for var_id: int in ty_param_subst_var_ids {
let tp_subst = ty::mk_var(fcx.ccx.tcx, var_id);
result_ty_param_substs += ~[tp_subst];
// Returns the types of the arguments to a tag variant.
fn variant_arg_types(ccx: &@crate_ctxt, sp: &span, vid: &ast::def_id,
- tag_ty_params: &ty::t[]) -> ty::t[] {
- let result: ty::t[] = ~[];
+ tag_ty_params: &[ty::t]) -> [ty::t] {
+ let result: [ty::t] = ~[];
let tpt = ty::lookup_item_type(ccx.tcx, vid);
alt ty::struct(ccx.tcx, tpt.ty) {
ty::ty_fn(_, ins, _, _, _) {
};
let new_substs_opt;
alt tpot.substs {
- none[ty::t[]]. { new_substs_opt = none[ty::t[]]; }
- some[ty::t[]](substs) {
- let new_substs: ty::t[] = ~[];
+ none[[ty::t]]. { new_substs_opt = none[[ty::t]]; }
+ some[[ty::t]](substs) {
+ let new_substs: [ty::t] = ~[];
for subst: ty::t in substs {
alt resolve_type_vars_in_type(fcx, sp, subst) {
some(t) { new_substs += ~[t]; }
none. { wbcx.success = false; ret; }
}
}
- new_substs_opt = some[ty::t[]](new_substs);
+ new_substs_opt = some[[ty::t]](new_substs);
}
}
write::ty(fcx.ccx.tcx, id, {substs: new_substs_opt, ty: new_ty});
};
// Don't descend into fns and items
- fn visit_fn[E](f: &ast::_fn, tp: &ast::ty_param[], sp: &span,
+ fn visit_fn[E](f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
i: &ast::fn_ident, id: ast::node_id, e: &E,
v: &visit::vt[E]) { }
fn visit_item[E](i: &@ast::item, e: &E, v: &visit::vt[E]) { }
demand::full(fcx, pat.span, expected, ctor_ty, expected_tps,
NO_AUTODEREF);
path_tpot =
- {substs: some[ty::t[]](path_tpt.substs), ty: path_tpt.ty};
+ {substs: some[[ty::t]](path_tpt.substs), ty: path_tpt.ty};
// Get the number of arguments in this tag variant.
let arg_types =
// A generic function to factor out common logic from call and bind
// expressions.
fn check_call_or_bind(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr,
- args: &(option::t[@ast::expr])[],
+ args: &[option::t[@ast::expr]],
call_kind: call_kind) -> bool {
// Check the function.
let bot = check_expr(fcx, f);
// A generic function for checking call expressions
fn check_call(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr,
- args: &(@ast::expr)[], call_kind: call_kind) -> bool {
- let args_opt_0: (option::t[@ast::expr])[] = ~[];
+ args: &[@ast::expr], call_kind: call_kind) -> bool {
+ let args_opt_0: [option::t[@ast::expr]] = ~[];
for arg: @ast::expr in args {
args_opt_0 += ~[some[@ast::expr](arg)];
}
// A generic function for doing all of the checking for call expressions
fn check_call_full(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr,
- args: &(@ast::expr)[], call_kind: call_kind,
+ args: &[@ast::expr], call_kind: call_kind,
id: ast::node_id) -> bool {
/* here we're kind of hosed, as f can be any expr
need to restrict it to being an explicit expr_path if we're
// Pull the argument and return types out.
let proto_1;
- let arg_tys_1: ty::arg[] = ~[];
+ let arg_tys_1: [ty::arg] = ~[];
let rt_1;
let fty = expr_ty(tcx, f);
let t_1;
}
ast::expr_rec(fields, base) {
alt base { none. {/* no-op */ } some(b_0) { check_expr(fcx, b_0); } }
- let fields_t: (spanned[field])[] = ~[];
+ let fields_t: [spanned[field]] = ~[];
for f: ast::field in fields {
bot |= check_expr(fcx, f.node.expr);
let expr_t = expr_ty(tcx, f.node.expr);
some(bexpr) {
bot |= check_expr(fcx, bexpr);
let bexpr_t = expr_ty(tcx, bexpr);
- let base_fields: field[] = ~[];
+ let base_fields: [field] = ~[];
alt structure_of(fcx, expr.span, bexpr_t) {
ty::ty_rec(flds) { base_fields = flds; }
_ {
}
}
ast::expr_anon_obj(ao) {
- let fields: ast::anon_obj_field[] = ~[];
+ let fields: [ast::anon_obj_field] = ~[];
alt ao.fields { none. { } some(v) { fields = v; } }
// FIXME: These next three functions are largely ripped off from
constrs: out_constrs};
}
- let method_types: ty::method[] = ~[];
+ let method_types: [ty::method] = ~[];
{
// Outer methods.
for m: @ast::method in ao.methods {
// Typecheck 'inner_obj'. If it exists, it had better have object
// type.
- let inner_obj_methods: ty::method[] = ~[];
+ let inner_obj_methods: [ty::method] = ~[];
let inner_obj_ty: ty::t = ty::mk_nil(tcx);
let inner_obj_sty: option::t[ty::sty] = none;
alt ao.inner_obj {
// any methods that share a name with an outer method.
fn filtering_fn(ccx: @crate_ctxt,
m: &ty::method,
- outer_obj_methods: (@ast::method)[]) ->
+ outer_obj_methods: [@ast::method]) ->
option::t[ty::method] {
for om: @ast::method in outer_obj_methods {
// FIXME: this is kinda a kludge; we manufacture a fake function context
// and statement context for checking the initializer expression.
let rty = node_id_to_type(ccx.tcx, id);
- let fixups: ast::node_id[] = ~[];
+ let fixups: [ast::node_id] = ~[];
let fcx: @fn_ctxt =
@{ret_ty: rty,
purity: ast::pure_fn,
let decl = f.decl;
let body = f.body;
let gather_result = gather_locals(ccx, f, id, old_fcx);
- let fixups: ast::node_id[] = ~[];
+ let fixups: [ast::node_id] = ~[];
let fcx: @fn_ctxt =
@{ret_ty: ast_ty_to_ty_crate(ccx, decl.output),
purity: decl.purity,
fn check_crate(tcx: &ty::ctxt, crate: &@ast::crate) {
collect::collect_item_types(tcx, crate);
- let obj_infos: obj_info[] = ~[];
+ let obj_infos: [obj_info] = ~[];
let ccx = @{mutable obj_infos: obj_infos, tcx: tcx};
let visit = visit::mk_simple_visitor
// FIXME: with typestate constraint, could say
// idents and types are the same length, and are
// non-empty
-type path_ = {global: bool, idents: ident[], types: (@ty)[]};
+type path_ = {global: bool, idents: [ident], types: [@ty]};
type path = spanned[path_];
fn path_name(p: &path) -> str { path_name_i(p.node.idents) }
-fn path_name_i(idents: &ident[]) -> str { str::connect_ivec(idents, "::") }
+fn path_name_i(idents: &[ident]) -> str { str::connect_ivec(idents, "::") }
type crate_num = int;
type node_id = int;
// The set of meta_items that define the compilation environment of the crate,
// used to drive conditional compilation
-type crate_cfg = (@meta_item)[];
+type crate_cfg = [@meta_item];
type crate = spanned[crate_];
type crate_ =
- {directives: (@crate_directive)[],
+ {directives: [@crate_directive],
module: _mod,
- attrs: attribute[],
+ attrs: [attribute],
config: crate_cfg};
tag crate_directive_ {
- cdir_src_mod(ident, option::t[filename], attribute[]);
+ cdir_src_mod(ident, option::t[filename], [attribute]);
cdir_dir_mod(ident,
option::t[filename],
- (@crate_directive)[],
- attribute[]);
+ [@crate_directive],
+ [attribute]);
cdir_view_item(@view_item);
cdir_syntax(path);
cdir_auth(path, _auth);
tag meta_item_ {
meta_word(ident);
- meta_list(ident, (@meta_item)[]);
+ meta_list(ident, [@meta_item]);
meta_name_value(ident, lit);
}
type blk = spanned[blk_];
-type blk_ = {stmts: (@stmt)[], expr: option::t[@expr], id: node_id};
+type blk_ = {stmts: [@stmt], expr: option::t[@expr], id: node_id};
type pat = {id: node_id, node: pat_, span: span};
pat_wild;
pat_bind(ident);
pat_lit(@lit);
- pat_tag(path, (@pat)[]);
- pat_rec(field_pat[], bool);
+ pat_tag(path, [@pat]);
+ pat_rec([field_pat], bool);
pat_box(@pat);
}
}
}
-fn pat_binding_ids(pat: &@pat) -> node_id[] {
+fn pat_binding_ids(pat: &@pat) -> [node_id] {
let found = ~[];
for each b in pat_bindings(pat) { found += ~[b.id]; }
ret found;
type decl = spanned[decl_];
-tag decl_ { decl_local((@local)[]); decl_item(@item); }
+tag decl_ { decl_local([@local]); decl_item(@item); }
-type arm = {pats: (@pat)[], block: blk};
+type arm = {pats: [@pat], block: blk};
type elt = {mut: mutability, expr: @expr};
type expr = {id: node_id, node: expr_, span: span};
tag expr_ {
- expr_vec((@expr)[], mutability, seq_kind);
- expr_rec(field[], option::t[@expr]);
- expr_call(@expr, (@expr)[]);
+ expr_vec([@expr], mutability, seq_kind);
+ expr_rec([field], option::t[@expr]);
+ expr_call(@expr, [@expr]);
expr_self_method(ident);
- expr_bind(@expr, (option::t[@expr])[]);
- expr_spawn(spawn_dom, option::t[str], @expr, (@expr)[]);
+ expr_bind(@expr, [option::t[@expr]]);
+ expr_spawn(spawn_dom, option::t[str], @expr, [@expr]);
expr_binary(binop, @expr, @expr);
expr_unary(unop, @expr);
expr_lit(@lit);
expr_for(@local, @expr, blk);
expr_for_each(@local, @expr, blk);
expr_do_while(blk, @expr);
- expr_alt(@expr, arm[]);
+ expr_alt(@expr, [arm]);
expr_fn(_fn);
expr_block(blk);
type ty_method_ =
{proto: proto,
ident: ident,
- inputs: ty_arg[],
+ inputs: [ty_arg],
output: @ty,
cf: controlflow,
- constrs: (@constr)[]};
+ constrs: [@constr]};
type ty_field = spanned[ty_field_];
ty_task;
ty_port(@ty);
ty_chan(@ty);
- ty_rec(ty_field[]);
- ty_fn(proto, ty_arg[], @ty, controlflow, (@constr)[]);
- ty_obj(ty_method[]);
+ ty_rec([ty_field]);
+ ty_fn(proto, [ty_arg], @ty, controlflow, [@constr]);
+ ty_obj([ty_method]);
ty_path(path, node_id);
ty_type;
- ty_constr(@ty, (@ty_constr)[]);
+ ty_constr(@ty, [@ty_constr]);
ty_mac(mac);
}
// constrained type, is * (referring to the base record)
type constr_general_[ARG, ID] =
- {path: path, args: (@spanned[constr_arg_general_[ARG]])[], id: ID};
+ {path: path, args: [@spanned[constr_arg_general_[ARG]]], id: ID};
// In the front end, constraints have a node ID attached.
// Typeck turns this to a def_id, using the output of resolve.
tag inlineness { il_normal; il_inline; }
type fn_decl =
- {inputs: arg[],
+ {inputs: [arg],
output: @ty,
purity: purity,
il: inlineness,
cf: controlflow,
- constraints: (@constr)[]};
+ constraints: [@constr]};
tag purity {
pure_fn; // declared with "pred"
type anon_obj_field =
{mut: mutability, ty: @ty, expr: @expr, ident: ident, id: node_id};
-type _obj = {fields: obj_field[], methods: (@method)[]};
+type _obj = {fields: [obj_field], methods: [@method]};
type anon_obj =
// New fields and methods, if they exist.
- {fields: option::t[anon_obj_field[]],
- methods: (@method)[],
+ {fields: option::t[[anon_obj_field]],
+ methods: [@method],
// inner_obj: the original object being extended, if it exists.
inner_obj: option::t[@expr]};
-type _mod = {view_items: (@view_item)[], items: (@item)[]};
+type _mod = {view_items: [@view_item], items: [@item]};
tag native_abi {
native_abi_rust;
type native_mod =
{native_name: str,
abi: native_abi,
- view_items: (@view_item)[],
- items: (@native_item)[]};
+ view_items: [@view_item],
+ items: [@native_item]};
type variant_arg = {ty: @ty, id: node_id};
-type variant_ = {name: str, args: variant_arg[], id: node_id};
+type variant_ = {name: str, args: [variant_arg], id: node_id};
type variant = spanned[variant_];
type view_item = spanned[view_item_];
tag view_item_ {
- view_item_use(ident, (@meta_item)[], node_id);
- view_item_import(ident, ident[], node_id);
- view_item_import_glob(ident[], node_id);
+ view_item_use(ident, [@meta_item], node_id);
+ view_item_import(ident, [ident], node_id);
+ view_item_import_glob([ident], node_id);
view_item_export(ident, node_id);
}
type attribute_ = {style: attr_style, value: meta_item};
type item = // For objs and resources, this is the type def_id
- {ident: ident, attrs: attribute[], id: node_id, node: item_, span: span};
+ {ident: ident, attrs: [attribute], id: node_id, node: item_, span: span};
tag item_ {
item_const(@ty, @expr);
- item_fn(_fn, ty_param[]);
+ item_fn(_fn, [ty_param]);
item_mod(_mod);
item_native_mod(native_mod);
- item_ty(@ty, ty_param[]);
- item_tag(variant[], ty_param[]);
- item_obj(_obj, ty_param[], /* constructor id */node_id);
+ item_ty(@ty, [ty_param]);
+ item_tag([variant], [ty_param]);
+ item_obj(_obj, [ty_param], /* constructor id */node_id);
item_res(_fn, /* dtor */
node_id, /* dtor id */
- ty_param[],
+ [ty_param],
node_id /* ctor id */);
}
type native_item =
{ident: ident,
- attrs: attribute[],
+ attrs: [attribute],
node: native_item_,
id: node_id,
span: span};
tag native_item_ {
native_item_ty;
- native_item_fn(option::t[str], fn_decl, ty_param[]);
+ native_item_fn(option::t[str], fn_decl, [ty_param]);
}
fn is_exported(i: ident, m: _mod) -> bool {
* compiler.
*/
type filemap =
- @{name: filename, start_pos: file_pos, mutable lines: file_pos[]};
+ @{name: filename, start_pos: file_pos, mutable lines: [file_pos]};
-type codemap = @{mutable files: filemap[]};
+type codemap = @{mutable files: [filemap]};
type loc = {filename: filename, line: uint, col: uint};
emit_diagnostic(sp, msg, "note", 10u8, cm);
}
-type file_lines = {name: str, lines: uint[]};
+type file_lines = {name: str, lines: [uint]};
fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
let lo = lookup_char_pos(cm, sp.lo);
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr {
- let args: (@ast::expr)[] = alt arg.node {
+ let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#concat_idents requires a vector argument .") }
};
node: {global: false, idents: ~[res], types: ~[]},
span: sp}),
span: sp};
-}
\ No newline at end of file
+}
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr {
- let args: (@ast::expr)[] = alt arg.node {
+ let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#env requires arguments of the form `[...]`.") }
};
fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr {
- let args: (@ast::expr)[] = alt arg.node {
+ let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#fmt requires arguments of the form `[...]`.") }
};
// be factored out in common with other code that builds expressions.
// FIXME: Cleanup the naming of these functions
fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece],
- args: &(@ast::expr)[]) -> @ast::expr {
+ args: &[@ast::expr]) -> @ast::expr {
fn make_new_lit(cx: &ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
let sp_lit = @{node: lit, span: sp};
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
let binexpr = ast::expr_binary(ast::add, lhs, rhs);
ret @{id: cx.next_id(), node: binexpr, span: sp};
}
- fn make_path_expr(cx: &ext_ctxt, sp: span, idents: &ast::ident[]) ->
+ fn make_path_expr(cx: &ext_ctxt, sp: span, idents: &[ast::ident]) ->
@ast::expr {
let path = {global: false, idents: idents, types: ~[]};
let sp_path = {node: path, span: sp};
let pathexpr = ast::expr_path(sp_path);
ret @{id: cx.next_id(), node: pathexpr, span: sp};
}
- fn make_vec_expr(cx: &ext_ctxt, sp: span, exprs: &(@ast::expr)[]) ->
+ fn make_vec_expr(cx: &ext_ctxt, sp: span, exprs: &[@ast::expr]) ->
@ast::expr {
let vecexpr = ast::expr_vec(exprs, ast::imm, ast::sk_rc);
ret @{id: cx.next_id(), node: vecexpr, span: sp};
}
- fn make_call(cx: &ext_ctxt, sp: span, fn_path: &ast::ident[],
- args: &(@ast::expr)[]) -> @ast::expr {
+ fn make_call(cx: &ext_ctxt, sp: span, fn_path: &[ast::ident],
+ args: &[@ast::expr]) -> @ast::expr {
let pathexpr = make_path_expr(cx, sp, fn_path);
let callexpr = ast::expr_call(pathexpr, args);
ret @{id: cx.next_id(), node: callexpr, span: sp};
fn make_rec_expr(cx: &ext_ctxt, sp: span,
fields: vec[{ident: ast::ident, ex: @ast::expr}]) ->
@ast::expr {
- let astfields: ast::field[] = ~[];
+ let astfields: [ast::field] = ~[];
for field: {ident: ast::ident, ex: @ast::expr} in fields {
let ident = field.ident;
let val = field.ex;
let recexpr = ast::expr_rec(astfields, option::none[@ast::expr]);
ret @{id: cx.next_id(), node: recexpr, span: sp};
}
- fn make_path_vec(cx: &ext_ctxt, ident: str) -> str[] {
+ fn make_path_vec(cx: &ext_ctxt, ident: str) -> [str] {
fn compiling_std(cx: &ext_ctxt) -> bool {
ret str::find(cx.crate_file_name_hack, "std.rc") >= 0;
}
fn make_rt_conv_expr(cx: &ext_ctxt, sp: span, cnv: &conv) -> @ast::expr {
fn make_flags(cx: &ext_ctxt, sp: span, flags: vec[flag]) ->
@ast::expr {
- let flagexprs: (@ast::expr)[] = ~[];
+ let flagexprs: [@ast::expr] = ~[];
for f: flag in flags {
let fstr;
alt f {
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr {
- let args: (@ast::expr)[] = alt arg.node {
+ let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#ident_to_str requires a vector argument .") }
};
"expected an ident"),
ast::sk_rc));
-}
\ No newline at end of file
+}
type match_result = option::t[arb_depth[matchable]];
type selector = fn(&matchable) -> match_result ;
-fn elts_to_ell(cx: &ext_ctxt, elts: &(@expr)[])
- -> {fixed: (@expr)[], rep: option::t[@expr]} {
+fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr])
+ -> {fixed: [@expr], rep: option::t[@expr]} {
let idx: uint = 0u;
for elt: @expr in elts {
alt elt.node {
type binders =
{real_binders: hashmap[ident, selector],
- mutable literal_ast_matchers: selector[]};
+ mutable literal_ast_matchers: [selector]};
type bindings = hashmap[ident, arb_depth[matchable]];
fn acumm_bindings(cx: &ext_ctxt, b_dest: &bindings, b_src: &bindings) { }
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
- recur: fn(&@expr) -> @expr , exprs: (@expr)[])
- -> (@expr)[] {
+ recur: fn(&@expr) -> @expr , exprs: [@expr])
+ -> [@expr] {
alt elts_to_ell(cx, exprs) {
{fixed: fixed, rep: repeat_me_maybe} {
let res = ivec::map(recur, fixed);
/* TODO: move this to vec.rs */
-fn ivec_to_vec[T](v: &T[]) -> vec[T] {
+fn ivec_to_vec[T](v: &[T]) -> vec[T] {
let rs: vec[T] = vec::alloc[T](ivec::len(v));
for ve: T in v { rs += [ve]; }
ret rs;
compose_sels(s, bind select(cx, repeat_me, offset, _)), b);
}
-fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: (@expr)[], repeat_after: bool,
+fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], repeat_after: bool,
s: &selector, b: &binders) {
fn len_select(cx: &ext_ctxt, m: &matchable, repeat_after: bool, len: uint)
-> match_result {
fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
body: option::t[str]) -> base::macro_def {
- let args: (@ast::expr)[] = alt arg.node {
+ let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts }
_ {
cx.span_fatal(sp, "#macro requires arguments of the form `[...]`.")
};
let macro_name: option::t[str] = none;
- let clauses: clause[] = ~[];
+ let clauses: [clause] = ~[];
for arg: @expr in args {
alt arg.node {
expr_vec(elts, mut, seq_kind) {
ext: normal(ext)};
fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr,
- body: option::t[str], clauses: clause[]) -> @expr {
+ body: option::t[str], clauses: [clause]) -> @expr {
for c: clause in clauses {
alt use_selectors_to_bind(c.params, arg) {
some(bindings) {
fold_ident: fn(&ident, ast_fold) -> ident ,
fold_path: fn(&path_, ast_fold) -> path_ ,
fold_local: fn(&local_, ast_fold) -> local_ ,
- map_exprs: fn(fn(&@expr) -> @expr , (@expr)[]) -> (@expr)[] };
+ map_exprs: fn(fn(&@expr) -> @expr , [@expr]) -> [@expr] };
type a_f =
{fold_crate: fn(&crate) -> crate ,
fold_ident: fn(&ident) -> ident ,
fold_path: fn(&path) -> path ,
fold_local: fn(&@local) -> @local ,
- map_exprs: fn(fn(&@expr) -> @expr , (@expr)[]) -> (@expr)[] };
+ map_exprs: fn(fn(&@expr) -> @expr , [@expr]) -> [@expr] };
//fn nf_dummy[T](&T node) -> T { fail; }
fn nf_crate_dummy(c: &crate) -> crate { fail; }
/* temporarily eta-expand because of a compiler bug with using `fn[T]` as a
value */
-fn noop_map_exprs(f: fn(&@expr) -> @expr , es: (@expr)[]) -> (@expr)[] {
+fn noop_map_exprs(f: fn(&@expr) -> @expr , es: [@expr]) -> [@expr] {
ret ivec::map(f, es);
}
type ctx =
@{p: parser,
mode: eval_mode,
- mutable deps: str[],
+ mutable deps: [str],
sess: parser::parse_sess,
mutable chpos: uint,
mutable byte_pos: uint,
cfg: ast::crate_cfg};
-fn eval_crate_directives(cx: ctx, cdirs: &(@ast::crate_directive)[],
+fn eval_crate_directives(cx: ctx, cdirs: &[@ast::crate_directive],
prefix: str,
- view_items: &mutable (@ast::view_item)[],
- items: &mutable (@ast::item)[]) {
+ view_items: &mutable [@ast::view_item],
+ items: &mutable [@ast::item]) {
for sub_cdir: @ast::crate_directive in cdirs {
eval_crate_directive(cx, sub_cdir, prefix, view_items, items);
}
}
-fn eval_crate_directives_to_mod(cx: ctx, cdirs: &(@ast::crate_directive)[],
+fn eval_crate_directives_to_mod(cx: ctx, cdirs: &[@ast::crate_directive],
prefix: str) -> ast::_mod {
- let view_items: (@ast::view_item)[] = ~[];
- let items: (@ast::item)[] = ~[];
+ let view_items: [@ast::view_item] = ~[];
+ let items: [@ast::item] = ~[];
eval_crate_directives(cx, cdirs, prefix, view_items, items);
ret {view_items: view_items, items: items};
}
fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
- view_items: &mutable (@ast::view_item)[],
- items: &mutable (@ast::item)[]) {
+ view_items: &mutable [@ast::view_item],
+ items: &mutable [@ast::item]) {
alt cdir.node {
ast::cdir_src_mod(id, file_opt, attrs) {
let file_path = id + ".rs";
mutable pos: uint,
mutable ch: char,
mutable chpos: uint,
- mutable strs: str[],
+ mutable strs: [str],
fm: codemap::filemap,
itr: @interner::interner[str]) {
fn is_eof() -> bool { ret ch == -1 as char; }
codemap::emit_error(some({lo: chpos, hi: chpos}), m, cm);
}
}
- let strs: str[] = ~[];
+ let strs: [str] = ~[];
let rd =
reader(cm, src, str::byte_len(src), 0u, 0u, -1 as char,
filemap.start_pos.ch, strs, filemap, itr);
blank_line; // Just a manual blank line "\n\n", for layout
}
-type cmnt = {style: cmnt_style, lines: str[], pos: uint};
+type cmnt = {style: cmnt_style, lines: [str], pos: uint};
fn read_to_eol(rdr: &reader) -> str {
let val = "";
}
}
-fn push_blank_line_comment(rdr: &reader, comments: &mutable cmnt[]) {
+fn push_blank_line_comment(rdr: &reader, comments: &mutable [cmnt]) {
log ">>> blank-line comment";
- let v: str[] = ~[];
+ let v: [str] = ~[];
comments += ~[{style: blank_line, lines: v, pos: rdr.get_chpos()}];
}
fn consume_whitespace_counting_blank_lines(rdr: &reader,
- comments: &mutable cmnt[]) {
+ comments: &mutable [cmnt]) {
while is_whitespace(rdr.curr()) && !rdr.is_eof() {
if rdr.get_col() == 0u && rdr.curr() == '\n' {
push_blank_line_comment(rdr, comments);
fn read_line_comments(rdr: &reader, code_to_the_left: bool) -> cmnt {
log ">>> line comments";
let p = rdr.get_chpos();
- let lines: str[] = ~[];
+ let lines: [str] = ~[];
while rdr.curr() == '/' && rdr.next() == '/' {
let line = read_one_line_comment(rdr);
log line;
ret true;
}
-fn trim_whitespace_prefix_and_push_line(lines: &mutable str[], s: &str,
+fn trim_whitespace_prefix_and_push_line(lines: &mutable [str], s: &str,
col: uint) {
let s1;
if all_whitespace(s, 0u, col) {
fn read_block_comment(rdr: &reader, code_to_the_left: bool) -> cmnt {
log ">>> block comment";
let p = rdr.get_chpos();
- let lines: str[] = ~[];
+ let lines: [str] = ~[];
let col: uint = rdr.get_col();
rdr.bump();
rdr.bump();
}
fn consume_comment(rdr: &reader, code_to_the_left: bool,
- comments: &mutable cmnt[]) {
+ comments: &mutable [cmnt]) {
log ">>> consume comment";
if rdr.curr() == '/' && rdr.next() == '/' {
comments += ~[read_line_comments(rdr, code_to_the_left)];
fn gather_comments_and_literals(cm: &codemap::codemap, path: str,
srdr: ioivec::reader) ->
- {cmnts: cmnt[], lits: lit[]} {
+ {cmnts: [cmnt], lits: [lit]} {
let src = str::unsafe_from_bytes_ivec(srdr.read_whole_stream());
let itr = @interner::mk[str](str::hash, str::eq);
let rdr = new_reader(cm, src, codemap::new_filemap(path, 0u, 0u), itr);
- let comments: cmnt[] = ~[];
- let literals: lit[] = ~[];
+ let comments: [cmnt] = ~[];
+ let literals: [lit] = ~[];
let first_read: bool = true;
while !rdr.is_eof() {
while true {
fn get_hi_pos() -> uint ;
fn get_last_lo_pos() -> uint ;
fn get_last_hi_pos() -> uint ;
- fn get_prec_table() -> @op_spec[] ;
+ fn get_prec_table() -> @[op_spec] ;
fn get_str(token::str_num) -> str ;
fn get_reader() -> lexer::reader ;
fn get_filemap() -> codemap::filemap ;
mutable tok: token::token,
mutable tok_span: span,
mutable last_tok_span: span,
- mutable buffer: {tok: token::token, span: span}[],
+ mutable buffer: [{tok: token::token, span: span}],
mutable restr: restriction,
rdr: lexer::reader,
- precs: @op_spec[],
+ precs: @[op_spec],
bad_words: hashmap[str, ()]) {
fn peek() -> token::token { ret tok; }
fn bump() {
fn get_last_hi_pos() -> uint { ret last_tok_span.hi; }
fn get_file_type() -> file_type { ret ftype; }
fn get_cfg() -> ast::crate_cfg { ret cfg; }
- fn get_prec_table() -> @op_spec[] { ret precs; }
+ fn get_prec_table() -> @[op_spec] { ret precs; }
fn get_str(i: token::str_num) -> str {
ret interner::get(*rdr.get_interner(), i);
}
parse_fn_input_ty, p);
// FIXME: there's no syntax for this right now anyway
// auto constrs = parse_constrs(~[], p);
- let constrs: (@ast::constr)[] = ~[];
+ let constrs: [@ast::constr] = ~[];
let output: @ast::ty;
let cf = ast::return;
if p.peek() == token::RARROW {
// if i is the jth ident in args, return j
// otherwise, fail
-fn ident_index(p: &parser, args: &ast::arg[], i: &ast::ident) -> uint {
+fn ident_index(p: &parser, args: &[ast::arg], i: &ast::ident) -> uint {
let j = 0u;
for a: ast::arg in args { if a.ident == i { ret j; } j += 1u; }
p.fatal("Unbound variable " + i + " in constraint arg");
ret @{node: carg, span: sp};
}
-fn parse_constr_arg(args: &ast::arg[], p: &parser) -> @ast::constr_arg {
+fn parse_constr_arg(args: &[ast::arg], p: &parser) -> @ast::constr_arg {
let sp = p.get_span();
let carg = ast::carg_base;
if p.peek() == token::BINOP(token::STAR) {
ret @{node: carg, span: sp};
}
-fn parse_ty_constr(fn_args: &ast::arg[], p: &parser) -> @ast::constr {
+fn parse_ty_constr(fn_args: &[ast::arg], p: &parser) -> @ast::constr {
let lo = p.get_lo_pos();
let path = parse_path(p);
let pf = bind parse_constr_arg(fn_args, _);
- let args: {node: (@ast::constr_arg)[], span: span} =
+ let args: {node: [@ast::constr_arg], span: span} =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), pf, p);
ret @spanned(lo, args.span.hi,
{path: path, args: args.node, id: p.get_id()});
fn parse_constr_in_type(p: &parser) -> @ast::ty_constr {
let lo = p.get_lo_pos();
let path = parse_path(p);
- let args: (@ast::ty_constr_arg)[] =
+ let args: [@ast::ty_constr_arg] =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_type_constr_arg, p).node;
let hi = p.get_lo_pos();
fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general[T] , p: &parser)
- -> (@ast::constr_general[T])[] {
- let constrs: (@ast::constr_general[T])[] = ~[];
+ -> [@ast::constr_general[T]] {
+ let constrs: [@ast::constr_general[T]] = ~[];
while true {
let constr = pser(p);
constrs += ~[constr];
constrs
}
-fn parse_type_constraints(p: &parser) -> (@ast::ty_constr)[] {
+fn parse_type_constraints(p: &parser) -> [@ast::ty_constr] {
ret parse_constrs(parse_constr_in_type, p);
}
fn parse_ty_postfix(orig_t: ast::ty_, p: &parser) -> @ast::ty {
let lo = p.get_lo_pos();
if p.peek() == token::LBRACKET {
+ // This is explicit type parameter instantiation.
p.bump();
let mut;
}
fn parse_seq_to_end[T](ket: token::token, sep: option::t[token::token],
- f: fn(&parser) -> T , p: &parser) -> T[] {
+ f: fn(&parser) -> T , p: &parser) -> [T] {
let val = parse_seq_to_before_end(ket, sep, f, p);
p.bump();
ret val;
}
fn parse_seq_to_before_end[T](ket: token::token, sep: option::t[token::token],
- f: fn(&parser) -> T , p: &parser) -> T[] {
+ f: fn(&parser) -> T , p: &parser) -> [T] {
let first: bool = true;
- let v: T[] = ~[];
+ let v: [T] = ~[];
while p.peek() != ket {
alt sep {
some(t) { if first { first = false; } else { expect(p, t); } }
fn parse_seq[T](bra: token::token, ket: token::token,
sep: option::t[token::token], f: fn(&parser) -> T ,
- p: &parser) -> spanned[T[]] {
+ p: &parser) -> spanned[[T]] {
let lo = p.get_lo_pos();
expect(p, bra);
let result = parse_seq_to_before_end[T](ket, sep, f, p);
p.bump();
} else { global = false; }
- let ids: ast::ident[] = ~[];
+ let ids: [ast::ident] = ~[];
while true {
alt p.peek() {
token::IDENT(i, _) {
// Anonymous object
// Only make people type () if they're actually adding new fields
- let fields: option::t[ast::anon_obj_field[]] = none;
+ let fields: option::t[[ast::anon_obj_field]] = none;
if p.peek() == token::LPAREN {
p.bump();
fields =
some(parse_seq_to_end(token::RPAREN, some(token::COMMA),
parse_anon_obj_field, p));
}
- let meths: (@ast::method)[] = ~[];
+ let meths: [@ast::method] = ~[];
let inner_obj: option::t[@ast::expr] = none;
expect(p, token::LBRACE);
while p.peek() != token::RBRACE {
// FIXME make this a const, don't store it in parser state
-fn prec_table() -> @op_spec[] {
+fn prec_table() -> @[op_spec] {
ret @~[{tok: token::BINOP(token::STAR), op: ast::mul, prec: 11},
{tok: token::BINOP(token::SLASH), op: ast::div, prec: 11},
{tok: token::BINOP(token::PERCENT), op: ast::rem, prec: 11},
let lo = p.get_last_lo_pos();
let discriminant = parse_expr(p);
expect(p, token::LBRACE);
- let arms: ast::arm[] = ~[];
+ let arms: [ast::arm] = ~[];
while p.peek() != token::RBRACE {
let pats = parse_pats(p);
let blk = parse_block(p);
}
}
-fn parse_pats(p: &parser) -> (@ast::pat)[] {
+fn parse_pats(p: &parser) -> [@ast::pat] {
let pats = ~[];
while true {
pats += ~[parse_pat(p)];
} else {
let tag_path = parse_path_and_ty_param_substs(p);
hi = tag_path.span.hi;
- let args: (@ast::pat)[];
+ let args: [@ast::pat];
alt p.peek() {
token::LPAREN. {
let a =
// some blocks start with "#{"...
fn parse_block_tail(p: &parser, lo: uint) -> ast::blk {
- let stmts: (@ast::stmt)[] = ~[];
+ let stmts: [@ast::stmt] = ~[];
let expr: option::t[@ast::expr] = none;
while p.peek() != token::RBRACE {
alt p.peek() {
ret {ident: parse_ident(p), kind: k};
}
-fn parse_ty_params(p: &parser) -> ast::ty_param[] {
- let ty_params: ast::ty_param[] = ~[];
+fn parse_ty_params(p: &parser) -> [ast::ty_param] {
+ let ty_params: [ast::ty_param] = ~[];
if p.peek() == token::LBRACKET {
ty_params =
parse_seq(token::LBRACKET, token::RBRACKET, some(token::COMMA),
fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness)
-> ast::fn_decl {
- let inputs: ast::spanned[ast::arg[]] =
+ let inputs: ast::spanned[[ast::arg]] =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg,
p);
let rslt: ty_or_bang;
ret {decl: decl, proto: proto, body: body};
}
-fn parse_fn_header(p: &parser) -> {ident: ast::ident, tps: ast::ty_param[]} {
+fn parse_fn_header(p: &parser) -> {ident: ast::ident, tps: [ast::ty_param]} {
let id = parse_value_ident(p);
let ty_params = parse_ty_params(p);
ret {ident: id, tps: ty_params};
}
fn mk_item(p: &parser, lo: uint, hi: uint, ident: &ast::ident,
- node: &ast::item_, attrs: &ast::attribute[]) -> @ast::item {
+ node: &ast::item_, attrs: &[ast::attribute]) -> @ast::item {
ret @{ident: ident,
attrs: attrs,
id: p.get_id(),
}
fn parse_item_fn_or_iter(p: &parser, purity: ast::purity, proto: ast::proto,
- attrs: &ast::attribute[], il: ast::inlineness)
+ attrs: &[ast::attribute], il: ast::inlineness)
-> @ast::item {
let lo = p.get_last_lo_pos();
let t = parse_fn_header(p);
ret @spanned(lo, f.body.span.hi, meth);
}
-fn parse_item_obj(p: &parser, attrs: &ast::attribute[]) ->
+fn parse_item_obj(p: &parser, attrs: &[ast::attribute]) ->
@ast::item {
let lo = p.get_last_lo_pos();
let ident = parse_value_ident(p);
let ty_params = parse_ty_params(p);
- let fields: ast::spanned[ast::obj_field[]] =
+ let fields: ast::spanned[[ast::obj_field]] =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_obj_field, p);
- let meths: (@ast::method)[] = ~[];
+ let meths: [@ast::method] = ~[];
expect(p, token::LBRACE);
while p.peek() != token::RBRACE {
meths += ~[parse_method(p)];
attrs);
}
-fn parse_item_res(p: &parser, attrs: &ast::attribute[]) ->
+fn parse_item_res(p: &parser, attrs: &[ast::attribute]) ->
@ast::item {
let lo = p.get_last_lo_pos();
let ident = parse_value_ident(p);
}
fn parse_mod_items(p: &parser, term: token::token,
- first_item_attrs: &ast::attribute[]) -> ast::_mod {
+ first_item_attrs: &[ast::attribute]) -> ast::_mod {
// Shouldn't be any view items since we've already parsed an item attr
let view_items =
if ivec::len(first_item_attrs) == 0u { parse_view(p) } else { ~[] };
- let items: (@ast::item)[] = ~[];
+ let items: [@ast::item] = ~[];
let initial_attrs = first_item_attrs;
while p.peek() != term {
let attrs = initial_attrs + parse_outer_attributes(p);
ret {view_items: view_items, items: items};
}
-fn parse_item_const(p: &parser, attrs: &ast::attribute[]) -> @ast::item {
+fn parse_item_const(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
let lo = p.get_last_lo_pos();
let id = parse_value_ident(p);
expect(p, token::COLON);
ret mk_item(p, lo, hi, id, ast::item_const(ty, e), attrs);
}
-fn parse_item_mod(p: &parser, attrs: &ast::attribute[]) -> @ast::item {
+fn parse_item_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
let lo = p.get_last_lo_pos();
let id = parse_ident(p);
expect(p, token::LBRACE);
ret mk_item(p, lo, hi, id, ast::item_mod(m), attrs + inner_attrs.inner);
}
-fn parse_item_native_type(p: &parser, attrs: &ast::attribute[]) ->
+fn parse_item_native_type(p: &parser, attrs: &[ast::attribute]) ->
@ast::native_item {
let t = parse_type_decl(p);
let hi = p.get_hi_pos();
span: {lo: t.lo, hi: hi}};
}
-fn parse_item_native_fn(p: &parser, attrs: &ast::attribute[]) ->
+fn parse_item_native_fn(p: &parser, attrs: &[ast::attribute]) ->
@ast::native_item {
let lo = p.get_last_lo_pos();
let t = parse_fn_header(p);
span: {lo: lo, hi: hi}};
}
-fn parse_native_item(p: &parser, attrs: &ast::attribute[]) ->
+fn parse_native_item(p: &parser, attrs: &[ast::attribute]) ->
@ast::native_item {
if eat_word(p, "type") {
ret parse_item_native_type(p, attrs);
}
fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi,
- first_item_attrs: &ast::attribute[])
+ first_item_attrs: &[ast::attribute])
-> ast::native_mod {
// Shouldn't be any view items since we've already parsed an item attr
let view_items =
if ivec::len(first_item_attrs) == 0u {
parse_native_view(p)
} else { ~[] };
- let items: (@ast::native_item)[] = ~[];
+ let items: [@ast::native_item] = ~[];
let initial_attrs = first_item_attrs;
while p.peek() != token::RBRACE {
let attrs = initial_attrs + parse_outer_attributes(p);
items: items};
}
-fn parse_item_native_mod(p: &parser, attrs: &ast::attribute[]) -> @ast::item {
+fn parse_item_native_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
let lo = p.get_last_lo_pos();
let abi = ast::native_abi_cdecl;
if !is_word(p, "mod") {
ret {lo: lo, ident: id};
}
-fn parse_item_type(p: &parser, attrs: &ast::attribute[]) -> @ast::item {
+fn parse_item_type(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
let t = parse_type_decl(p);
let tps = parse_ty_params(p);
expect(p, token::EQ);
ret mk_item(p, t.lo, hi, t.ident, ast::item_ty(ty, tps), attrs);
}
-fn parse_item_tag(p: &parser, attrs: &ast::attribute[]) -> @ast::item {
+fn parse_item_tag(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
let lo = p.get_last_lo_pos();
let id = parse_ident(p);
let ty_params = parse_ty_params(p);
- let variants: ast::variant[] = ~[];
+ let variants: [ast::variant] = ~[];
// Newtype syntax
if p.peek() == token::EQ {
if p.get_bad_expr_words().contains_key(id) {
check_bad_word(p);
let vlo = p.get_lo_pos();
p.bump();
- let args: ast::variant_arg[] = ~[];
+ let args: [ast::variant_arg] = ~[];
let vhi = p.get_hi_pos();
alt p.peek() {
token::LPAREN. {
} else { unexpected(p, p.peek()); }
}
-fn parse_item(p: &parser, attrs: &ast::attribute[]) -> option::t[@ast::item] {
+fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t[@ast::item] {
if eat_word(p, "const") {
ret some(parse_item_const(p, attrs));
} else if (eat_word(p, "inline")) {
// A type to distingush between the parsing of item attributes or syntax
// extensions, which both begin with token.POUND
-type attr_or_ext = option::t[either::t[ast::attribute[], @ast::expr]];
+type attr_or_ext = option::t[either::t[[ast::attribute], @ast::expr]];
fn parse_outer_attrs_or_ext(p: &parser) -> attr_or_ext {
if p.peek() == token::POUND {
}
// Parse attributes that appear before an item
-fn parse_outer_attributes(p: &parser) -> ast::attribute[] {
- let attrs: ast::attribute[] = ~[];
+fn parse_outer_attributes(p: &parser) -> [ast::attribute] {
+ let attrs: [ast::attribute] = ~[];
while p.peek() == token::POUND {
attrs += ~[parse_attribute(p, ast::attr_outer)];
}
// of the containing item or an outer attribute of the first contained item
// until we see the semi).
fn parse_inner_attrs_and_next(p: &parser) ->
- {inner: ast::attribute[], next: ast::attribute[]} {
- let inner_attrs: ast::attribute[] = ~[];
- let next_outer_attrs: ast::attribute[] = ~[];
+ {inner: [ast::attribute], next: [ast::attribute]} {
+ let inner_attrs: [ast::attribute] = ~[];
+ let next_outer_attrs: [ast::attribute] = ~[];
while p.peek() == token::POUND {
let attr = parse_attribute(p, ast::attr_inner);
if p.peek() == token::SEMI {
}
}
-fn parse_meta_seq(p: &parser) -> (@ast::meta_item)[] {
+fn parse_meta_seq(p: &parser) -> [@ast::meta_item] {
ret parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_meta_item, p).node;
}
-fn parse_optional_meta(p: &parser) -> (@ast::meta_item)[] {
+fn parse_optional_meta(p: &parser) -> [@ast::meta_item] {
alt p.peek() { token::LPAREN. { ret parse_meta_seq(p); } _ { ret ~[]; } }
}
fn parse_rest_import_name(p: &parser, first: ast::ident,
def_ident: option::t[ast::ident]) ->
ast::view_item_ {
- let identifiers: ast::ident[] = ~[first];
+ let identifiers: [ast::ident] = ~[first];
let glob: bool = false;
while true {
alt p.peek() {
}
}
-fn parse_view(p: &parser) -> (@ast::view_item)[] {
- let items: (@ast::view_item)[] = ~[];
+fn parse_view(p: &parser) -> [@ast::view_item] {
+ let items: [@ast::view_item] = ~[];
while is_view_item(p) { items += ~[parse_view_item(p)]; }
ret items;
}
-fn parse_native_view(p: &parser) -> (@ast::view_item)[] {
- let items: (@ast::view_item)[] = ~[];
+fn parse_native_view(p: &parser) -> [@ast::view_item] {
+ let items: [@ast::view_item] = ~[];
while is_view_item(p) { items += ~[parse_view_item(p)]; }
ret items;
}
// Each crate file is a sequence of directives.
//
// Each directive imperatively extends its environment with 0 or more items.
-fn parse_crate_directive(p: &parser, first_outer_attr: &ast::attribute[]) ->
+fn parse_crate_directive(p: &parser, first_outer_attr: &[ast::attribute]) ->
ast::crate_directive {
// Collect the next attributes
}
fn parse_crate_directives(p: &parser, term: token::token,
- first_outer_attr: &ast::attribute[]) ->
- (@ast::crate_directive)[] {
+ first_outer_attr: &[ast::attribute]) ->
+ [@ast::crate_directive] {
// This is pretty ugly. If we have an outer attribute then we can't accept
// seeing the terminator next, so if we do see it then fail the same way
expect_word(p, "mod");
}
- let cdirs: (@ast::crate_directive)[] = ~[];
+ let cdirs: [@ast::crate_directive] = ~[];
while p.peek() != term {
let cdir = @parse_crate_directive(p, first_outer_attr);
cdirs += ~[cdir];
let crate_attrs = leading_attrs.inner;
let first_cdir_attr = leading_attrs.next;
let cdirs = parse_crate_directives(p, token::EOF, first_cdir_attr);
- let deps: str[] = ~[];
+ let deps: [str] = ~[];
let cx =
@{p: p,
mode: eval::mode_parse,
}
}
-fn buf_str(toks: &token[mutable ], szs: &int[mutable ], left: uint,
+fn buf_str(toks: &[mutable token], szs: &[mutable int], left: uint,
right: uint, lim: uint) -> str {
let n = ivec::len(toks);
assert (n == ivec::len(szs));
let n: uint = 3u * linewidth;
log #fmt("mk_printer %u", linewidth);
- let token: token[mutable ] = ivec::init_elt_mut(EOF, n);
- let size: int[mutable ] = ivec::init_elt_mut(0, n);
- let scan_stack: uint[mutable ] = ivec::init_elt_mut(0u, n);
- let print_stack: print_stack_elt[] = ~[];
+ let token: [mutable token] = ivec::init_elt_mut(EOF, n);
+ let size: [mutable int] = ivec::init_elt_mut(0, n);
+ let scan_stack: [mutable uint] = ivec::init_elt_mut(0u, n);
+ let print_stack: [print_stack_elt] = ~[];
ret printer(out, n, linewidth as int, // margin
linewidth as int, // space
0u, // left
mutable right: uint, // index of right side of input stream
- mutable token: token[mutable ],
+ mutable token: [mutable token],
// ring-buffr stream goes through
- mutable size: int[mutable ], // ring-buffer of calculated sizes
+ mutable size: [mutable int], // ring-buffer of calculated sizes
mutable left_total: int, // running size of stream "...left"
// BEGIN (if there is any) on top of it. Stuff is flushed off the
// bottom as it becomes irrelevant due to the primary ring-buffer
// advancing.
- mutable scan_stack: uint[mutable ],
+ mutable scan_stack: [mutable uint],
mutable scan_stack_empty: bool, // top==bottom disambiguator
mutable top: uint, // index of top of scan_stack
mutable bottom: uint, // index of bottom of scan_stack
// stack of blocks-in-progress being flushed by print
- mutable print_stack: print_stack_elt[],
+ mutable print_stack: [print_stack_elt],
// buffered indentation to avoid writing trailing whitespace
type ps =
@{s: pp::printer,
cm: option::t[codemap],
- comments: option::t[lexer::cmnt[]],
- literals: option::t[lexer::lit[]],
+ comments: option::t[[lexer::cmnt]],
+ literals: option::t[[lexer::lit]],
mutable cur_cmnt: uint,
mutable cur_lit: uint,
- mutable boxes: pp::breaks[],
+ mutable boxes: [pp::breaks],
ann: pp_ann};
fn ibox(s: &ps, u: uint) { s.boxes += ~[pp::inconsistent]; pp::ibox(s.s, u); }
fn end(s: &ps) { ivec::pop(s.boxes); pp::end(s.s); }
fn rust_printer(writer: ioivec::writer) -> ps {
- let boxes: pp::breaks[] = ~[];
+ let boxes: [pp::breaks] = ~[];
ret @{s: pp::mk_printer(writer, default_columns),
cm: none[codemap],
- comments: none[lexer::cmnt[]],
- literals: none[lexer::lit[]],
+ comments: none[[lexer::cmnt]],
+ literals: none[[lexer::lit]],
mutable cur_cmnt: 0u,
mutable cur_lit: 0u,
mutable boxes: boxes,
// copy forward.
fn print_crate(cm: &codemap, crate: @ast::crate, filename: str,
in: ioivec::reader, out: ioivec::writer, ann: &pp_ann) {
- let boxes: pp::breaks[] = ~[];
+ let boxes: [pp::breaks] = ~[];
let r = lexer::gather_comments_and_literals(cm, filename, in);
let s =
@{s: pp::mk_printer(out, default_columns),
fn path_to_str(p: &ast::path) -> str { be to_str(p, print_path); }
-fn fun_to_str(f: &ast::_fn, name: str, params: &ast::ty_param[]) -> str {
+fn fun_to_str(f: &ast::_fn, name: str, params: &[ast::ty_param]) -> str {
let writer = ioivec::string_writer();
let s = rust_printer(writer.get_writer());
print_fn(s, f.decl, f.proto, name, params, f.decl.constraints);
word(s.s, "*/");
}
-fn commasep[IN](s: &ps, b: breaks, elts: &IN[], op: fn(&ps, &IN) ) {
+fn commasep[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
box(s, 0u, b);
let first = true;
for elt: IN in elts {
}
-fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &IN[], op: fn(&ps, &IN) ,
+fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ,
get_span: fn(&IN) -> codemap::span ) {
box(s, 0u, b);
let len = ivec::len[IN](elts);
end(s);
}
-fn commasep_exprs(s: &ps, b: breaks, exprs: &(@ast::expr)[]) {
+fn commasep_exprs(s: &ps, b: breaks, exprs: &[@ast::expr]) {
fn expr_span(expr: &@ast::expr) -> codemap::span { ret expr.span; }
commasep_cmnt(s, b, exprs, print_expr, expr_span);
}
-fn print_mod(s: &ps, _mod: &ast::_mod, attrs: &ast::attribute[]) {
+fn print_mod(s: &ps, _mod: &ast::_mod, attrs: &[ast::attribute]) {
print_inner_attributes(s, attrs);
for vitem: @ast::view_item in _mod.view_items {
print_view_item(s, vitem);
}
fn print_native_mod(s: &ps, nmod: &ast::native_mod,
- attrs: &ast::attribute[]) {
+ attrs: &[ast::attribute]) {
print_inner_attributes(s, attrs);
for vitem: @ast::view_item in nmod.view_items {
print_view_item(s, vitem);
space(s.s);
bopen(s);
for meth: @ast::method in _obj.methods {
- let typarams: ast::ty_param[] = ~[];
+ let typarams: [ast::ty_param] = ~[];
hardbreak_if_not_bol(s);
maybe_print_comment(s, meth.span.lo);
print_fn(s, meth.node.meth.decl, meth.node.meth.proto,
s.ann.post(ann_node);
}
-fn print_outer_attributes(s: &ps, attrs: &ast::attribute[]) {
+fn print_outer_attributes(s: &ps, attrs: &[ast::attribute]) {
let count = 0;
for attr: ast::attribute in attrs {
alt attr.node.style {
if count > 0 { hardbreak_if_not_bol(s); }
}
-fn print_inner_attributes(s: &ps, attrs: &ast::attribute[]) {
+fn print_inner_attributes(s: &ps, attrs: &[ast::attribute]) {
let count = 0;
for attr: ast::attribute in attrs {
alt attr.node.style {
// Methods
for meth: @ast::method in anon_obj.methods {
- let typarams: ast::ty_param[] = ~[];
+ let typarams: [ast::ty_param] = ~[];
hardbreak_if_not_bol(s);
maybe_print_comment(s, meth.span.lo);
print_fn(s, meth.node.meth.decl, meth.node.meth.proto,
}
fn print_fn(s: &ps, decl: ast::fn_decl, proto: ast::proto, name: str,
- typarams: &ast::ty_param[], constrs: (@ast::constr)[]) {
+ typarams: &[ast::ty_param], constrs: [@ast::constr]) {
alt decl.purity {
ast::impure_fn. { head(s, proto_to_str(proto)); }
_ { head(s, "pred"); }
}
fn print_fn_args_and_ret(s: &ps, decl: &ast::fn_decl,
- constrs: (@ast::constr)[]) {
+ constrs: [@ast::constr]) {
popen(s);
fn print_arg(s: &ps, x: &ast::arg) {
ibox(s, indent_unit);
}
}
-fn print_type_params(s: &ps, params: &ast::ty_param[]) {
+fn print_type_params(s: &ps, params: &[ast::ty_param]) {
if ivec::len(params) > 0u {
word(s.s, "[");
fn printParam(s: &ps, param: &ast::ty_param) {
}
fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str],
- inputs: &ast::ty_arg[], output: &@ast::ty,
- cf: &ast::controlflow, constrs: &(@ast::constr)[]) {
+ inputs: &[ast::ty_arg], output: &@ast::ty,
+ cf: &ast::controlflow, constrs: &[@ast::constr]) {
ibox(s, indent_unit);
word(s.s, proto_to_str(proto));
alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } }
// Removing the aliases from the type of f in the next two functions
// triggers memory corruption, but I haven't isolated the bug yet. FIXME
fn constr_args_to_str[T](f: &fn(&T) -> str ,
- args: &(@ast::sp_constr_arg[T])[]) -> str {
+ args: &[@ast::sp_constr_arg[T]]) -> str {
let comma = false;
let s = "(";
for a: @ast::sp_constr_arg[T] in args {
}
// FIXME: fix repeated code
-fn ast_ty_fn_constrs_str(constrs: &(@ast::constr)[]) -> str {
+fn ast_ty_fn_constrs_str(constrs: &[@ast::constr]) -> str {
let s = "";
let colon = true;
for c: @ast::constr in constrs {
// FIXME: fix repeated code
fn ast_fn_constrs_str(decl: &ast::fn_decl,
- constrs: &(@ast::constr)[]) -> str {
+ constrs: &[@ast::constr]) -> str {
let s = "";
let colon = true;
for c: @ast::constr in constrs {
}
-fn ast_ty_constrs_str(constrs: &(@ast::ty_constr)[]) -> str {
+fn ast_ty_constrs_str(constrs: &[@ast::ty_constr]) -> str {
let s = "";
let colon = true;
for c: @ast::ty_constr in constrs {
type interner[T] =
{map: hashmap[T, uint],
- mutable vect: T[],
+ mutable vect: [T],
hasher: hashfn[T],
eqer: eqfn[T]};
visit_ty: fn(&@ty, &E, &vt[E]) ,
visit_constr: fn(&path, &span, node_id, &E, &vt[E]) ,
visit_fn:
- fn(&_fn, &ty_param[], &span, &fn_ident, node_id, &E, &vt[E]) };
+ fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt[E]) };
fn default_visitor[E]() -> visitor[E] {
ret @{visit_mod: bind visit_mod[E](_, _, _, _),
v.visit_ty(fd.output, e, v);
}
-fn visit_fn[E](f: &_fn, tp: &ty_param[], sp: &span, i: &fn_ident, id: node_id,
+fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id,
e: &E, v: &vt[E]) {
visit_fn_decl(f.decl, e, v);
v.visit_block(f.body, e, v);
alt eo { none. { } some(ex) { v.visit_expr(ex, e, v); } }
}
-fn visit_exprs[E](exprs: &(@expr)[], e: &E, v: &vt[E]) {
+fn visit_exprs[E](exprs: &[@expr], e: &E, v: &vt[E]) {
for ex: @expr in exprs { v.visit_expr(ex, e, v); }
}
visit_expr: fn(&@expr) ,
visit_ty: fn(&@ty) ,
visit_constr: fn(&path, &span, node_id) ,
- visit_fn: fn(&_fn, &ty_param[], &span, &fn_ident, node_id) };
+ visit_fn: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) };
fn default_simple_visitor() -> simple_visitor {
ret @{visit_mod: fn (m: &_mod, sp: &span) { },
visit_ty: fn (t: &@ty) { },
visit_constr: fn (p: &path, sp: &span, id: node_id) { },
visit_fn:
- fn (f: &_fn, tps: &ty_param[], sp: &span, ident: &fn_ident,
+ fn (f: &_fn, tps: &[ty_param], sp: &span, ident: &fn_ident,
id: node_id) {
}};
}
f(pt, sp, id);
visit_constr(pt, sp, id, e, v);
}
- fn v_fn(f: fn(&_fn, &ty_param[], &span, &fn_ident, node_id) , ff: &_fn,
- tps: &ty_param[], sp: &span, ident: &fn_ident, id: node_id,
+ fn v_fn(f: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) , ff: &_fn,
+ tps: &[ty_param], sp: &span, ident: &fn_ident, id: node_id,
e: &(), v: &vt[()]) {
f(ff, tps, sp, ident, id);
visit_fn(ff, tps, sp, ident, id, e, v);
fn elt_expr(e: &ast::elt) -> @ast::expr { ret e.expr; }
-fn elt_exprs(elts: &ast::elt[]) -> (@ast::expr)[] {
+fn elt_exprs(elts: &[ast::elt]) -> [@ast::expr] {
let es = ~[];
for e: ast::elt in elts { es += ~[e.expr]; }
ret es;
fn field_expr(f: &ast::field) -> @ast::expr { ret f.node.expr; }
-fn field_exprs(fields: &ast::field[]) -> (@ast::expr)[] {
+fn field_exprs(fields: &[ast::field]) -> [@ast::expr] {
let es = ~[];
for f: ast::field in fields { es += ~[f.node.expr]; }
ret es;
fn log_item_err(i: &@ast::item) { log_err print::pprust::item_to_str(i); }
-fn log_fn(f: &ast::_fn, name: str, params: &ast::ty_param[]) {
+fn log_fn(f: &ast::_fn, name: str, params: &[ast::ty_param]) {
log print::pprust::fun_to_str(f, name, params);
}
-fn log_fn_err(f: &ast::_fn, name: str, params: &ast::ty_param[]) {
+fn log_fn_err(f: &ast::_fn, name: str, params: &[ast::ty_param]) {
log_err print::pprust::fun_to_str(f, name, params);
}
}
}
-fn is_main_name(path: &str[]) -> bool {
+fn is_main_name(path: &[str]) -> bool {
str::eq(option::get(std::ivec::last(path)), "main")
}
ret s + ty_to_str(cx, input.ty);
}
fn fn_to_str(cx: &ctxt, proto: ast::proto, ident: option::t[ast::ident],
- inputs: &arg[], output: t, cf: ast::controlflow,
- constrs: &(@constr)[]) -> str {
+ inputs: &[arg], output: t, cf: ast::controlflow,
+ constrs: &[@constr]) -> str {
let s = proto_to_str(proto);
alt ident { some(i) { s += " "; s += i; } _ { } }
s += "(";
ty_type. { s += "type"; }
ty_task. { s += "task"; }
ty_rec(elems) {
- let strs: str[] = ~[];
+ let strs: [str] = ~[];
for fld: field in elems { strs += ~[field_to_str(cx, fld)]; }
s += "{" + str::connect_ivec(strs, ",") + "}";
}
s += "<tag#" + int::str(id.crate) + ":" + int::str(id.node) + ">";
if ivec::len[t](tps) > 0u {
- let strs: str[] = ~[];
+ let strs: [str] = ~[];
for typ: t in tps { strs += ~[ty_to_str(cx, typ)]; }
s += "[" + str::connect_ivec(strs, ",") + "]";
}
pprust::constr_args_to_str(pprust::uint_to_str, c.node.args);
}
-fn constrs_str(constrs: &(@constr)[]) -> str {
+fn constrs_str(constrs: &[@constr]) -> str {
let s = "";
let colon = true;
for c: @constr in constrs {