Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ivec type syntax from T[] to [T] #806

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/comp/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
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 {
Expand Down Expand Up @@ -412,7 +412,7 @@ fn get_symbol_hash(ccx: &@crate_ctxt, t: &ty::t) -> str {
ret hash;
}

fn mangle(ss: &str[]) -> str {
fn mangle(ss: &[str]) -> str {
// Follow C++ namespace-mangling style

let n = "_ZN"; // Begin name-sequence.
Expand All @@ -423,14 +423,14 @@ fn mangle(ss: &str[]) -> str {
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);
}
Expand All @@ -442,12 +442,12 @@ fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: &ty::t, name: &str)
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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/comp/back/upcall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ type upcalls =
fn declare_upcalls(tn: type_names, tydesc_type: TypeRef,
taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls {
fn decl(tn: type_names, tydesc_type: TypeRef, taskptr_type: TypeRef,
llmod: ModuleRef, name: str, tys: TypeRef[], rv: TypeRef) ->
llmod: ModuleRef, name: str, tys: [TypeRef], rv: TypeRef) ->
ValueRef {
let arg_tys: TypeRef[] = ~[taskptr_type];
let arg_tys: [TypeRef] = ~[taskptr_type];
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);
Expand All @@ -82,7 +82,7 @@ fn declare_upcalls(tn: type_names, tydesc_type: TypeRef,
// FIXME: Sigh:.. remove this when I fix the typechecker pushdown.
// --pcwalton

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()]),
Expand Down
4 changes: 2 additions & 2 deletions src/comp/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type options =
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,
Expand All @@ -46,7 +46,7 @@ type options =
no_trans: bool
};

type crate_metadata = {name: str, data: u8[]};
type crate_metadata = {name: str, data: [u8]};

obj session(targ_cfg: @config,
opts: @options,
Expand Down
32 changes: 16 additions & 16 deletions src/comp/front/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export mk_attr;

// 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; }
Expand All @@ -41,8 +41,8 @@ fn find_linkage_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] {
}

// 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] {
Expand All @@ -57,8 +57,8 @@ fn get_attr_name(attr: &ast::attribute) -> ast::ident {
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] {
Expand Down Expand Up @@ -94,7 +94,7 @@ fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t[str] {
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;
Expand All @@ -121,7 +121,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
}
}

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 {
Expand All @@ -133,13 +133,13 @@ fn contains(haystack: &(@ast::meta_item)[], needle: @ast::meta_item) -> bool {
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 {
Expand All @@ -152,18 +152,18 @@ fn sort_meta_items(items: &(@ast::meta_item)[]) -> (@ast::meta_item)[] {
}

// 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) ->
Expand All @@ -177,7 +177,7 @@ fn remove_meta_items_by_name(items: &(@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);
Expand All @@ -202,7 +202,7 @@ fn mk_name_value_item(name: ast::ident, value: ast::lit) -> @ast::meta_item {
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));
}
Expand Down
6 changes: 3 additions & 3 deletions src/comp/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn native_item_in_cfg(cfg: &ast::crate_cfg, item: &@ast::native_item) ->

// 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");
Expand All @@ -103,9 +103,9 @@ fn in_cfg(cfg: &ast::crate_cfg, attrs: &ast::attribute[]) -> bool {
// 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");
Expand Down
10 changes: 5 additions & 5 deletions src/comp/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export modify_for_testing;

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
Expand Down Expand Up @@ -139,7 +139,7 @@ mod __test {
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 ...
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ fn empty_fn_ty() -> ast::ty {
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,
Expand Down
32 changes: 16 additions & 16 deletions src/comp/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
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),
Expand Down Expand Up @@ -941,7 +941,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
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;
Expand Down Expand Up @@ -1151,13 +1151,13 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
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(""));
Expand Down Expand Up @@ -1289,7 +1289,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool,


/* 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(""));
Expand All @@ -1299,20 +1299,20 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
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),
Expand All @@ -1321,7 +1321,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
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),
Expand Down Expand Up @@ -1392,7 +1392,7 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
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(""));
}
Expand Down Expand Up @@ -1447,7 +1447,7 @@ fn type_to_str(names: type_names, ty: TypeRef) -> str {
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); }
Expand All @@ -1456,7 +1456,7 @@ fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) ->

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 {
Expand Down Expand Up @@ -1493,7 +1493,7 @@ fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) ->
let s = "fn(";
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
let n_args: 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 += ") -> ";
Expand All @@ -1505,7 +1505,7 @@ fn type_to_str_inner(names: type_names, outer0: &TypeRef[], ty: TypeRef) ->
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 += "}";
Expand Down Expand Up @@ -1552,7 +1552,7 @@ fn float_width(llt: TypeRef) -> uint {
};
}

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;
Expand Down
Loading