mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Rewrite everything to use [] instead of vec() in value position.
This commit is contained in:
+41
-41
@@ -63,8 +63,8 @@
|
||||
fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
|
||||
fn decl(type_names tn, ModuleRef llmod, str name, vec[TypeRef] tys,
|
||||
TypeRef rv) -> ValueRef {
|
||||
let vec[TypeRef] arg_tys = vec(T_taskptr(tn));
|
||||
for (TypeRef t in tys) { arg_tys += vec(t); }
|
||||
let vec[TypeRef] arg_tys = [T_taskptr(tn)];
|
||||
for (TypeRef t in tys) { arg_tys += [t]; }
|
||||
auto fn_ty = T_fn(arg_tys, rv);
|
||||
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
|
||||
}
|
||||
@@ -74,61 +74,61 @@ fn decl(type_names tn, ModuleRef llmod, str name, vec[TypeRef] tys,
|
||||
|
||||
// FIXME: Sigh:.. remove this when I fix the typechecker pushdown.
|
||||
// --pcwalton
|
||||
let vec[TypeRef] empty_vec = vec();
|
||||
let vec[TypeRef] empty_vec = [];
|
||||
|
||||
ret @rec(
|
||||
grow_task=dv("grow_task", vec(T_size_t())),
|
||||
log_int=dv("log_int", vec(T_i32(), T_i32())),
|
||||
log_float=dv("log_float", vec(T_i32(), T_f32())),
|
||||
log_double=dv("log_double", vec(T_i32(), T_ptr(T_f64()))),
|
||||
log_str=dv("log_str", vec(T_i32(), T_ptr(T_str()))),
|
||||
trace_word=dv("trace_word", vec(T_int())),
|
||||
trace_str=dv("trace_str", vec(T_ptr(T_i8()))),
|
||||
new_port=d("new_port", vec(T_size_t()), T_opaque_port_ptr()),
|
||||
del_port=dv("del_port", vec(T_opaque_port_ptr())),
|
||||
new_chan=d("new_chan", vec(T_opaque_port_ptr()), T_opaque_chan_ptr()),
|
||||
flush_chan=dv("flush_chan", vec(T_opaque_chan_ptr())),
|
||||
del_chan=dv("del_chan", vec(T_opaque_chan_ptr())),
|
||||
clone_chan=d("clone_chan", vec(T_taskptr(tn), T_opaque_chan_ptr()),
|
||||
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()]),
|
||||
log_double=dv("log_double", [T_i32(), T_ptr(T_f64())]),
|
||||
log_str=dv("log_str", [T_i32(), T_ptr(T_str())]),
|
||||
trace_word=dv("trace_word", [T_int()]),
|
||||
trace_str=dv("trace_str", [T_ptr(T_i8())]),
|
||||
new_port=d("new_port", [T_size_t()], T_opaque_port_ptr()),
|
||||
del_port=dv("del_port", [T_opaque_port_ptr()]),
|
||||
new_chan=d("new_chan", [T_opaque_port_ptr()], T_opaque_chan_ptr()),
|
||||
flush_chan=dv("flush_chan", [T_opaque_chan_ptr()]),
|
||||
del_chan=dv("del_chan", [T_opaque_chan_ptr()]),
|
||||
clone_chan=d("clone_chan", [T_taskptr(tn), T_opaque_chan_ptr()],
|
||||
T_opaque_chan_ptr()),
|
||||
_yield=dv("yield", empty_vec),
|
||||
sleep=dv("sleep", vec(T_size_t())),
|
||||
_join=dv("join", vec(T_taskptr(tn))),
|
||||
send=dv("send", vec(T_opaque_chan_ptr(), T_ptr(T_i8()))),
|
||||
recv=dv("recv", vec(T_ptr(T_ptr(T_i8())), T_opaque_port_ptr())),
|
||||
_fail=dv("fail", vec(T_ptr(T_i8()), T_ptr(T_i8()), T_size_t())),
|
||||
kill=dv("kill", vec(T_taskptr(tn))),
|
||||
sleep=dv("sleep", [T_size_t()]),
|
||||
_join=dv("join", [T_taskptr(tn)]),
|
||||
send=dv("send", [T_opaque_chan_ptr(), T_ptr(T_i8())]),
|
||||
recv=dv("recv", [T_ptr(T_ptr(T_i8())), T_opaque_port_ptr()]),
|
||||
_fail=dv("fail", [T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
|
||||
kill=dv("kill", [T_taskptr(tn)]),
|
||||
exit=dv("exit", empty_vec),
|
||||
malloc=d("malloc", vec(T_size_t(), T_ptr(T_tydesc(tn))),
|
||||
malloc=d("malloc", [T_size_t(), T_ptr(T_tydesc(tn))],
|
||||
T_ptr(T_i8())),
|
||||
free=dv("free", vec(T_ptr(T_i8()), T_int())),
|
||||
mark=d("mark", vec(T_ptr(T_i8())), T_int()),
|
||||
new_str=d("new_str", vec(T_ptr(T_i8()), T_size_t()), T_ptr(T_str())),
|
||||
new_vec=d("new_vec", vec(T_size_t(), T_ptr(T_tydesc(tn))),
|
||||
free=dv("free", [T_ptr(T_i8()), T_int()]),
|
||||
mark=d("mark", [T_ptr(T_i8())], T_int()),
|
||||
new_str=d("new_str", [T_ptr(T_i8()), T_size_t()], T_ptr(T_str())),
|
||||
new_vec=d("new_vec", [T_size_t(), T_ptr(T_tydesc(tn))],
|
||||
T_opaque_vec_ptr()),
|
||||
vec_grow=d("vec_grow", vec(T_opaque_vec_ptr(), T_size_t(),
|
||||
T_ptr(T_int()), T_ptr(T_tydesc(tn))),
|
||||
vec_grow=d("vec_grow", [T_opaque_vec_ptr(), T_size_t(),
|
||||
T_ptr(T_int()), T_ptr(T_tydesc(tn))],
|
||||
T_opaque_vec_ptr()),
|
||||
require_rust_sym=d("require_rust_sym",
|
||||
vec(T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_size_t(), T_ptr(T_i8()),
|
||||
T_ptr(T_ptr(T_i8()))),
|
||||
T_ptr(T_ptr(T_i8()))],
|
||||
T_int()),
|
||||
require_c_sym=d("require_c_sym",
|
||||
vec(T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_ptr(T_i8()), T_ptr(T_i8())),
|
||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_ptr(T_i8()), T_ptr(T_i8())],
|
||||
T_int()),
|
||||
get_type_desc=d("get_type_desc",
|
||||
vec(T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))),
|
||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
|
||||
T_ptr(T_tydesc(tn))),
|
||||
new_task=d("new_task", vec(T_ptr(T_i8())), T_taskptr(tn)),
|
||||
start_task=d("start_task", vec(T_taskptr(tn), T_int(), T_int(),
|
||||
T_int(), T_size_t()),
|
||||
new_task=d("new_task", [T_ptr(T_i8())], T_taskptr(tn)),
|
||||
start_task=d("start_task", [T_taskptr(tn), T_int(), T_int(),
|
||||
T_int(), T_size_t()],
|
||||
T_taskptr(tn)),
|
||||
new_thread=d("new_thread", vec(T_ptr(T_i8())), T_taskptr(tn)),
|
||||
start_thread=d("start_thread", vec(T_taskptr(tn), T_int(), T_int(),
|
||||
T_int(), T_size_t()),
|
||||
new_thread=d("new_thread", [T_ptr(T_i8())], T_taskptr(tn)),
|
||||
start_thread=d("start_thread", [T_taskptr(tn), T_int(), T_int(),
|
||||
T_int(), T_size_t()],
|
||||
T_taskptr(tn))
|
||||
);
|
||||
}
|
||||
|
||||
+40
-40
@@ -12,78 +12,78 @@ fn wstr(int i) -> str {
|
||||
}
|
||||
|
||||
fn start() -> vec[str] {
|
||||
ret vec(".cfi_startproc");
|
||||
ret [".cfi_startproc"];
|
||||
}
|
||||
|
||||
fn end() -> vec[str] {
|
||||
ret vec(".cfi_endproc");
|
||||
ret [".cfi_endproc"];
|
||||
}
|
||||
|
||||
fn save_callee_saves() -> vec[str] {
|
||||
ret vec("pushl %ebp",
|
||||
ret ["pushl %ebp",
|
||||
"pushl %edi",
|
||||
"pushl %esi",
|
||||
"pushl %ebx");
|
||||
"pushl %ebx"];
|
||||
}
|
||||
|
||||
fn save_callee_saves_with_cfi() -> vec[str] {
|
||||
auto offset = 8;
|
||||
auto t;
|
||||
t = vec("pushl %ebp");
|
||||
t += vec(".cfi_def_cfa_offset " + istr(offset));
|
||||
t += vec(".cfi_offset %ebp, -" + istr(offset));
|
||||
t = ["pushl %ebp"];
|
||||
t += [".cfi_def_cfa_offset " + istr(offset)];
|
||||
t += [".cfi_offset %ebp, -" + istr(offset)];
|
||||
|
||||
t += vec("pushl %edi");
|
||||
t += ["pushl %edi"];
|
||||
offset += 4;
|
||||
t += vec(".cfi_def_cfa_offset " + istr(offset));
|
||||
t += [".cfi_def_cfa_offset " + istr(offset)];
|
||||
|
||||
t += vec("pushl %esi");
|
||||
t += ["pushl %esi"];
|
||||
offset += 4;
|
||||
t += vec(".cfi_def_cfa_offset " + istr(offset));
|
||||
t += [".cfi_def_cfa_offset " + istr(offset)];
|
||||
|
||||
t += vec("pushl %ebx");
|
||||
t += ["pushl %ebx"];
|
||||
offset += 4;
|
||||
t += vec(".cfi_def_cfa_offset " + istr(offset));
|
||||
t += [".cfi_def_cfa_offset " + istr(offset)];
|
||||
ret t;
|
||||
}
|
||||
|
||||
fn restore_callee_saves() -> vec[str] {
|
||||
ret vec("popl %ebx",
|
||||
ret ["popl %ebx",
|
||||
"popl %esi",
|
||||
"popl %edi",
|
||||
"popl %ebp");
|
||||
"popl %ebp"];
|
||||
}
|
||||
|
||||
fn load_esp_from_rust_sp_first_arg() -> vec[str] {
|
||||
ret vec("movl " + wstr(abi::task_field_rust_sp) + "(%ecx), %esp");
|
||||
ret ["movl " + wstr(abi::task_field_rust_sp) + "(%ecx), %esp"];
|
||||
}
|
||||
|
||||
fn load_esp_from_runtime_sp_first_arg() -> vec[str] {
|
||||
ret vec("movl " + wstr(abi::task_field_runtime_sp) + "(%ecx), %esp");
|
||||
ret ["movl " + wstr(abi::task_field_runtime_sp) + "(%ecx), %esp"];
|
||||
}
|
||||
|
||||
fn store_esp_to_rust_sp_first_arg() -> vec[str] {
|
||||
ret vec("movl %esp, " + wstr(abi::task_field_rust_sp) + "(%ecx)");
|
||||
ret ["movl %esp, " + wstr(abi::task_field_rust_sp) + "(%ecx)"];
|
||||
}
|
||||
|
||||
fn store_esp_to_runtime_sp_first_arg() -> vec[str] {
|
||||
ret vec("movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%ecx)");
|
||||
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%ecx)"];
|
||||
}
|
||||
|
||||
fn load_esp_from_rust_sp_second_arg() -> vec[str] {
|
||||
ret vec("movl " + wstr(abi::task_field_rust_sp) + "(%edx), %esp");
|
||||
ret ["movl " + wstr(abi::task_field_rust_sp) + "(%edx), %esp"];
|
||||
}
|
||||
|
||||
fn load_esp_from_runtime_sp_second_arg() -> vec[str] {
|
||||
ret vec("movl " + wstr(abi::task_field_runtime_sp) + "(%edx), %esp");
|
||||
ret ["movl " + wstr(abi::task_field_runtime_sp) + "(%edx), %esp"];
|
||||
}
|
||||
|
||||
fn store_esp_to_rust_sp_second_arg() -> vec[str] {
|
||||
ret vec("movl %esp, " + wstr(abi::task_field_rust_sp) + "(%edx)");
|
||||
ret ["movl %esp, " + wstr(abi::task_field_rust_sp) + "(%edx)"];
|
||||
}
|
||||
|
||||
fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
|
||||
ret vec("movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%edx)");
|
||||
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%edx)"];
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
|
||||
*/
|
||||
|
||||
fn rust_activate_glue() -> vec[str] {
|
||||
ret vec("movl 4(%esp), %ecx # ecx = rust_task")
|
||||
ret ["movl 4(%esp), %ecx # ecx = rust_task"]
|
||||
+ save_callee_saves()
|
||||
+ store_esp_to_runtime_sp_first_arg()
|
||||
+ load_esp_from_rust_sp_first_arg()
|
||||
@@ -157,7 +157,7 @@ fn rust_activate_glue() -> vec[str] {
|
||||
* will be a no-op. Esp won't move, and the task's stack won't
|
||||
* grow.
|
||||
*/
|
||||
+ vec("addl $20, " + wstr(abi::task_field_rust_sp) + "(%ecx)")
|
||||
+ ["addl $20, " + wstr(abi::task_field_rust_sp) + "(%ecx)"]
|
||||
|
||||
|
||||
/*
|
||||
@@ -167,10 +167,10 @@ fn rust_activate_glue() -> vec[str] {
|
||||
* activating, the task needs to be in the fastcall 2nd parameter
|
||||
* expected by the rust main function. That's edx.
|
||||
*/
|
||||
+ vec("mov %ecx, %edx")
|
||||
+ ["mov %ecx, %edx"]
|
||||
|
||||
+ restore_callee_saves()
|
||||
+ vec("ret");
|
||||
+ ["ret"];
|
||||
}
|
||||
|
||||
/* More glue code, this time the 'bottom half' of yielding.
|
||||
@@ -200,13 +200,13 @@ fn rust_activate_glue() -> vec[str] {
|
||||
*/
|
||||
|
||||
fn rust_yield_glue() -> vec[str] {
|
||||
ret vec("movl 0(%esp), %ecx # ecx = rust_task")
|
||||
ret ["movl 0(%esp), %ecx # ecx = rust_task"]
|
||||
+ load_esp_from_rust_sp_first_arg()
|
||||
+ save_callee_saves()
|
||||
+ store_esp_to_rust_sp_first_arg()
|
||||
+ load_esp_from_runtime_sp_first_arg()
|
||||
+ restore_callee_saves()
|
||||
+ vec("ret");
|
||||
+ ["ret"];
|
||||
}
|
||||
|
||||
fn native_glue(int n_args, abi::native_glue_type ngt) -> vec[str] {
|
||||
@@ -239,8 +239,8 @@ fn copy_arg(bool pass_task, uint i) -> str {
|
||||
} else {
|
||||
src_off = wstr(5 + (i as int));
|
||||
}
|
||||
auto m = vec("movl " + src_off + "(%ebp),%eax",
|
||||
"movl %eax," + dst_off + "(%esp)");
|
||||
auto m = ["movl " + src_off + "(%ebp),%eax",
|
||||
"movl %eax," + dst_off + "(%esp)"];
|
||||
ret _str::connect(m, "\n\t");
|
||||
}
|
||||
|
||||
@@ -250,24 +250,24 @@ fn copy_arg(bool pass_task, uint i) -> str {
|
||||
start()
|
||||
+ save_callee_saves_with_cfi()
|
||||
|
||||
+ vec("movl %esp, %ebp # ebp = rust_sp")
|
||||
+ vec(".cfi_def_cfa_register %ebp")
|
||||
+ ["movl %esp, %ebp # ebp = rust_sp"]
|
||||
+ [".cfi_def_cfa_register %ebp"]
|
||||
|
||||
+ store_esp_to_rust_sp_second_arg()
|
||||
+ load_esp_from_runtime_sp_second_arg()
|
||||
|
||||
+ vec("subl $" + wstr(n_args) + ", %esp # esp -= args",
|
||||
"andl $~0xf, %esp # align esp down")
|
||||
+ ["subl $" + wstr(n_args) + ", %esp # esp -= args",
|
||||
"andl $~0xf, %esp # align esp down"]
|
||||
|
||||
+ _vec::init_fn[str](carg, (n_args) as uint)
|
||||
|
||||
+ vec("movl %edx, %edi # save task from edx to edi",
|
||||
+ ["movl %edx, %edi # save task from edx to edi",
|
||||
"call *%ecx # call *%ecx",
|
||||
"movl %edi, %edx # restore edi-saved task to edx")
|
||||
"movl %edi, %edx # restore edi-saved task to edx"]
|
||||
|
||||
+ load_esp_from_rust_sp_second_arg()
|
||||
+ restore_callee_saves()
|
||||
+ vec("ret")
|
||||
+ ["ret"]
|
||||
+ end();
|
||||
|
||||
}
|
||||
@@ -305,13 +305,13 @@ fn get_module_asm() -> str {
|
||||
auto prefix = get_symbol_prefix();
|
||||
|
||||
auto glues =
|
||||
vec(decl_glue(align, prefix,
|
||||
[decl_glue(align, prefix,
|
||||
abi::activate_glue_name(),
|
||||
rust_activate_glue()),
|
||||
|
||||
decl_glue(align, prefix,
|
||||
abi::yield_glue_name(),
|
||||
rust_yield_glue()))
|
||||
rust_yield_glue())]
|
||||
|
||||
+ _vec::init_fn[str](bind decl_native_glue(align, prefix,
|
||||
abi::ngt_rust, _), (abi::n_native_glues + 1) as uint)
|
||||
|
||||
+22
-22
@@ -44,7 +44,7 @@ fn default_environment(session::session sess,
|
||||
}
|
||||
|
||||
ret
|
||||
vec(
|
||||
[
|
||||
// Target bindings.
|
||||
tup("target_os", eval::val_str(std::os::target_os())),
|
||||
tup("target_arch", eval::val_str("x86")),
|
||||
@@ -53,7 +53,7 @@ fn default_environment(session::session sess,
|
||||
// Build bindings.
|
||||
tup("build_compiler", eval::val_str(argv0)),
|
||||
tup("build_input", eval::val_str(input))
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
fn parse_input(session::session sess,
|
||||
@@ -205,7 +205,7 @@ fn main(vec[str] args) {
|
||||
uint_type = common::ty_u32,
|
||||
float_type = common::ty_f64);
|
||||
|
||||
auto opts = vec(optflag("h"), optflag("help"),
|
||||
auto opts = [optflag("h"), optflag("help"),
|
||||
optflag("v"), optflag("version"),
|
||||
optflag("glue"), optflag("emit-llvm"),
|
||||
optflag("pretty"), optflag("ls"), optflag("parse-only"),
|
||||
@@ -214,7 +214,7 @@ fn main(vec[str] args) {
|
||||
optflag("save-temps"), optopt("sysroot"),
|
||||
optflag("stats"),
|
||||
optflag("time-passes"), optflag("time-llvm-passes"),
|
||||
optflag("no-typestate"), optflag("noverify"));
|
||||
optflag("no-typestate"), optflag("noverify")];
|
||||
auto binary = _vec::shift[str](args);
|
||||
auto match;
|
||||
alt (getopts::getopts(args, opts)) {
|
||||
@@ -287,7 +287,7 @@ fn main(vec[str] args) {
|
||||
|
||||
auto crate_cache = common::new_int_hash[session::crate_metadata]();
|
||||
auto target_crate_num = 0;
|
||||
let vec[@ast::meta_item] md = vec();
|
||||
let vec[@ast::meta_item] md = [];
|
||||
auto sess =
|
||||
session::session(target_crate_num, target_cfg, sopts,
|
||||
crate_cache, md, front::codemap::new_codemap());
|
||||
@@ -323,13 +323,13 @@ fn main(vec[str] args) {
|
||||
_vec::pop[str](parts);
|
||||
saved_out_filename = parts.(0);
|
||||
alt (output_type) {
|
||||
case (link::output_type_none) { parts += vec("pp"); }
|
||||
case (link::output_type_bitcode) { parts += vec("bc"); }
|
||||
case (link::output_type_assembly) { parts += vec("s"); }
|
||||
case (link::output_type_none) { parts += ["pp"]; }
|
||||
case (link::output_type_bitcode) { parts += ["bc"]; }
|
||||
case (link::output_type_assembly) { parts += ["s"]; }
|
||||
|
||||
// Object and exe output both use the '.o' extension here
|
||||
case (link::output_type_object) { parts += vec("o"); }
|
||||
case (link::output_type_exe) { parts += vec("o"); }
|
||||
case (link::output_type_object) { parts += ["o"]; }
|
||||
case (link::output_type_exe) { parts += ["o"]; }
|
||||
}
|
||||
auto ofile = _str::connect(parts, ".");
|
||||
compile_input(sess, env, ifile, ofile);
|
||||
@@ -353,33 +353,33 @@ fn main(vec[str] args) {
|
||||
let str exe_suffix = "";
|
||||
|
||||
// The invocations of gcc share some flags across platforms
|
||||
let vec[str] common_cflags = vec("-fno-strict-aliasing", "-fPIC",
|
||||
"-Wall", "-fno-rtti", "-fno-exceptions", "-g");
|
||||
let vec[str] common_libs = vec(stage, "-Lrustllvm", "-Lrt",
|
||||
"-lrustrt", "-lrustllvm", "-lstd", "-lm");
|
||||
let vec[str] common_cflags = ["-fno-strict-aliasing", "-fPIC",
|
||||
"-Wall", "-fno-rtti", "-fno-exceptions", "-g"];
|
||||
let vec[str] common_libs = [stage, "-Lrustllvm", "-Lrt",
|
||||
"-lrustrt", "-lrustllvm", "-lstd", "-lm"];
|
||||
|
||||
alt (sess.get_targ_cfg().os) {
|
||||
case (session::os_win32) {
|
||||
exe_suffix = ".exe";
|
||||
gcc_args = common_cflags + vec(
|
||||
gcc_args = common_cflags + [
|
||||
"-march=i686", "-O2",
|
||||
glu, "-o",
|
||||
saved_out_filename + exe_suffix,
|
||||
saved_out_filename + ".o") + common_libs;
|
||||
saved_out_filename + ".o"] + common_libs;
|
||||
}
|
||||
case (session::os_macos) {
|
||||
gcc_args = common_cflags + vec(
|
||||
gcc_args = common_cflags + [
|
||||
"-arch i386", "-O0", "-m32",
|
||||
glu, "-o",
|
||||
saved_out_filename + exe_suffix,
|
||||
saved_out_filename + ".o") + common_libs;
|
||||
saved_out_filename + ".o"] + common_libs;
|
||||
}
|
||||
case (session::os_linux) {
|
||||
gcc_args = common_cflags + vec(
|
||||
gcc_args = common_cflags + [
|
||||
"-march=i686", "-O2", "-m32",
|
||||
glu, "-o",
|
||||
saved_out_filename + exe_suffix,
|
||||
saved_out_filename + ".o") + common_libs;
|
||||
saved_out_filename + ".o"] + common_libs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,12 +388,12 @@ fn main(vec[str] args) {
|
||||
|
||||
// Clean up on Darwin
|
||||
if (sess.get_targ_cfg().os == session::os_macos) {
|
||||
run::run_program("dsymutil", vec(saved_out_filename));
|
||||
run::run_program("dsymutil", [saved_out_filename]);
|
||||
}
|
||||
|
||||
// Remove the temporary object file if we aren't saving temps
|
||||
if (!save_temps) {
|
||||
run::run_program("rm", vec(saved_out_filename + ".o"));
|
||||
run::run_program("rm", [saved_out_filename + ".o"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
type loc = rec(str filename, uint line, uint col);
|
||||
|
||||
fn new_codemap() -> codemap {
|
||||
let vec[filemap] files = vec();
|
||||
let vec[filemap] files = [];
|
||||
ret @rec(mutable files=files);
|
||||
}
|
||||
|
||||
fn new_filemap(str filename, uint start_pos) -> filemap {
|
||||
ret @rec(name=filename,
|
||||
start_pos=start_pos,
|
||||
mutable lines=vec(0u));
|
||||
mutable lines=[0u]);
|
||||
}
|
||||
|
||||
fn next_line(filemap file, uint pos) {
|
||||
|
||||
+18
-18
@@ -90,9 +90,9 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
|
||||
case ('t') {
|
||||
assert (next(st) as char == '[');
|
||||
auto def = parse_def(st, sd);
|
||||
let vec[ty::t] params = vec();
|
||||
let vec[ty::t] params = [];
|
||||
while (peek(st) as char != ']') {
|
||||
params += vec(parse_ty(st, sd));
|
||||
params += [parse_ty(st, sd)];
|
||||
}
|
||||
st.pos = st.pos + 1u;
|
||||
ret ty::mk_tag(st.tcx, def, params);
|
||||
@@ -104,23 +104,23 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
|
||||
case ('C') { ret ty::mk_chan(st.tcx, parse_ty(st, sd)); }
|
||||
case ('T') {
|
||||
assert (next(st) as char == '[');
|
||||
let vec[ty::mt] params = vec();
|
||||
let vec[ty::mt] params = [];
|
||||
while (peek(st) as char != ']') {
|
||||
params += vec(parse_mt(st, sd));
|
||||
params += [parse_mt(st, sd)];
|
||||
}
|
||||
st.pos = st.pos + 1u;
|
||||
ret ty::mk_tup(st.tcx, params);
|
||||
}
|
||||
case ('R') {
|
||||
assert (next(st) as char == '[');
|
||||
let vec[ty::field] fields = vec();
|
||||
let vec[ty::field] fields = [];
|
||||
while (peek(st) as char != ']') {
|
||||
auto name = "";
|
||||
while (peek(st) as char != '=') {
|
||||
name += _str::unsafe_from_byte(next(st));
|
||||
}
|
||||
st.pos = st.pos + 1u;
|
||||
fields += vec(rec(ident=name, mt=parse_mt(st, sd)));
|
||||
fields += [rec(ident=name, mt=parse_mt(st, sd))];
|
||||
}
|
||||
st.pos = st.pos + 1u;
|
||||
ret ty::mk_rec(st.tcx, fields);
|
||||
@@ -146,7 +146,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
|
||||
}
|
||||
case ('O') {
|
||||
assert (next(st) as char == '[');
|
||||
let vec[ty::method] methods = vec();
|
||||
let vec[ty::method] methods = [];
|
||||
while (peek(st) as char != ']') {
|
||||
auto proto;
|
||||
alt (next(st) as char) {
|
||||
@@ -158,10 +158,10 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
|
||||
name += _str::unsafe_from_byte(next(st));
|
||||
}
|
||||
auto func = parse_ty_fn(st, sd);
|
||||
methods += vec(rec(proto=proto,
|
||||
methods += [rec(proto=proto,
|
||||
ident=name,
|
||||
inputs=func._0,
|
||||
output=func._1));
|
||||
output=func._1)];
|
||||
}
|
||||
st.pos += 1u;
|
||||
ret ty::mk_obj(st.tcx, methods);
|
||||
@@ -242,14 +242,14 @@ fn parse_hex(@pstate st) -> uint {
|
||||
|
||||
fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty::arg], ty::t) {
|
||||
assert (next(st) as char == '[');
|
||||
let vec[ty::arg] inputs = vec();
|
||||
let vec[ty::arg] inputs = [];
|
||||
while (peek(st) as char != ']') {
|
||||
auto mode = ty::mo_val;
|
||||
if (peek(st) as char == '&') {
|
||||
mode = ty::mo_alias;
|
||||
st.pos = st.pos + 1u;
|
||||
}
|
||||
inputs += vec(rec(mode=mode, ty=parse_ty(st, sd)));
|
||||
inputs += [rec(mode=mode, ty=parse_ty(st, sd))];
|
||||
}
|
||||
st.pos = st.pos + 1u;
|
||||
ret tup(inputs, parse_ty(st, sd));
|
||||
@@ -285,7 +285,7 @@ fn lookup_hash(&ebml::doc d, fn(vec[u8]) -> bool eq_fn, uint hash)
|
||||
auto pos = ebml::be_uint_from_bytes(d.data, hash_pos, 4u);
|
||||
auto bucket = ebml::doc_at(d.data, pos);
|
||||
// Awkward logic because we can't ret from foreach yet
|
||||
let vec[ebml::doc] result = vec();
|
||||
let vec[ebml::doc] result = [];
|
||||
auto belt = metadata::tag_index_buckets_bucket_elt;
|
||||
for each (ebml::doc elt in ebml::tagged_docs(bucket, belt)) {
|
||||
auto pos = ebml::be_uint_from_bytes(elt.data, elt.start, 4u);
|
||||
@@ -306,7 +306,7 @@ fn eq_item(vec[u8] data, str s) -> bool {
|
||||
auto md = ebml::new_doc(data);
|
||||
auto paths = ebml::get_doc(md, metadata::tag_paths);
|
||||
auto eqer = bind eq_item(_, s);
|
||||
let vec[ast::def_id] result = vec();
|
||||
let vec[ast::def_id] result = [];
|
||||
for (ebml::doc doc in lookup_hash(paths, eqer, metadata::hash_path(s))) {
|
||||
auto did_doc = ebml::get_doc(doc, metadata::tag_def_id);
|
||||
_vec::push(result, parse_def_id(ebml::doc_data(did_doc)));
|
||||
@@ -380,7 +380,7 @@ fn item_ty_param_count(&ebml::doc item, int this_cnum) -> uint {
|
||||
}
|
||||
|
||||
fn tag_variant_ids(&ebml::doc item, int this_cnum) -> vec[ast::def_id] {
|
||||
let vec[ast::def_id] ids = vec();
|
||||
let vec[ast::def_id] ids = [];
|
||||
auto v = metadata::tag_items_data_item_variant;
|
||||
for each (ebml::doc p in ebml::tagged_docs(item, v)) {
|
||||
auto ext = parse_def_id(ebml::doc_data(p));
|
||||
@@ -544,23 +544,23 @@ fn get_tag_variants(session::session sess, ty::ctxt tcx, ast::def_id def)
|
||||
auto items = ebml::get_doc(ebml::new_doc(data), metadata::tag_items);
|
||||
auto item = find_item(def._1, items);
|
||||
|
||||
let vec[trans::variant_info] infos = vec();
|
||||
let vec[trans::variant_info] infos = [];
|
||||
auto variant_ids = tag_variant_ids(item, external_crate_id);
|
||||
for (ast::def_id did in variant_ids) {
|
||||
auto item = find_item(did._1, items);
|
||||
auto ctor_ty = item_type(item, external_crate_id, tcx);
|
||||
let vec[ty::t] arg_tys = vec();
|
||||
let vec[ty::t] arg_tys = [];
|
||||
alt (ty::struct(tcx, ctor_ty)) {
|
||||
case (ty::ty_fn(_, ?args, _)) {
|
||||
for (ty::arg a in args) {
|
||||
arg_tys += vec(a.ty);
|
||||
arg_tys += [a.ty];
|
||||
}
|
||||
}
|
||||
case (_) {
|
||||
// Nullary tag variant.
|
||||
}
|
||||
}
|
||||
infos += vec(rec(args=arg_tys, ctor_ty=ctor_ty, id=did));
|
||||
infos += [rec(args=arg_tys, ctor_ty=ctor_ty, id=did)];
|
||||
}
|
||||
|
||||
ret infos;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
mutable uint next_ann);
|
||||
|
||||
fn mk_env() -> env {
|
||||
let env e = vec();
|
||||
let env e = [];
|
||||
ret e;
|
||||
}
|
||||
|
||||
@@ -249,8 +249,8 @@ fn eval_crate_directives(ctx cx,
|
||||
fn eval_crate_directives_to_mod(ctx cx, env e,
|
||||
vec[@ast::crate_directive] cdirs,
|
||||
str prefix) -> ast::_mod {
|
||||
let vec[@ast::view_item] view_items = vec();
|
||||
let vec[@ast::item] items = vec();
|
||||
let vec[@ast::view_item] view_items = [];
|
||||
let vec[@ast::item] items = [];
|
||||
|
||||
eval_crate_directives(cx, e, cdirs, prefix,
|
||||
view_items, items);
|
||||
@@ -356,7 +356,7 @@ fn eval_crate_directive(ctx cx,
|
||||
|
||||
case (ast::cdir_let(?id, ?x, ?cdirs)) {
|
||||
auto v = eval_expr(cx, e, x);
|
||||
auto e0 = vec(tup(id, v)) + e;
|
||||
auto e0 = [tup(id, v)] + e;
|
||||
eval_crate_directives(cx, e0, cdirs, prefix,
|
||||
view_items, items);
|
||||
}
|
||||
@@ -379,7 +379,7 @@ fn eval_crate_directive(ctx cx,
|
||||
auto full_path = prefix + std::fs::path_sep() + file_path;
|
||||
|
||||
if (cx.mode == mode_depend) {
|
||||
cx.deps += vec(full_path);
|
||||
cx.deps += [full_path];
|
||||
ret;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -118,7 +118,7 @@ fn make_add_expr(parser p, common::span sp,
|
||||
|
||||
fn make_path_expr(parser p, common::span sp, vec[ast::ident] idents)
|
||||
-> @ast::expr {
|
||||
let vec[@ast::ty] types = vec();
|
||||
let vec[@ast::ty] types = [];
|
||||
auto path = rec(idents=idents, types=types);
|
||||
auto sp_path = rec(node=path, span=sp);
|
||||
auto pathexpr = ast::expr_path(sp_path, p.get_ann());
|
||||
@@ -143,14 +143,14 @@ fn make_call(parser p, common::span sp, vec[ast::ident] fn_path,
|
||||
|
||||
fn make_rec_expr(parser p, common::span sp,
|
||||
vec[tup(ast::ident, @ast::expr)] fields) -> @ast::expr {
|
||||
let vec[ast::field] astfields = vec();
|
||||
let vec[ast::field] astfields = [];
|
||||
for (tup(ast::ident, @ast::expr) field in fields) {
|
||||
auto ident = field._0;
|
||||
auto val = field._1;
|
||||
auto astfield = rec(mut = ast::imm,
|
||||
ident = ident,
|
||||
expr = val);
|
||||
astfields += vec(astfield);
|
||||
astfields += [astfield];
|
||||
}
|
||||
|
||||
auto recexpr = ast::expr_rec(astfields,
|
||||
@@ -163,7 +163,7 @@ fn make_rec_expr(parser p, common::span sp,
|
||||
fn make_path_vec(str ident) -> vec[str] {
|
||||
// FIXME: #fmt can't currently be used from within std
|
||||
// because we're explicitly referencing the 'std' crate here
|
||||
ret vec("std", "extfmt", "rt", ident);
|
||||
ret ["std", "extfmt", "rt", ident];
|
||||
}
|
||||
|
||||
fn make_rt_path_expr(parser p, common::span sp, str ident) -> @ast::expr {
|
||||
@@ -177,7 +177,7 @@ fn make_rt_conv_expr(parser p, common::span sp, &conv cnv) -> @ast::expr {
|
||||
|
||||
fn make_flags(parser p, common::span sp, vec[flag] flags)
|
||||
-> @ast::expr {
|
||||
let vec[@ast::expr] flagexprs = vec();
|
||||
let vec[@ast::expr] flagexprs = [];
|
||||
for (flag f in flags) {
|
||||
auto fstr;
|
||||
alt (f) {
|
||||
@@ -197,14 +197,14 @@ fn make_flags(parser p, common::span sp, vec[flag] flags)
|
||||
fstr = "flag_alternate";
|
||||
}
|
||||
}
|
||||
flagexprs += vec(make_rt_path_expr(p, sp, fstr));
|
||||
flagexprs += [make_rt_path_expr(p, sp, fstr)];
|
||||
}
|
||||
|
||||
// FIXME: 0-length vectors can't have their type inferred
|
||||
// through the rec that these flags are a member of, so
|
||||
// this is a hack placeholder flag
|
||||
if (_vec::len[@ast::expr](flagexprs) == 0u) {
|
||||
flagexprs += vec(make_rt_path_expr(p, sp, "flag_none"));
|
||||
flagexprs += [make_rt_path_expr(p, sp, "flag_none")];
|
||||
}
|
||||
|
||||
ret make_vec_expr(p, sp, flagexprs);
|
||||
@@ -218,7 +218,7 @@ fn make_count(parser p, common::span sp, &count cnt) -> @ast::expr {
|
||||
case (count_is(?c)) {
|
||||
auto count_lit = make_new_int(p, sp, c);
|
||||
auto count_is_path = make_path_vec("count_is");
|
||||
auto count_is_args = vec(count_lit);
|
||||
auto count_is_args = [count_lit];
|
||||
ret make_call(p, sp, count_is_path, count_is_args);
|
||||
}
|
||||
case (_) {
|
||||
@@ -261,10 +261,10 @@ fn make_conv_rec(parser p,
|
||||
@ast::expr width_expr,
|
||||
@ast::expr precision_expr,
|
||||
@ast::expr ty_expr) -> @ast::expr {
|
||||
ret make_rec_expr(p, sp, vec(tup("flags", flags_expr),
|
||||
ret make_rec_expr(p, sp, [tup("flags", flags_expr),
|
||||
tup("width", width_expr),
|
||||
tup("precision", precision_expr),
|
||||
tup("ty", ty_expr)));
|
||||
tup("ty", ty_expr)]);
|
||||
}
|
||||
|
||||
auto rt_conv_flags = make_flags(p, sp, cnv.flags);
|
||||
@@ -284,7 +284,7 @@ fn make_conv_call(parser p, common::span sp, str conv_type,
|
||||
auto fname = "conv_" + conv_type;
|
||||
auto path = make_path_vec(fname);
|
||||
auto cnv_expr = make_rt_conv_expr(p, sp, cnv);
|
||||
auto args = vec(cnv_expr, arg);
|
||||
auto args = [cnv_expr, arg];
|
||||
ret make_call(p, arg.span, path, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ fn err(str m) {
|
||||
}
|
||||
}
|
||||
auto file = _str::unsafe_from_bytes(rdr.read_whole_stream());
|
||||
let vec[str] strs = vec();
|
||||
let vec[str] strs = [];
|
||||
auto rd = reader(sess, file, _str::byte_len(file), 0u, -1 as char,
|
||||
filemap.start_pos, filemap.start_pos,
|
||||
strs, filemap, itr);
|
||||
@@ -228,11 +228,11 @@ fn scan_exponent(reader rdr) -> option::t[str] {
|
||||
auto res = "";
|
||||
|
||||
if (c == 'e' || c == 'E') {
|
||||
res += _str::from_bytes(vec(c as u8));
|
||||
res += _str::from_bytes([c as u8]);
|
||||
rdr.bump();
|
||||
c = rdr.curr();
|
||||
if (c == '-' || c == '+') {
|
||||
res += _str::from_bytes(vec(c as u8));
|
||||
res += _str::from_bytes([c as u8]);
|
||||
rdr.bump();
|
||||
}
|
||||
auto exponent = scan_dec_digits(rdr);
|
||||
@@ -256,7 +256,7 @@ fn scan_dec_digits(reader rdr) -> str {
|
||||
|
||||
while (is_dec_digit (c) || c == '_') {
|
||||
if (c != '_') {
|
||||
res += _str::from_bytes(vec(c as u8));
|
||||
res += _str::from_bytes([c as u8]);
|
||||
}
|
||||
rdr.bump();
|
||||
c = rdr.curr();
|
||||
@@ -766,7 +766,7 @@ fn read_block_comment(reader rdr) -> cmnt {
|
||||
auto p = rdr.get_chpos();
|
||||
rdr.bump(); rdr.bump();
|
||||
while (rdr.curr() == ' ') {rdr.bump();}
|
||||
let vec[str] lines = vec();
|
||||
let vec[str] lines = [];
|
||||
auto val = "";
|
||||
auto level = 1;
|
||||
while (true) {
|
||||
@@ -802,7 +802,7 @@ fn gather_comments(session sess, str path) -> vec[cmnt] {
|
||||
auto srdr = io::file_reader(path);
|
||||
auto itr = @interner::mk_interner[str](_str::hash, _str::eq);
|
||||
auto rdr = new_reader(sess, srdr, codemap::new_filemap(path, 0u), itr);
|
||||
let vec[cmnt] comments = vec();
|
||||
let vec[cmnt] comments = [];
|
||||
while (!rdr.is_eof()) {
|
||||
while (true) {
|
||||
consume_whitespace(rdr);
|
||||
|
||||
+39
-39
@@ -422,7 +422,7 @@ fn parse_ty_constr(parser p) -> @ast::constr {
|
||||
fn parse_constrs(parser p) -> common::spanned[vec[@ast::constr]] {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = p.get_hi_pos();
|
||||
let vec[@ast::constr] constrs = vec();
|
||||
let vec[@ast::constr] constrs = [];
|
||||
if (p.peek() == token::COLON) {
|
||||
p.bump();
|
||||
while (true) {
|
||||
@@ -580,7 +580,7 @@ fn parse_seq_to_end[T](token::token ket,
|
||||
uint hi,
|
||||
parser p) -> vec[T] {
|
||||
let bool first = true;
|
||||
let vec[T] v = vec();
|
||||
let vec[T] v = [];
|
||||
while (p.peek() != ket) {
|
||||
alt(sep) {
|
||||
case (some[token::token](?t)) {
|
||||
@@ -595,7 +595,7 @@ fn parse_seq_to_end[T](token::token ket,
|
||||
}
|
||||
// FIXME: v += f(p) doesn't work at the moment.
|
||||
let T t = f(p);
|
||||
v += vec(t);
|
||||
v += [t];
|
||||
}
|
||||
hi = p.get_hi_pos();
|
||||
expect(p, ket);
|
||||
@@ -677,7 +677,7 @@ fn parse_ty_args(parser p, uint hi) ->
|
||||
some(token::COMMA),
|
||||
pf, p);
|
||||
}
|
||||
let vec[@ast::ty] v = vec();
|
||||
let vec[@ast::ty] v = [];
|
||||
auto pos = p.get_lo_pos();
|
||||
ret spanned(hi, hi, v);
|
||||
}
|
||||
@@ -687,12 +687,12 @@ fn parse_path(parser p) -> ast::path {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = lo;
|
||||
|
||||
let vec[ast::ident] ids = vec();
|
||||
let vec[ast::ident] ids = [];
|
||||
while (true) {
|
||||
alt (p.peek()) {
|
||||
case (token::IDENT(?i, _)) {
|
||||
hi = p.get_hi_pos();
|
||||
ids += vec(p.get_str(i));
|
||||
ids += [p.get_str(i)];
|
||||
p.bump();
|
||||
if (p.peek() == token::MOD_SEP) {
|
||||
p.bump();
|
||||
@@ -797,7 +797,7 @@ fn parse_elt(parser p) -> ast::elt {
|
||||
pf, hi, p));
|
||||
}
|
||||
|
||||
let vec[@ast::method] meths = vec();
|
||||
let vec[@ast::method] meths = [];
|
||||
let option::t[ast::ident] with_obj = none[ast::ident];
|
||||
|
||||
expect(p, token::LBRACE);
|
||||
@@ -830,7 +830,7 @@ fn parse_elt(parser p) -> ast::elt {
|
||||
|
||||
} else if (eat_word(p, "rec")) {
|
||||
expect(p, token::LPAREN);
|
||||
auto fields = vec(parse_field(p));
|
||||
auto fields = [parse_field(p)];
|
||||
|
||||
auto more = true;
|
||||
auto base = none[@ast::expr];
|
||||
@@ -846,7 +846,7 @@ fn parse_elt(parser p) -> ast::elt {
|
||||
more = false;
|
||||
} else if (p.peek() == token::COMMA) {
|
||||
p.bump();
|
||||
fields += vec(parse_field(p));
|
||||
fields += [parse_field(p)];
|
||||
} else {
|
||||
unexpected(p, p.peek());
|
||||
}
|
||||
@@ -1151,7 +1151,7 @@ fn parse_prefix_expr(parser p) -> @ast::expr {
|
||||
|
||||
// FIXME make this a const, don't store it in parser state
|
||||
fn prec_table() -> vec[op_spec] {
|
||||
ret vec(rec(tok=token::BINOP(token::STAR), op=ast::mul, prec=11),
|
||||
ret [rec(tok=token::BINOP(token::STAR), op=ast::mul, prec=11),
|
||||
rec(tok=token::BINOP(token::SLASH), op=ast::div, prec=11),
|
||||
rec(tok=token::BINOP(token::PERCENT), op=ast::rem, prec=11),
|
||||
rec(tok=token::BINOP(token::PLUS), op=ast::add, prec=10),
|
||||
@@ -1170,7 +1170,7 @@ fn prec_table() -> vec[op_spec] {
|
||||
rec(tok=token::EQEQ, op=ast::eq, prec=3),
|
||||
rec(tok=token::NE, op=ast::ne, prec=3),
|
||||
rec(tok=token::ANDAND, op=ast::and, prec=2),
|
||||
rec(tok=token::OROR, op=ast::or, prec=1));
|
||||
rec(tok=token::OROR, op=ast::or, prec=1)];
|
||||
}
|
||||
|
||||
fn parse_binops(parser p) -> @ast::expr {
|
||||
@@ -1342,14 +1342,14 @@ fn parse_alt_expr(parser p) -> @ast::expr {
|
||||
expect(p, token::RPAREN);
|
||||
expect(p, token::LBRACE);
|
||||
|
||||
let vec[ast::arm] arms = vec();
|
||||
let vec[ast::arm] arms = [];
|
||||
while (p.peek() != token::RBRACE) {
|
||||
if (eat_word(p, "case")) {
|
||||
expect(p, token::LPAREN);
|
||||
auto pat = parse_pat(p);
|
||||
expect(p, token::RPAREN);
|
||||
auto block = parse_block(p);
|
||||
arms += vec(rec(pat=pat, block=block));
|
||||
arms += [rec(pat=pat, block=block)];
|
||||
} else if (p.peek() == token::RBRACE) {
|
||||
/* empty */
|
||||
} else {
|
||||
@@ -1480,7 +1480,7 @@ fn parse_pat(parser p) -> @ast::pat {
|
||||
args = a.node;
|
||||
hi = a.span.hi;
|
||||
}
|
||||
case (_) { args = vec(); }
|
||||
case (_) { args = []; }
|
||||
}
|
||||
|
||||
pat = ast::pat_tag(tag_path, args, p.get_ann());
|
||||
@@ -1630,7 +1630,7 @@ fn stmt_ends_with_semi(@ast::stmt stmt) -> bool {
|
||||
fn parse_block(parser p) -> ast::block {
|
||||
auto lo = p.get_lo_pos();
|
||||
|
||||
let vec[@ast::stmt] stmts = vec();
|
||||
let vec[@ast::stmt] stmts = [];
|
||||
let option::t[@ast::expr] expr = none[@ast::expr];
|
||||
|
||||
expect(p, token::LBRACE);
|
||||
@@ -1650,7 +1650,7 @@ fn parse_block(parser p) -> ast::block {
|
||||
alt (p.peek()) {
|
||||
case (token::SEMI) {
|
||||
p.bump();
|
||||
stmts += vec(stmt);
|
||||
stmts += [stmt];
|
||||
}
|
||||
case (token::RBRACE) { expr = some(e); }
|
||||
case (?t) {
|
||||
@@ -1660,13 +1660,13 @@ fn parse_block(parser p) -> ast::block {
|
||||
token::to_str(p.get_reader(), t));
|
||||
fail;
|
||||
}
|
||||
stmts += vec(stmt);
|
||||
stmts += [stmt];
|
||||
}
|
||||
}
|
||||
}
|
||||
case (none[@ast::expr]) {
|
||||
// Not an expression statement.
|
||||
stmts += vec(stmt);
|
||||
stmts += [stmt];
|
||||
// FIXME: crazy differentiation between conditions
|
||||
// used in branches and binary expressions in rustboot
|
||||
// means we cannot use && here. I know, right?
|
||||
@@ -1693,7 +1693,7 @@ fn parse_ty_param(parser p) -> ast::ty_param {
|
||||
}
|
||||
|
||||
fn parse_ty_params(parser p) -> vec[ast::ty_param] {
|
||||
let vec[ast::ty_param] ty_params = vec();
|
||||
let vec[ast::ty_param] ty_params = [];
|
||||
if (p.peek() == token::LBRACKET) {
|
||||
auto f = parse_ty_param; // FIXME: pass as lval directly
|
||||
ty_params = parse_seq[ast::ty_param](token::LBRACKET, token::RBRACKET,
|
||||
@@ -1775,7 +1775,7 @@ fn parse_method(parser p) -> @ast::method {
|
||||
fn parse_dtor(parser p) -> @ast::method {
|
||||
auto lo = p.get_last_lo_pos();
|
||||
let ast::block b = parse_block(p);
|
||||
let vec[ast::arg] inputs = vec();
|
||||
let vec[ast::arg] inputs = [];
|
||||
let @ast::ty output = @spanned(lo, lo, ast::ty_nil);
|
||||
let ast::fn_decl d = rec(inputs=inputs,
|
||||
output=output,
|
||||
@@ -1802,7 +1802,7 @@ fn parse_item_obj(parser p, ast::layer lyr) -> @ast::item {
|
||||
some(token::COMMA),
|
||||
pf, p);
|
||||
|
||||
let vec[@ast::method] meths = vec();
|
||||
let vec[@ast::method] meths = [];
|
||||
let option::t[@ast::method] dtor = none[@ast::method];
|
||||
|
||||
expect(p, token::LBRACE);
|
||||
@@ -1829,9 +1829,9 @@ fn parse_item_obj(parser p, ast::layer lyr) -> @ast::item {
|
||||
|
||||
fn parse_mod_items(parser p, token::token term) -> ast::_mod {
|
||||
auto view_items = parse_view(p);
|
||||
let vec[@ast::item] items = vec();
|
||||
let vec[@ast::item] items = [];
|
||||
while (p.peek() != term) {
|
||||
items += vec(parse_item(p));
|
||||
items += [parse_item(p)];
|
||||
}
|
||||
ret rec(view_items=view_items, items=items);
|
||||
}
|
||||
@@ -1899,12 +1899,12 @@ fn parse_native_item(parser p) -> @ast::native_item {
|
||||
fn parse_native_mod_items(parser p,
|
||||
str native_name,
|
||||
ast::native_abi abi) -> ast::native_mod {
|
||||
let vec[@ast::native_item] items = vec();
|
||||
let vec[@ast::native_item] items = [];
|
||||
|
||||
auto view_items = parse_native_view(p);
|
||||
|
||||
while (p.peek() != token::RBRACE) {
|
||||
items += vec(parse_native_item(p));
|
||||
items += [parse_native_item(p)];
|
||||
}
|
||||
ret rec(native_name=native_name, abi=abi,
|
||||
view_items=view_items,
|
||||
@@ -1982,7 +1982,7 @@ fn parse_item_tag(parser p) -> @ast::item {
|
||||
auto id = parse_ident(p);
|
||||
auto ty_params = parse_ty_params(p);
|
||||
|
||||
let vec[ast::variant] variants = vec();
|
||||
let vec[ast::variant] variants = [];
|
||||
expect(p, token::LBRACE);
|
||||
while (p.peek() != token::RBRACE) {
|
||||
auto tok = p.peek();
|
||||
@@ -1992,7 +1992,7 @@ fn parse_item_tag(parser p) -> @ast::item {
|
||||
auto vlo = p.get_lo_pos();
|
||||
p.bump();
|
||||
|
||||
let vec[ast::variant_arg] args = vec();
|
||||
let vec[ast::variant_arg] args = [];
|
||||
alt (p.peek()) {
|
||||
case (token::LPAREN) {
|
||||
auto f = parse_ty;
|
||||
@@ -2001,7 +2001,7 @@ fn parse_item_tag(parser p) -> @ast::item {
|
||||
some(token::COMMA),
|
||||
f, p);
|
||||
for (@ast::ty ty in arg_tys.node) {
|
||||
args += vec(rec(ty=ty, id=p.next_def_id()));
|
||||
args += [rec(ty=ty, id=p.next_def_id())];
|
||||
}
|
||||
}
|
||||
case (_) { /* empty */ }
|
||||
@@ -2013,7 +2013,7 @@ fn parse_item_tag(parser p) -> @ast::item {
|
||||
auto id = p.next_def_id();
|
||||
auto vr = rec(name=p.get_str(name), args=args,
|
||||
id=id, ann=p.get_ann());
|
||||
variants += vec(spanned[ast::variant_](vlo, vhi, vr));
|
||||
variants += [spanned[ast::variant_](vlo, vhi, vr)];
|
||||
}
|
||||
case (token::RBRACE) { /* empty */ }
|
||||
case (_) {
|
||||
@@ -2135,7 +2135,7 @@ fn parse_optional_meta(parser p) -> vec[@ast::meta_item] {
|
||||
ret parse_meta(p);
|
||||
}
|
||||
case (_) {
|
||||
let vec[@ast::meta_item] v = vec();
|
||||
let vec[@ast::meta_item] v = [];
|
||||
ret v;
|
||||
}
|
||||
}
|
||||
@@ -2156,11 +2156,11 @@ fn parse_rest_import_name(parser p, ast::ident first,
|
||||
option::t[ast::ident] def_ident)
|
||||
-> @ast::view_item {
|
||||
auto lo = p.get_lo_pos();
|
||||
let vec[ast::ident] identifiers = vec(first);
|
||||
let vec[ast::ident] identifiers = [first];
|
||||
while (p.peek() != token::SEMI) {
|
||||
expect(p, token::MOD_SEP);
|
||||
auto i = parse_ident(p);
|
||||
identifiers += vec(i);
|
||||
identifiers += [i];
|
||||
}
|
||||
auto hi = p.get_hi_pos();
|
||||
p.bump();
|
||||
@@ -2248,17 +2248,17 @@ fn is_view_item(&parser p) -> bool {
|
||||
}
|
||||
|
||||
fn parse_view(parser p) -> vec[@ast::view_item] {
|
||||
let vec[@ast::view_item] items = vec();
|
||||
let vec[@ast::view_item] items = [];
|
||||
while (is_view_item(p)) {
|
||||
items += vec(parse_view_item(p));
|
||||
items += [parse_view_item(p)];
|
||||
}
|
||||
ret items;
|
||||
}
|
||||
|
||||
fn parse_native_view(parser p) -> vec[@ast::view_item] {
|
||||
let vec[@ast::view_item] items = vec();
|
||||
let vec[@ast::view_item] items = [];
|
||||
while (is_view_item(p)) {
|
||||
items += vec(parse_view_item(p));
|
||||
items += [parse_view_item(p)];
|
||||
}
|
||||
ret items;
|
||||
}
|
||||
@@ -2267,7 +2267,7 @@ fn parse_native_view(parser p) -> vec[@ast::view_item] {
|
||||
fn parse_crate_from_source_file(parser p) -> @ast::crate {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto m = parse_mod_items(p, token::EOF);
|
||||
let vec[@ast::crate_directive] cdirs = vec();
|
||||
let vec[@ast::crate_directive] cdirs = [];
|
||||
ret @spanned(lo, p.get_lo_pos(), rec(directives=cdirs,
|
||||
module=m));
|
||||
}
|
||||
@@ -2362,7 +2362,7 @@ fn parse_crate_directive(parser p) -> ast::crate_directive
|
||||
fn parse_crate_directives(parser p, token::token term)
|
||||
-> vec[@ast::crate_directive] {
|
||||
|
||||
let vec[@ast::crate_directive] cdirs = vec();
|
||||
let vec[@ast::crate_directive] cdirs = [];
|
||||
|
||||
while (p.peek() != term) {
|
||||
auto cdir = @parse_crate_directive(p);
|
||||
@@ -2376,7 +2376,7 @@ fn parse_crate_from_crate_file(parser p) -> @ast::crate {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto prefix = std::fs::dirname(p.get_filemap().name);
|
||||
auto cdirs = parse_crate_directives(p, token::EOF);
|
||||
let vec[str] deps = vec();
|
||||
let vec[str] deps = [];
|
||||
auto cx = @rec(p=p,
|
||||
mode=eval::mode_parse,
|
||||
mutable deps = deps,
|
||||
|
||||
@@ -1395,7 +1395,7 @@ fn Trap() -> ValueRef {
|
||||
let ValueRef T = llvm::LLVMGetNamedFunction(M,
|
||||
_str::buf("llvm.trap"));
|
||||
assert (T as int != 0);
|
||||
let vec[ValueRef] Args = vec();
|
||||
let vec[ValueRef] Args = [];
|
||||
ret llvm::LLVMBuildCall(B, T,
|
||||
_vec::buf[ValueRef](Args),
|
||||
_vec::len[ValueRef](Args),
|
||||
@@ -1467,7 +1467,7 @@ fn eq(&TypeRef a, &TypeRef b) -> bool {
|
||||
}
|
||||
|
||||
fn type_to_str(type_names names, TypeRef ty) -> str {
|
||||
let vec[TypeRef] v = vec();
|
||||
let vec[TypeRef] v = [];
|
||||
ret type_to_str_inner(names, v, ty);
|
||||
}
|
||||
|
||||
@@ -1478,7 +1478,7 @@ fn type_to_str_inner(type_names names,
|
||||
ret names.get_name(ty);
|
||||
}
|
||||
|
||||
auto outer = outer0 + vec(ty);
|
||||
auto outer = outer0 + [ty];
|
||||
|
||||
let int kind = llvm::LLVMGetTypeKind(ty);
|
||||
|
||||
|
||||
+37
-37
@@ -358,7 +358,7 @@
|
||||
//// Fold drivers.
|
||||
|
||||
fn fold_path[ENV](&ENV env, &ast_fold[ENV] fld, &path p) -> path {
|
||||
let vec[@ast::ty] tys_ = vec();
|
||||
let vec[@ast::ty] tys_ = [];
|
||||
for (@ast::ty t in p.node.types) {
|
||||
_vec::push[@ast::ty](tys_, fold_ty(env, fld, t));
|
||||
}
|
||||
@@ -398,7 +398,7 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
|
||||
}
|
||||
|
||||
case (ast::ty_tup(?elts)) {
|
||||
let vec[mt] elts_ = vec();
|
||||
let vec[mt] elts_ = [];
|
||||
for (mt elt in elts) {
|
||||
auto ty_ = fold_ty(env, fld, elt.ty);
|
||||
_vec::push[mt](elts_, rec(ty=ty_, mut=elt.mut));
|
||||
@@ -407,7 +407,7 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
|
||||
}
|
||||
|
||||
case (ast::ty_rec(?flds)) {
|
||||
let vec[ast::ty_field] flds_ = vec();
|
||||
let vec[ast::ty_field] flds_ = [];
|
||||
for (ast::ty_field f in flds) {
|
||||
auto ty_ = fold_ty(env, fld, f.mt.ty);
|
||||
_vec::push[ast::ty_field]
|
||||
@@ -417,7 +417,7 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
|
||||
}
|
||||
|
||||
case (ast::ty_obj(?meths)) {
|
||||
let vec[ast::ty_method] meths_ = vec();
|
||||
let vec[ast::ty_method] meths_ = [];
|
||||
for (ast::ty_method m in meths) {
|
||||
auto tfn = fold_ty_fn(env_, fld, t.span, m.proto,
|
||||
m.inputs, m.output);
|
||||
@@ -458,11 +458,11 @@ fn fold_ty_fn[ENV](&ENV env, &ast_fold[ENV] fld, &span sp,
|
||||
&vec[rec(ast::mode mode, @ty ty)] inputs,
|
||||
&@ty output) -> @ty {
|
||||
auto output_ = fold_ty(env, fld, output);
|
||||
let vec[rec(ast::mode mode, @ty ty)] inputs_ = vec();
|
||||
let vec[rec(ast::mode mode, @ty ty)] inputs_ = [];
|
||||
for (rec(ast::mode mode, @ty ty) input in inputs) {
|
||||
auto ty_ = fold_ty(env, fld, input.ty);
|
||||
auto input_ = rec(ty=ty_ with input);
|
||||
inputs_ += vec(input_);
|
||||
inputs_ += [input_];
|
||||
}
|
||||
ret fld.fold_ty_fn(env, sp, proto, inputs_, output_);
|
||||
}
|
||||
@@ -524,9 +524,9 @@ fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast::pat p) -> @ast::pat {
|
||||
case (ast::pat_tag(?path, ?pats, ?t)) {
|
||||
auto ppath = fold_path(env, fld, path);
|
||||
|
||||
let vec[@ast::pat] ppats = vec();
|
||||
let vec[@ast::pat] ppats = [];
|
||||
for (@ast::pat pat in pats) {
|
||||
ppats += vec(fold_pat(env_, fld, pat));
|
||||
ppats += [fold_pat(env_, fld, pat)];
|
||||
}
|
||||
|
||||
ret fld.fold_pat_tag(env_, p.span, ppath, ppats, t);
|
||||
@@ -536,7 +536,7 @@ fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast::pat p) -> @ast::pat {
|
||||
|
||||
fn fold_exprs[ENV](&ENV env, &ast_fold[ENV] fld,
|
||||
&vec[@expr] es) -> vec[@expr] {
|
||||
let vec[@expr] exprs = vec();
|
||||
let vec[@expr] exprs = [];
|
||||
for (@expr e in es) {
|
||||
_vec::push[@expr](exprs, fold_expr(env, fld, e));
|
||||
}
|
||||
@@ -568,19 +568,19 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
|
||||
}
|
||||
|
||||
case (ast::expr_tup(?es, ?t)) {
|
||||
let vec[ast::elt] elts = vec();
|
||||
let vec[ast::elt] elts = [];
|
||||
for (ast::elt e in es) {
|
||||
elts += vec(fold_tup_elt[ENV](env, fld, e));
|
||||
elts += [fold_tup_elt[ENV](env, fld, e)];
|
||||
}
|
||||
auto t2 = fld.fold_ann(env_, t);
|
||||
ret fld.fold_expr_tup(env_, e.span, elts, t2);
|
||||
}
|
||||
|
||||
case (ast::expr_rec(?fs, ?base, ?t)) {
|
||||
let vec[ast::field] fields = vec();
|
||||
let vec[ast::field] fields = [];
|
||||
let option::t[@expr] b = none[@expr];
|
||||
for (ast::field f in fs) {
|
||||
fields += vec(fold_rec_field(env, fld, f));
|
||||
fields += [fold_rec_field(env, fld, f)];
|
||||
}
|
||||
alt (base) {
|
||||
case (none[@ast::expr]) { }
|
||||
@@ -606,14 +606,14 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
|
||||
|
||||
case (ast::expr_bind(?f, ?args_opt, ?t)) {
|
||||
auto ff = fold_expr(env_, fld, f);
|
||||
let vec[option::t[@ast::expr]] aargs_opt = vec();
|
||||
let vec[option::t[@ast::expr]] aargs_opt = [];
|
||||
for (option::t[@ast::expr] t_opt in args_opt) {
|
||||
alt (t_opt) {
|
||||
case (none[@ast::expr]) {
|
||||
aargs_opt += vec(none[@ast::expr]);
|
||||
aargs_opt += [none[@ast::expr]];
|
||||
}
|
||||
case (some[@ast::expr](?e)) {
|
||||
aargs_opt += vec(some(fold_expr(env_, fld, e)));
|
||||
aargs_opt += [some(fold_expr(env_, fld, e))];
|
||||
}
|
||||
case (none[@ast::expr]) { /* empty */ }
|
||||
}
|
||||
@@ -700,9 +700,9 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
|
||||
|
||||
case (ast::expr_alt(?expr, ?arms, ?t)) {
|
||||
auto eexpr = fold_expr(env_, fld, expr);
|
||||
let vec[ast::arm] aarms = vec();
|
||||
let vec[ast::arm] aarms = [];
|
||||
for (ast::arm a in arms) {
|
||||
aarms += vec(fold_arm(env_, fld, a));
|
||||
aarms += [fold_arm(env_, fld, a)];
|
||||
}
|
||||
auto t2 = fld.fold_ann(env_, t);
|
||||
ret fld.fold_expr_alt(env_, e.span, eexpr, aarms, t2);
|
||||
@@ -887,7 +887,7 @@ fn fold_block[ENV](&ENV env, &ast_fold[ENV] fld, &block blk) -> block {
|
||||
ret blk;
|
||||
}
|
||||
|
||||
let vec[@ast::stmt] stmts = vec();
|
||||
let vec[@ast::stmt] stmts = [];
|
||||
for (@ast::stmt s in blk.node.stmts) {
|
||||
auto new_stmt = fold_stmt[ENV](env_, fld, s);
|
||||
_vec::push[@ast::stmt](stmts, new_stmt);
|
||||
@@ -921,9 +921,9 @@ fn fold_arg[ENV](&ENV env, &ast_fold[ENV] fld, &arg a) -> arg {
|
||||
|
||||
fn fold_fn_decl[ENV](&ENV env, &ast_fold[ENV] fld,
|
||||
&ast::fn_decl decl) -> ast::fn_decl {
|
||||
let vec[ast::arg] inputs = vec();
|
||||
let vec[ast::arg] inputs = [];
|
||||
for (ast::arg a in decl.inputs) {
|
||||
inputs += vec(fold_arg(env, fld, a));
|
||||
inputs += [fold_arg(env, fld, a)];
|
||||
}
|
||||
auto output = fold_ty[ENV](env, fld, decl.output);
|
||||
ret fld.fold_fn_decl(env, inputs, output, decl.purity);
|
||||
@@ -953,10 +953,10 @@ fn fold_method[ENV](&ENV env, &ast_fold[ENV] fld,
|
||||
|
||||
fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_obj ob) -> ast::_obj {
|
||||
|
||||
let vec[ast::obj_field] fields = vec();
|
||||
let vec[@ast::method] meths = vec();
|
||||
let vec[ast::obj_field] fields = [];
|
||||
let vec[@ast::method] meths = [];
|
||||
for (ast::obj_field f in ob.fields) {
|
||||
fields += vec(fold_obj_field(env, fld, f));
|
||||
fields += [fold_obj_field(env, fld, f)];
|
||||
}
|
||||
let option::t[@ast::method] dtor = none[@ast::method];
|
||||
alt (ob.dtor) {
|
||||
@@ -965,7 +965,7 @@ fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_obj ob) -> ast::_obj {
|
||||
dtor = some[@ast::method](fold_method[ENV](env, fld, m));
|
||||
}
|
||||
}
|
||||
let vec[ast::ty_param] tp = vec();
|
||||
let vec[ast::ty_param] tp = [];
|
||||
for (@ast::method m in ob.methods) {
|
||||
// Fake-up an ast::item for this method.
|
||||
// FIXME: this is kinda awful. Maybe we should reformulate
|
||||
@@ -990,9 +990,9 @@ fn fold_anon_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::anon_obj ob)
|
||||
alt (ob.fields) {
|
||||
case (none[vec[ast::obj_field]]) { }
|
||||
case (some[vec[ast::obj_field]](?v)) {
|
||||
let vec[ast::obj_field] fields = vec();
|
||||
let vec[ast::obj_field] fields = [];
|
||||
for (ast::obj_field f in v) {
|
||||
fields += vec(fold_obj_field(env, fld, f));
|
||||
fields += [fold_obj_field(env, fld, f)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1007,8 +1007,8 @@ fn fold_anon_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::anon_obj ob)
|
||||
}
|
||||
|
||||
// Methods
|
||||
let vec[@ast::method] meths = vec();
|
||||
let vec[ast::ty_param] tp = vec();
|
||||
let vec[@ast::method] meths = [];
|
||||
let vec[ast::ty_param] tp = [];
|
||||
for (@ast::method m in ob.methods) {
|
||||
// Fake-up an ast::item for this method.
|
||||
// FIXME: this is kinda awful. Maybe we should reformulate
|
||||
@@ -1089,16 +1089,16 @@ fn fold_item[ENV](&ENV env, &ast_fold[ENV] fld, &@item i) -> @item {
|
||||
}
|
||||
|
||||
case (ast::item_tag(?ident, ?variants, ?ty_params, ?id, ?ann)) {
|
||||
let vec[ast::variant] new_variants = vec();
|
||||
let vec[ast::variant] new_variants = [];
|
||||
for (ast::variant v in variants) {
|
||||
let vec[ast::variant_arg] new_args = vec();
|
||||
let vec[ast::variant_arg] new_args = [];
|
||||
for (ast::variant_arg va in v.node.args) {
|
||||
auto new_ty = fold_ty[ENV](env_, fld, va.ty);
|
||||
new_args += vec(rec(ty=new_ty, id=va.id));
|
||||
new_args += [rec(ty=new_ty, id=va.id)];
|
||||
}
|
||||
auto new_v = rec(name=v.node.name, args=new_args,
|
||||
id=v.node.id, ann=v.node.ann);
|
||||
new_variants += vec(respan[ast::variant_](v.span, new_v));
|
||||
new_variants += [respan[ast::variant_](v.span, new_v)];
|
||||
}
|
||||
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
|
||||
ty_params, id, ann);
|
||||
@@ -1116,8 +1116,8 @@ fn fold_item[ENV](&ENV env, &ast_fold[ENV] fld, &@item i) -> @item {
|
||||
|
||||
fn fold_mod[ENV](&ENV e, &ast_fold[ENV] fld, &ast::_mod m) -> ast::_mod {
|
||||
|
||||
let vec[@view_item] view_items = vec();
|
||||
let vec[@item] items = vec();
|
||||
let vec[@view_item] view_items = [];
|
||||
let vec[@item] items = [];
|
||||
|
||||
for (@view_item vi in m.view_items) {
|
||||
auto new_vi = fold_view_item[ENV](e, fld, vi);
|
||||
@@ -1154,8 +1154,8 @@ fn fold_native_item[ENV](&ENV env, &ast_fold[ENV] fld,
|
||||
|
||||
fn fold_native_mod[ENV](&ENV e, &ast_fold[ENV] fld,
|
||||
&ast::native_mod m) -> ast::native_mod {
|
||||
let vec[@view_item] view_items = vec();
|
||||
let vec[@native_item] items = vec();
|
||||
let vec[@view_item] view_items = [];
|
||||
let vec[@native_item] items = [];
|
||||
|
||||
for (@view_item vi in m.view_items) {
|
||||
auto new_vi = fold_view_item[ENV](e, fld, vi);
|
||||
|
||||
+20
-20
@@ -299,8 +299,8 @@ fn add_to_index(&ebml::writer ebml_w,
|
||||
&vec[str] path,
|
||||
&mutable vec[tup(str, uint)] index,
|
||||
&str name) {
|
||||
auto full_path = path + vec(name);
|
||||
index += vec(tup(_str::connect(full_path, "::"), ebml_w.writer.tell()));
|
||||
auto full_path = path + [name];
|
||||
index += [tup(_str::connect(full_path, "::"), ebml_w.writer.tell())];
|
||||
}
|
||||
|
||||
fn encode_native_module_item_paths(&ebml::writer ebml_w,
|
||||
@@ -353,7 +353,7 @@ fn encode_module_item_paths(&ebml::writer ebml_w,
|
||||
ebml::start_tag(ebml_w, tag_paths_data_mod);
|
||||
encode_name(ebml_w, id);
|
||||
encode_def_id(ebml_w, did);
|
||||
encode_module_item_paths(ebml_w, _mod, path + vec(id), index);
|
||||
encode_module_item_paths(ebml_w, _mod, path + [id], index);
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
case (ast::item_native_mod(?id, ?nmod, ?did)) {
|
||||
@@ -361,7 +361,7 @@ fn encode_module_item_paths(&ebml::writer ebml_w,
|
||||
ebml::start_tag(ebml_w, tag_paths_data_mod);
|
||||
encode_name(ebml_w, id);
|
||||
encode_def_id(ebml_w, did);
|
||||
encode_native_module_item_paths(ebml_w, nmod, path + vec(id),
|
||||
encode_native_module_item_paths(ebml_w, nmod, path + [id],
|
||||
index);
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
@@ -400,8 +400,8 @@ fn encode_module_item_paths(&ebml::writer ebml_w,
|
||||
|
||||
fn encode_item_paths(&ebml::writer ebml_w, &@ast::crate crate)
|
||||
-> vec[tup(str, uint)] {
|
||||
let vec[tup(str, uint)] index = vec();
|
||||
let vec[str] path = vec();
|
||||
let vec[tup(str, uint)] index = [];
|
||||
let vec[str] path = [];
|
||||
ebml::start_tag(ebml_w, tag_paths);
|
||||
encode_module_item_paths(ebml_w, crate.node.module, path, index);
|
||||
ebml::end_tag(ebml_w);
|
||||
@@ -413,7 +413,7 @@ fn encode_item_paths(&ebml::writer ebml_w, &@ast::crate crate)
|
||||
|
||||
fn encode_kind(&ebml::writer ebml_w, u8 c) {
|
||||
ebml::start_tag(ebml_w, tag_items_data_item_kind);
|
||||
ebml_w.writer.write(vec(c));
|
||||
ebml_w.writer.write([c]);
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ fn encode_tag_variant_info(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
|
||||
&mutable vec[tup(int, uint)] index,
|
||||
&vec[ast::ty_param] ty_params) {
|
||||
for (ast::variant variant in variants) {
|
||||
index += vec(tup(variant.node.id._1, ebml_w.writer.tell()));
|
||||
index += [tup(variant.node.id._1, ebml_w.writer.tell())];
|
||||
|
||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||
encode_def_id(ebml_w, variant.node.id);
|
||||
@@ -549,7 +549,7 @@ fn encode_info_for_item(@trans::crate_ctxt cx, &ebml::writer ebml_w,
|
||||
encode_symbol(cx, ebml_w, odid.ctor);
|
||||
ebml::end_tag(ebml_w);
|
||||
|
||||
index += vec(tup(odid.ty._1, ebml_w.writer.tell()));
|
||||
index += [tup(odid.ty._1, ebml_w.writer.tell())];
|
||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||
encode_def_id(ebml_w, odid.ty);
|
||||
encode_kind(ebml_w, 'y' as u8);
|
||||
@@ -582,16 +582,16 @@ fn encode_info_for_native_item(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
|
||||
|
||||
fn encode_info_for_items(&@trans::crate_ctxt cx, &ebml::writer ebml_w)
|
||||
-> vec[tup(int, uint)] {
|
||||
let vec[tup(int, uint)] index = vec();
|
||||
let vec[tup(int, uint)] index = [];
|
||||
|
||||
ebml::start_tag(ebml_w, tag_items_data);
|
||||
for each (@tup(ast::def_id, @ast::item) kvp in cx.items.items()) {
|
||||
index += vec(tup(kvp._0._1, ebml_w.writer.tell()));
|
||||
index += [tup(kvp._0._1, ebml_w.writer.tell())];
|
||||
encode_info_for_item(cx, ebml_w, kvp._1, index);
|
||||
}
|
||||
for each (@tup(ast::def_id, @ast::native_item) kvp in
|
||||
cx.native_items.items()) {
|
||||
index += vec(tup(kvp._0._1, ebml_w.writer.tell()));
|
||||
index += [tup(kvp._0._1, ebml_w.writer.tell())];
|
||||
encode_info_for_native_item(cx, ebml_w, kvp._1);
|
||||
}
|
||||
ebml::end_tag(ebml_w);
|
||||
@@ -618,15 +618,15 @@ fn hash_path(&str s) -> uint {
|
||||
|
||||
fn create_index[T](&vec[tup(T, uint)] index, fn(&T) -> uint hash_fn)
|
||||
-> vec[vec[tup(T, uint)]] {
|
||||
let vec[vec[tup(T, uint)]] buckets = vec();
|
||||
let vec[vec[tup(T, uint)]] buckets = [];
|
||||
for each (uint i in _uint::range(0u, 256u)) {
|
||||
let vec[tup(T, uint)] bucket = vec();
|
||||
buckets += vec(bucket);
|
||||
let vec[tup(T, uint)] bucket = [];
|
||||
buckets += [bucket];
|
||||
}
|
||||
|
||||
for (tup(T, uint) elt in index) {
|
||||
auto h = hash_fn(elt._0);
|
||||
buckets.(h % 256u) += vec(elt);
|
||||
buckets.(h % 256u) += [elt];
|
||||
}
|
||||
|
||||
ret buckets;
|
||||
@@ -638,10 +638,10 @@ fn encode_index[T](&ebml::writer ebml_w, &vec[vec[tup(T, uint)]] buckets,
|
||||
|
||||
ebml::start_tag(ebml_w, tag_index);
|
||||
|
||||
let vec[uint] bucket_locs = vec();
|
||||
let vec[uint] bucket_locs = [];
|
||||
ebml::start_tag(ebml_w, tag_index_buckets);
|
||||
for (vec[tup(T, uint)] bucket in buckets) {
|
||||
bucket_locs += vec(ebml_w.writer.tell());
|
||||
bucket_locs += [ebml_w.writer.tell()];
|
||||
|
||||
ebml::start_tag(ebml_w, tag_index_buckets_bucket);
|
||||
for (tup(T, uint) elt in bucket) {
|
||||
@@ -698,7 +698,7 @@ fn encode_metadata(&@trans::crate_ctxt cx, &@ast::crate crate)
|
||||
|
||||
// Pad this, since something (LLVM, presumably) is cutting off the
|
||||
// remaining % 4 bytes.
|
||||
buf_w.write(vec(0u8, 0u8, 0u8, 0u8));
|
||||
buf_w.write([0u8, 0u8, 0u8, 0u8]);
|
||||
|
||||
ret C_postr(string_w.get_str());
|
||||
}
|
||||
@@ -709,7 +709,7 @@ fn write_metadata(&@trans::crate_ctxt cx, &@ast::crate crate) {
|
||||
llmeta = encode_metadata(cx, crate);
|
||||
}
|
||||
|
||||
auto llconst = trans::C_struct(vec(llmeta));
|
||||
auto llconst = trans::C_struct([llmeta]);
|
||||
auto llglobal = llvm::LLVMAddGlobal(cx.llmod, trans::val_ty(llconst),
|
||||
_str::buf("rust_metadata"));
|
||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||
|
||||
@@ -253,7 +253,7 @@ fn pop_env_for_item(@mutable list[scope] sc, &@ast::item i) {
|
||||
}
|
||||
|
||||
fn push_env_for_method(@mutable list[scope] sc, &@ast::method m) {
|
||||
let vec[ast::ty_param] tp = vec();
|
||||
let vec[ast::ty_param] tp = [];
|
||||
let @ast::item i = @rec(node=ast::item_fn(m.node.ident,
|
||||
m.node.meth,
|
||||
tp,
|
||||
@@ -686,7 +686,7 @@ fn lookup_in_mod(&env e, def m, &ident id, namespace ns, dir dr)
|
||||
if (defid._0 != ast::local_crate) { // Not in this crate
|
||||
auto cached = e.ext_cache.find(tup(defid,id,ns));
|
||||
if (!option::is_none(cached)) { ret cached; }
|
||||
auto path = vec(id);
|
||||
auto path = [id];
|
||||
if (defid._1 != -1) {
|
||||
path = e.ext_map.get(defid) + path;
|
||||
}
|
||||
|
||||
+464
-464
@@ -193,7 +193,7 @@ fn sep() -> str {
|
||||
}
|
||||
|
||||
fn extend_path(@local_ctxt cx, &str name) -> @local_ctxt {
|
||||
ret @rec(path = cx.path + vec(name) with *cx);
|
||||
ret @rec(path = cx.path + [name] with *cx);
|
||||
}
|
||||
|
||||
fn path_name(&vec[str] path) -> str {
|
||||
@@ -341,8 +341,8 @@ fn T_fn(vec[TypeRef] inputs, TypeRef output) -> TypeRef {
|
||||
}
|
||||
|
||||
fn T_fn_pair(&type_names tn, TypeRef tfn) -> TypeRef {
|
||||
ret T_struct(vec(T_ptr(tfn),
|
||||
T_opaque_closure_ptr(tn)));
|
||||
ret T_struct([T_ptr(tfn),
|
||||
T_opaque_closure_ptr(tn)]);
|
||||
}
|
||||
|
||||
fn T_ptr(TypeRef t) -> TypeRef {
|
||||
@@ -365,7 +365,7 @@ fn T_task(&type_names tn) -> TypeRef {
|
||||
ret tn.get_type(s);
|
||||
}
|
||||
|
||||
auto t = T_struct(vec(T_int(), // Refcount
|
||||
auto t = T_struct([T_int(), // Refcount
|
||||
T_int(), // Delegate pointer
|
||||
T_int(), // Stack segment pointer
|
||||
T_int(), // Runtime SP
|
||||
@@ -373,7 +373,7 @@ fn T_task(&type_names tn) -> TypeRef {
|
||||
T_int(), // GC chain
|
||||
T_int(), // Domain pointer
|
||||
T_int() // Crate cache pointer
|
||||
));
|
||||
]);
|
||||
tn.associate(s, t);
|
||||
ret t;
|
||||
}
|
||||
@@ -426,19 +426,19 @@ fn T_tydesc(&type_names tn) -> TypeRef {
|
||||
auto abs_tydesc = llvm::LLVMResolveTypeHandle(th.llth);
|
||||
auto tydescpp = T_ptr(T_ptr(abs_tydesc));
|
||||
auto pvoid = T_ptr(T_i8());
|
||||
auto glue_fn_ty = T_ptr(T_fn(vec(T_ptr(T_nil()),
|
||||
auto glue_fn_ty = T_ptr(T_fn([T_ptr(T_nil()),
|
||||
T_taskptr(tn),
|
||||
T_ptr(T_nil()),
|
||||
tydescpp,
|
||||
pvoid), T_void()));
|
||||
auto cmp_glue_fn_ty = T_ptr(T_fn(vec(T_ptr(T_i1()),
|
||||
pvoid], T_void()));
|
||||
auto cmp_glue_fn_ty = T_ptr(T_fn([T_ptr(T_i1()),
|
||||
T_taskptr(tn),
|
||||
T_ptr(T_nil()),
|
||||
tydescpp,
|
||||
pvoid,
|
||||
pvoid,
|
||||
T_i8()), T_void()));
|
||||
auto tydesc = T_struct(vec(tydescpp, // first_param
|
||||
T_i8()], T_void()));
|
||||
auto tydesc = T_struct([tydescpp, // first_param
|
||||
T_int(), // size
|
||||
T_int(), // align
|
||||
glue_fn_ty, // take_glue
|
||||
@@ -448,7 +448,7 @@ fn T_tydesc(&type_names tn) -> TypeRef {
|
||||
glue_fn_ty, // mark_glue
|
||||
glue_fn_ty, // obj_drop_glue
|
||||
glue_fn_ty, // is_stateful
|
||||
cmp_glue_fn_ty)); // cmp_glue
|
||||
cmp_glue_fn_ty]); // cmp_glue
|
||||
|
||||
llvm::LLVMRefineType(abs_tydesc, tydesc);
|
||||
auto t = llvm::LLVMResolveTypeHandle(th.llth);
|
||||
@@ -462,12 +462,12 @@ fn T_array(TypeRef t, uint n) -> TypeRef {
|
||||
}
|
||||
|
||||
fn T_vec(TypeRef t) -> TypeRef {
|
||||
ret T_struct(vec(T_int(), // Refcount
|
||||
ret T_struct([T_int(), // Refcount
|
||||
T_int(), // Alloc
|
||||
T_int(), // Fill
|
||||
T_int(), // Pad
|
||||
T_array(t, 1u) // Body elements
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
fn T_opaque_vec_ptr() -> TypeRef {
|
||||
@@ -479,15 +479,15 @@ fn T_str() -> TypeRef {
|
||||
}
|
||||
|
||||
fn T_box(TypeRef t) -> TypeRef {
|
||||
ret T_struct(vec(T_int(), t));
|
||||
ret T_struct([T_int(), t]);
|
||||
}
|
||||
|
||||
fn T_port(TypeRef t) -> TypeRef {
|
||||
ret T_struct(vec(T_int())); // Refcount
|
||||
ret T_struct([T_int()]); // Refcount
|
||||
}
|
||||
|
||||
fn T_chan(TypeRef t) -> TypeRef {
|
||||
ret T_struct(vec(T_int())); // Refcount
|
||||
ret T_struct([T_int()]); // Refcount
|
||||
}
|
||||
|
||||
fn T_crate(&type_names tn) -> TypeRef {
|
||||
@@ -496,7 +496,7 @@ fn T_crate(&type_names tn) -> TypeRef {
|
||||
ret tn.get_type(s);
|
||||
}
|
||||
|
||||
auto t = T_struct(vec(T_int(), // ptrdiff_t image_base_off
|
||||
auto t = T_struct([T_int(), // ptrdiff_t image_base_off
|
||||
T_int(), // uintptr_t self_addr
|
||||
T_int(), // ptrdiff_t debug_abbrev_off
|
||||
T_int(), // size_t debug_abbrev_sz
|
||||
@@ -511,7 +511,7 @@ fn T_crate(&type_names tn) -> TypeRef {
|
||||
T_int(), // int n_c_syms
|
||||
T_int(), // int n_libs
|
||||
T_int() // uintptr_t abi_tag
|
||||
));
|
||||
]);
|
||||
tn.associate(s, t);
|
||||
ret t;
|
||||
}
|
||||
@@ -544,10 +544,10 @@ fn T_closure_ptr(&type_names tn,
|
||||
// NB: keep this in sync with code in trans_bind; we're making
|
||||
// an LLVM typeref structure that has the same "shape" as the ty::t
|
||||
// it constructs.
|
||||
ret T_ptr(T_box(T_struct(vec(T_ptr(T_tydesc(tn)),
|
||||
ret T_ptr(T_box(T_struct([T_ptr(T_tydesc(tn)),
|
||||
lltarget_ty,
|
||||
llbindings_ty,
|
||||
T_captured_tydescs(tn, n_ty_params))
|
||||
T_captured_tydescs(tn, n_ty_params)]
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -556,8 +556,8 @@ fn T_opaque_closure_ptr(&type_names tn) -> TypeRef {
|
||||
if (tn.name_has_type(s)) {
|
||||
ret tn.get_type(s);
|
||||
}
|
||||
auto t = T_closure_ptr(tn, T_struct(vec(T_ptr(T_nil()),
|
||||
T_ptr(T_nil()))),
|
||||
auto t = T_closure_ptr(tn, T_struct([T_ptr(T_nil()),
|
||||
T_ptr(T_nil())]),
|
||||
T_nil(),
|
||||
0u);
|
||||
tn.associate(s, t);
|
||||
@@ -572,9 +572,9 @@ fn T_tag(&type_names tn, uint size) -> TypeRef {
|
||||
|
||||
auto t;
|
||||
if (size == 0u) {
|
||||
t = T_struct(vec(T_int()));
|
||||
t = T_struct([T_int()]);
|
||||
} else {
|
||||
t = T_struct(vec(T_int(), T_array(T_i8(), size)));
|
||||
t = T_struct([T_int(), T_array(T_i8(), size)]);
|
||||
}
|
||||
|
||||
tn.associate(s, t);
|
||||
@@ -586,7 +586,7 @@ fn T_opaque_tag(&type_names tn) -> TypeRef {
|
||||
if (tn.name_has_type(s)) {
|
||||
ret tn.get_type(s);
|
||||
}
|
||||
auto t = T_struct(vec(T_int(), T_i8()));
|
||||
auto t = T_struct([T_int(), T_i8()]);
|
||||
tn.associate(s, t);
|
||||
ret t;
|
||||
}
|
||||
@@ -603,8 +603,8 @@ fn T_obj_ptr(&type_names tn, uint n_captured_tydescs) -> TypeRef {
|
||||
// This function is not publicly exposed because it returns an incomplete
|
||||
// type. The dynamically-sized fields follow the captured tydescs.
|
||||
fn T_obj(type_names tn, uint n_captured_tydescs) -> TypeRef {
|
||||
ret T_struct(vec(T_ptr(T_tydesc(tn)),
|
||||
T_captured_tydescs(tn, n_captured_tydescs)));
|
||||
ret T_struct([T_ptr(T_tydesc(tn)),
|
||||
T_captured_tydescs(tn, n_captured_tydescs)]);
|
||||
}
|
||||
|
||||
ret T_ptr(T_box(T_obj(tn, n_captured_tydescs)));
|
||||
@@ -635,11 +635,11 @@ fn type_of(&@crate_ctxt cx, &ty::t t) -> TypeRef {
|
||||
|
||||
fn type_of_explicit_args(&@crate_ctxt cx,
|
||||
&vec[ty::arg] inputs) -> vec[TypeRef] {
|
||||
let vec[TypeRef] atys = vec();
|
||||
let vec[TypeRef] atys = [];
|
||||
for (ty::arg arg in inputs) {
|
||||
if (ty::type_has_dynamic_size(cx.tcx, arg.ty)) {
|
||||
assert (arg.mode == ty::mo_alias);
|
||||
atys += vec(T_typaram_ptr(cx.tn));
|
||||
atys += [T_typaram_ptr(cx.tn)];
|
||||
} else {
|
||||
let TypeRef t;
|
||||
alt (arg.mode) {
|
||||
@@ -650,7 +650,7 @@ fn type_of_explicit_args(&@crate_ctxt cx,
|
||||
t = type_of_inner(cx, arg.ty);
|
||||
}
|
||||
}
|
||||
atys += vec(t);
|
||||
atys += [t];
|
||||
}
|
||||
}
|
||||
ret atys;
|
||||
@@ -669,26 +669,26 @@ fn type_of_fn_full(&@crate_ctxt cx,
|
||||
&vec[ty::arg] inputs,
|
||||
&ty::t output,
|
||||
uint ty_param_count) -> TypeRef {
|
||||
let vec[TypeRef] atys = vec();
|
||||
let vec[TypeRef] atys = [];
|
||||
|
||||
// Arg 0: Output pointer.
|
||||
if (ty::type_has_dynamic_size(cx.tcx, output)) {
|
||||
atys += vec(T_typaram_ptr(cx.tn));
|
||||
atys += [T_typaram_ptr(cx.tn)];
|
||||
} else {
|
||||
atys += vec(T_ptr(type_of_inner(cx, output)));
|
||||
atys += [T_ptr(type_of_inner(cx, output))];
|
||||
}
|
||||
|
||||
// Arg 1: task pointer.
|
||||
atys += vec(T_taskptr(cx.tn));
|
||||
atys += [T_taskptr(cx.tn)];
|
||||
|
||||
// Arg 2: Env (closure-bindings / self-obj)
|
||||
alt (obj_self) {
|
||||
case (some[TypeRef](?t)) {
|
||||
assert (t as int != 0);
|
||||
atys += vec(t);
|
||||
atys += [t];
|
||||
}
|
||||
case (_) {
|
||||
atys += vec(T_opaque_closure_ptr(cx.tn));
|
||||
atys += [T_opaque_closure_ptr(cx.tn)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ fn type_of_fn_full(&@crate_ctxt cx,
|
||||
if (obj_self == none[TypeRef]) {
|
||||
auto i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
atys += vec(T_ptr(T_tydesc(cx.tn)));
|
||||
atys += [T_ptr(T_tydesc(cx.tn))];
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
@@ -706,11 +706,11 @@ fn type_of_fn_full(&@crate_ctxt cx,
|
||||
// *input* type of the function we're given as our iter-block
|
||||
// argument.
|
||||
atys +=
|
||||
vec(T_fn_pair(cx.tn,
|
||||
[T_fn_pair(cx.tn,
|
||||
type_of_fn_full(cx, ast::proto_fn, none[TypeRef],
|
||||
vec(rec(mode=ty::mo_alias,
|
||||
ty=output)),
|
||||
ty::mk_nil(cx.tcx), 0u)));
|
||||
[rec(mode=ty::mo_alias,
|
||||
ty=output)],
|
||||
ty::mk_nil(cx.tcx), 0u))];
|
||||
}
|
||||
|
||||
// ... then explicit args.
|
||||
@@ -732,13 +732,13 @@ fn type_of_native_fn(&@crate_ctxt cx, ast::native_abi abi,
|
||||
&vec[ty::arg] inputs,
|
||||
&ty::t output,
|
||||
uint ty_param_count) -> TypeRef {
|
||||
let vec[TypeRef] atys = vec();
|
||||
let vec[TypeRef] atys = [];
|
||||
if (abi == ast::native_abi_rust) {
|
||||
atys += vec(T_taskptr(cx.tn));
|
||||
atys += [T_taskptr(cx.tn)];
|
||||
auto t = ty::ty_native_fn(abi, inputs, output);
|
||||
auto i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
atys += vec(T_ptr(T_tydesc(cx.tn)));
|
||||
atys += [T_ptr(T_tydesc(cx.tn))];
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
@@ -798,16 +798,16 @@ fn type_of_inner(&@crate_ctxt cx, &ty::t t) -> TypeRef {
|
||||
llty = T_ptr(T_chan(type_of_inner(cx, t)));
|
||||
}
|
||||
case (ty::ty_tup(?elts)) {
|
||||
let vec[TypeRef] tys = vec();
|
||||
let vec[TypeRef] tys = [];
|
||||
for (ty::mt elt in elts) {
|
||||
tys += vec(type_of_inner(cx, elt.ty));
|
||||
tys += [type_of_inner(cx, elt.ty)];
|
||||
}
|
||||
llty = T_struct(tys);
|
||||
}
|
||||
case (ty::ty_rec(?fields)) {
|
||||
let vec[TypeRef] tys = vec();
|
||||
let vec[TypeRef] tys = [];
|
||||
for (ty::field f in fields) {
|
||||
tys += vec(type_of_inner(cx, f.mt.ty));
|
||||
tys += [type_of_inner(cx, f.mt.ty)];
|
||||
}
|
||||
llty = T_struct(tys);
|
||||
}
|
||||
@@ -822,17 +822,17 @@ fn type_of_inner(&@crate_ctxt cx, &ty::t t) -> TypeRef {
|
||||
auto th = mk_type_handle();
|
||||
auto self_ty = llvm::LLVMResolveTypeHandle(th.llth);
|
||||
|
||||
let vec[TypeRef] mtys = vec(T_ptr(T_i8()));
|
||||
let vec[TypeRef] mtys = [T_ptr(T_i8())];
|
||||
for (ty::method m in meths) {
|
||||
let TypeRef mty =
|
||||
type_of_fn_full(cx, m.proto,
|
||||
some[TypeRef](self_ty),
|
||||
m.inputs, m.output, 0u);
|
||||
mtys += vec(T_ptr(mty));
|
||||
mtys += [T_ptr(mty)];
|
||||
}
|
||||
let TypeRef vtbl = T_struct(mtys);
|
||||
let TypeRef pair = T_struct(vec(T_ptr(vtbl),
|
||||
T_opaque_obj_ptr(cx.tn)));
|
||||
let TypeRef pair = T_struct([T_ptr(vtbl),
|
||||
T_opaque_obj_ptr(cx.tn)]);
|
||||
|
||||
auto abs_pair = llvm::LLVMResolveTypeHandle(th.llth);
|
||||
llvm::LLVMRefineType(abs_pair, pair);
|
||||
@@ -917,7 +917,7 @@ fn sanitize(&str s) -> str {
|
||||
if (c != 10u8 && c != ('}' as u8) && c != (')' as u8) &&
|
||||
c != (' ' as u8) && c != ('\t' as u8) &&
|
||||
c != (';' as u8)) {
|
||||
auto v = vec(c);
|
||||
auto v = [c];
|
||||
result += _str::from_bytes(v);
|
||||
}
|
||||
}
|
||||
@@ -987,12 +987,12 @@ fn C_cstr(&@crate_ctxt cx, &str s) -> ValueRef {
|
||||
// A rust boxed-and-length-annotated string.
|
||||
fn C_str(&@crate_ctxt cx, &str s) -> ValueRef {
|
||||
auto len = _str::byte_len(s);
|
||||
auto box = C_struct(vec(C_int(abi::const_refcount as int),
|
||||
auto box = C_struct([C_int(abi::const_refcount as int),
|
||||
C_int(len + 1u as int), // 'alloc'
|
||||
C_int(len + 1u as int), // 'fill'
|
||||
C_int(0), // 'pad'
|
||||
llvm::LLVMConstString(_str::buf(s),
|
||||
len, False)));
|
||||
len, False)]);
|
||||
auto g = llvm::LLVMAddGlobal(cx.llmod, val_ty(box),
|
||||
_str::buf(cx.names.next("str")));
|
||||
llvm::LLVMSetInitializer(g, box);
|
||||
@@ -1004,9 +1004,9 @@ fn C_str(&@crate_ctxt cx, &str s) -> ValueRef {
|
||||
|
||||
fn C_zero_byte_arr(uint size) -> ValueRef {
|
||||
auto i = 0u;
|
||||
let vec[ValueRef] elts = vec();
|
||||
let vec[ValueRef] elts = [];
|
||||
while (i < size) {
|
||||
elts += vec(C_u8(0u));
|
||||
elts += [C_u8(0u)];
|
||||
i += 1u;
|
||||
}
|
||||
ret llvm::LLVMConstArray(T_i8(), _vec::buf[ValueRef](elts),
|
||||
@@ -1050,7 +1050,7 @@ fn decl_internal_fastcall_fn(ModuleRef llmod,
|
||||
}
|
||||
|
||||
fn decl_glue(ModuleRef llmod, type_names tn, &str s) -> ValueRef {
|
||||
ret decl_cdecl_fn(llmod, s, T_fn(vec(T_taskptr(tn)), T_void()));
|
||||
ret decl_cdecl_fn(llmod, s, T_fn([T_taskptr(tn)], T_void()));
|
||||
}
|
||||
|
||||
fn decl_native_glue(ModuleRef llmod, &type_names tn,
|
||||
@@ -1068,10 +1068,10 @@ fn decl_native_glue(ModuleRef llmod, &type_names tn,
|
||||
// to call them directly, once we have a calling convention worked out.
|
||||
let int n = _n as int;
|
||||
let str s = abi::native_glue_name(n, ngt);
|
||||
let vec[TypeRef] args = vec(T_int()); // callee
|
||||
let vec[TypeRef] args = [T_int()]; // callee
|
||||
|
||||
if (!pass_task) {
|
||||
args += vec(T_int()); // taskptr, will not be passed
|
||||
args += [T_int()]; // taskptr, will not be passed
|
||||
}
|
||||
|
||||
args += _vec::init_elt[TypeRef](T_int(), n as uint);
|
||||
@@ -1123,14 +1123,14 @@ fn trans_native_call(&builder b, @glue_fns glues, ValueRef lltaskptr,
|
||||
} else {
|
||||
llglue = glues.native_glues_cdecl.(n);
|
||||
}
|
||||
let vec[ValueRef] call_args = vec(llnative);
|
||||
let vec[ValueRef] call_args = [llnative];
|
||||
|
||||
if (!pass_task) {
|
||||
call_args += vec(lltaskptr);
|
||||
call_args += [lltaskptr];
|
||||
}
|
||||
|
||||
for (ValueRef a in args) {
|
||||
call_args += vec(b.ZExtOrBitCast(a, T_int()));
|
||||
call_args += [b.ZExtOrBitCast(a, T_int())];
|
||||
}
|
||||
|
||||
ret b.FastCall(llglue, call_args);
|
||||
@@ -1138,8 +1138,8 @@ fn trans_native_call(&builder b, @glue_fns glues, ValueRef lltaskptr,
|
||||
|
||||
fn trans_non_gc_free(&@block_ctxt cx, ValueRef v) -> result {
|
||||
cx.build.Call(cx.fcx.lcx.ccx.upcalls.free,
|
||||
vec(cx.fcx.lltaskptr,
|
||||
cx.build.PointerCast(v, T_ptr(T_i8())), C_int(0)));
|
||||
[cx.fcx.lltaskptr,
|
||||
cx.build.PointerCast(v, T_ptr(T_i8())), C_int(0)]);
|
||||
ret res(cx, C_int(0));
|
||||
}
|
||||
|
||||
@@ -1322,16 +1322,16 @@ fn align_elements(&@block_ctxt cx, &vec[ty::t] elts) -> result {
|
||||
ret res(szptr.bcx, szptr.bcx.build.Load(szptr.val));
|
||||
}
|
||||
case (ty::ty_tup(?elts)) {
|
||||
let vec[ty::t] tys = vec();
|
||||
let vec[ty::t] tys = [];
|
||||
for (ty::mt mt in elts) {
|
||||
tys += vec(mt.ty);
|
||||
tys += [mt.ty];
|
||||
}
|
||||
ret align_elements(cx, tys);
|
||||
}
|
||||
case (ty::ty_rec(?flds)) {
|
||||
let vec[ty::t] tys = vec();
|
||||
let vec[ty::t] tys = [];
|
||||
for (ty::field f in flds) {
|
||||
tys += vec(f.mt.ty);
|
||||
tys += [f.mt.ty];
|
||||
}
|
||||
ret align_elements(cx, tys);
|
||||
}
|
||||
@@ -1346,13 +1346,13 @@ fn align_elements(&@block_ctxt cx, &vec[ty::t] elts) -> result {
|
||||
for (variant_info variant in variants) {
|
||||
// Perform type substitution on the raw argument types.
|
||||
let vec[ty::t] raw_tys = variant.args;
|
||||
let vec[ty::t] tys = vec();
|
||||
let vec[ty::t] tys = [];
|
||||
for (ty::t raw_ty in raw_tys) {
|
||||
auto t = ty::bind_params_in_type(cx.fcx.lcx.ccx.tcx,
|
||||
raw_ty);
|
||||
t = ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, tps,
|
||||
t);
|
||||
tys += vec(t);
|
||||
tys += [t];
|
||||
}
|
||||
|
||||
auto rslt = align_elements(bcx, tys);
|
||||
@@ -1417,9 +1417,9 @@ fn GEP_tup_like(&@block_ctxt cx, &ty::t t,
|
||||
// It might be a static-known type. Handle this.
|
||||
|
||||
if (! ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
let vec[ValueRef] v = vec();
|
||||
let vec[ValueRef] v = [];
|
||||
for (int i in ixs) {
|
||||
v += vec(C_int(i));
|
||||
v += [C_int(i)];
|
||||
}
|
||||
ret res(cx, cx.build.GEP(base, v));
|
||||
}
|
||||
@@ -1463,7 +1463,7 @@ fn split_type(&@crate_ctxt ccx, &ty::t t, &vec[int] ixs, uint n)
|
||||
assert (n < len);
|
||||
|
||||
let int ix = ixs.(n);
|
||||
let vec[ty::t] prefix = vec();
|
||||
let vec[ty::t] prefix = [];
|
||||
let int i = 0;
|
||||
while (i < ix) {
|
||||
_vec::push[ty::t](prefix,
|
||||
@@ -1497,7 +1497,7 @@ fn split_type(&@crate_ctxt ccx, &ty::t t, &vec[int] ixs, uint n)
|
||||
auto sz = size_of(bcx, prefix_ty);
|
||||
bcx = sz.bcx;
|
||||
auto raw = bcx.build.PointerCast(base, T_ptr(T_i8()));
|
||||
auto bumped = bcx.build.GEP(raw, vec(sz.val));
|
||||
auto bumped = bcx.build.GEP(raw, [sz.val]);
|
||||
|
||||
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, s.target)) {
|
||||
ret res(bcx, bumped);
|
||||
@@ -1525,12 +1525,12 @@ fn GEP_tag(@block_ctxt cx,
|
||||
auto arg_tys = variant.args;
|
||||
auto elem_ty = ty::mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
|
||||
auto i = 0;
|
||||
let vec[ty::t] true_arg_tys = vec();
|
||||
let vec[ty::t] true_arg_tys = [];
|
||||
for (ty::t aty in arg_tys) {
|
||||
auto arg_ty = ty::bind_params_in_type(cx.fcx.lcx.ccx.tcx, aty);
|
||||
arg_ty = ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs,
|
||||
arg_ty);
|
||||
true_arg_tys += vec(arg_ty);
|
||||
true_arg_tys += [arg_ty];
|
||||
if (i == ix) {
|
||||
elem_ty = arg_ty;
|
||||
}
|
||||
@@ -1551,7 +1551,7 @@ fn GEP_tag(@block_ctxt cx,
|
||||
}
|
||||
|
||||
// Do the GEP_tup_like().
|
||||
auto rslt = GEP_tup_like(cx, tup_ty, llunionptr, vec(0, ix));
|
||||
auto rslt = GEP_tup_like(cx, tup_ty, llunionptr, [0, ix]);
|
||||
|
||||
// Cast the result to the appropriate type, if necessary.
|
||||
auto val;
|
||||
@@ -1571,7 +1571,7 @@ fn trans_raw_malloc(&@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
|
||||
// FIXME: need a table to collect tydesc globals.
|
||||
auto tydesc = C_null(T_ptr(T_tydesc(cx.fcx.lcx.ccx.tn)));
|
||||
auto rval = cx.build.Call(cx.fcx.lcx.ccx.upcalls.malloc,
|
||||
vec(cx.fcx.lltaskptr, llsize, tydesc));
|
||||
[cx.fcx.lltaskptr, llsize, tydesc]);
|
||||
ret res(cx, cx.build.PointerCast(rval, llptr_ty));
|
||||
}
|
||||
|
||||
@@ -1579,7 +1579,7 @@ fn trans_malloc_boxed(&@block_ctxt cx, ty::t t) -> result {
|
||||
// Synthesize a fake box type structurally so we have something
|
||||
// to measure the size of.
|
||||
auto boxed_body = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
|
||||
vec(ty::mk_int(cx.fcx.lcx.ccx.tcx), t));
|
||||
[ty::mk_int(cx.fcx.lcx.ccx.tcx), t]);
|
||||
auto box_ptr = ty::mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
|
||||
auto sz = size_of(cx, boxed_body);
|
||||
auto llty = type_of(cx.fcx.lcx.ccx, box_ptr);
|
||||
@@ -1597,7 +1597,7 @@ fn field_of_tydesc(&@block_ctxt cx, &ty::t t, bool escapes, int field)
|
||||
auto ti = none[@tydesc_info];
|
||||
auto tydesc = get_tydesc(cx, t, escapes, ti);
|
||||
ret res(tydesc.bcx,
|
||||
tydesc.bcx.build.GEP(tydesc.val, vec(C_int(0), C_int(field))));
|
||||
tydesc.bcx.build.GEP(tydesc.val, [C_int(0), C_int(field)]));
|
||||
}
|
||||
|
||||
// Given a type containing ty params, build a vector containing a ValueRef for
|
||||
@@ -1606,8 +1606,8 @@ fn field_of_tydesc(&@block_ctxt cx, &ty::t t, bool escapes, int field)
|
||||
// constructing derived tydescs.
|
||||
fn linearize_ty_params(&@block_ctxt cx, &ty::t t) ->
|
||||
tup(vec[uint], vec[ValueRef]) {
|
||||
let vec[ValueRef] param_vals = vec();
|
||||
let vec[uint] param_defs = vec();
|
||||
let vec[ValueRef] param_vals = [];
|
||||
let vec[uint] param_defs = [];
|
||||
type rr = rec(@block_ctxt cx,
|
||||
mutable vec[ValueRef] vals,
|
||||
mutable vec[uint] defs);
|
||||
@@ -1622,8 +1622,8 @@ fn linearizer(@rr r, ty::t t) {
|
||||
}
|
||||
}
|
||||
if (!seen) {
|
||||
r.vals += vec(r.cx.fcx.lltydescs.(pid));
|
||||
r.defs += vec(pid);
|
||||
r.vals += [r.cx.fcx.lltydescs.(pid)];
|
||||
r.defs += [pid];
|
||||
}
|
||||
}
|
||||
case (_) { }
|
||||
@@ -1654,7 +1654,7 @@ fn trans_stack_local_derived_tydesc(&@block_ctxt cx, ValueRef llsz,
|
||||
|
||||
// Store a pointer to the rest of the descriptors.
|
||||
auto llrootfirstparam = cx.build.GEP(llmyroottydesc,
|
||||
vec(C_int(0), C_int(0)));
|
||||
[C_int(0), C_int(0)]);
|
||||
|
||||
auto llfirstparam;
|
||||
alt (llparamtydescs) {
|
||||
@@ -1663,16 +1663,16 @@ fn trans_stack_local_derived_tydesc(&@block_ctxt cx, ValueRef llsz,
|
||||
}
|
||||
case (some[ValueRef](?llparamtydescs)) {
|
||||
llfirstparam = cx.build.GEP(llparamtydescs,
|
||||
vec(C_int(0), C_int(0)));
|
||||
[C_int(0), C_int(0)]);
|
||||
}
|
||||
}
|
||||
cx.build.Store(llfirstparam,
|
||||
cx.build.GEP(llmyroottydesc, vec(C_int(0), C_int(0))));
|
||||
cx.build.GEP(llmyroottydesc, [C_int(0), C_int(0)]));
|
||||
|
||||
cx.build.Store(llsz,
|
||||
cx.build.GEP(llmyroottydesc, vec(C_int(0), C_int(1))));
|
||||
cx.build.GEP(llmyroottydesc, [C_int(0), C_int(1)]));
|
||||
cx.build.Store(llalign,
|
||||
cx.build.GEP(llmyroottydesc, vec(C_int(0), C_int(2))));
|
||||
cx.build.GEP(llmyroottydesc, [C_int(0), C_int(2)]));
|
||||
|
||||
ret llmyroottydesc;
|
||||
}
|
||||
@@ -1715,11 +1715,11 @@ fn get_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
|
||||
1u /* for root*/ + n_params));
|
||||
|
||||
auto i = 0;
|
||||
auto tdp = bcx.build.GEP(tydescs, vec(C_int(0), C_int(i)));
|
||||
auto tdp = bcx.build.GEP(tydescs, [C_int(0), C_int(i)]);
|
||||
bcx.build.Store(root, tdp);
|
||||
i += 1;
|
||||
for (ValueRef td in tys._1) {
|
||||
auto tdp = bcx.build.GEP(tydescs, vec(C_int(0), C_int(i)));
|
||||
auto tdp = bcx.build.GEP(tydescs, [C_int(0), C_int(i)]);
|
||||
bcx.build.Store(td, tdp);
|
||||
i += 1;
|
||||
}
|
||||
@@ -1727,12 +1727,12 @@ fn get_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
|
||||
auto lltydescsptr = bcx.build.PointerCast(tydescs,
|
||||
T_ptr(T_ptr(T_tydesc(bcx.fcx.lcx.ccx.tn))));
|
||||
auto td_val = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.get_type_desc,
|
||||
vec(bcx.fcx.lltaskptr,
|
||||
[bcx.fcx.lltaskptr,
|
||||
bcx.fcx.lcx.ccx.crate_ptr,
|
||||
sz.val,
|
||||
align.val,
|
||||
C_int((1u + n_params) as int),
|
||||
lltydescsptr));
|
||||
lltydescsptr]);
|
||||
v = td_val;
|
||||
} else {
|
||||
auto llparamtydescs_opt;
|
||||
@@ -1745,7 +1745,7 @@ fn get_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
|
||||
auto i = 0;
|
||||
for (ValueRef td in tys._1) {
|
||||
auto tdp = bcx.build.GEP(llparamtydescs,
|
||||
vec(C_int(0), C_int(i)));
|
||||
[C_int(0), C_int(i)]);
|
||||
bcx.build.Store(td, tdp);
|
||||
i += 1;
|
||||
}
|
||||
@@ -1777,7 +1777,7 @@ fn get_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
|
||||
}
|
||||
|
||||
// Otherwise, generate a tydesc if necessary, and return it.
|
||||
let vec[uint] tps = vec();
|
||||
let vec[uint] tps = [];
|
||||
auto info = get_static_tydesc(cx, t, tps);
|
||||
static_ti = some[@tydesc_info](info);
|
||||
ret res(cx, info.tydesc);
|
||||
@@ -1901,7 +1901,7 @@ fn make_generic_glue(&@local_ctxt cx,
|
||||
auto p = 0u;
|
||||
while (p < ty_param_count) {
|
||||
auto llparam = copy_args_bcx.build.GEP(lltyparams,
|
||||
vec(C_int(p as int)));
|
||||
[C_int(p as int)]);
|
||||
llparam = copy_args_bcx.build.Load(llparam);
|
||||
_vec::grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
|
||||
llparam);
|
||||
@@ -1977,7 +1977,7 @@ fn emit_tydescs(&@crate_ctxt ccx) {
|
||||
};
|
||||
|
||||
|
||||
auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))),
|
||||
auto tydesc = C_struct([C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))),
|
||||
ti.size,
|
||||
ti.align,
|
||||
take_glue, // take_glue
|
||||
@@ -1987,7 +1987,7 @@ fn emit_tydescs(&@crate_ctxt ccx) {
|
||||
C_null(glue_fn_ty), // mark_glue
|
||||
C_null(glue_fn_ty), // obj_drop_glue
|
||||
C_null(glue_fn_ty), // is_stateful
|
||||
cmp_glue)); // cmp_glue
|
||||
cmp_glue]); // cmp_glue
|
||||
|
||||
auto gvar = ti.tydesc;
|
||||
llvm::LLVMSetInitializer(gvar, tydesc);
|
||||
@@ -2014,8 +2014,8 @@ fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty::t t) {
|
||||
}
|
||||
|
||||
fn incr_refcnt_of_boxed(&@block_ctxt cx, ValueRef box_ptr) -> result {
|
||||
auto rc_ptr = cx.build.GEP(box_ptr, vec(C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)));
|
||||
auto rc_ptr = cx.build.GEP(box_ptr, [C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)]);
|
||||
auto rc = cx.build.Load(rc_ptr);
|
||||
|
||||
auto rc_adj_cx = new_sub_block_ctxt(cx, "rc++");
|
||||
@@ -2063,8 +2063,8 @@ fn hit_zero(&@block_ctxt cx, ValueRef v,
|
||||
fn hit_zero(&@block_ctxt cx, ValueRef v,
|
||||
ty::t body_ty) -> result {
|
||||
auto body = cx.build.GEP(v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
|
||||
auto body_val = load_if_immediate(cx, body, body_ty);
|
||||
auto res = drop_ty(cx, body_val, body_ty);
|
||||
@@ -2081,8 +2081,8 @@ fn hit_zero(&@block_ctxt cx, ValueRef v,
|
||||
case (ty::ty_port(_)) {
|
||||
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
|
||||
cx.build.Call(cx.fcx.lcx.ccx.upcalls.del_port,
|
||||
vec(cx.fcx.lltaskptr,
|
||||
cx.build.PointerCast(v, T_opaque_port_ptr())));
|
||||
[cx.fcx.lltaskptr,
|
||||
cx.build.PointerCast(v, T_opaque_port_ptr())]);
|
||||
ret res(cx, C_int(0));
|
||||
}
|
||||
auto v = cx.build.Load(v0);
|
||||
@@ -2095,8 +2095,8 @@ fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
|
||||
case (ty::ty_chan(_)) {
|
||||
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
|
||||
cx.build.Call(cx.fcx.lcx.ccx.upcalls.del_chan,
|
||||
vec(cx.fcx.lltaskptr,
|
||||
cx.build.PointerCast(v, T_opaque_chan_ptr())));
|
||||
[cx.fcx.lltaskptr,
|
||||
cx.build.PointerCast(v, T_opaque_chan_ptr())]);
|
||||
ret res(cx, C_int(0));
|
||||
}
|
||||
auto v = cx.build.Load(v0);
|
||||
@@ -2110,12 +2110,12 @@ fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
|
||||
fn hit_zero(&@block_ctxt cx, ValueRef b, ValueRef o) -> result {
|
||||
auto body =
|
||||
cx.build.GEP(b,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
auto tydescptr =
|
||||
cx.build.GEP(body,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_body_elt_tydesc)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_body_elt_tydesc)]);
|
||||
auto tydesc = cx.build.Load(tydescptr);
|
||||
|
||||
auto cx_ = maybe_call_dtor(cx, o);
|
||||
@@ -2131,8 +2131,8 @@ fn hit_zero(&@block_ctxt cx, ValueRef b, ValueRef o) -> result {
|
||||
}
|
||||
auto box_cell =
|
||||
cx.build.GEP(v0,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_box)]);
|
||||
|
||||
auto boxptr = cx.build.Load(box_cell);
|
||||
|
||||
@@ -2148,17 +2148,17 @@ fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
|
||||
// Call through the closure's own fields-drop glue first.
|
||||
auto body =
|
||||
cx.build.GEP(v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
auto bindings =
|
||||
cx.build.GEP(body,
|
||||
vec(C_int(0),
|
||||
C_int(abi::closure_elt_bindings)));
|
||||
[C_int(0),
|
||||
C_int(abi::closure_elt_bindings)]);
|
||||
|
||||
auto tydescptr =
|
||||
cx.build.GEP(body,
|
||||
vec(C_int(0),
|
||||
C_int(abi::closure_elt_tydesc)));
|
||||
[C_int(0),
|
||||
C_int(abi::closure_elt_tydesc)]);
|
||||
|
||||
auto ti = none[@tydesc_info];
|
||||
call_tydesc_glue_full(cx, bindings, cx.build.Load(tydescptr),
|
||||
@@ -2171,8 +2171,8 @@ fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
|
||||
}
|
||||
auto box_cell =
|
||||
cx.build.GEP(v0,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
|
||||
auto boxptr = cx.build.Load(box_cell);
|
||||
|
||||
@@ -2216,8 +2216,8 @@ fn decr_refcnt_and_if_zero(&@block_ctxt cx,
|
||||
|
||||
|
||||
auto rc_ptr = load_rc_cx.build.GEP(box_ptr,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)]);
|
||||
|
||||
auto rc = load_rc_cx.build.Load(rc_ptr);
|
||||
auto const_test =
|
||||
@@ -2234,11 +2234,11 @@ fn decr_refcnt_and_if_zero(&@block_ctxt cx,
|
||||
inner_res.bcx.build.Br(next_cx.llbb);
|
||||
|
||||
auto phi = next_cx.build.Phi(t_else,
|
||||
vec(v_else, v_else, v_else, inner_res.val),
|
||||
vec(cx.llbb,
|
||||
[v_else, v_else, v_else, inner_res.val],
|
||||
[cx.llbb,
|
||||
load_rc_cx.llbb,
|
||||
rc_adj_cx.llbb,
|
||||
inner_res.bcx.llbb));
|
||||
inner_res.bcx.llbb]);
|
||||
|
||||
ret res(next_cx, phi);
|
||||
}
|
||||
@@ -2263,8 +2263,8 @@ fn make_cmp_glue(&@block_ctxt cx,
|
||||
make_scalar_cmp_glue(cx, lhs, rhs, t, llop);
|
||||
|
||||
} else if (ty::type_is_box(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
lhs = cx.build.GEP(lhs, vec(C_int(0), C_int(abi::box_rc_field_body)));
|
||||
rhs = cx.build.GEP(rhs, vec(C_int(0), C_int(abi::box_rc_field_body)));
|
||||
lhs = cx.build.GEP(lhs, [C_int(0), C_int(abi::box_rc_field_body)]);
|
||||
rhs = cx.build.GEP(rhs, [C_int(0), C_int(abi::box_rc_field_body)]);
|
||||
auto t_inner = alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
case (ty::ty_box(?ti)) { ti.ty }
|
||||
};
|
||||
@@ -2378,7 +2378,7 @@ fn inner(@block_ctxt last_cx,
|
||||
auto rhs_p0 = vec_p0(r.bcx, rhs);
|
||||
auto min_len = umin(r.bcx, vec_fill(r.bcx, lhs),
|
||||
vec_fill(r.bcx, rhs));
|
||||
auto rhs_lim = r.bcx.build.GEP(rhs_p0, vec(min_len));
|
||||
auto rhs_lim = r.bcx.build.GEP(rhs_p0, [min_len]);
|
||||
auto elt_ty = ty::sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
|
||||
r = size_of(r.bcx, elt_ty);
|
||||
r = iter_sequence_raw(r.bcx, lhs_p0, rhs_p0, rhs_lim, r.val,
|
||||
@@ -2452,8 +2452,8 @@ fn make_fp_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
|
||||
llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_le), le_cx.llbb);
|
||||
|
||||
auto last_result =
|
||||
last_cx.build.Phi(T_i1(), vec(eq_result, lt_result, le_result),
|
||||
vec(eq_cx.llbb, lt_cx.llbb, le_cx.llbb));
|
||||
last_cx.build.Phi(T_i1(), [eq_result, lt_result, le_result],
|
||||
[eq_cx.llbb, lt_cx.llbb, le_cx.llbb]);
|
||||
last_cx.build.Store(last_result, cx.fcx.llretptr);
|
||||
last_cx.build.RetVoid();
|
||||
}
|
||||
@@ -2494,8 +2494,8 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
|
||||
llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_le), le_cx.llbb);
|
||||
|
||||
auto last_result =
|
||||
last_cx.build.Phi(T_i1(), vec(eq_result, lt_result, le_result),
|
||||
vec(eq_cx.llbb, lt_cx.llbb, le_cx.llbb));
|
||||
last_cx.build.Phi(T_i1(), [eq_result, lt_result, le_result],
|
||||
[eq_cx.llbb, lt_cx.llbb, le_cx.llbb]);
|
||||
ret res(last_cx, last_result);
|
||||
}
|
||||
|
||||
@@ -2522,17 +2522,17 @@ fn tag_variants(&@crate_ctxt cx, &ast::def_id id) -> vec[variant_info] {
|
||||
assert (cx.items.contains_key(id));
|
||||
alt (cx.items.get(id).node) {
|
||||
case (ast::item_tag(_, ?variants, _, _, _)) {
|
||||
let vec[variant_info] result = vec();
|
||||
let vec[variant_info] result = [];
|
||||
for (ast::variant variant in variants) {
|
||||
auto ctor_ty = node_ann_type(cx, variant.node.ann);
|
||||
let vec[ty::t] arg_tys = vec();
|
||||
let vec[ty::t] arg_tys = [];
|
||||
if (_vec::len[ast::variant_arg](variant.node.args) > 0u) {
|
||||
for (ty::arg a in ty::ty_fn_args(cx.tcx, ctor_ty)) {
|
||||
arg_tys += vec(a.ty);
|
||||
arg_tys += [a.ty];
|
||||
}
|
||||
}
|
||||
auto did = variant.node.id;
|
||||
result += vec(rec(args=arg_tys, ctor_ty=ctor_ty, id=did));
|
||||
result += [rec(args=arg_tys, ctor_ty=ctor_ty, id=did)];
|
||||
}
|
||||
ret result;
|
||||
}
|
||||
@@ -2616,9 +2616,9 @@ fn iter_boxpp(@block_ctxt cx,
|
||||
case (ty::ty_tup(?args)) {
|
||||
let int i = 0;
|
||||
for (ty::mt arg in args) {
|
||||
r = GEP_tup_like(r.bcx, t, av, vec(0, i));
|
||||
r = GEP_tup_like(r.bcx, t, av, [0, i]);
|
||||
auto elt_a = r.val;
|
||||
r = GEP_tup_like(r.bcx, t, bv, vec(0, i));
|
||||
r = GEP_tup_like(r.bcx, t, bv, [0, i]);
|
||||
auto elt_b = r.val;
|
||||
r = f(r.bcx,
|
||||
load_if_immediate(r.bcx, elt_a, arg.ty),
|
||||
@@ -2630,9 +2630,9 @@ fn iter_boxpp(@block_ctxt cx,
|
||||
case (ty::ty_rec(?fields)) {
|
||||
let int i = 0;
|
||||
for (ty::field fld in fields) {
|
||||
r = GEP_tup_like(r.bcx, t, av, vec(0, i));
|
||||
r = GEP_tup_like(r.bcx, t, av, [0, i]);
|
||||
auto llfld_a = r.val;
|
||||
r = GEP_tup_like(r.bcx, t, bv, vec(0, i));
|
||||
r = GEP_tup_like(r.bcx, t, bv, [0, i]);
|
||||
auto llfld_b = r.val;
|
||||
r = f(r.bcx,
|
||||
load_if_immediate(r.bcx, llfld_a, fld.mt.ty),
|
||||
@@ -2651,15 +2651,15 @@ fn iter_boxpp(@block_ctxt cx,
|
||||
auto bv_tag = cx.build.PointerCast(bv, lltagty);
|
||||
|
||||
auto lldiscrim_a_ptr = cx.build.GEP(av_tag,
|
||||
vec(C_int(0), C_int(0)));
|
||||
[C_int(0), C_int(0)]);
|
||||
auto llunion_a_ptr = cx.build.GEP(av_tag,
|
||||
vec(C_int(0), C_int(1)));
|
||||
[C_int(0), C_int(1)]);
|
||||
auto lldiscrim_a = cx.build.Load(lldiscrim_a_ptr);
|
||||
|
||||
auto lldiscrim_b_ptr = cx.build.GEP(bv_tag,
|
||||
vec(C_int(0), C_int(0)));
|
||||
[C_int(0), C_int(0)]);
|
||||
auto llunion_b_ptr = cx.build.GEP(bv_tag,
|
||||
vec(C_int(0), C_int(1)));
|
||||
[C_int(0), C_int(1)]);
|
||||
auto lldiscrim_b = cx.build.Load(lldiscrim_b_ptr);
|
||||
|
||||
// NB: we must hit the discriminant first so that structural
|
||||
@@ -2690,7 +2690,7 @@ fn iter_boxpp(@block_ctxt cx,
|
||||
case (ty::ty_fn(_, ?args, _)) {
|
||||
auto j = 0;
|
||||
for (ty::arg a in args) {
|
||||
auto v = vec(C_int(0), C_int(j as int));
|
||||
auto v = [C_int(0), C_int(j as int)];
|
||||
|
||||
auto rslt = GEP_tag(variant_cx, llunion_a_ptr,
|
||||
tid, variant.id, tps, j);
|
||||
@@ -2740,23 +2740,23 @@ fn iter_boxpp(@block_ctxt cx,
|
||||
case (ty::ty_fn(_,_,_)) {
|
||||
auto box_cell_a =
|
||||
cx.build.GEP(av,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
auto box_cell_b =
|
||||
cx.build.GEP(bv,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
ret iter_boxpp(cx, box_cell_a, box_cell_b, f);
|
||||
}
|
||||
case (ty::ty_obj(_)) {
|
||||
auto box_cell_a =
|
||||
cx.build.GEP(av,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_box)]);
|
||||
auto box_cell_b =
|
||||
cx.build.GEP(bv,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_box)]);
|
||||
ret iter_boxpp(cx, box_cell_a, box_cell_b, f);
|
||||
}
|
||||
case (_) {
|
||||
@@ -2787,9 +2787,9 @@ fn iter_sequence_raw(@block_ctxt cx,
|
||||
bcx.build.Br(cond_cx.llbb);
|
||||
|
||||
let ValueRef dst_curr = cond_cx.build.Phi(T_int(),
|
||||
vec(dst_int), vec(bcx.llbb));
|
||||
[dst_int], [bcx.llbb]);
|
||||
let ValueRef src_curr = cond_cx.build.Phi(T_int(),
|
||||
vec(src_int), vec(bcx.llbb));
|
||||
[src_int], [bcx.llbb]);
|
||||
|
||||
auto end_test = cond_cx.build.ICmp(lib::llvm::LLVMIntULT,
|
||||
src_curr, src_lim_int);
|
||||
@@ -2806,10 +2806,10 @@ fn iter_sequence_raw(@block_ctxt cx,
|
||||
auto src_next = body_cx.build.Add(src_curr, elt_sz);
|
||||
body_cx.build.Br(cond_cx.llbb);
|
||||
|
||||
cond_cx.build.AddIncomingToPhi(dst_curr, vec(dst_next),
|
||||
vec(body_cx.llbb));
|
||||
cond_cx.build.AddIncomingToPhi(src_curr, vec(src_next),
|
||||
vec(body_cx.llbb));
|
||||
cond_cx.build.AddIncomingToPhi(dst_curr, [dst_next],
|
||||
[body_cx.llbb]);
|
||||
cond_cx.build.AddIncomingToPhi(src_curr, [src_next],
|
||||
[body_cx.llbb]);
|
||||
|
||||
ret res(next_cx, C_nil());
|
||||
}
|
||||
@@ -2855,10 +2855,10 @@ fn iter_sequence_body(@block_ctxt cx,
|
||||
&val_and_ty_fn f,
|
||||
bool trailing_null) -> result {
|
||||
|
||||
auto p0 = cx.build.GEP(v, vec(C_int(0),
|
||||
C_int(abi::vec_elt_data)));
|
||||
auto lenptr = cx.build.GEP(v, vec(C_int(0),
|
||||
C_int(abi::vec_elt_fill)));
|
||||
auto p0 = cx.build.GEP(v, [C_int(0),
|
||||
C_int(abi::vec_elt_data)]);
|
||||
auto lenptr = cx.build.GEP(v, [C_int(0),
|
||||
C_int(abi::vec_elt_fill)]);
|
||||
|
||||
auto llunit_ty;
|
||||
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
|
||||
@@ -2993,17 +2993,17 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v,
|
||||
|
||||
auto llrawptr = cx.build.BitCast(v, T_ptr(T_i8()));
|
||||
auto lltydescs = cx.build.GEP(tydesc,
|
||||
vec(C_int(0),
|
||||
C_int(abi::tydesc_field_first_param)));
|
||||
[C_int(0),
|
||||
C_int(abi::tydesc_field_first_param)]);
|
||||
lltydescs = cx.build.Load(lltydescs);
|
||||
auto llfnptr = cx.build.GEP(tydesc, vec(C_int(0), C_int(field)));
|
||||
auto llfnptr = cx.build.GEP(tydesc, [C_int(0), C_int(field)]);
|
||||
auto llfn = cx.build.Load(llfnptr);
|
||||
|
||||
cx.build.FastCall(llfn, vec(C_null(T_ptr(T_nil())),
|
||||
cx.build.FastCall(llfn, [C_null(T_ptr(T_nil())),
|
||||
cx.fcx.lltaskptr,
|
||||
C_null(T_ptr(T_nil())),
|
||||
lltydescs,
|
||||
llrawptr));
|
||||
llrawptr]);
|
||||
}
|
||||
|
||||
fn call_tydesc_glue(&@block_ctxt cx, ValueRef v,
|
||||
@@ -3019,9 +3019,9 @@ fn call_tydesc_glue(&@block_ctxt cx, ValueRef v,
|
||||
}
|
||||
|
||||
fn maybe_call_dtor(&@block_ctxt cx, ValueRef v) -> @block_ctxt {
|
||||
auto vtbl = cx.build.GEP(v, vec(C_int(0), C_int(abi::obj_field_vtbl)));
|
||||
auto vtbl = cx.build.GEP(v, [C_int(0), C_int(abi::obj_field_vtbl)]);
|
||||
vtbl = cx.build.Load(vtbl);
|
||||
auto dtor_ptr = cx.build.GEP(vtbl, vec(C_int(0), C_int(0)));
|
||||
auto dtor_ptr = cx.build.GEP(vtbl, [C_int(0), C_int(0)]);
|
||||
dtor_ptr = cx.build.Load(dtor_ptr);
|
||||
auto self_t = llvm::LLVMGetElementType(val_ty(v));
|
||||
dtor_ptr = cx.build.BitCast(dtor_ptr,
|
||||
@@ -3034,8 +3034,8 @@ fn maybe_call_dtor(&@block_ctxt cx, ValueRef v) -> @block_ctxt {
|
||||
cx.build.CondBr(test, dtor_cx.llbb, after_cx.llbb);
|
||||
|
||||
auto me = dtor_cx.build.Load(v);
|
||||
dtor_cx.build.FastCall(dtor_ptr, vec(C_null(T_ptr(T_nil())),
|
||||
cx.fcx.lltaskptr, me));
|
||||
dtor_cx.build.FastCall(dtor_ptr, [C_null(T_ptr(T_nil())),
|
||||
cx.fcx.lltaskptr, me]);
|
||||
dtor_cx.build.Br(after_cx.llbb);
|
||||
ret after_cx;
|
||||
}
|
||||
@@ -3060,23 +3060,23 @@ fn call_cmp_glue(&@block_ctxt cx,
|
||||
lazily_emit_tydesc_glue(cx, abi::tydesc_field_cmp_glue, ti);
|
||||
|
||||
auto lltydescs =
|
||||
r.bcx.build.GEP(r.val, vec(C_int(0),
|
||||
C_int(abi::tydesc_field_first_param)));
|
||||
r.bcx.build.GEP(r.val, [C_int(0),
|
||||
C_int(abi::tydesc_field_first_param)]);
|
||||
lltydescs = r.bcx.build.Load(lltydescs);
|
||||
auto llfnptr =
|
||||
r.bcx.build.GEP(r.val, vec(C_int(0),
|
||||
C_int(abi::tydesc_field_cmp_glue)));
|
||||
r.bcx.build.GEP(r.val, [C_int(0),
|
||||
C_int(abi::tydesc_field_cmp_glue)]);
|
||||
auto llfn = r.bcx.build.Load(llfnptr);
|
||||
|
||||
auto llcmpresultptr = r.bcx.build.Alloca(T_i1());
|
||||
|
||||
let vec[ValueRef] llargs = vec(llcmpresultptr,
|
||||
let vec[ValueRef] llargs = [llcmpresultptr,
|
||||
r.bcx.fcx.lltaskptr,
|
||||
C_null(T_ptr(T_nil())),
|
||||
lltydescs,
|
||||
llrawlhsptr,
|
||||
llrawrhsptr,
|
||||
llop);
|
||||
llop];
|
||||
|
||||
r.bcx.build.FastCall(llfn, llargs);
|
||||
|
||||
@@ -3132,8 +3132,8 @@ fn call_memmove(&@block_ctxt cx,
|
||||
|
||||
auto volatile = C_bool(false);
|
||||
ret res(cx, cx.build.Call(memmove,
|
||||
vec(dst_ptr, src_ptr,
|
||||
size, align, volatile)));
|
||||
[dst_ptr, src_ptr,
|
||||
size, align, volatile]));
|
||||
}
|
||||
|
||||
fn call_bzero(&@block_ctxt cx,
|
||||
@@ -3155,8 +3155,8 @@ fn call_bzero(&@block_ctxt cx,
|
||||
|
||||
auto volatile = C_bool(false);
|
||||
ret res(cx, cx.build.Call(memset,
|
||||
vec(dst_ptr, C_u8(0u),
|
||||
size, align, volatile)));
|
||||
[dst_ptr, C_u8(0u),
|
||||
size, align, volatile]));
|
||||
}
|
||||
|
||||
fn memmove_ty(&@block_ctxt cx,
|
||||
@@ -3328,15 +3328,15 @@ fn trans_unary(&@block_ctxt cx, ast::unop op,
|
||||
auto box_ty = node_ann_type(sub.bcx.fcx.lcx.ccx, a);
|
||||
sub = trans_malloc_boxed(sub.bcx, e_ty);
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, sub.val, box_ty)));
|
||||
[clean(bind drop_ty(_, sub.val, box_ty))];
|
||||
|
||||
auto box = sub.val;
|
||||
auto rc = sub.bcx.build.GEP(box,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)]);
|
||||
auto body = sub.bcx.build.GEP(box,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
sub.bcx.build.Store(C_int(1), rc);
|
||||
|
||||
// Cast the body type to the type of the value. This is needed to
|
||||
@@ -3426,10 +3426,10 @@ fn trans_vec_append(&@block_ctxt cx, &ty::t t,
|
||||
auto src = bcx.build.PointerCast(rhs, T_opaque_vec_ptr());
|
||||
|
||||
ret res(bcx, bcx.build.FastCall(cx.fcx.lcx.ccx.glues.vec_append_glue,
|
||||
vec(cx.fcx.lltaskptr,
|
||||
[cx.fcx.lltaskptr,
|
||||
llvec_tydesc.val,
|
||||
llelt_tydesc.val,
|
||||
dst, src, skip_null)));
|
||||
dst, src, skip_null]));
|
||||
}
|
||||
|
||||
fn trans_vec_add(&@block_ctxt cx, &ty::t t,
|
||||
@@ -3440,7 +3440,7 @@ fn trans_vec_add(&@block_ctxt cx, &ty::t t,
|
||||
auto bcx = trans_vec_append(r.bcx, t, tmp, rhs).bcx;
|
||||
tmp = load_if_immediate(bcx, tmp, t);
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, tmp, t)));
|
||||
[clean(bind drop_ty(_, tmp, t))];
|
||||
ret res(bcx, tmp);
|
||||
}
|
||||
|
||||
@@ -3530,8 +3530,8 @@ fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
|
||||
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t1)) {
|
||||
case (ty::ty_box(?mt)) {
|
||||
auto body = cx.build.GEP(v1,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
t1 = mt.ty;
|
||||
|
||||
// Since we're changing levels of box indirection, we may have
|
||||
@@ -3596,7 +3596,7 @@ fn trans_binary(&@block_ctxt cx, ast::binop op,
|
||||
lhs_false_cx.llbb);
|
||||
|
||||
ret join_results(cx, T_bool(),
|
||||
vec(lhs_false_res, rhs_res));
|
||||
[lhs_false_res, rhs_res]);
|
||||
}
|
||||
|
||||
case (ast::or) {
|
||||
@@ -3620,7 +3620,7 @@ fn trans_binary(&@block_ctxt cx, ast::binop op,
|
||||
rhs_cx.llbb);
|
||||
|
||||
ret join_results(cx, T_bool(),
|
||||
vec(lhs_true_res, rhs_res));
|
||||
[lhs_true_res, rhs_res]);
|
||||
}
|
||||
|
||||
case (_) {
|
||||
@@ -3645,15 +3645,15 @@ fn join_results(&@block_ctxt parent_cx,
|
||||
&vec[result] ins)
|
||||
-> result {
|
||||
|
||||
let vec[result] live = vec();
|
||||
let vec[ValueRef] vals = vec();
|
||||
let vec[BasicBlockRef] bbs = vec();
|
||||
let vec[result] live = [];
|
||||
let vec[ValueRef] vals = [];
|
||||
let vec[BasicBlockRef] bbs = [];
|
||||
|
||||
for (result r in ins) {
|
||||
if (! is_terminated(r.bcx)) {
|
||||
live += vec(r);
|
||||
vals += vec(r.val);
|
||||
bbs += vec(r.bcx.llbb);
|
||||
live += [r];
|
||||
vals += [r.val];
|
||||
bbs += [r.bcx.llbb];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3730,7 +3730,7 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond,
|
||||
else_cx.llbb);
|
||||
|
||||
ret join_results(cx, expr_llty,
|
||||
vec(then_res, else_res));
|
||||
[then_res, else_res]);
|
||||
}
|
||||
|
||||
fn trans_for(&@block_ctxt cx,
|
||||
@@ -3751,7 +3751,7 @@ fn inner(&@block_ctxt cx,
|
||||
auto local_res = alloc_local(scope_cx, local);
|
||||
auto bcx = copy_ty(local_res.bcx, INIT, local_res.val, curr, t).bcx;
|
||||
scope_cx.cleanups +=
|
||||
vec(clean(bind drop_slot(_, local_res.val, t)));
|
||||
[clean(bind drop_slot(_, local_res.val, t))];
|
||||
bcx = trans_block(bcx, body).bcx;
|
||||
bcx.build.Br(next_cx.llbb);
|
||||
ret res(next_cx, C_nil());
|
||||
@@ -3814,7 +3814,7 @@ fn walk_decl(env e, &@ast::decl decl) {
|
||||
}
|
||||
}
|
||||
|
||||
let vec[ast::def_id] refs = vec();
|
||||
let vec[ast::def_id] refs = [];
|
||||
let hashmap[ast::def_id,()] decls = new_def_hash[()]();
|
||||
decls.insert(initial_decl, ());
|
||||
let env e = @rec(mutable refs=refs,
|
||||
@@ -3827,10 +3827,10 @@ fn walk_decl(env e, &@ast::decl decl) {
|
||||
walk::walk_block(*visitor, bloc);
|
||||
|
||||
// Calculate (refs - decls). This is the set of captured upvars.
|
||||
let vec[ast::def_id] result = vec();
|
||||
let vec[ast::def_id] result = [];
|
||||
for (ast::def_id ref_id in e.refs) {
|
||||
if (!decls.contains_key(ref_id)) {
|
||||
result += vec(ref_id);
|
||||
result += [ref_id];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3884,8 +3884,8 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
auto llbindingsptr;
|
||||
if (upvar_count > 0u) {
|
||||
// Gather up the upvars.
|
||||
let vec[ValueRef] llbindings = vec();
|
||||
let vec[TypeRef] llbindingtys = vec();
|
||||
let vec[ValueRef] llbindings = [];
|
||||
let vec[TypeRef] llbindingtys = [];
|
||||
for (ast::def_id did in upvars) {
|
||||
auto llbinding;
|
||||
alt (cx.fcx.lllocals.find(did)) {
|
||||
@@ -3899,8 +3899,8 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
}
|
||||
case (some[ValueRef](?llval)) { llbinding = llval; }
|
||||
}
|
||||
llbindings += vec(llbinding);
|
||||
llbindingtys += vec(val_ty(llbinding));
|
||||
llbindings += [llbinding];
|
||||
llbindingtys += [val_ty(llbinding)];
|
||||
}
|
||||
|
||||
// Create an array of bindings and copy in aliases to the upvars.
|
||||
@@ -3908,7 +3908,7 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
auto i = 0u;
|
||||
while (i < upvar_count) {
|
||||
auto llbindingptr = cx.build.GEP(llbindingsptr,
|
||||
vec(C_int(0), C_int(i as int)));
|
||||
[C_int(0), C_int(i as int)]);
|
||||
cx.build.Store(llbindings.(i), llbindingptr);
|
||||
i += 1u;
|
||||
}
|
||||
@@ -3924,21 +3924,21 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
auto llenvptr = alloca(cx, llvm::LLVMGetElementType(llenvptrty));
|
||||
|
||||
auto llbindingsptrptr = cx.build.GEP(llenvptr,
|
||||
vec(C_int(0),
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body),
|
||||
C_int(2)));
|
||||
C_int(2)]);
|
||||
cx.build.Store(llbindingsptr, llbindingsptrptr);
|
||||
|
||||
// Copy in our type descriptors, in case the iterator body needs to refer
|
||||
// to them.
|
||||
auto lltydescsptr = cx.build.GEP(llenvptr,
|
||||
vec(C_int(0),
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body),
|
||||
C_int(abi::closure_elt_ty_params)));
|
||||
C_int(abi::closure_elt_ty_params)]);
|
||||
auto i = 0u;
|
||||
while (i < tydesc_count) {
|
||||
auto lltydescptr = cx.build.GEP(lltydescsptr,
|
||||
vec(C_int(0), C_int(i as int)));
|
||||
[C_int(0), C_int(i as int)]);
|
||||
cx.build.Store(cx.fcx.lltydescs.(i), lltydescptr);
|
||||
i += 1u;
|
||||
}
|
||||
@@ -3956,7 +3956,7 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
auto iter_body_llty =
|
||||
type_of_fn_full(lcx.ccx, ast::proto_fn,
|
||||
none[TypeRef],
|
||||
vec(rec(mode=ty::mo_alias, ty=decl_ty)),
|
||||
[rec(mode=ty::mo_alias, ty=decl_ty)],
|
||||
ty::mk_nil(lcx.ccx.tcx), 0u);
|
||||
|
||||
let ValueRef lliterbody = decl_internal_fastcall_fn(lcx.ccx.llmod,
|
||||
@@ -3971,9 +3971,9 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
llenvptrty);
|
||||
auto llremotebindingsptrptr =
|
||||
copy_args_bcx.build.GEP(llremoteenvptr,
|
||||
vec(C_int(0),
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body),
|
||||
C_int(abi::closure_elt_bindings)));
|
||||
C_int(abi::closure_elt_bindings)]);
|
||||
auto llremotebindingsptr =
|
||||
copy_args_bcx.build.Load(llremotebindingsptrptr);
|
||||
|
||||
@@ -3982,7 +3982,7 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
auto upvar_id = upvars.(i);
|
||||
auto llupvarptrptr =
|
||||
copy_args_bcx.build.GEP(llremotebindingsptr,
|
||||
vec(C_int(0), C_int(i as int)));
|
||||
[C_int(0), C_int(i as int)]);
|
||||
auto llupvarptr = copy_args_bcx.build.Load(llupvarptrptr);
|
||||
fcx.llupvars.insert(upvar_id, llupvarptr);
|
||||
|
||||
@@ -3992,17 +3992,17 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
// Populate the type parameters from the environment.
|
||||
auto llremotetydescsptr =
|
||||
copy_args_bcx.build.GEP(llremoteenvptr,
|
||||
vec(C_int(0),
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body),
|
||||
C_int(abi::closure_elt_ty_params)));
|
||||
C_int(abi::closure_elt_ty_params)]);
|
||||
|
||||
i = 0u;
|
||||
while (i < tydesc_count) {
|
||||
auto llremotetydescptr =
|
||||
copy_args_bcx.build.GEP(llremotetydescsptr, vec(C_int(0),
|
||||
C_int(i as int)));
|
||||
copy_args_bcx.build.GEP(llremotetydescsptr, [C_int(0),
|
||||
C_int(i as int)]);
|
||||
auto llremotetydesc = copy_args_bcx.build.Load(llremotetydescptr);
|
||||
fcx.lltydescs += vec(llremotetydesc);
|
||||
fcx.lltydescs += [llremotetydesc];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -4027,12 +4027,12 @@ fn trans_for_each(&@block_ctxt cx,
|
||||
auto pair = alloca(cx, T_fn_pair(lcx.ccx.tn,
|
||||
iter_body_llty));
|
||||
auto code_cell = cx.build.GEP(pair,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_code)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_code)]);
|
||||
cx.build.Store(lliterbody, code_cell);
|
||||
|
||||
auto env_cell = cx.build.GEP(pair, vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
auto env_cell = cx.build.GEP(pair, [C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
auto llenvblobptr = cx.build.PointerCast(llenvptr,
|
||||
T_opaque_closure_ptr(lcx.ccx.tn));
|
||||
cx.build.Store(llenvblobptr, env_cell);
|
||||
@@ -4109,7 +4109,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
||||
T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn));
|
||||
|
||||
auto lldiscrimptr = cx.build.GEP(lltagptr,
|
||||
vec(C_int(0), C_int(0)));
|
||||
[C_int(0), C_int(0)]);
|
||||
auto lldiscrim = cx.build.Load(lldiscrimptr);
|
||||
|
||||
auto vdef = ast::variant_def_ids
|
||||
@@ -4138,7 +4138,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
||||
|
||||
if (_vec::len[@ast::pat](subpats) > 0u) {
|
||||
auto llblobptr = matched_cx.build.GEP(lltagptr,
|
||||
vec(C_int(0), C_int(1)));
|
||||
[C_int(0), C_int(1)]);
|
||||
auto i = 0;
|
||||
for (@ast::pat subpat in subpats) {
|
||||
auto rslt = GEP_tag(matched_cx, llblobptr, vdef._0,
|
||||
@@ -4183,7 +4183,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
|
||||
maybe_name_value(cx.fcx.lcx.ccx, dst, id);
|
||||
bcx.fcx.lllocals.insert(def_id, dst);
|
||||
bcx.cleanups +=
|
||||
vec(clean(bind drop_slot(_, dst, t)));
|
||||
[clean(bind drop_slot(_, dst, t))];
|
||||
ret copy_ty(bcx, INIT, dst, llval, t);
|
||||
}
|
||||
}
|
||||
@@ -4196,7 +4196,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
|
||||
|
||||
auto lltagptr = cx.build.PointerCast(llval,
|
||||
T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn));
|
||||
auto llblobptr = cx.build.GEP(lltagptr, vec(C_int(0), C_int(1)));
|
||||
auto llblobptr = cx.build.GEP(lltagptr, [C_int(0), C_int(1)]);
|
||||
|
||||
auto ty_param_substs =
|
||||
ty::ann_to_type_params(cx.fcx.lcx.ccx.node_types, ann);
|
||||
@@ -4223,7 +4223,7 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr,
|
||||
auto expr_res = trans_expr(cx, expr);
|
||||
|
||||
auto this_cx = expr_res.bcx;
|
||||
let vec[result] arm_results = vec();
|
||||
let vec[result] arm_results = [];
|
||||
for (ast::arm arm in arms) {
|
||||
auto next_cx = new_sub_block_ctxt(expr_res.bcx, "next");
|
||||
auto match_res = trans_pat_match(this_cx, arm.pat, expr_res.val,
|
||||
@@ -4236,7 +4236,7 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr,
|
||||
expr_res.val, false);
|
||||
|
||||
auto block_res = trans_block(binding_res.bcx, arm.block);
|
||||
arm_results += vec(block_res);
|
||||
arm_results += [block_res];
|
||||
|
||||
this_cx = next_cx;
|
||||
}
|
||||
@@ -4325,13 +4325,13 @@ fn lval_generic_fn(&@block_ctxt cx,
|
||||
|
||||
if (_vec::len[ty::t](tys) != 0u) {
|
||||
auto bcx = lv.res.bcx;
|
||||
let vec[ValueRef] tydescs = vec();
|
||||
let vec[option::t[@tydesc_info]] tis = vec();
|
||||
let vec[ValueRef] tydescs = [];
|
||||
let vec[option::t[@tydesc_info]] tis = [];
|
||||
for (ty::t t in tys) {
|
||||
// TODO: Doesn't always escape.
|
||||
auto ti = none[@tydesc_info];
|
||||
auto td = get_tydesc(bcx, t, true, ti);
|
||||
tis += vec(ti);
|
||||
tis += [ti];
|
||||
bcx = td.bcx;
|
||||
_vec::push[ValueRef](tydescs, td.val);
|
||||
}
|
||||
@@ -4438,7 +4438,7 @@ fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
|
||||
PointerCast(lltagblob, T_ptr(lltagty));
|
||||
|
||||
auto lldiscrimptr = alloc_result.bcx.build.GEP
|
||||
(lltagptr, vec(C_int(0), C_int(0)));
|
||||
(lltagptr, [C_int(0), C_int(0)]);
|
||||
alloc_result.bcx.build.Store(lldiscrim,
|
||||
lldiscrimptr);
|
||||
|
||||
@@ -4472,25 +4472,25 @@ fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
|
||||
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
case (ty::ty_tup(_)) {
|
||||
let uint ix = ty::field_num(cx.fcx.lcx.ccx.sess, sp, field);
|
||||
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
|
||||
auto v = GEP_tup_like(r.bcx, t, r.val, [0, ix as int]);
|
||||
ret lval_mem(v.bcx, v.val);
|
||||
}
|
||||
case (ty::ty_rec(?fields)) {
|
||||
let uint ix = ty::field_idx(cx.fcx.lcx.ccx.sess, sp, field,
|
||||
fields);
|
||||
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
|
||||
auto v = GEP_tup_like(r.bcx, t, r.val, [0, ix as int]);
|
||||
ret lval_mem(v.bcx, v.val);
|
||||
}
|
||||
case (ty::ty_obj(?methods)) {
|
||||
let uint ix = ty::method_idx(cx.fcx.lcx.ccx.sess, sp, field,
|
||||
methods);
|
||||
auto vtbl = r.bcx.build.GEP(r.val,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_vtbl)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_vtbl)]);
|
||||
vtbl = r.bcx.build.Load(vtbl);
|
||||
// +1 because slot #0 contains the destructor
|
||||
auto v = r.bcx.build.GEP(vtbl, vec(C_int(0),
|
||||
C_int((ix + 1u) as int)));
|
||||
auto v = r.bcx.build.GEP(vtbl, [C_int(0),
|
||||
C_int((ix + 1u) as int)]);
|
||||
|
||||
auto lvo = lval_mem(r.bcx, v);
|
||||
let ty::t fn_ty = ty::method_ty_to_fn_ty(cx.fcx.lcx.ccx.tcx,
|
||||
@@ -4535,7 +4535,7 @@ fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base,
|
||||
auto scaled_ix = bcx.build.Mul(ix_val, unit_sz.val);
|
||||
maybe_name_value(cx.fcx.lcx.ccx, scaled_ix, "scaled_ix");
|
||||
|
||||
auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi::vec_elt_fill)));
|
||||
auto lim = bcx.build.GEP(v, [C_int(0), C_int(abi::vec_elt_fill)]);
|
||||
lim = bcx.build.Load(lim);
|
||||
|
||||
auto bounds_check = bcx.build.ICmp(lib::llvm::LLVMIntULT,
|
||||
@@ -4549,13 +4549,13 @@ fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base,
|
||||
auto fail_res = trans_fail(fail_cx, some[common::span](sp),
|
||||
"bounds check");
|
||||
|
||||
auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi::vec_elt_data)));
|
||||
auto body = next_cx.build.GEP(v, [C_int(0), C_int(abi::vec_elt_data)]);
|
||||
auto elt;
|
||||
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
|
||||
body = next_cx.build.PointerCast(body, T_ptr(T_array(T_i8(), 1u)));
|
||||
elt = next_cx.build.GEP(body, vec(C_int(0), scaled_ix));
|
||||
elt = next_cx.build.GEP(body, [C_int(0), scaled_ix]);
|
||||
} else {
|
||||
elt = next_cx.build.GEP(body, vec(C_int(0), ix_val));
|
||||
elt = next_cx.build.GEP(body, [C_int(0), ix_val]);
|
||||
|
||||
// We're crossing a box boundary here, so we may need to pointer cast.
|
||||
auto llunitty = type_of(next_cx.fcx.lcx.ccx, unit_ty);
|
||||
@@ -4588,8 +4588,8 @@ fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
|
||||
|
||||
auto sub = trans_expr(cx, base);
|
||||
auto val = sub.bcx.build.GEP(sub.val,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
ret lval_mem(sub.bcx, val);
|
||||
}
|
||||
case (ast::expr_self_method(?ident, ?ann)) {
|
||||
@@ -4677,13 +4677,13 @@ fn trans_bind_thunk(&@local_ctxt cx,
|
||||
auto llclosure = bcx.build.PointerCast(fcx.llenv, llclosure_ptr_ty);
|
||||
|
||||
auto lltarget = GEP_tup_like(bcx, closure_ty, llclosure,
|
||||
vec(0,
|
||||
[0,
|
||||
abi::box_rc_field_body,
|
||||
abi::closure_elt_target));
|
||||
abi::closure_elt_target]);
|
||||
bcx = lltarget.bcx;
|
||||
auto lltargetclosure = bcx.build.GEP(lltarget.val,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
lltargetclosure = bcx.build.Load(lltargetclosure);
|
||||
|
||||
auto outgoing_ret_ty = ty::ty_fn_ret(cx.ccx.tcx, outgoing_fty);
|
||||
@@ -4694,23 +4694,23 @@ fn trans_bind_thunk(&@local_ctxt cx,
|
||||
llretptr = bcx.build.PointerCast(llretptr, T_typaram_ptr(cx.ccx.tn));
|
||||
}
|
||||
|
||||
let vec[ValueRef] llargs = vec(llretptr,
|
||||
let vec[ValueRef] llargs = [llretptr,
|
||||
fcx.lltaskptr,
|
||||
lltargetclosure);
|
||||
lltargetclosure];
|
||||
|
||||
// Copy in the type parameters.
|
||||
let uint i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
auto lltyparam_ptr =
|
||||
GEP_tup_like(bcx, closure_ty, llclosure,
|
||||
vec(0,
|
||||
[0,
|
||||
abi::box_rc_field_body,
|
||||
abi::closure_elt_ty_params,
|
||||
(i as int)));
|
||||
(i as int)]);
|
||||
bcx = lltyparam_ptr.bcx;
|
||||
auto td = bcx.build.Load(lltyparam_ptr.val);
|
||||
llargs += vec(td);
|
||||
fcx.lltydescs += vec(td);
|
||||
llargs += [td];
|
||||
fcx.lltydescs += [td];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -4732,10 +4732,10 @@ fn trans_bind_thunk(&@local_ctxt cx,
|
||||
auto e_ty = ty::expr_ty(cx.ccx.tcx, cx.ccx.node_types, e);
|
||||
auto bound_arg =
|
||||
GEP_tup_like(bcx, closure_ty, llclosure,
|
||||
vec(0,
|
||||
[0,
|
||||
abi::box_rc_field_body,
|
||||
abi::closure_elt_bindings,
|
||||
b));
|
||||
b]);
|
||||
|
||||
bcx = bound_arg.bcx;
|
||||
auto val = bound_arg.val;
|
||||
@@ -4754,7 +4754,7 @@ fn trans_bind_thunk(&@local_ctxt cx,
|
||||
val = bcx.build.PointerCast(val, llout_arg_ty);
|
||||
}
|
||||
|
||||
llargs += vec(val);
|
||||
llargs += [val];
|
||||
b += 1;
|
||||
}
|
||||
|
||||
@@ -4768,7 +4768,7 @@ fn trans_bind_thunk(&@local_ctxt cx,
|
||||
llout_arg_ty);
|
||||
}
|
||||
|
||||
llargs += vec(passed_arg);
|
||||
llargs += [passed_arg];
|
||||
a += 1u;
|
||||
}
|
||||
}
|
||||
@@ -4778,8 +4778,8 @@ fn trans_bind_thunk(&@local_ctxt cx,
|
||||
|
||||
// FIXME: turn this call + ret into a tail call.
|
||||
auto lltargetfn = bcx.build.GEP(lltarget.val,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_code)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_code)]);
|
||||
|
||||
// Cast the outgoing function to the appropriate type (see the comments in
|
||||
// trans_bind below for why this is necessary).
|
||||
@@ -4808,7 +4808,7 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
if (f_res.is_mem) {
|
||||
cx.fcx.lcx.ccx.sess.unimpl("re-binding existing function");
|
||||
} else {
|
||||
let vec[@ast::expr] bound = vec();
|
||||
let vec[@ast::expr] bound = [];
|
||||
|
||||
for (option::t[@ast::expr] argopt in args) {
|
||||
alt (argopt) {
|
||||
@@ -4827,7 +4827,7 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
case (none[generic_info]) {
|
||||
outgoing_fty = ty::expr_ty(cx.fcx.lcx.ccx.tcx,
|
||||
cx.fcx.lcx.ccx.node_types, f);
|
||||
lltydescs = vec();
|
||||
lltydescs = [];
|
||||
}
|
||||
case (some[generic_info](?ginfo)) {
|
||||
lazily_emit_all_generic_info_tydesc_glues(cx, ginfo);
|
||||
@@ -4846,8 +4846,8 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
auto pair_v = alloca(bcx, pair_t);
|
||||
|
||||
// Translate the bound expressions.
|
||||
let vec[ty::t] bound_tys = vec();
|
||||
let vec[ValueRef] bound_vals = vec();
|
||||
let vec[ty::t] bound_tys = [];
|
||||
let vec[ValueRef] bound_vals = [];
|
||||
auto i = 0u;
|
||||
for (@ast::expr e in bound) {
|
||||
auto arg = trans_expr(bcx, e);
|
||||
@@ -4874,10 +4874,10 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
_vec::init_elt[ty::t](tydesc_ty, ty_param_count);
|
||||
|
||||
let vec[ty::t] closure_tys =
|
||||
vec(tydesc_ty,
|
||||
[tydesc_ty,
|
||||
outgoing_fty,
|
||||
bindings_ty,
|
||||
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys));
|
||||
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys)];
|
||||
|
||||
let ty::t closure_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
|
||||
closure_tys);
|
||||
@@ -4886,19 +4886,19 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
auto box = r.val;
|
||||
bcx = r.bcx;
|
||||
auto rc = bcx.build.GEP(box,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_refcnt)]);
|
||||
auto closure =
|
||||
bcx.build.GEP(box,
|
||||
vec(C_int(0),
|
||||
C_int(abi::box_rc_field_body)));
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body)]);
|
||||
bcx.build.Store(C_int(1), rc);
|
||||
|
||||
// Store bindings tydesc.
|
||||
auto bound_tydesc =
|
||||
bcx.build.GEP(closure,
|
||||
vec(C_int(0),
|
||||
C_int(abi::closure_elt_tydesc)));
|
||||
[C_int(0),
|
||||
C_int(abi::closure_elt_tydesc)]);
|
||||
auto ti = none[@tydesc_info];
|
||||
auto bindings_tydesc = get_tydesc(bcx, bindings_ty, true, ti);
|
||||
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_drop_glue, ti);
|
||||
@@ -4921,8 +4921,8 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
// Store thunk-target.
|
||||
auto bound_target =
|
||||
bcx.build.GEP(closure,
|
||||
vec(C_int(0),
|
||||
C_int(abi::closure_elt_target)));
|
||||
[C_int(0),
|
||||
C_int(abi::closure_elt_target)]);
|
||||
auto src = bcx.build.Load(f_res.res.val);
|
||||
bound_target = bcx.build.PointerCast(bound_target, llclosurety);
|
||||
bcx.build.Store(src, bound_target);
|
||||
@@ -4931,11 +4931,11 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
i = 0u;
|
||||
auto bindings =
|
||||
bcx.build.GEP(closure,
|
||||
vec(C_int(0),
|
||||
C_int(abi::closure_elt_bindings)));
|
||||
[C_int(0),
|
||||
C_int(abi::closure_elt_bindings)]);
|
||||
for (ValueRef v in bound_vals) {
|
||||
auto bound = bcx.build.GEP(bindings,
|
||||
vec(C_int(0), C_int(i as int)));
|
||||
[C_int(0), C_int(i as int)]);
|
||||
bcx = copy_ty(bcx, INIT, bound, v, bound_tys.(i)).bcx;
|
||||
i += 1u;
|
||||
}
|
||||
@@ -4949,13 +4949,13 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
lazily_emit_all_generic_info_tydesc_glues(cx, ginfo);
|
||||
auto ty_params_slot =
|
||||
bcx.build.GEP(closure,
|
||||
vec(C_int(0),
|
||||
C_int(abi::closure_elt_ty_params)));
|
||||
[C_int(0),
|
||||
C_int(abi::closure_elt_ty_params)]);
|
||||
auto i = 0;
|
||||
for (ValueRef td in ginfo.tydescs) {
|
||||
auto ty_param_slot = bcx.build.GEP(ty_params_slot,
|
||||
vec(C_int(0),
|
||||
C_int(i)));
|
||||
[C_int(0),
|
||||
C_int(i)]);
|
||||
bcx.build.Store(td, ty_param_slot);
|
||||
i += 1;
|
||||
}
|
||||
@@ -4966,8 +4966,8 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
|
||||
// Make thunk and store thunk-ptr in outer pair's code slot.
|
||||
auto pair_code = bcx.build.GEP(pair_v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_code)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_code)]);
|
||||
|
||||
let ty::t pair_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
|
||||
|
||||
@@ -4980,8 +4980,8 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
|
||||
// Store box ptr in outer pair's box slot.
|
||||
auto pair_box = bcx.build.GEP(pair_v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
bcx.build.Store
|
||||
(bcx.build.PointerCast
|
||||
(box,
|
||||
@@ -4989,7 +4989,7 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
pair_box);
|
||||
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_slot(_, pair_v, pair_ty)));
|
||||
[clean(bind drop_slot(_, pair_v, pair_ty))];
|
||||
|
||||
ret res(bcx, pair_v);
|
||||
}
|
||||
@@ -5079,8 +5079,8 @@ fn trans_args(&@block_ctxt cx,
|
||||
-> tup(@block_ctxt, vec[ValueRef], ValueRef) {
|
||||
|
||||
let vec[ty::arg] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
|
||||
let vec[ValueRef] llargs = vec();
|
||||
let vec[ValueRef] lltydescs = vec();
|
||||
let vec[ValueRef] llargs = [];
|
||||
let vec[ValueRef] lltydescs = [];
|
||||
let @block_ctxt bcx = cx;
|
||||
|
||||
|
||||
@@ -5101,8 +5101,8 @@ fn trans_args(&@block_ctxt cx,
|
||||
}
|
||||
}
|
||||
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, retty)) {
|
||||
llargs += vec(bcx.build.PointerCast
|
||||
(llretslot, T_typaram_ptr(cx.fcx.lcx.ccx.tn)));
|
||||
llargs += [bcx.build.PointerCast
|
||||
(llretslot, T_typaram_ptr(cx.fcx.lcx.ccx.tn))];
|
||||
} else if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, retty)) {
|
||||
// It's possible that the callee has some generic-ness somewhere in
|
||||
// its return value -- say a method signature within an obj or a fn
|
||||
@@ -5110,15 +5110,15 @@ fn trans_args(&@block_ctxt cx,
|
||||
// of. If so, cast the caller's view of the restlot to the callee's
|
||||
// view, for the sake of making a type-compatible call.
|
||||
llargs +=
|
||||
vec(cx.build.PointerCast(llretslot,
|
||||
T_ptr(type_of(bcx.fcx.lcx.ccx, retty))));
|
||||
[cx.build.PointerCast(llretslot,
|
||||
T_ptr(type_of(bcx.fcx.lcx.ccx, retty)))];
|
||||
} else {
|
||||
llargs += vec(llretslot);
|
||||
llargs += [llretslot];
|
||||
}
|
||||
|
||||
|
||||
// Arg 1: task pointer.
|
||||
llargs += vec(bcx.fcx.lltaskptr);
|
||||
llargs += [bcx.fcx.lltaskptr];
|
||||
|
||||
// Arg 2: Env (closure-bindings / self-obj)
|
||||
alt (llobj) {
|
||||
@@ -5126,10 +5126,10 @@ fn trans_args(&@block_ctxt cx,
|
||||
// Every object is always found in memory,
|
||||
// and not-yet-loaded (as part of an lval x.y
|
||||
// doted method-call).
|
||||
llargs += vec(bcx.build.Load(ob));
|
||||
llargs += [bcx.build.Load(ob)];
|
||||
}
|
||||
case (_) {
|
||||
llargs += vec(llenv);
|
||||
llargs += [llenv];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5140,7 +5140,7 @@ fn trans_args(&@block_ctxt cx,
|
||||
alt (lliterbody) {
|
||||
case (none[ValueRef]) {}
|
||||
case (some[ValueRef](?lli)) {
|
||||
llargs += vec(lli);
|
||||
llargs += [lli];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5155,7 +5155,7 @@ fn trans_args(&@block_ctxt cx,
|
||||
for (@ast::expr e in es) {
|
||||
auto r = trans_arg_expr(bcx, args.(i), arg_tys.(i), e);
|
||||
bcx = r.bcx;
|
||||
llargs += vec(r.val);
|
||||
llargs += [r.val];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -5184,13 +5184,13 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f,
|
||||
// It's a closure.
|
||||
auto bcx = f_res.res.bcx;
|
||||
auto pair = faddr;
|
||||
faddr = bcx.build.GEP(pair, vec(C_int(0),
|
||||
C_int(abi::fn_field_code)));
|
||||
faddr = bcx.build.GEP(pair, [C_int(0),
|
||||
C_int(abi::fn_field_code)]);
|
||||
faddr = bcx.build.Load(faddr);
|
||||
|
||||
auto llclosure = bcx.build.GEP(pair,
|
||||
vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
llenv = bcx.build.Load(llclosure);
|
||||
}
|
||||
}
|
||||
@@ -5239,7 +5239,7 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f,
|
||||
// the frame, but it's a ref all the same, so we put a note
|
||||
// here to drop it when we're done in this scope.
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, retval, ret_ty)));
|
||||
[clean(bind drop_ty(_, retval, ret_ty))];
|
||||
}
|
||||
}
|
||||
case (some[ValueRef](_)) {
|
||||
@@ -5260,7 +5260,7 @@ fn trans_tup(&@block_ctxt cx, &vec[ast::elt] elts,
|
||||
bcx = tup_res.bcx;
|
||||
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, tup_val, t)));
|
||||
[clean(bind drop_ty(_, tup_val, t))];
|
||||
let int i = 0;
|
||||
|
||||
for (ast::elt e in elts) {
|
||||
@@ -5268,7 +5268,7 @@ fn trans_tup(&@block_ctxt cx, &vec[ast::elt] elts,
|
||||
e.expr);
|
||||
auto src_res = trans_expr(bcx, e.expr);
|
||||
bcx = src_res.bcx;
|
||||
auto dst_res = GEP_tup_like(bcx, t, tup_val, vec(0, i));
|
||||
auto dst_res = GEP_tup_like(bcx, t, tup_val, [0, i]);
|
||||
bcx = dst_res.bcx;
|
||||
bcx = copy_ty(src_res.bcx, INIT, dst_res.val, src_res.val, e_ty).bcx;
|
||||
i += 1;
|
||||
@@ -5297,16 +5297,16 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args,
|
||||
|
||||
// FIXME: pass tydesc properly.
|
||||
auto vec_val = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.new_vec,
|
||||
vec(bcx.fcx.lltaskptr, data_sz,
|
||||
C_null(T_ptr(T_tydesc(bcx.fcx.lcx.ccx.tn)))));
|
||||
[bcx.fcx.lltaskptr, data_sz,
|
||||
C_null(T_ptr(T_tydesc(bcx.fcx.lcx.ccx.tn)))]);
|
||||
auto llty = type_of(bcx.fcx.lcx.ccx, t);
|
||||
vec_val = bcx.build.PointerCast(vec_val, llty);
|
||||
|
||||
find_scope_cx(bcx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, vec_val, t)));
|
||||
[clean(bind drop_ty(_, vec_val, t))];
|
||||
|
||||
auto body = bcx.build.GEP(vec_val, vec(C_int(0),
|
||||
C_int(abi::vec_elt_data)));
|
||||
auto body = bcx.build.GEP(vec_val, [C_int(0),
|
||||
C_int(abi::vec_elt_data)]);
|
||||
|
||||
auto pseudo_tup_ty =
|
||||
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
|
||||
@@ -5317,7 +5317,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args,
|
||||
for (@ast::expr e in args) {
|
||||
auto src_res = trans_expr(bcx, e);
|
||||
bcx = src_res.bcx;
|
||||
auto dst_res = GEP_tup_like(bcx, pseudo_tup_ty, body, vec(0, i));
|
||||
auto dst_res = GEP_tup_like(bcx, pseudo_tup_ty, body, [0, i]);
|
||||
bcx = dst_res.bcx;
|
||||
|
||||
// Cast the destination type to the source type. This is needed to
|
||||
@@ -5344,7 +5344,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args,
|
||||
i += 1;
|
||||
}
|
||||
auto fill = bcx.build.GEP(vec_val,
|
||||
vec(C_int(0), C_int(abi::vec_elt_fill)));
|
||||
[C_int(0), C_int(abi::vec_elt_fill)]);
|
||||
bcx.build.Store(data_sz, fill);
|
||||
|
||||
ret res(bcx, vec_val);
|
||||
@@ -5360,7 +5360,7 @@ fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields,
|
||||
bcx = rec_res.bcx;
|
||||
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, rec_val, t)));
|
||||
[clean(bind drop_ty(_, rec_val, t))];
|
||||
let int i = 0;
|
||||
|
||||
auto base_val = C_nil();
|
||||
@@ -5374,14 +5374,14 @@ fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields,
|
||||
}
|
||||
}
|
||||
|
||||
let vec[ty::field] ty_fields = vec();
|
||||
let vec[ty::field] ty_fields = [];
|
||||
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
case (ty::ty_rec(?flds)) { ty_fields = flds; }
|
||||
}
|
||||
|
||||
for (ty::field tf in ty_fields) {
|
||||
auto e_ty = tf.mt.ty;
|
||||
auto dst_res = GEP_tup_like(bcx, t, rec_val, vec(0, i));
|
||||
auto dst_res = GEP_tup_like(bcx, t, rec_val, [0, i]);
|
||||
bcx = dst_res.bcx;
|
||||
|
||||
auto expr_provided = false;
|
||||
@@ -5394,7 +5394,7 @@ fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields,
|
||||
}
|
||||
}
|
||||
if (!expr_provided) {
|
||||
src_res = GEP_tup_like(bcx, t, base_val, vec(0, i));
|
||||
src_res = GEP_tup_like(bcx, t, base_val, [0, i]);
|
||||
src_res = res(src_res.bcx,
|
||||
load_if_immediate(bcx, src_res.val, e_ty));
|
||||
}
|
||||
@@ -5662,29 +5662,29 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
|
||||
}
|
||||
if (is32bit) {
|
||||
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_float,
|
||||
vec(log_bcx.fcx.lltaskptr, C_int(lvl),
|
||||
sub.val));
|
||||
[log_bcx.fcx.lltaskptr, C_int(lvl),
|
||||
sub.val]);
|
||||
} else {
|
||||
// FIXME: Eliminate this level of indirection.
|
||||
auto tmp = alloca(log_bcx, tr);
|
||||
sub.bcx.build.Store(sub.val, tmp);
|
||||
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_double,
|
||||
vec(log_bcx.fcx.lltaskptr, C_int(lvl), tmp));
|
||||
[log_bcx.fcx.lltaskptr, C_int(lvl), tmp]);
|
||||
}
|
||||
} else {
|
||||
alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
|
||||
case (ty::ty_str) {
|
||||
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_str,
|
||||
vec(log_bcx.fcx.lltaskptr, C_int(lvl),
|
||||
sub.val));
|
||||
[log_bcx.fcx.lltaskptr, C_int(lvl),
|
||||
sub.val]);
|
||||
}
|
||||
case (_) {
|
||||
// FIXME: Handle signedness properly.
|
||||
auto llintval = int_cast(log_bcx, T_int(), val_ty(sub.val),
|
||||
sub.val, false);
|
||||
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_int,
|
||||
vec(log_bcx.fcx.lltaskptr, C_int(lvl),
|
||||
llintval));
|
||||
[log_bcx.fcx.lltaskptr, C_int(lvl),
|
||||
llintval]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5729,7 +5729,7 @@ fn trans_fail(&@block_ctxt cx, &option::t[common::span] sp_opt, &str fail_str)
|
||||
V_fail_str = cx.build.PointerCast(V_fail_str, T_ptr(T_i8()));
|
||||
V_filename = cx.build.PointerCast(V_filename, T_ptr(T_i8()));
|
||||
|
||||
auto args = vec(cx.fcx.lltaskptr, V_fail_str, V_filename, C_int(V_line));
|
||||
auto args = [cx.fcx.lltaskptr, V_fail_str, V_filename, C_int(V_line)];
|
||||
|
||||
cx.build.Call(cx.fcx.lcx.ccx.upcalls._fail, args);
|
||||
cx.build.Unreachable();
|
||||
@@ -5745,28 +5745,28 @@ fn trans_put(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
|
||||
auto slot = alloca(cx, val_ty(lli));
|
||||
cx.build.Store(lli, slot);
|
||||
|
||||
llcallee = cx.build.GEP(slot, vec(C_int(0),
|
||||
C_int(abi::fn_field_code)));
|
||||
llcallee = cx.build.GEP(slot, [C_int(0),
|
||||
C_int(abi::fn_field_code)]);
|
||||
llcallee = cx.build.Load(llcallee);
|
||||
|
||||
llenv = cx.build.GEP(slot, vec(C_int(0),
|
||||
C_int(abi::fn_field_box)));
|
||||
llenv = cx.build.GEP(slot, [C_int(0),
|
||||
C_int(abi::fn_field_box)]);
|
||||
llenv = cx.build.Load(llenv);
|
||||
}
|
||||
}
|
||||
auto bcx = cx;
|
||||
auto dummy_retslot = alloca(bcx, T_nil());
|
||||
let vec[ValueRef] llargs = vec(dummy_retslot, cx.fcx.lltaskptr, llenv);
|
||||
let vec[ValueRef] llargs = [dummy_retslot, cx.fcx.lltaskptr, llenv];
|
||||
alt (e) {
|
||||
case (none[@ast::expr]) { }
|
||||
case (some[@ast::expr](?x)) {
|
||||
auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx,
|
||||
cx.fcx.lcx.ccx.node_types, x);
|
||||
auto arg = rec(mode=ty::mo_alias, ty=e_ty);
|
||||
auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, vec(arg));
|
||||
auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, [arg]);
|
||||
auto r = trans_arg_expr(bcx, arg, arg_tys.(0), x);
|
||||
bcx = r.bcx;
|
||||
llargs += vec(r.val);
|
||||
llargs += [r.val];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5882,11 +5882,11 @@ fn trans_port(&@block_ctxt cx, &ast::ann ann) -> result {
|
||||
auto unit_sz = size_of(bcx, unit_ty);
|
||||
bcx = unit_sz.bcx;
|
||||
auto port_raw_val = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.new_port,
|
||||
vec(bcx.fcx.lltaskptr, unit_sz.val));
|
||||
[bcx.fcx.lltaskptr, unit_sz.val]);
|
||||
auto llty = type_of(cx.fcx.lcx.ccx, t);
|
||||
auto port_val = bcx.build.PointerCast(port_raw_val, llty);
|
||||
auto dropref = clean(bind drop_ty(_, port_val, t));
|
||||
find_scope_cx(bcx).cleanups += vec(dropref);
|
||||
find_scope_cx(bcx).cleanups += [dropref];
|
||||
|
||||
ret res(bcx, port_val);
|
||||
}
|
||||
@@ -5899,13 +5899,13 @@ fn trans_chan(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
|
||||
|
||||
auto prt_val = bcx.build.PointerCast(prt.val, T_opaque_port_ptr());
|
||||
auto chan_raw_val = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.new_chan,
|
||||
vec(bcx.fcx.lltaskptr, prt_val));
|
||||
[bcx.fcx.lltaskptr, prt_val]);
|
||||
|
||||
auto chan_ty = node_ann_type(bcx.fcx.lcx.ccx, ann);
|
||||
auto chan_llty = type_of(bcx.fcx.lcx.ccx, chan_ty);
|
||||
auto chan_val = bcx.build.PointerCast(chan_raw_val, chan_llty);
|
||||
auto dropref = clean(bind drop_ty(_, chan_val, chan_ty));
|
||||
find_scope_cx(bcx).cleanups += vec(dropref);
|
||||
find_scope_cx(bcx).cleanups += [dropref];
|
||||
|
||||
ret res(bcx, chan_val);
|
||||
}
|
||||
@@ -5937,12 +5937,12 @@ fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
|
||||
bcx = data_tmp.bcx;
|
||||
|
||||
find_scope_cx(bcx).cleanups +=
|
||||
vec(clean(bind drop_ty(_, data_alloc.val, unit_ty)));
|
||||
[clean(bind drop_ty(_, data_alloc.val, unit_ty))];
|
||||
|
||||
auto llchanval = bcx.build.PointerCast(chn.val, T_opaque_chan_ptr());
|
||||
auto lldataptr = bcx.build.PointerCast(data_alloc.val, T_ptr(T_i8()));
|
||||
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.send,
|
||||
vec(bcx.fcx.lltaskptr, llchanval, lldataptr));
|
||||
[bcx.fcx.lltaskptr, llchanval, lldataptr]);
|
||||
|
||||
ret res(bcx, chn.val);
|
||||
}
|
||||
@@ -5970,7 +5970,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs,
|
||||
auto lldataptr = bcx.build.PointerCast(lhs, T_ptr(T_ptr(T_i8())));
|
||||
auto llportptr = bcx.build.PointerCast(prt.val, T_opaque_port_ptr());
|
||||
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.recv,
|
||||
vec(bcx.fcx.lltaskptr, lldataptr, llportptr));
|
||||
[bcx.fcx.lltaskptr, lldataptr, llportptr]);
|
||||
|
||||
auto data_load = load_if_immediate(bcx, lhs, unit_ty);
|
||||
auto cp = copy_ty(bcx, action, lhs, data_load, unit_ty);
|
||||
@@ -5990,7 +5990,7 @@ fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
|
||||
auto bcx = cx;
|
||||
|
||||
find_scope_cx(cx).cleanups +=
|
||||
vec(clean(bind drop_slot(_, llptr, ty)));
|
||||
[clean(bind drop_slot(_, llptr, ty))];
|
||||
|
||||
alt (local.init) {
|
||||
case (some[ast::initializer](?init)) {
|
||||
@@ -6061,7 +6061,7 @@ fn new_builder(BasicBlockRef llbb) -> builder {
|
||||
fn new_block_ctxt(&@fn_ctxt cx, &block_parent parent,
|
||||
block_kind kind,
|
||||
&str name) -> @block_ctxt {
|
||||
let vec[cleanup] cleanups = vec();
|
||||
let vec[cleanup] cleanups = [];
|
||||
auto s = _str::buf("");
|
||||
if (cx.lcx.ccx.sess.get_opts().save_temps) {
|
||||
s = _str::buf(cx.lcx.ccx.names.next(name));
|
||||
@@ -6098,7 +6098,7 @@ fn new_sub_block_ctxt(&@block_ctxt bcx, &str n) -> @block_ctxt {
|
||||
}
|
||||
|
||||
fn new_raw_block_ctxt(&@fn_ctxt fcx, BasicBlockRef llbb) -> @block_ctxt {
|
||||
let vec[cleanup] cleanups = vec();
|
||||
let vec[cleanup] cleanups = [];
|
||||
ret @rec(llbb=llbb, build=new_builder(llbb), parent=parent_none,
|
||||
kind=NON_SCOPE_BLOCK, mutable cleanups=cleanups, fcx=fcx);
|
||||
}
|
||||
@@ -6144,7 +6144,7 @@ fn trans_block_cleanups(&@block_ctxt cx,
|
||||
}
|
||||
|
||||
fn llallocas_block_ctxt(&@fn_ctxt fcx) -> @block_ctxt {
|
||||
let vec[cleanup] cleanups = vec();
|
||||
let vec[cleanup] cleanups = [];
|
||||
ret @rec(llbb=fcx.llallocas,
|
||||
build=new_builder(fcx.llallocas),
|
||||
parent=parent_none,
|
||||
@@ -6246,7 +6246,7 @@ fn drop_hoisted_ty(&@block_ctxt cx,
|
||||
|
||||
auto cleanup = bind drop_hoisted_ty(_, res_alloca.val,
|
||||
r_ty);
|
||||
find_outer_scope_cx(bcx).cleanups += vec(clean(cleanup));
|
||||
find_outer_scope_cx(bcx).cleanups += [clean(cleanup)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6260,11 +6260,11 @@ fn drop_hoisted_ty(&@block_ctxt cx,
|
||||
}
|
||||
|
||||
fn new_local_ctxt(&@crate_ctxt ccx) -> @local_ctxt {
|
||||
let vec[str] pth = vec();
|
||||
let vec[ast::ty_param] obj_typarams = vec();
|
||||
let vec[ast::obj_field] obj_fields = vec();
|
||||
let vec[str] pth = [];
|
||||
let vec[ast::ty_param] obj_typarams = [];
|
||||
let vec[ast::obj_field] obj_fields = [];
|
||||
ret @rec(path=pth,
|
||||
module_path=vec(crate_name(ccx, "main")),
|
||||
module_path=[crate_name(ccx, "main")],
|
||||
obj_typarams = obj_typarams,
|
||||
obj_fields = obj_fields,
|
||||
ccx = ccx);
|
||||
@@ -6346,7 +6346,7 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
|
||||
for (ast::ty_param tp in ty_params) {
|
||||
auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
|
||||
assert (llarg as int != 0);
|
||||
cx.lltydescs += vec(llarg);
|
||||
cx.lltydescs += [llarg];
|
||||
arg_n += 1u;
|
||||
i += 1u;
|
||||
}
|
||||
@@ -6422,7 +6422,7 @@ fn add_cleanups_for_args(&@block_ctxt bcx,
|
||||
if (aarg.mode != ast::alias) {
|
||||
auto argval = bcx.fcx.llargs.get(aarg.id);
|
||||
find_scope_cx(bcx).cleanups +=
|
||||
vec(clean(bind drop_slot(_, argval, arg_tys.(arg_n).ty)));
|
||||
[clean(bind drop_slot(_, argval, arg_tys.(arg_n).ty))];
|
||||
}
|
||||
arg_n += 1u;
|
||||
}
|
||||
@@ -6460,10 +6460,10 @@ fn ret_ty_of_fn(&@crate_ctxt ccx, ast::ann ann) -> ty::t {
|
||||
fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
|
||||
auto bcx = llallocas_block_ctxt(fcx);
|
||||
|
||||
let vec[ty::t] field_tys = vec();
|
||||
let vec[ty::t] field_tys = [];
|
||||
|
||||
for (ast::obj_field f in bcx.fcx.lcx.obj_fields) {
|
||||
field_tys += vec(node_ann_type(bcx.fcx.lcx.ccx, f.ann));
|
||||
field_tys += [node_ann_type(bcx.fcx.lcx.ccx, f.ann)];
|
||||
}
|
||||
|
||||
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
|
||||
@@ -6475,17 +6475,17 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
|
||||
|
||||
auto box_cell =
|
||||
bcx.build.GEP(llself.v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_box)]);
|
||||
|
||||
auto box_ptr = bcx.build.Load(box_cell);
|
||||
|
||||
box_ptr = bcx.build.PointerCast(box_ptr, llobj_box_ty);
|
||||
|
||||
auto obj_typarams = bcx.build.GEP(box_ptr,
|
||||
vec(C_int(0),
|
||||
[C_int(0),
|
||||
C_int(abi::box_rc_field_body),
|
||||
C_int(abi::obj_body_elt_typarams)));
|
||||
C_int(abi::obj_body_elt_typarams)]);
|
||||
|
||||
// The object fields immediately follow the type parameters, so we skip
|
||||
// over them to get the pointer.
|
||||
@@ -6507,16 +6507,16 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
|
||||
|
||||
for (ast::ty_param p in fcx.lcx.obj_typarams) {
|
||||
let ValueRef lltyparam = bcx.build.GEP(obj_typarams,
|
||||
vec(C_int(0),
|
||||
C_int(i)));
|
||||
[C_int(0),
|
||||
C_int(i)]);
|
||||
lltyparam = bcx.build.Load(lltyparam);
|
||||
fcx.lltydescs += vec(lltyparam);
|
||||
fcx.lltydescs += [lltyparam];
|
||||
i += 1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (ast::obj_field f in fcx.lcx.obj_fields) {
|
||||
auto rslt = GEP_tup_like(bcx, fields_tup_ty, obj_fields, vec(0, i));
|
||||
auto rslt = GEP_tup_like(bcx, fields_tup_ty, obj_fields, [0, i]);
|
||||
bcx = llallocas_block_ctxt(fcx);
|
||||
auto llfield = rslt.val;
|
||||
fcx.llobjfields.insert(f.id, llfield);
|
||||
@@ -6584,7 +6584,7 @@ fn trans_vtbl(@local_ctxt cx,
|
||||
}
|
||||
case (none[@ast::method]) {}
|
||||
}
|
||||
let vec[ValueRef] methods = vec(dtor);
|
||||
let vec[ValueRef] methods = [dtor];
|
||||
|
||||
fn meth_lteq(&@ast::method a, &@ast::method b) -> bool {
|
||||
ret _str::lteq(a.node.ident, b.node.ident);
|
||||
@@ -6615,7 +6615,7 @@ fn meth_lteq(&@ast::method a, &@ast::method b) -> bool {
|
||||
trans_fn(mcx, m.node.meth, m.node.id,
|
||||
some[tup(TypeRef, ty::t)](tup(llself_ty, self_ty)),
|
||||
ty_params, m.node.ann);
|
||||
methods += vec(llfn);
|
||||
methods += [llfn];
|
||||
}
|
||||
auto vtbl = C_struct(methods);
|
||||
auto vtbl_name = mangle_name_by_seq(cx.ccx, cx.path, "vtbl");
|
||||
@@ -6654,9 +6654,9 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
auto llctor_decl = ccx.item_ids.get(oid);
|
||||
|
||||
// Translate obj ctor args to function arguments.
|
||||
let vec[ast::arg] fn_args = vec();
|
||||
let vec[ast::arg] fn_args = [];
|
||||
for (ast::obj_field f in ob.fields) {
|
||||
fn_args += vec(rec(mode=ast::alias, ty=f.ty, ident=f.ident, id=f.id));
|
||||
fn_args += [rec(mode=ast::alias, ty=f.ty, ident=f.ident, id=f.id)];
|
||||
}
|
||||
|
||||
auto fcx = new_fn_ctxt(cx, llctor_decl);
|
||||
@@ -6677,11 +6677,11 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
|
||||
auto vtbl = trans_vtbl(cx, llself_ty, self_ty, ob, ty_params);
|
||||
auto pair_vtbl = bcx.build.GEP(pair,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_vtbl)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_vtbl)]);
|
||||
auto pair_box = bcx.build.GEP(pair,
|
||||
vec(C_int(0),
|
||||
C_int(abi::obj_field_box)));
|
||||
[C_int(0),
|
||||
C_int(abi::obj_field_box)]);
|
||||
bcx.build.Store(vtbl, pair_vtbl);
|
||||
|
||||
let TypeRef llbox_ty = T_opaque_obj_ptr(ccx.tn);
|
||||
@@ -6694,14 +6694,14 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
bcx.build.Store(C_null(llbox_ty), pair_box);
|
||||
} else {
|
||||
// Malloc a box for the body and copy args in.
|
||||
let vec[ty::t] obj_fields = vec();
|
||||
let vec[ty::t] obj_fields = [];
|
||||
for (ty::arg a in arg_tys) {
|
||||
_vec::push[ty::t](obj_fields, a.ty);
|
||||
}
|
||||
|
||||
// Synthesize an obj body type.
|
||||
auto tydesc_ty = ty::mk_type(ccx.tcx);
|
||||
let vec[ty::t] tps = vec();
|
||||
let vec[ty::t] tps = [];
|
||||
for (ast::ty_param tp in ty_params) {
|
||||
_vec::push[ty::t](tps, tydesc_ty);
|
||||
}
|
||||
@@ -6709,26 +6709,26 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
|
||||
let ty::t fields_ty = ty::mk_imm_tup(ccx.tcx, obj_fields);
|
||||
let ty::t body_ty = ty::mk_imm_tup(ccx.tcx,
|
||||
vec(tydesc_ty,
|
||||
[tydesc_ty,
|
||||
typarams_ty,
|
||||
fields_ty));
|
||||
fields_ty]);
|
||||
let ty::t boxed_body_ty = ty::mk_imm_box(ccx.tcx, body_ty);
|
||||
|
||||
// Malloc a box for the body.
|
||||
auto box = trans_malloc_boxed(bcx, body_ty);
|
||||
bcx = box.bcx;
|
||||
auto rc = GEP_tup_like(bcx, boxed_body_ty, box.val,
|
||||
vec(0, abi::box_rc_field_refcnt));
|
||||
[0, abi::box_rc_field_refcnt]);
|
||||
bcx = rc.bcx;
|
||||
auto body = GEP_tup_like(bcx, boxed_body_ty, box.val,
|
||||
vec(0, abi::box_rc_field_body));
|
||||
[0, abi::box_rc_field_body]);
|
||||
bcx = body.bcx;
|
||||
bcx.build.Store(C_int(1), rc.val);
|
||||
|
||||
// Store body tydesc.
|
||||
auto body_tydesc =
|
||||
GEP_tup_like(bcx, body_ty, body.val,
|
||||
vec(0, abi::obj_body_elt_tydesc));
|
||||
[0, abi::obj_body_elt_tydesc]);
|
||||
bcx = body_tydesc.bcx;
|
||||
|
||||
auto ti = none[@tydesc_info];
|
||||
@@ -6749,13 +6749,13 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
// Copy typarams into captured typarams.
|
||||
auto body_typarams =
|
||||
GEP_tup_like(bcx, body_ty, body.val,
|
||||
vec(0, abi::obj_body_elt_typarams));
|
||||
[0, abi::obj_body_elt_typarams]);
|
||||
bcx = body_typarams.bcx;
|
||||
let int i = 0;
|
||||
for (ast::ty_param tp in ty_params) {
|
||||
auto typaram = bcx.fcx.lltydescs.(i);
|
||||
auto capture = GEP_tup_like(bcx, typarams_ty, body_typarams.val,
|
||||
vec(0, i));
|
||||
[0, i]);
|
||||
bcx = capture.bcx;
|
||||
bcx = copy_ty(bcx, INIT, capture.val, typaram, tydesc_ty).bcx;
|
||||
i += 1;
|
||||
@@ -6764,7 +6764,7 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
// Copy args into body fields.
|
||||
auto body_fields =
|
||||
GEP_tup_like(bcx, body_ty, body.val,
|
||||
vec(0, abi::obj_body_elt_fields));
|
||||
[0, abi::obj_body_elt_fields]);
|
||||
bcx = body_fields.bcx;
|
||||
|
||||
i = 0;
|
||||
@@ -6772,7 +6772,7 @@ fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
|
||||
auto arg = bcx.fcx.llargs.get(f.id);
|
||||
arg = load_if_immediate(bcx, arg, arg_tys.(i).ty);
|
||||
auto field = GEP_tup_like(bcx, fields_ty, body_fields.val,
|
||||
vec(0, i));
|
||||
[0, i]);
|
||||
bcx = field.bcx;
|
||||
bcx = copy_ty(bcx, INIT, field.val, arg, arg_tys.(i).ty).bcx;
|
||||
i += 1;
|
||||
@@ -6794,13 +6794,13 @@ fn trans_tag_variant(@local_ctxt cx, ast::def_id tag_id,
|
||||
}
|
||||
|
||||
// Translate variant arguments to function arguments.
|
||||
let vec[ast::arg] fn_args = vec();
|
||||
let vec[ast::arg] fn_args = [];
|
||||
auto i = 0u;
|
||||
for (ast::variant_arg varg in variant.node.args) {
|
||||
fn_args += vec(rec(mode=ast::alias,
|
||||
fn_args += [rec(mode=ast::alias,
|
||||
ty=varg.ty,
|
||||
ident="arg" + _uint::to_str(i, 10u),
|
||||
id=varg.id));
|
||||
id=varg.id)];
|
||||
}
|
||||
|
||||
assert (cx.ccx.item_ids.contains_key(variant.node.id));
|
||||
@@ -6813,10 +6813,10 @@ fn trans_tag_variant(@local_ctxt cx, ast::def_id tag_id,
|
||||
ret_ty_of_fn(cx.ccx, variant.node.ann),
|
||||
fn_args, ty_params);
|
||||
|
||||
let vec[ty::t] ty_param_substs = vec();
|
||||
let vec[ty::t] ty_param_substs = [];
|
||||
i = 0u;
|
||||
for (ast::ty_param tp in ty_params) {
|
||||
ty_param_substs += vec(ty::mk_param(cx.ccx.tcx, i));
|
||||
ty_param_substs += [ty::mk_param(cx.ccx.tcx, i)];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -6831,11 +6831,11 @@ fn trans_tag_variant(@local_ctxt cx, ast::def_id tag_id,
|
||||
T_opaque_tag_ptr(fcx.lcx.ccx.tn));
|
||||
|
||||
auto lldiscrimptr = bcx.build.GEP(lltagptr,
|
||||
vec(C_int(0), C_int(0)));
|
||||
[C_int(0), C_int(0)]);
|
||||
bcx.build.Store(C_int(index), lldiscrimptr);
|
||||
|
||||
auto llblobptr = bcx.build.GEP(lltagptr,
|
||||
vec(C_int(0), C_int(1)));
|
||||
[C_int(0), C_int(1)]);
|
||||
|
||||
i = 0u;
|
||||
for (ast::variant_arg va in variant.node.args) {
|
||||
@@ -6911,8 +6911,8 @@ fn trans_item(@local_ctxt cx, &ast::item item) {
|
||||
trans_obj(sub_cx, ob, oid.ctor, tps, ann);
|
||||
}
|
||||
case (ast::item_mod(?name, ?m, _)) {
|
||||
auto sub_cx = @rec(path = cx.path + vec(name),
|
||||
module_path = cx.module_path + vec(name)
|
||||
auto sub_cx = @rec(path = cx.path + [name],
|
||||
module_path = cx.module_path + [name]
|
||||
with *cx);
|
||||
trans_mod(sub_cx, m);
|
||||
}
|
||||
@@ -6939,7 +6939,7 @@ fn trans_mod(@local_ctxt cx, &ast::_mod m) {
|
||||
|
||||
fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
|
||||
// Bit of a kludge: pick the fn typeref out of the pair.
|
||||
let vec[TypeRef] pair_tys = vec(T_nil(), T_nil());
|
||||
let vec[TypeRef] pair_tys = [T_nil(), T_nil()];
|
||||
llvm::LLVMGetStructElementTypes(llpairty,
|
||||
_vec::buf[TypeRef](pair_tys));
|
||||
ret llvm::LLVMGetElementType(pair_tys.(0));
|
||||
@@ -6980,8 +6980,8 @@ fn register_fn_pair(&@crate_ctxt cx, str ps, TypeRef llpairty, ValueRef llfn,
|
||||
ast::def_id id) {
|
||||
let ValueRef gvar = llvm::LLVMAddGlobal(cx.llmod, llpairty,
|
||||
_str::buf(ps));
|
||||
auto pair = C_struct(vec(llfn,
|
||||
C_null(T_opaque_closure_ptr(cx.tn))));
|
||||
auto pair = C_struct([llfn,
|
||||
C_null(T_opaque_closure_ptr(cx.tn))]);
|
||||
|
||||
llvm::LLVMSetInitializer(gvar, pair);
|
||||
llvm::LLVMSetGlobalConstant(gvar, True);
|
||||
@@ -7089,19 +7089,19 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
|
||||
lltaskptr = fcx.lltaskptr;
|
||||
}
|
||||
|
||||
let vec[ValueRef] call_args = vec();
|
||||
if (pass_task) { call_args += vec(lltaskptr); }
|
||||
let vec[ValueRef] call_args = [];
|
||||
if (pass_task) { call_args += [lltaskptr]; }
|
||||
|
||||
auto arg_n = 3u;
|
||||
for each (uint i in _uint::range(0u, num_ty_param)) {
|
||||
auto llarg = llvm::LLVMGetParam(fcx.llfn, arg_n);
|
||||
fcx.lltydescs += vec(llarg);
|
||||
fcx.lltydescs += [llarg];
|
||||
assert (llarg as int != 0);
|
||||
|
||||
if (cast_to_i32) {
|
||||
call_args += vec(vp2i(bcx, llarg));
|
||||
call_args += [vp2i(bcx, llarg)];
|
||||
} else {
|
||||
call_args += vec(llarg);
|
||||
call_args += [llarg];
|
||||
}
|
||||
|
||||
arg_n += 1u;
|
||||
@@ -7134,9 +7134,9 @@ fn trans_simple_native_abi(&@block_ctxt bcx,
|
||||
&mutable vec[ValueRef] call_args,
|
||||
ty::t fn_type,
|
||||
uint first_arg_n) -> tup(ValueRef, ValueRef) {
|
||||
let vec[TypeRef] call_arg_tys = vec();
|
||||
let vec[TypeRef] call_arg_tys = [];
|
||||
for (ValueRef arg in call_args) {
|
||||
call_arg_tys += vec(val_ty(arg));
|
||||
call_arg_tys += [val_ty(arg)];
|
||||
}
|
||||
|
||||
auto llnativefnty =
|
||||
@@ -7158,7 +7158,7 @@ fn trans_simple_native_abi(&@block_ctxt bcx,
|
||||
auto args = ty::ty_fn_args(ccx.tcx, fn_type);
|
||||
|
||||
// Build up the list of arguments.
|
||||
let vec[tup(ValueRef, ty::t)] drop_args = vec();
|
||||
let vec[tup(ValueRef, ty::t)] drop_args = [];
|
||||
auto i = arg_n;
|
||||
for (ty::arg arg in args) {
|
||||
auto llarg = llvm::LLVMGetParam(fcx.llfn, i);
|
||||
@@ -7166,13 +7166,13 @@ fn trans_simple_native_abi(&@block_ctxt bcx,
|
||||
|
||||
if (cast_to_i32) {
|
||||
auto llarg_i32 = convert_arg_to_i32(bcx, llarg, arg.ty, arg.mode);
|
||||
call_args += vec(llarg_i32);
|
||||
call_args += [llarg_i32];
|
||||
} else {
|
||||
call_args += vec(llarg);
|
||||
call_args += [llarg];
|
||||
}
|
||||
|
||||
if (arg.mode == ty::mo_val) {
|
||||
drop_args += vec(tup(llarg, arg.ty));
|
||||
drop_args += [tup(llarg, arg.ty)];
|
||||
}
|
||||
|
||||
i += 1u;
|
||||
@@ -7217,7 +7217,7 @@ fn trans_simple_native_abi(&@block_ctxt bcx,
|
||||
|
||||
type walk_ctxt = rec(mutable vec[str] path);
|
||||
fn new_walk_ctxt() -> @walk_ctxt {
|
||||
let vec[str] path = vec();
|
||||
let vec[str] path = [];
|
||||
ret @rec(mutable path=path);
|
||||
}
|
||||
|
||||
@@ -7338,7 +7338,7 @@ fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
|
||||
case (ast::item_tag(_, ?variants, ?tps, _, _)) {
|
||||
for (ast::variant variant in variants) {
|
||||
if (_vec::len[ast::variant_arg](variant.node.args) != 0u) {
|
||||
decl_fn_and_pair(ccx, wcx.path + vec(variant.node.name),
|
||||
decl_fn_and_pair(ccx, wcx.path + [variant.node.name],
|
||||
"tag", tps, variant.node.ann,
|
||||
variant.node.id);
|
||||
}
|
||||
@@ -7392,7 +7392,7 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item it) {
|
||||
// with consts.
|
||||
auto v = C_int(1);
|
||||
ccx.item_ids.insert(cid, v);
|
||||
auto s = mangle_name_by_type(ccx, wcx.path + vec(name),
|
||||
auto s = mangle_name_by_type(ccx, wcx.path + [name],
|
||||
node_ann_type(ccx, ann));
|
||||
ccx.item_symbols.insert(cid, s);
|
||||
}
|
||||
@@ -7430,8 +7430,8 @@ fn i2p(ValueRef v, TypeRef t) -> ValueRef {
|
||||
fn trans_exit_task_glue(@glue_fns glues,
|
||||
&hashmap[str, ValueRef] externs,
|
||||
type_names tn, ModuleRef llmod) {
|
||||
let vec[TypeRef] T_args = vec();
|
||||
let vec[ValueRef] V_args = vec();
|
||||
let vec[TypeRef] T_args = [];
|
||||
let vec[ValueRef] V_args = [];
|
||||
|
||||
auto llfn = glues.exit_task_glue;
|
||||
|
||||
@@ -7444,14 +7444,14 @@ fn trans_exit_task_glue(@glue_fns glues,
|
||||
let ValueRef arg4 = llvm::LLVMGetParam(llfn, 3u);
|
||||
let ValueRef arg5 = llvm::LLVMGetParam(llfn, 4u);
|
||||
|
||||
auto main_type = T_fn(vec(T_int(), T_int(), T_int(), T_int()), T_void());
|
||||
auto main_type = T_fn([T_int(), T_int(), T_int(), T_int()], T_void());
|
||||
|
||||
auto fun = build.IntToPtr(arg1, T_ptr(main_type));
|
||||
auto call_args = vec(arg2, arg3, arg4, arg5);
|
||||
auto call_args = [arg2, arg3, arg4, arg5];
|
||||
build.FastCall(fun, call_args);
|
||||
|
||||
trans_native_call(build, glues, arg3,
|
||||
externs, tn, llmod, "upcall_exit", true, vec(arg3));
|
||||
externs, tn, llmod, "upcall_exit", true, [arg3]);
|
||||
|
||||
build.RetVoid();
|
||||
}
|
||||
@@ -7476,7 +7476,7 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
|
||||
llvm::LLVMConstSub(p2i(glues.exit_task_glue), crate_addr);
|
||||
|
||||
let ValueRef crate_val =
|
||||
C_struct(vec(C_null(T_int()), // ptrdiff_t image_base_off
|
||||
C_struct([C_null(T_int()), // ptrdiff_t image_base_off
|
||||
p2i(crate_ptr), // uintptr_t self_addr
|
||||
C_null(T_int()), // ptrdiff_t debug_abbrev_off
|
||||
C_null(T_int()), // size_t debug_abbrev_sz
|
||||
@@ -7491,7 +7491,7 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
|
||||
C_null(T_int()), // int n_c_syms
|
||||
C_null(T_int()), // int n_libs
|
||||
C_int(abi::abi_x86_rustc_fastcall) // uintptr_t abi_tag
|
||||
));
|
||||
]);
|
||||
|
||||
llvm::LLVMSetInitializer(crate_ptr, crate_val);
|
||||
}
|
||||
@@ -7521,8 +7521,8 @@ fn find_main_fn(&@crate_ctxt cx) -> ValueRef {
|
||||
}
|
||||
|
||||
fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
|
||||
auto T_main_args = vec(T_int(), T_int());
|
||||
auto T_rust_start_args = vec(T_int(), T_int(), T_int(), T_int(), T_int());
|
||||
auto T_main_args = [T_int(), T_int()];
|
||||
auto T_rust_start_args = [T_int(), T_int(), T_int(), T_int(), T_int()];
|
||||
|
||||
auto main_name;
|
||||
if (_str::eq(std::os::target_os(), "win32")) {
|
||||
@@ -7553,25 +7553,25 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
|
||||
llvm::LLVMAppendBasicBlock(llmain, _str::buf(""));
|
||||
auto b = new_builder(llbb);
|
||||
|
||||
auto start_args = vec(p2i(llrust_main), p2i(llcrate), llargc, llargv,
|
||||
p2i(crate_map));
|
||||
auto start_args = [p2i(llrust_main), p2i(llcrate), llargc, llargv,
|
||||
p2i(crate_map)];
|
||||
|
||||
b.Ret(b.Call(llrust_start, start_args));
|
||||
}
|
||||
|
||||
fn declare_intrinsics(ModuleRef llmod) -> hashmap[str,ValueRef] {
|
||||
|
||||
let vec[TypeRef] T_memmove32_args = vec(T_ptr(T_i8()), T_ptr(T_i8()),
|
||||
T_i32(), T_i32(), T_i1());
|
||||
let vec[TypeRef] T_memmove64_args = vec(T_ptr(T_i8()), T_ptr(T_i8()),
|
||||
T_i64(), T_i32(), T_i1());
|
||||
let vec[TypeRef] T_memmove32_args = [T_ptr(T_i8()), T_ptr(T_i8()),
|
||||
T_i32(), T_i32(), T_i1()];
|
||||
let vec[TypeRef] T_memmove64_args = [T_ptr(T_i8()), T_ptr(T_i8()),
|
||||
T_i64(), T_i32(), T_i1()];
|
||||
|
||||
let vec[TypeRef] T_memset32_args = vec(T_ptr(T_i8()), T_i8(),
|
||||
T_i32(), T_i32(), T_i1());
|
||||
let vec[TypeRef] T_memset64_args = vec(T_ptr(T_i8()), T_i8(),
|
||||
T_i64(), T_i32(), T_i1());
|
||||
let vec[TypeRef] T_memset32_args = [T_ptr(T_i8()), T_i8(),
|
||||
T_i32(), T_i32(), T_i1()];
|
||||
let vec[TypeRef] T_memset64_args = [T_ptr(T_i8()), T_i8(),
|
||||
T_i64(), T_i32(), T_i1()];
|
||||
|
||||
let vec[TypeRef] T_trap_args = vec();
|
||||
let vec[TypeRef] T_trap_args = [];
|
||||
|
||||
auto memmove32 = decl_cdecl_fn(llmod, "llvm.memmove.p0i8.p0i8.i32",
|
||||
T_fn(T_memmove32_args, T_void()));
|
||||
@@ -7598,12 +7598,12 @@ fn declare_intrinsics(ModuleRef llmod) -> hashmap[str,ValueRef] {
|
||||
|
||||
fn trace_str(&@block_ctxt cx, str s) {
|
||||
cx.build.Call(cx.fcx.lcx.ccx.upcalls.trace_str,
|
||||
vec(cx.fcx.lltaskptr, C_cstr(cx.fcx.lcx.ccx, s)));
|
||||
[cx.fcx.lltaskptr, C_cstr(cx.fcx.lcx.ccx, s)]);
|
||||
}
|
||||
|
||||
fn trace_word(&@block_ctxt cx, ValueRef v) {
|
||||
cx.build.Call(cx.fcx.lcx.ccx.upcalls.trace_word,
|
||||
vec(cx.fcx.lltaskptr, v));
|
||||
[cx.fcx.lltaskptr, v]);
|
||||
}
|
||||
|
||||
fn trace_ptr(&@block_ctxt cx, ValueRef v) {
|
||||
@@ -7611,12 +7611,12 @@ fn trace_ptr(&@block_ctxt cx, ValueRef v) {
|
||||
}
|
||||
|
||||
fn trap(&@block_ctxt bcx) {
|
||||
let vec[ValueRef] v = vec();
|
||||
let vec[ValueRef] v = [];
|
||||
bcx.build.Call(bcx.fcx.lcx.ccx.intrinsics.get("llvm.trap"), v);
|
||||
}
|
||||
|
||||
fn decl_no_op_type_glue(ModuleRef llmod, type_names tn) -> ValueRef {
|
||||
auto ty = T_fn(vec(T_taskptr(tn), T_ptr(T_i8())), T_void());
|
||||
auto ty = T_fn([T_taskptr(tn), T_ptr(T_i8())], T_void());
|
||||
ret decl_fastcall_fn(llmod, abi::no_op_type_glue_name(), ty);
|
||||
}
|
||||
|
||||
@@ -7647,11 +7647,11 @@ fn make_vec_append_glue(ModuleRef llmod, type_names tn) -> ValueRef {
|
||||
*
|
||||
*/
|
||||
|
||||
auto ty = T_fn(vec(T_taskptr(tn),
|
||||
auto ty = T_fn([T_taskptr(tn),
|
||||
T_ptr(T_tydesc(tn)),
|
||||
T_ptr(T_tydesc(tn)),
|
||||
T_ptr(T_opaque_vec_ptr()),
|
||||
T_opaque_vec_ptr(), T_bool()),
|
||||
T_opaque_vec_ptr(), T_bool()],
|
||||
T_void());
|
||||
|
||||
auto llfn = decl_fastcall_fn(llmod, abi::vec_append_glue_name(), ty);
|
||||
@@ -7660,41 +7660,41 @@ fn make_vec_append_glue(ModuleRef llmod, type_names tn) -> ValueRef {
|
||||
|
||||
|
||||
fn vec_fill(&@block_ctxt bcx, ValueRef v) -> ValueRef {
|
||||
ret bcx.build.Load(bcx.build.GEP(v, vec(C_int(0),
|
||||
C_int(abi::vec_elt_fill))));
|
||||
ret bcx.build.Load(bcx.build.GEP(v, [C_int(0),
|
||||
C_int(abi::vec_elt_fill)]));
|
||||
}
|
||||
|
||||
fn put_vec_fill(&@block_ctxt bcx, ValueRef v, ValueRef fill) -> ValueRef {
|
||||
ret bcx.build.Store(fill,
|
||||
bcx.build.GEP(v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::vec_elt_fill))));
|
||||
[C_int(0),
|
||||
C_int(abi::vec_elt_fill)]));
|
||||
}
|
||||
|
||||
fn vec_fill_adjusted(&@block_ctxt bcx, ValueRef v,
|
||||
ValueRef skipnull) -> ValueRef {
|
||||
auto f = bcx.build.Load(bcx.build.GEP(v,
|
||||
vec(C_int(0),
|
||||
C_int(abi::vec_elt_fill))));
|
||||
[C_int(0),
|
||||
C_int(abi::vec_elt_fill)]));
|
||||
ret bcx.build.Select(skipnull, bcx.build.Sub(f, C_int(1)), f);
|
||||
}
|
||||
|
||||
fn vec_p0(&@block_ctxt bcx, ValueRef v) -> ValueRef {
|
||||
auto p = bcx.build.GEP(v, vec(C_int(0),
|
||||
C_int(abi::vec_elt_data)));
|
||||
auto p = bcx.build.GEP(v, [C_int(0),
|
||||
C_int(abi::vec_elt_data)]);
|
||||
ret bcx.build.PointerCast(p, T_ptr(T_i8()));
|
||||
}
|
||||
|
||||
|
||||
fn vec_p1(&@block_ctxt bcx, ValueRef v) -> ValueRef {
|
||||
auto len = vec_fill(bcx, v);
|
||||
ret bcx.build.GEP(vec_p0(bcx, v), vec(len));
|
||||
ret bcx.build.GEP(vec_p0(bcx, v), [len]);
|
||||
}
|
||||
|
||||
fn vec_p1_adjusted(&@block_ctxt bcx, ValueRef v,
|
||||
ValueRef skipnull) -> ValueRef {
|
||||
auto len = vec_fill_adjusted(bcx, v, skipnull);
|
||||
ret bcx.build.GEP(vec_p0(bcx, v), vec(len));
|
||||
ret bcx.build.GEP(vec_p0(bcx, v), [len]);
|
||||
}
|
||||
|
||||
fn trans_vec_append_glue(@local_ctxt cx) {
|
||||
@@ -7739,9 +7739,9 @@ fn trans_vec_append_glue(@local_ctxt cx) {
|
||||
|
||||
auto llcopy_dst_ptr = alloca(bcx, T_int());
|
||||
auto llnew_vec = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.vec_grow,
|
||||
vec(bcx.fcx.lltaskptr, lldst_vec,
|
||||
[bcx.fcx.lltaskptr, lldst_vec,
|
||||
vec_fill_adjusted(bcx, llsrc_vec, llskipnull),
|
||||
llcopy_dst_ptr, llvec_tydesc));
|
||||
llcopy_dst_ptr, llvec_tydesc]);
|
||||
maybe_name_value(bcx.fcx.lcx.ccx, llnew_vec, "llnew_vec");
|
||||
|
||||
auto copy_dst_cx = new_sub_block_ctxt(bcx, "copy new <- dst");
|
||||
@@ -7764,19 +7764,19 @@ fn copy_elts(&@block_ctxt cx,
|
||||
ValueRef src,
|
||||
ValueRef n_bytes) -> result {
|
||||
|
||||
auto src_lim = cx.build.GEP(src, vec(n_bytes));
|
||||
auto src_lim = cx.build.GEP(src, [n_bytes]);
|
||||
maybe_name_value(cx.fcx.lcx.ccx, src_lim, "src_lim");
|
||||
|
||||
auto elt_llsz =
|
||||
cx.build.Load(cx.build.GEP(elt_tydesc,
|
||||
vec(C_int(0),
|
||||
C_int(abi::tydesc_field_size))));
|
||||
[C_int(0),
|
||||
C_int(abi::tydesc_field_size)]));
|
||||
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llsz");
|
||||
|
||||
auto elt_llalign =
|
||||
cx.build.Load(cx.build.GEP(elt_tydesc,
|
||||
vec(C_int(0),
|
||||
C_int(abi::tydesc_field_align))));
|
||||
[C_int(0),
|
||||
C_int(abi::tydesc_field_align)]));
|
||||
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llalign");
|
||||
|
||||
|
||||
@@ -7841,11 +7841,11 @@ fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
|
||||
ret @rec(activate_glue = decl_glue(llmod, tn, abi::activate_glue_name()),
|
||||
yield_glue = decl_glue(llmod, tn, abi::yield_glue_name()),
|
||||
exit_task_glue = decl_cdecl_fn(llmod, abi::exit_task_glue_name(),
|
||||
T_fn(vec(T_int(),
|
||||
T_fn([T_int(),
|
||||
T_int(),
|
||||
T_int(),
|
||||
T_int(),
|
||||
T_int()),
|
||||
T_int()],
|
||||
T_void())),
|
||||
|
||||
native_glues_rust =
|
||||
@@ -7889,18 +7889,18 @@ fn make_common_glue(&session::session sess, &str output) {
|
||||
}
|
||||
|
||||
fn create_module_map(&@crate_ctxt ccx) -> ValueRef {
|
||||
auto elttype = T_struct(vec(T_int(), T_int()));
|
||||
auto elttype = T_struct([T_int(), T_int()]);
|
||||
auto maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||
auto map = llvm::LLVMAddGlobal(ccx.llmod, maptype,
|
||||
_str::buf("_rust_mod_map"));
|
||||
llvm::LLVMSetLinkage(map, lib::llvm::LLVMInternalLinkage
|
||||
as llvm::Linkage);
|
||||
let vec[ValueRef] elts = vec();
|
||||
let vec[ValueRef] elts = [];
|
||||
for each (@tup(str, ValueRef) item in ccx.module_data.items()) {
|
||||
auto elt = C_struct(vec(p2i(C_cstr(ccx, item._0)), p2i(item._1)));
|
||||
auto elt = C_struct([p2i(C_cstr(ccx, item._0)), p2i(item._1)]);
|
||||
_vec::push[ValueRef](elts, elt);
|
||||
}
|
||||
auto term = C_struct(vec(C_int(0), C_int(0)));
|
||||
auto term = C_struct([C_int(0), C_int(0)]);
|
||||
_vec::push[ValueRef](elts, term);
|
||||
llvm::LLVMSetInitializer(map, C_array(elttype, elts));
|
||||
ret map;
|
||||
@@ -7917,7 +7917,7 @@ fn crate_name(&@crate_ctxt ccx, &str deflt) -> str {
|
||||
|
||||
// FIXME use hashed metadata instead of crate names once we have that
|
||||
fn create_crate_map(&@crate_ctxt ccx) -> ValueRef {
|
||||
let vec[ValueRef] subcrates = vec();
|
||||
let vec[ValueRef] subcrates = [];
|
||||
auto i = 1;
|
||||
while (ccx.sess.has_external_crate(i)) {
|
||||
auto name = ccx.sess.get_external_crate(i).name;
|
||||
@@ -7929,12 +7929,12 @@ fn create_crate_map(&@crate_ctxt ccx) -> ValueRef {
|
||||
_vec::push[ValueRef](subcrates, C_int(0));
|
||||
auto sym_name = "_rust_crate_map_" + crate_name(ccx, "__none__");
|
||||
auto arrtype = T_array(T_int(), _vec::len[ValueRef](subcrates));
|
||||
auto maptype = T_struct(vec(T_int(), arrtype));
|
||||
auto maptype = T_struct([T_int(), arrtype]);
|
||||
auto map = llvm::LLVMAddGlobal(ccx.llmod, maptype, _str::buf(sym_name));
|
||||
llvm::LLVMSetLinkage(map, lib::llvm::LLVMExternalLinkage
|
||||
as llvm::Linkage);
|
||||
llvm::LLVMSetInitializer(map, C_struct(vec(p2i(create_module_map(ccx)),
|
||||
C_array(T_int(), subcrates))));
|
||||
llvm::LLVMSetInitializer(map, C_struct([p2i(create_module_map(ccx)),
|
||||
C_array(T_int(), subcrates)]));
|
||||
ret map;
|
||||
}
|
||||
|
||||
|
||||
+46
-46
@@ -420,9 +420,9 @@ fn mk_imm_vec(&ctxt cx, &t typ) -> t {
|
||||
|
||||
fn mk_imm_tup(&ctxt cx, &vec[t] tys) -> t {
|
||||
// TODO: map
|
||||
let vec[ty::mt] mts = vec();
|
||||
let vec[ty::mt] mts = [];
|
||||
for (t typ in tys) {
|
||||
mts += vec(rec(ty=typ, mut=ast::imm));
|
||||
mts += [rec(ty=typ, mut=ast::imm)];
|
||||
}
|
||||
ret mk_tup(cx, mts);
|
||||
}
|
||||
@@ -625,12 +625,12 @@ fn mt_to_str(ctxt cx, &mt m) -> str {
|
||||
}
|
||||
|
||||
case (ty_param(?id)) {
|
||||
s += "'" + _str::unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
|
||||
s += "'" + _str::unsafe_from_bytes([('a' as u8) + (id as u8)]);
|
||||
}
|
||||
|
||||
case (ty_bound_param(?id)) {
|
||||
s += "''" + _str::unsafe_from_bytes(vec(('a' as u8) +
|
||||
(id as u8)));
|
||||
s += "''" + _str::unsafe_from_bytes([('a' as u8) +
|
||||
(id as u8)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,7 +693,7 @@ fn walk_ty(ctxt cx, ty_walk walker, t ty) {
|
||||
walk_ty(cx, walker, ret_ty);
|
||||
}
|
||||
case (ty_obj(?methods)) {
|
||||
let vec[method] new_methods = vec();
|
||||
let vec[method] new_methods = [];
|
||||
for (method m in methods) {
|
||||
for (arg a in m.inputs) {
|
||||
walk_ty(cx, walker, a.ty);
|
||||
@@ -740,58 +740,58 @@ fn fold_ty(ctxt cx, ty_fold fld, t ty_0) -> t {
|
||||
ty = copy_cname(cx, mk_chan(cx, fold_ty(cx, fld, subty)), ty);
|
||||
}
|
||||
case (ty_tag(?tid, ?subtys)) {
|
||||
let vec[t] new_subtys = vec();
|
||||
let vec[t] new_subtys = [];
|
||||
for (t subty in subtys) {
|
||||
new_subtys += vec(fold_ty(cx, fld, subty));
|
||||
new_subtys += [fold_ty(cx, fld, subty)];
|
||||
}
|
||||
ty = copy_cname(cx, mk_tag(cx, tid, new_subtys), ty);
|
||||
}
|
||||
case (ty_tup(?mts)) {
|
||||
let vec[mt] new_mts = vec();
|
||||
let vec[mt] new_mts = [];
|
||||
for (mt tm in mts) {
|
||||
auto new_subty = fold_ty(cx, fld, tm.ty);
|
||||
new_mts += vec(rec(ty=new_subty, mut=tm.mut));
|
||||
new_mts += [rec(ty=new_subty, mut=tm.mut)];
|
||||
}
|
||||
ty = copy_cname(cx, mk_tup(cx, new_mts), ty);
|
||||
}
|
||||
case (ty_rec(?fields)) {
|
||||
let vec[field] new_fields = vec();
|
||||
let vec[field] new_fields = [];
|
||||
for (field fl in fields) {
|
||||
auto new_ty = fold_ty(cx, fld, fl.mt.ty);
|
||||
auto new_mt = rec(ty=new_ty, mut=fl.mt.mut);
|
||||
new_fields += vec(rec(ident=fl.ident, mt=new_mt));
|
||||
new_fields += [rec(ident=fl.ident, mt=new_mt)];
|
||||
}
|
||||
ty = copy_cname(cx, mk_rec(cx, new_fields), ty);
|
||||
}
|
||||
case (ty_fn(?proto, ?args, ?ret_ty)) {
|
||||
let vec[arg] new_args = vec();
|
||||
let vec[arg] new_args = [];
|
||||
for (arg a in args) {
|
||||
auto new_ty = fold_ty(cx, fld, a.ty);
|
||||
new_args += vec(rec(mode=a.mode, ty=new_ty));
|
||||
new_args += [rec(mode=a.mode, ty=new_ty)];
|
||||
}
|
||||
ty = copy_cname(cx, mk_fn(cx, proto, new_args,
|
||||
fold_ty(cx, fld, ret_ty)), ty);
|
||||
}
|
||||
case (ty_native_fn(?abi, ?args, ?ret_ty)) {
|
||||
let vec[arg] new_args = vec();
|
||||
let vec[arg] new_args = [];
|
||||
for (arg a in args) {
|
||||
auto new_ty = fold_ty(cx, fld, a.ty);
|
||||
new_args += vec(rec(mode=a.mode, ty=new_ty));
|
||||
new_args += [rec(mode=a.mode, ty=new_ty)];
|
||||
}
|
||||
ty = copy_cname(cx, mk_native_fn(cx, abi, new_args,
|
||||
fold_ty(cx, fld, ret_ty)), ty);
|
||||
}
|
||||
case (ty_obj(?methods)) {
|
||||
let vec[method] new_methods = vec();
|
||||
let vec[method] new_methods = [];
|
||||
for (method m in methods) {
|
||||
let vec[arg] new_args = vec();
|
||||
let vec[arg] new_args = [];
|
||||
for (arg a in m.inputs) {
|
||||
new_args += vec(rec(mode=a.mode,
|
||||
ty=fold_ty(cx, fld, a.ty)));
|
||||
new_args += [rec(mode=a.mode,
|
||||
ty=fold_ty(cx, fld, a.ty))];
|
||||
}
|
||||
new_methods += vec(rec(proto=m.proto, ident=m.ident,
|
||||
new_methods += [rec(proto=m.proto, ident=m.ident,
|
||||
inputs=new_args,
|
||||
output=fold_ty(cx, fld, m.output)));
|
||||
output=fold_ty(cx, fld, m.output))];
|
||||
}
|
||||
ty = copy_cname(cx, mk_obj(cx, new_methods), ty);
|
||||
}
|
||||
@@ -1443,7 +1443,7 @@ fn ann_to_type(&node_type_table ntt, &ast::ann ann) -> t {
|
||||
fn ann_to_type_params(&node_type_table ntt, &ast::ann ann) -> vec[t] {
|
||||
alt (ann_to_ty_param_substs_opt_and_ty(ntt, ann)._0) {
|
||||
case (none[vec[t]]) {
|
||||
let vec[t] result = vec();
|
||||
let vec[t] result = [];
|
||||
ret result;
|
||||
}
|
||||
case (some[vec[t]](?tps)) { ret tps; }
|
||||
@@ -1492,14 +1492,14 @@ fn counter(ctxt cx, @mutable vec[uint] param_indices, t ty) {
|
||||
}
|
||||
}
|
||||
if (!seen) {
|
||||
*param_indices += vec(param_idx);
|
||||
*param_indices += [param_idx];
|
||||
}
|
||||
}
|
||||
case (_) { /* fall through */ }
|
||||
}
|
||||
}
|
||||
|
||||
let vec[uint] v = vec(); // FIXME: typechecker botch
|
||||
let vec[uint] v = []; // FIXME: typechecker botch
|
||||
let @mutable vec[uint] param_indices = @mutable v;
|
||||
auto f = bind counter(cx, param_indices, _);
|
||||
walk_ty(cx, f, ty);
|
||||
@@ -1873,7 +1873,7 @@ fn unify_fn_common(&@ctxt cx,
|
||||
}
|
||||
|
||||
// TODO: as above, we should have an iter2 iterator.
|
||||
let vec[arg] result_ins = vec();
|
||||
let vec[arg] result_ins = [];
|
||||
auto i = 0u;
|
||||
while (i < expected_len) {
|
||||
auto expected_input = expected_inputs.(i);
|
||||
@@ -1897,7 +1897,7 @@ fn unify_fn_common(&@ctxt cx,
|
||||
|
||||
alt (result) {
|
||||
case (ures_ok(?rty)) {
|
||||
result_ins += vec(rec(mode=result_mode, ty=rty));
|
||||
result_ins += [rec(mode=result_mode, ty=rty)];
|
||||
}
|
||||
|
||||
case (_) {
|
||||
@@ -1979,7 +1979,7 @@ fn unify_obj(&@ctxt cx,
|
||||
&t actual,
|
||||
&vec[method] expected_meths,
|
||||
&vec[method] actual_meths) -> result {
|
||||
let vec[method] result_meths = vec();
|
||||
let vec[method] result_meths = [];
|
||||
let uint i = 0u;
|
||||
let uint expected_len = _vec::len[method](expected_meths);
|
||||
let uint actual_len = _vec::len[method](actual_meths);
|
||||
@@ -2004,9 +2004,9 @@ fn unify_obj(&@ctxt cx,
|
||||
case (ures_ok(?tfn)) {
|
||||
alt (struct(cx.tcx, tfn)) {
|
||||
case (ty_fn(?proto, ?ins, ?out)) {
|
||||
result_meths += vec(rec(inputs = ins,
|
||||
result_meths += [rec(inputs = ins,
|
||||
output = out
|
||||
with e_meth));
|
||||
with e_meth)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2057,10 +2057,10 @@ fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {
|
||||
// Just bind the type variable to the expected type.
|
||||
auto vlen = _vec::len[vec[t]](cx.types);
|
||||
if (actual_n < vlen) {
|
||||
cx.types.(actual_n) += vec(expected);
|
||||
cx.types.(actual_n) += [expected];
|
||||
} else {
|
||||
assert (actual_n == vlen);
|
||||
cx.types += vec(mutable vec(expected));
|
||||
cx.types += [mutable [expected]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2120,7 +2120,7 @@ fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {
|
||||
|
||||
// TODO: factor this cruft out, see the TODO in the
|
||||
// ty::ty_tup case
|
||||
let vec[t] result_tps = vec();
|
||||
let vec[t] result_tps = [];
|
||||
auto i = 0u;
|
||||
auto expected_len = _vec::len[t](expected_tps);
|
||||
while (i < expected_len) {
|
||||
@@ -2272,7 +2272,7 @@ fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {
|
||||
|
||||
// TODO: implement an iterator that can iterate over
|
||||
// two arrays simultaneously.
|
||||
let vec[ty::mt] result_elems = vec();
|
||||
let vec[ty::mt] result_elems = [];
|
||||
auto i = 0u;
|
||||
while (i < expected_len) {
|
||||
auto expected_elem = expected_elems.(i);
|
||||
@@ -2294,7 +2294,7 @@ fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {
|
||||
alt (result) {
|
||||
case (ures_ok(?rty)) {
|
||||
auto mt = rec(ty=rty, mut=mut);
|
||||
result_elems += vec(mt);
|
||||
result_elems += [mt];
|
||||
}
|
||||
case (_) {
|
||||
ret result;
|
||||
@@ -2326,7 +2326,7 @@ fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {
|
||||
|
||||
// TODO: implement an iterator that can iterate over
|
||||
// two arrays simultaneously.
|
||||
let vec[field] result_fields = vec();
|
||||
let vec[field] result_fields = [];
|
||||
auto i = 0u;
|
||||
while (i < expected_len) {
|
||||
auto expected_field = expected_fields.(i);
|
||||
@@ -2425,10 +2425,10 @@ fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {
|
||||
auto expected_n = get_or_create_set(cx, expected_id);
|
||||
auto vlen = _vec::len[vec[t]](cx.types);
|
||||
if (expected_n < vlen) {
|
||||
cx.types.(expected_n) += vec(actual);
|
||||
cx.types.(expected_n) += [actual];
|
||||
} else {
|
||||
assert (expected_n == vlen);
|
||||
cx.types += vec(mutable vec(actual));
|
||||
cx.types += [mutable [actual]];
|
||||
}
|
||||
ret ures_ok(expected);
|
||||
}
|
||||
@@ -2485,13 +2485,13 @@ fn substituter(@ctxt cx, vec[t] types, t typ) -> t {
|
||||
}
|
||||
|
||||
fn unify_sets(&@ctxt cx) -> vec[t] {
|
||||
let vec[t] throwaway = vec();
|
||||
let vec[mutable vec[t]] set_types = vec(mutable throwaway);
|
||||
let vec[t] throwaway = [];
|
||||
let vec[mutable vec[t]] set_types = [mutable throwaway];
|
||||
_vec::pop[vec[t]](set_types); // FIXME: botch
|
||||
|
||||
for (ufind::node node in cx.sets.nodes) {
|
||||
let vec[t] v = vec();
|
||||
set_types += vec(mutable v);
|
||||
let vec[t] v = [];
|
||||
set_types += [mutable v];
|
||||
}
|
||||
|
||||
auto i = 0u;
|
||||
@@ -2501,14 +2501,14 @@ fn unify_sets(&@ctxt cx) -> vec[t] {
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
let vec[t] result = vec();
|
||||
let vec[t] result = [];
|
||||
for (vec[t] types in set_types) {
|
||||
if (_vec::len[t](types) > 1u) {
|
||||
log_err "unification of > 1 types in a type set is " +
|
||||
"unimplemented";
|
||||
fail;
|
||||
}
|
||||
result += vec(types.(0));
|
||||
result += [types.(0)];
|
||||
}
|
||||
|
||||
ret result;
|
||||
@@ -2518,8 +2518,8 @@ fn unify(&t expected,
|
||||
&t actual,
|
||||
&unify_handler handler,
|
||||
&ty_ctxt tcx) -> result {
|
||||
let vec[t] throwaway = vec();
|
||||
let vec[mutable vec[t]] types = vec(mutable throwaway);
|
||||
let vec[t] throwaway = [];
|
||||
let vec[mutable vec[t]] types = [mutable throwaway];
|
||||
_vec::pop[vec[t]](types); // FIXME: botch
|
||||
|
||||
auto cx = @rec(sets=ufind::make(),
|
||||
|
||||
@@ -37,17 +37,17 @@ fn rc_shape_of(&ty::ctxt tcx, variant_getter getter, ty::t t) -> rc_shape {
|
||||
case (ty::ty_char) { ret rs_none; }
|
||||
case (ty::ty_str) { ret rs_none; }
|
||||
case (ty::ty_tag(?did, ?params)) {
|
||||
let vec[vec[@rc_shape]] result = vec();
|
||||
let vec[vec[@rc_shape]] result = [];
|
||||
|
||||
auto vinfos = getter(did);
|
||||
for (variant_info vinfo in vinfos) {
|
||||
let vec[@rc_shape] variant_rcs = vec();
|
||||
let vec[@rc_shape] variant_rcs = [];
|
||||
for (ty::t typ in vinfo.args) {
|
||||
auto ty_1 = ty::bind_params_in_type(tcx, typ);
|
||||
ty_1 = ty::substitute_type_params(tcx, params, ty_1);
|
||||
variant_rcs += vec(@rc_shape_of(tcx, getter, ty_1));
|
||||
variant_rcs += [@rc_shape_of(tcx, getter, ty_1)];
|
||||
}
|
||||
result += vec(variant_rcs);
|
||||
result += [variant_rcs];
|
||||
}
|
||||
|
||||
ret rs_tag(result);
|
||||
@@ -58,16 +58,16 @@ fn rc_shape_of(&ty::ctxt tcx, variant_getter getter, ty::t t) -> rc_shape {
|
||||
case (ty::ty_chan(_)) { ret rs_ref; }
|
||||
case (ty::ty_task) { ret rs_ref; }
|
||||
case (ty::ty_tup(?mts)) {
|
||||
let vec[@rc_shape] result = vec();
|
||||
let vec[@rc_shape] result = [];
|
||||
for (ty::mt tm in mts) {
|
||||
result += vec(@rc_shape_of(tcx, getter, tm.ty));
|
||||
result += [@rc_shape_of(tcx, getter, tm.ty)];
|
||||
}
|
||||
ret rs_tup(result);
|
||||
}
|
||||
case (ty::ty_rec(?fields)) {
|
||||
let vec[@rc_shape] result = vec();
|
||||
let vec[@rc_shape] result = [];
|
||||
for (ty::field fld in fields) {
|
||||
result += vec(@rc_shape_of(tcx, getter, fld.mt.ty));
|
||||
result += [@rc_shape_of(tcx, getter, fld.mt.ty)];
|
||||
}
|
||||
ret rs_tup(result);
|
||||
}
|
||||
|
||||
+70
-70
@@ -188,10 +188,10 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
|
||||
auto ty_substs_opt;
|
||||
auto ty_substs_len = _vec::len[@ast::ty](pth.node.types);
|
||||
if (ty_substs_len > 0u) {
|
||||
let vec[ty::t] ty_substs = vec();
|
||||
let vec[ty::t] ty_substs = [];
|
||||
auto i = 0u;
|
||||
while (i < ty_substs_len) {
|
||||
ty_substs += vec(ast_ty_to_ty_crate(fcx.ccx, pth.node.types.(i)));
|
||||
ty_substs += [ast_ty_to_ty_crate(fcx.ccx, pth.node.types.(i))];
|
||||
i += 1u;
|
||||
}
|
||||
ty_substs_opt = some[vec[ty::t]](ty_substs);
|
||||
@@ -203,10 +203,10 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
|
||||
}
|
||||
} else {
|
||||
// We will acquire the type parameters through unification.
|
||||
let vec[ty::t] ty_substs = vec();
|
||||
let vec[ty::t] ty_substs = [];
|
||||
auto i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
ty_substs += vec(next_ty_var(fcx.ccx));
|
||||
ty_substs += [next_ty_var(fcx.ccx)];
|
||||
i += 1u;
|
||||
}
|
||||
ty_substs_opt = some[vec[ty::t]](ty_substs);
|
||||
@@ -259,9 +259,9 @@ fn instantiate(&ty::ctxt tcx,
|
||||
// TODO: Make sure the number of supplied bindings matches the number
|
||||
// of type parameters in the typedef. Emit a friendly error otherwise.
|
||||
auto bound_ty = bind_params_in_type(tcx, params_opt_and_ty._1);
|
||||
let vec[ty::t] param_bindings = vec();
|
||||
let vec[ty::t] param_bindings = [];
|
||||
for (@ast::ty ast_ty in args) {
|
||||
param_bindings += vec(ast_ty_to_ty(tcx, getter, ast_ty));
|
||||
param_bindings += [ast_ty_to_ty(tcx, getter, ast_ty)];
|
||||
}
|
||||
ret ty::substitute_type_params(tcx, param_bindings, bound_ty);
|
||||
}
|
||||
@@ -294,14 +294,14 @@ fn instantiate(&ty::ctxt tcx,
|
||||
}
|
||||
|
||||
case (ast::ty_tup(?fields)) {
|
||||
let vec[ty::mt] flds = vec();
|
||||
let vec[ty::mt] flds = [];
|
||||
for (ast::mt field in fields) {
|
||||
_vec::push[ty::mt](flds, ast_mt_to_mt(tcx, getter, field));
|
||||
}
|
||||
typ = ty::mk_tup(tcx, flds);
|
||||
}
|
||||
case (ast::ty_rec(?fields)) {
|
||||
let vec[field] flds = vec();
|
||||
let vec[field] flds = [];
|
||||
for (ast::ty_field f in fields) {
|
||||
auto tm = ast_mt_to_mt(tcx, getter, f.mt);
|
||||
_vec::push[field](flds, rec(ident=f.ident, mt=tm));
|
||||
@@ -336,7 +336,7 @@ fn instantiate(&ty::ctxt tcx,
|
||||
}
|
||||
|
||||
case (ast::ty_obj(?meths)) {
|
||||
let vec[ty::method] tmeths = vec();
|
||||
let vec[ty::method] tmeths = [];
|
||||
auto f = bind ast_arg_to_arg(tcx, getter, _);
|
||||
for (ast::ty_method m in meths) {
|
||||
auto ins = _vec::map[ast::ty_arg, arg](f, m.inputs);
|
||||
@@ -502,7 +502,7 @@ fn ty_of_obj_ctor(@ctxt cx,
|
||||
-> ty::ty_param_count_and_ty {
|
||||
auto t_obj = ty_of_obj(cx, id, obj_info, ty_params);
|
||||
|
||||
let vec[arg] t_inputs = vec();
|
||||
let vec[arg] t_inputs = [];
|
||||
for (ast::obj_field f in obj_info.fields) {
|
||||
auto g = bind getter(cx, _);
|
||||
auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
|
||||
@@ -561,11 +561,11 @@ fn ty_of_item(&@ctxt cx, &@ast::item it) -> ty::ty_param_count_and_ty {
|
||||
|
||||
case (ast::item_tag(_, _, ?tps, ?def_id, _)) {
|
||||
// Create a new generic polytype.
|
||||
let vec[ty::t] subtys = vec();
|
||||
let vec[ty::t] subtys = [];
|
||||
|
||||
auto i = 0u;
|
||||
for (ast::ty_param tp in tps) {
|
||||
subtys += vec(ty::mk_param(cx.tcx, i));
|
||||
subtys += [ty::mk_param(cx.tcx, i)];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -613,13 +613,13 @@ fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
|
||||
&vec[ast::variant] variants,
|
||||
&vec[ast::ty_param] ty_params)
|
||||
-> vec[ast::variant] {
|
||||
let vec[ast::variant] result = vec();
|
||||
let vec[ast::variant] result = [];
|
||||
|
||||
// Create a set of parameter types shared among all the variants.
|
||||
let vec[ty::t] ty_param_tys = vec();
|
||||
let vec[ty::t] ty_param_tys = [];
|
||||
auto i = 0u;
|
||||
for (ast::ty_param tp in ty_params) {
|
||||
ty_param_tys += vec(ty::mk_param(cx.tcx, i));
|
||||
ty_param_tys += [ty::mk_param(cx.tcx, i)];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -636,10 +636,10 @@ fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
|
||||
// should be called to resolve named types.
|
||||
auto f = bind getter(cx, _);
|
||||
|
||||
let vec[arg] args = vec();
|
||||
let vec[arg] args = [];
|
||||
for (ast::variant_arg va in variant.node.args) {
|
||||
auto arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
|
||||
args += vec(rec(mode=ty::mo_alias, ty=arg_ty));
|
||||
args += [rec(mode=ty::mo_alias, ty=arg_ty)];
|
||||
}
|
||||
auto tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
|
||||
result_ty = ty::mk_fn(cx.tcx, ast::proto_fn, args, tag_t);
|
||||
@@ -653,7 +653,7 @@ fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
|
||||
);
|
||||
write_type_only(cx.node_types, ast::ann_tag(variant.node.ann),
|
||||
result_ty);
|
||||
result += vec(fold::respan(variant.span, variant_t));
|
||||
result += [fold::respan(variant.span, variant_t)];
|
||||
}
|
||||
|
||||
ret result;
|
||||
@@ -750,7 +750,7 @@ fn convert(@ctxt cx, @mutable option::t[ast::native_abi] abi,
|
||||
case (none[@ast::method]) { /* nothing to do */ }
|
||||
case (some[@ast::method](?m)) {
|
||||
// TODO: typechecker botch
|
||||
let vec[arg] no_args = vec();
|
||||
let vec[arg] no_args = [];
|
||||
auto t = ty::mk_fn(cx.tcx, ast::proto_fn, no_args,
|
||||
ty::mk_nil(cx.tcx));
|
||||
write_type_only(cx.node_types,
|
||||
@@ -795,7 +795,7 @@ fn collect_item_types(&session::session sess, &ty::ctxt tcx,
|
||||
auto id_to_ty_item = @common::new_def_hash[any_item]();
|
||||
|
||||
let vec[mutable option::t[ty::ty_param_substs_opt_and_ty]] ntt_sub =
|
||||
vec(mutable);
|
||||
[mutable];
|
||||
let node_type_table ntt = @mutable ntt_sub;
|
||||
|
||||
auto visit = rec(
|
||||
@@ -837,7 +837,7 @@ fn simple(&@fn_ctxt fcx, &ty::t expected,
|
||||
&ty::t actual) -> ty::unify::result {
|
||||
// FIXME: horrid botch
|
||||
let vec[mutable ty::t] param_substs =
|
||||
vec(mutable ty::mk_nil(fcx.ccx.tcx));
|
||||
[mutable ty::mk_nil(fcx.ccx.tcx)];
|
||||
_vec::pop(param_substs);
|
||||
ret with_params(fcx, expected, actual, param_substs);
|
||||
}
|
||||
@@ -884,9 +884,9 @@ fn record_local(ast::def_id id, ty::t new_type) {
|
||||
}
|
||||
|
||||
// TODO: "freeze"
|
||||
let vec[ty::t] param_substs_1 = vec();
|
||||
let vec[ty::t] param_substs_1 = [];
|
||||
for (ty::t subst in param_substs) {
|
||||
param_substs_1 += vec(subst);
|
||||
param_substs_1 += [subst];
|
||||
}
|
||||
|
||||
unified_type =
|
||||
@@ -968,13 +968,13 @@ fn count_boxes(&ty::ctxt tcx, &ty::t t) -> uint {
|
||||
mod Demand {
|
||||
fn simple(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual)
|
||||
-> ty::t {
|
||||
let vec[ty::t] tps = vec();
|
||||
let vec[ty::t] tps = [];
|
||||
ret full(fcx, sp, expected, actual, tps, NO_AUTODEREF)._1;
|
||||
}
|
||||
|
||||
fn autoderef(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual,
|
||||
autoderef_kind adk) -> ty::t {
|
||||
let vec[ty::t] tps = vec();
|
||||
let vec[ty::t] tps = [];
|
||||
ret full(fcx, sp, expected, actual, tps, adk)._1;
|
||||
}
|
||||
|
||||
@@ -996,18 +996,18 @@ fn full(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual,
|
||||
}
|
||||
|
||||
let vec[mutable ty::t] ty_param_substs =
|
||||
vec(mutable ty::mk_nil(fcx.ccx.tcx));
|
||||
[mutable ty::mk_nil(fcx.ccx.tcx)];
|
||||
_vec::pop(ty_param_substs); // FIXME: horrid botch
|
||||
for (ty::t ty_param_subst in ty_param_substs_0) {
|
||||
ty_param_substs += vec(mutable ty_param_subst);
|
||||
ty_param_substs += [mutable ty_param_subst];
|
||||
}
|
||||
|
||||
alt (unify::with_params(fcx, expected_1, actual_1, ty_param_substs)) {
|
||||
case (ures_ok(?t)) {
|
||||
// TODO: Use "freeze", when we have it.
|
||||
let vec[ty::t] result_ty_param_substs = vec();
|
||||
let vec[ty::t] result_ty_param_substs = [];
|
||||
for (ty::t ty_param_subst in ty_param_substs) {
|
||||
result_ty_param_substs += vec(ty_param_subst);
|
||||
result_ty_param_substs += [ty_param_subst];
|
||||
}
|
||||
|
||||
ret tup(result_ty_param_substs,
|
||||
@@ -1042,7 +1042,7 @@ fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
|
||||
&vec[ty::t] tag_ty_params) -> vec[ty::t] {
|
||||
auto ty_param_count = _vec::len[ty::t](tag_ty_params);
|
||||
|
||||
let vec[ty::t] result = vec();
|
||||
let vec[ty::t] result = [];
|
||||
|
||||
auto tpt = ty::lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, vid);
|
||||
alt (struct(ccx.tcx, tpt._1)) {
|
||||
@@ -1052,7 +1052,7 @@ fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
|
||||
auto arg_ty = bind_params_in_type(ccx.tcx, arg.ty);
|
||||
arg_ty = substitute_ty_params(ccx, arg_ty, ty_param_count,
|
||||
tag_ty_params, sp);
|
||||
result += vec(arg_ty);
|
||||
result += [arg_ty];
|
||||
}
|
||||
}
|
||||
case (_) {
|
||||
@@ -1163,11 +1163,11 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
|
||||
auto t = Demand::simple(fcx, e.span, expected,
|
||||
ann_to_type(fcx.ccx.node_types, ann));
|
||||
let vec[@ast::expr] es_1 = vec();
|
||||
let vec[@ast::expr] es_1 = [];
|
||||
alt (struct(fcx.ccx.tcx, t)) {
|
||||
case (ty::ty_vec(?mt)) {
|
||||
for (@ast::expr e_0 in es_0) {
|
||||
es_1 += vec(pushdown_expr(fcx, mt.ty, e_0));
|
||||
es_1 += [pushdown_expr(fcx, mt.ty, e_0)];
|
||||
}
|
||||
}
|
||||
case (_) {
|
||||
@@ -1182,14 +1182,14 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
case (ast::expr_tup(?es_0, ?ann)) {
|
||||
auto t = Demand::simple(fcx, e.span, expected,
|
||||
ann_to_type(fcx.ccx.node_types, ann));
|
||||
let vec[ast::elt] elts_1 = vec();
|
||||
let vec[ast::elt] elts_1 = [];
|
||||
alt (struct(fcx.ccx.tcx, t)) {
|
||||
case (ty::ty_tup(?mts)) {
|
||||
auto i = 0u;
|
||||
for (ast::elt elt_0 in es_0) {
|
||||
auto e_1 = pushdown_expr(fcx, mts.(i).ty,
|
||||
elt_0.expr);
|
||||
elts_1 += vec(rec(mut=elt_0.mut, expr=e_1));
|
||||
elts_1 += [rec(mut=elt_0.mut, expr=e_1)];
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
@@ -1207,7 +1207,7 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
|
||||
auto t = Demand::simple(fcx, e.span, expected,
|
||||
ann_to_type(fcx.ccx.node_types, ann));
|
||||
let vec[ast::field] fields_1 = vec();
|
||||
let vec[ast::field] fields_1 = [];
|
||||
alt (struct(fcx.ccx.tcx, t)) {
|
||||
case (ty::ty_rec(?field_mts)) {
|
||||
alt (base_0) {
|
||||
@@ -1220,9 +1220,9 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
pushdown_expr(fcx,
|
||||
field_mts.(i).mt.ty,
|
||||
field_0.expr);
|
||||
fields_1 += vec(rec(mut=field_0.mut,
|
||||
fields_1 += [rec(mut=field_0.mut,
|
||||
ident=field_0.ident,
|
||||
expr=e_1));
|
||||
expr=e_1)];
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
@@ -1231,7 +1231,7 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
base_1 = some[@ast::expr]
|
||||
(pushdown_expr(fcx, t, bx));
|
||||
|
||||
let vec[field] base_fields = vec();
|
||||
let vec[field] base_fields = [];
|
||||
|
||||
for (ast::field field_0 in fields_0) {
|
||||
|
||||
@@ -1242,9 +1242,9 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
pushdown_expr(fcx, ft.mt.ty,
|
||||
field_0.expr);
|
||||
fields_1 +=
|
||||
vec(rec(mut=field_0.mut,
|
||||
[rec(mut=field_0.mut,
|
||||
ident=field_0.ident,
|
||||
expr=e_1));
|
||||
expr=e_1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1479,13 +1479,13 @@ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
|
||||
|
||||
case (ast::expr_alt(?discrim, ?arms_0, ?ann)) {
|
||||
auto t = expected;
|
||||
let vec[ast::arm] arms_1 = vec();
|
||||
let vec[ast::arm] arms_1 = [];
|
||||
for (ast::arm arm_0 in arms_0) {
|
||||
auto block_1 = pushdown_block(fcx, expected, arm_0.block);
|
||||
t = Demand::simple(fcx, e.span, t,
|
||||
block_ty(fcx.ccx.tcx, fcx.ccx.node_types, block_1));
|
||||
auto arm_1 = rec(pat=arm_0.pat, block=block_1);
|
||||
arms_1 += vec(arm_1);
|
||||
arms_1 += [arm_1];
|
||||
}
|
||||
e_1 = ast::expr_alt(discrim, arms_1,
|
||||
triv_ann(ast::ann_tag(ann), t));
|
||||
@@ -1848,13 +1848,13 @@ fn check_call_or_bind(&@fn_ctxt fcx, &@ast::expr f,
|
||||
auto f_0 = check_expr(fcx, f);
|
||||
|
||||
// Check the arguments and generate the argument signature.
|
||||
let vec[option::t[@ast::expr]] args_0 = vec();
|
||||
let vec[arg] arg_tys_0 = vec();
|
||||
let vec[option::t[@ast::expr]] args_0 = [];
|
||||
let vec[arg] arg_tys_0 = [];
|
||||
for (option::t[@ast::expr] a_opt in args) {
|
||||
alt (a_opt) {
|
||||
case (some[@ast::expr](?a)) {
|
||||
auto a_0 = check_expr(fcx, a);
|
||||
args_0 += vec(some[@ast::expr](a_0));
|
||||
args_0 += [some[@ast::expr](a_0)];
|
||||
|
||||
auto arg_ty = rec(mode=mo_either,
|
||||
ty=expr_ty(fcx.ccx.tcx,
|
||||
@@ -1862,7 +1862,7 @@ fn check_call_or_bind(&@fn_ctxt fcx, &@ast::expr f,
|
||||
_vec::push[arg](arg_tys_0, arg_ty);
|
||||
}
|
||||
case (none[@ast::expr]) {
|
||||
args_0 += vec(none[@ast::expr]);
|
||||
args_0 += [none[@ast::expr]];
|
||||
|
||||
auto typ = next_ty_var(fcx.ccx);
|
||||
_vec::push[arg](arg_tys_0, rec(mode=mo_either, ty=typ));
|
||||
@@ -1920,18 +1920,18 @@ fn check_assignment(&@fn_ctxt fcx, &@ast::expr lhs, &@ast::expr rhs,
|
||||
fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
-> tup(@ast::expr, vec[@ast::expr]) {
|
||||
|
||||
let vec[option::t[@ast::expr]] args_opt_0 = vec();
|
||||
let vec[option::t[@ast::expr]] args_opt_0 = [];
|
||||
for (@ast::expr arg in args) {
|
||||
args_opt_0 += vec(some[@ast::expr](arg));
|
||||
args_opt_0 += [some[@ast::expr](arg)];
|
||||
}
|
||||
|
||||
// Call the generic checker.
|
||||
auto result = check_call_or_bind(fcx, f, args_opt_0);
|
||||
|
||||
// Pull out the arguments.
|
||||
let vec[@ast::expr] args_1 = vec();
|
||||
let vec[@ast::expr] args_1 = [];
|
||||
for (option::t[@ast::expr] arg in result._1) {
|
||||
args_1 += vec(option::get[@ast::expr](arg));
|
||||
args_1 += [option::get[@ast::expr](arg)];
|
||||
}
|
||||
|
||||
ret tup(result._0, args_1);
|
||||
@@ -2397,12 +2397,12 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
auto pattern_ty = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
|
||||
expr_0);
|
||||
|
||||
let vec[@ast::pat] pats = vec();
|
||||
let vec[@ast::pat] pats = [];
|
||||
for (ast::arm arm in arms) {
|
||||
check_pat(fcx, arm.pat);
|
||||
pattern_ty = Demand::simple(fcx, arm.pat.span, pattern_ty,
|
||||
pat_ty(fcx.ccx.tcx, fcx.ccx.node_types, arm.pat));
|
||||
pats += vec(arm.pat);
|
||||
pats += [arm.pat];
|
||||
}
|
||||
|
||||
for (@ast::pat pat in pats) {
|
||||
@@ -2412,15 +2412,15 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
// Now typecheck the blocks.
|
||||
auto result_ty = next_ty_var(fcx.ccx);
|
||||
|
||||
let vec[ast::block] blocks_0 = vec();
|
||||
let vec[ast::block] blocks_0 = [];
|
||||
for (ast::arm arm in arms) {
|
||||
auto block_0 = check_block(fcx, arm.block);
|
||||
result_ty = Demand::simple(fcx, block_0.span, result_ty,
|
||||
block_ty(fcx.ccx.tcx, fcx.ccx.node_types, block_0));
|
||||
blocks_0 += vec(block_0);
|
||||
blocks_0 += [block_0];
|
||||
}
|
||||
|
||||
let vec[ast::arm] arms_1 = vec();
|
||||
let vec[ast::arm] arms_1 = [];
|
||||
auto i = 0u;
|
||||
for (ast::block block_0 in blocks_0) {
|
||||
auto block_1 = Pushdown::pushdown_block(fcx, result_ty,
|
||||
@@ -2428,7 +2428,7 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
auto pat = pats.(i);
|
||||
auto arm = arms.(i);
|
||||
auto arm_1 = rec(pat=pat, block=block_1);
|
||||
arms_1 += vec(arm_1);
|
||||
arms_1 += [arm_1];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -2464,7 +2464,7 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
|
||||
// Pull the argument and return types out.
|
||||
auto proto_1;
|
||||
let vec[ty::arg] arg_tys_1 = vec();
|
||||
let vec[ty::arg] arg_tys_1 = [];
|
||||
auto rt_1;
|
||||
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
|
||||
result._0))) {
|
||||
@@ -2479,7 +2479,7 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
alt (args.(i)) {
|
||||
case (some[@ast::expr](_)) { /* no-op */ }
|
||||
case (none[@ast::expr]) {
|
||||
arg_tys_1 += vec(arg_tys.(i));
|
||||
arg_tys_1 += [arg_tys.(i)];
|
||||
}
|
||||
}
|
||||
i += 1u;
|
||||
@@ -2624,7 +2624,7 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
}
|
||||
|
||||
case (ast::expr_vec(?args, ?mut, ?a)) {
|
||||
let vec[@ast::expr] args_1 = vec();
|
||||
let vec[@ast::expr] args_1 = [];
|
||||
|
||||
let ty::t t;
|
||||
if (_vec::len[@ast::expr](args) == 0u) {
|
||||
@@ -2650,15 +2650,15 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
}
|
||||
|
||||
case (ast::expr_tup(?elts, ?a)) {
|
||||
let vec[ast::elt] elts_1 = vec();
|
||||
let vec[ty::mt] elts_mt = vec();
|
||||
let vec[ast::elt] elts_1 = [];
|
||||
let vec[ty::mt] elts_mt = [];
|
||||
|
||||
for (ast::elt e in elts) {
|
||||
auto expr_1 = check_expr(fcx, e.expr);
|
||||
auto expr_t = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
|
||||
expr_1);
|
||||
_vec::push[ast::elt](elts_1, rec(expr=expr_1 with e));
|
||||
elts_mt += vec(rec(ty=expr_t, mut=e.mut));
|
||||
elts_mt += [rec(ty=expr_t, mut=e.mut)];
|
||||
}
|
||||
|
||||
auto typ = ty::mk_tup(fcx.ccx.tcx, elts_mt);
|
||||
@@ -2678,8 +2678,8 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
}
|
||||
}
|
||||
|
||||
let vec[ast::field] fields_1 = vec();
|
||||
let vec[field] fields_t = vec();
|
||||
let vec[ast::field] fields_1 = [];
|
||||
let vec[field] fields_t = [];
|
||||
|
||||
for (ast::field f in fields) {
|
||||
auto expr_1 = check_expr(fcx, f.expr);
|
||||
@@ -2705,7 +2705,7 @@ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
|
||||
auto bexpr_t = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
|
||||
bexpr_1);
|
||||
|
||||
let vec[field] base_fields = vec();
|
||||
let vec[field] base_fields = [];
|
||||
|
||||
alt (struct(fcx.ccx.tcx, bexpr_t)) {
|
||||
case (ty::ty_rec(?flds)) {
|
||||
@@ -3000,7 +3000,7 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
|
||||
}
|
||||
|
||||
fn check_block(&@fn_ctxt fcx, &ast::block block) -> ast::block {
|
||||
let vec[@ast::stmt] stmts = vec();
|
||||
let vec[@ast::stmt] stmts = [];
|
||||
for (@ast::stmt s in block.node.stmts) {
|
||||
_vec::push[@ast::stmt](stmts, check_stmt(fcx, s));
|
||||
}
|
||||
@@ -3093,10 +3093,10 @@ fn check_item_fn(&@crate_ctxt ccx, &span sp, &ast::ident ident, &ast::_fn f,
|
||||
// and return type translated to typeck::ty values. We don't need do to it
|
||||
// again here, we can extract them.
|
||||
|
||||
let vec[arg] inputs = vec();
|
||||
let vec[arg] inputs = [];
|
||||
for (ast::arg arg in f.decl.inputs) {
|
||||
auto input_ty = ast_ty_to_ty_crate(ccx, arg.ty);
|
||||
inputs += vec(rec(mode=ast_mode_to_mode(arg.mode), ty=input_ty));
|
||||
inputs += [rec(mode=ast_mode_to_mode(arg.mode), ty=input_ty)];
|
||||
}
|
||||
|
||||
auto output_ty = ast_ty_to_ty_crate(ccx, f.decl.output);
|
||||
@@ -3182,7 +3182,7 @@ fn check_crate(&ty::ctxt tcx, &@ast::crate crate) -> typecheck_result {
|
||||
auto sess = tcx.sess;
|
||||
auto result = collect::collect_item_types(sess, tcx, crate);
|
||||
|
||||
let vec[ast::obj_field] fields = vec();
|
||||
let vec[ast::obj_field] fields = [];
|
||||
|
||||
auto hasher = hash_unify_cache_entry;
|
||||
auto eqer = eq_unify_cache_entry;
|
||||
|
||||
@@ -797,10 +797,10 @@ fn find_pre_post_loop(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
find_pre_post_expr(dm, fm, enclosing, index);
|
||||
find_pre_post_block(dm, fm, enclosing, body);
|
||||
auto loop_precond = declare_var(enclosing, decl_lhs(d),
|
||||
seq_preconds(enclosing, vec(expr_pp(index),
|
||||
block_pp(body))));
|
||||
seq_preconds(enclosing, [expr_pp(index),
|
||||
block_pp(body)]));
|
||||
auto loop_postcond = intersect_postconds
|
||||
(vec(expr_postcond(index), block_postcond(body)));
|
||||
([expr_postcond(index), block_postcond(body)]);
|
||||
set_pre_and_post(a, rec(precondition=loop_precond,
|
||||
postcondition=loop_postcond));
|
||||
}
|
||||
@@ -897,7 +897,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
}
|
||||
// doesn't check that lhs is an lval, but
|
||||
// that's probably ok
|
||||
find_pre_post_exprs(dm, fm, enclosing, vec(lhs, rhs), a);
|
||||
find_pre_post_exprs(dm, fm, enclosing, [lhs, rhs], a);
|
||||
}
|
||||
case (expr_recv(?lhs, ?rhs, ?a)) {
|
||||
alt (lhs.node) {
|
||||
@@ -918,12 +918,12 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
}
|
||||
// doesn't check that lhs is an lval, but
|
||||
// that's probably ok
|
||||
find_pre_post_exprs(dm, fm, enclosing, vec(lhs, rhs), a);
|
||||
find_pre_post_exprs(dm, fm, enclosing, [lhs, rhs], a);
|
||||
}
|
||||
case (expr_assign_op(_, ?lhs, ?rhs, ?a)) {
|
||||
/* Different from expr_assign in that the lhs *must*
|
||||
already be initialized */
|
||||
find_pre_post_exprs(dm, fm, enclosing, vec(lhs, rhs), a);
|
||||
find_pre_post_exprs(dm, fm, enclosing, [lhs, rhs], a);
|
||||
}
|
||||
case (expr_lit(_,?a)) {
|
||||
set_pre_and_post(a, empty_pre_post(num_local_vars));
|
||||
@@ -955,8 +955,8 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
alt (maybe_alt) {
|
||||
case (none[@expr]) {
|
||||
auto precond_res = seq_preconds(enclosing,
|
||||
vec(expr_pp(antec),
|
||||
block_pp(conseq)));
|
||||
[expr_pp(antec),
|
||||
block_pp(conseq)]);
|
||||
set_pre_and_post(a, rec(precondition=precond_res,
|
||||
postcondition=
|
||||
expr_poststate(antec)));
|
||||
@@ -965,21 +965,21 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
find_pre_post_expr(dm, fm, enclosing, altern);
|
||||
auto precond_true_case =
|
||||
seq_preconds(enclosing,
|
||||
vec(expr_pp(antec), block_pp(conseq)));
|
||||
[expr_pp(antec), block_pp(conseq)]);
|
||||
auto postcond_true_case = union_postconds
|
||||
(num_local_vars,
|
||||
vec(expr_postcond(antec), block_postcond(conseq)));
|
||||
[expr_postcond(antec), block_postcond(conseq)]);
|
||||
auto precond_false_case = seq_preconds
|
||||
(enclosing,
|
||||
vec(expr_pp(antec), expr_pp(altern)));
|
||||
[expr_pp(antec), expr_pp(altern)]);
|
||||
auto postcond_false_case = union_postconds
|
||||
(num_local_vars,
|
||||
vec(expr_postcond(antec), expr_postcond(altern)));
|
||||
[expr_postcond(antec), expr_postcond(altern)]);
|
||||
auto precond_res = union_postconds
|
||||
(num_local_vars,
|
||||
vec(precond_true_case, precond_false_case));
|
||||
[precond_true_case, precond_false_case]);
|
||||
auto postcond_res = intersect_postconds
|
||||
(vec(postcond_true_case, postcond_false_case));
|
||||
([postcond_true_case, postcond_false_case]);
|
||||
set_pre_and_post(a, rec(precondition=precond_res,
|
||||
postcondition=postcond_res));
|
||||
}
|
||||
@@ -988,10 +988,10 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
case (expr_binary(?bop,?l,?r,?a)) {
|
||||
/* *unless* bop is lazy (e.g. and, or)?
|
||||
FIXME */
|
||||
find_pre_post_exprs(dm, fm, enclosing, vec(l, r), a);
|
||||
find_pre_post_exprs(dm, fm, enclosing, [l, r], a);
|
||||
}
|
||||
case (expr_send(?l, ?r, ?a)) {
|
||||
find_pre_post_exprs(dm, fm, enclosing, vec(l, r), a);
|
||||
find_pre_post_exprs(dm, fm, enclosing, [l, r], a);
|
||||
}
|
||||
case (expr_unary(_,?operand,?a)) {
|
||||
find_pre_post_expr(dm, fm, enclosing, operand);
|
||||
@@ -1007,18 +1007,18 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
set_pre_and_post(a,
|
||||
rec(precondition=
|
||||
seq_preconds(enclosing,
|
||||
vec(expr_pp(test),
|
||||
block_pp(body))),
|
||||
[expr_pp(test),
|
||||
block_pp(body)]),
|
||||
postcondition=
|
||||
intersect_postconds(vec(expr_postcond(test),
|
||||
block_postcond(body)))));
|
||||
intersect_postconds([expr_postcond(test),
|
||||
block_postcond(body)])));
|
||||
}
|
||||
case (expr_do_while(?body, ?test, ?a)) {
|
||||
find_pre_post_block(dm, fm, enclosing, body);
|
||||
find_pre_post_expr(dm, fm, enclosing, test);
|
||||
|
||||
auto loop_postcond = union_postconds(num_local_vars,
|
||||
vec(block_postcond(body), expr_postcond(test)));
|
||||
[block_postcond(body), expr_postcond(test)]);
|
||||
/* conservative approximination: if the body
|
||||
could break or cont, the test may never be executed */
|
||||
if (has_nonlocal_exits(body)) {
|
||||
@@ -1027,8 +1027,8 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
|
||||
set_pre_and_post(a,
|
||||
rec(precondition=seq_preconds(enclosing,
|
||||
vec(block_pp(body),
|
||||
expr_pp(test))),
|
||||
[block_pp(body),
|
||||
expr_pp(test)]),
|
||||
postcondition=loop_postcond));
|
||||
}
|
||||
case (expr_for(?d, ?index, ?body, ?a)) {
|
||||
@@ -1038,7 +1038,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
find_pre_post_loop(dm, fm, enclosing, d, index, body, a);
|
||||
}
|
||||
case (expr_index(?e, ?sub, ?a)) {
|
||||
find_pre_post_exprs(dm, fm, enclosing, vec(e, sub), a);
|
||||
find_pre_post_exprs(dm, fm, enclosing, [e, sub], a);
|
||||
}
|
||||
case (expr_alt(?e, ?alts, ?a)) {
|
||||
find_pre_post_expr(dm, fm, enclosing, e);
|
||||
@@ -1053,7 +1053,7 @@ fn combine_pp(pre_and_post antec,
|
||||
fn_info enclosing, &pre_and_post pp,
|
||||
&pre_and_post next) -> pre_and_post {
|
||||
union(pp.precondition, seq_preconds(enclosing,
|
||||
vec(antec, next)));
|
||||
[antec, next]));
|
||||
intersect(pp.postcondition, next.postcondition);
|
||||
ret pp;
|
||||
}
|
||||
@@ -1214,7 +1214,7 @@ fn do_inner_(def_map dm, fn_info_map fm, fn_info i, &@expr e) -> () {
|
||||
auto do_inner = bind do_inner_(dm, fm, enclosing, _);
|
||||
option::map[@expr, ()](do_inner, b.node.expr);
|
||||
|
||||
let vec[pre_and_post] pps = vec();
|
||||
let vec[pre_and_post] pps = [];
|
||||
|
||||
fn get_pp_stmt(&@stmt s) -> pre_and_post {
|
||||
ret stmt_pp(*s);
|
||||
@@ -1408,8 +1408,8 @@ fn find_pre_post_state_loop(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
(poststate of index, poststate of body) */
|
||||
changed = find_pre_post_state_block(dm, fm, enclosing,
|
||||
expr_poststate(index), body) || changed;
|
||||
auto res_p = intersect_postconds(vec(expr_poststate(index),
|
||||
block_poststate(body)));
|
||||
auto res_p = intersect_postconds([expr_poststate(index),
|
||||
block_poststate(body)]);
|
||||
|
||||
changed = extend_poststate_ann(a, res_p) || changed;
|
||||
ret changed;
|
||||
@@ -1603,7 +1603,7 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
changed = find_pre_post_state_expr(dm, fm, enclosing,
|
||||
expr_poststate(antec), altern) || changed;
|
||||
auto poststate_res = intersect_postconds
|
||||
(vec(block_poststate(conseq), expr_poststate(altern)));
|
||||
([block_poststate(conseq), expr_poststate(altern)]);
|
||||
changed = extend_poststate_ann(a, poststate_res) || changed;
|
||||
}
|
||||
}
|
||||
@@ -1660,8 +1660,8 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|
||||
changed = find_pre_post_state_block(dm, fm,
|
||||
enclosing, expr_poststate(test), body) || changed;
|
||||
changed = extend_poststate_ann(a,
|
||||
intersect_postconds(vec(expr_poststate(test),
|
||||
block_poststate(body)))) || changed;
|
||||
intersect_postconds([expr_poststate(test),
|
||||
block_poststate(body)])) || changed;
|
||||
ret changed;
|
||||
}
|
||||
case (expr_do_while(?body, ?test, ?a)) {
|
||||
@@ -2335,7 +2335,7 @@ fn annotate_stmt(&fn_info_map fm, &@stmt s) -> @stmt {
|
||||
}
|
||||
}
|
||||
fn annotate_block(&fn_info_map fm, &block b) -> block {
|
||||
let vec[@stmt] new_stmts = vec();
|
||||
let vec[@stmt] new_stmts = [];
|
||||
|
||||
for (@stmt s in b.node.stmts) {
|
||||
auto new_s = annotate_stmt(fm, s);
|
||||
@@ -2357,7 +2357,7 @@ fn annotate_fn(&fn_info_map fm, &ast::_fn f) -> ast::_fn {
|
||||
ret rec(body=annotate_block(fm, f.body) with f);
|
||||
}
|
||||
fn annotate_mod(&fn_info_map fm, &ast::_mod m) -> ast::_mod {
|
||||
let vec[@item] new_items = vec();
|
||||
let vec[@item] new_items = [];
|
||||
|
||||
for (@item i in m.items) {
|
||||
auto new_i = annotate_item(fm, i);
|
||||
@@ -2470,7 +2470,7 @@ fn annotate_item(&fn_info_map fm, &@ast::item item) -> @ast::item {
|
||||
}
|
||||
|
||||
fn annotate_module(&fn_info_map fm, &ast::_mod module) -> ast::_mod {
|
||||
let vec[@item] new_items = vec();
|
||||
let vec[@item] new_items = [];
|
||||
|
||||
for (@item i in module.items) {
|
||||
auto new_item = annotate_item(fm, i);
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
mutable bool potential_brk);
|
||||
|
||||
fn mkstate(io::writer out, uint width) -> ps {
|
||||
let vec[context] stack = vec(rec(tp=cx_v, indent=0u));
|
||||
let vec[token] buff = vec();
|
||||
let vec[boxtype] sd = vec();
|
||||
let vec[context] stack = [rec(tp=cx_v, indent=0u)];
|
||||
let vec[token] buff = [];
|
||||
let vec[boxtype] sd = [];
|
||||
ret @rec(mutable context=stack,
|
||||
width=width,
|
||||
out=out,
|
||||
@@ -81,7 +81,7 @@ fn direct_token(ps p, token tok) {
|
||||
}
|
||||
|
||||
fn buffer_token(ps p, token tok) {
|
||||
p.buffered += vec(tok);
|
||||
p.buffered += [tok];
|
||||
auto col = p.scancol;
|
||||
p.scancol = col + token_size(tok);
|
||||
if (p.scancol > p.width) {
|
||||
@@ -140,13 +140,13 @@ fn finish_scan(ps p, bool fits) {
|
||||
push_context(p, cx_h, base_indent(p) + ind);
|
||||
}
|
||||
}
|
||||
p.scandepth = vec();
|
||||
p.scandepth = [];
|
||||
p.scanning = scan_none;
|
||||
for (token t in buf) { add_token(p, t); }
|
||||
}
|
||||
|
||||
fn start_scan(ps p, token tok, scantype tp) {
|
||||
p.buffered = vec();
|
||||
p.buffered = [];
|
||||
p.scancol = p.col;
|
||||
p.scanning = tp;
|
||||
buffer_token(p, tok);
|
||||
|
||||
@@ -307,7 +307,7 @@ fn print_field(ps s, &ast::obj_field field) {
|
||||
bopen(s);
|
||||
for (@ast::method meth in _obj.methods) {
|
||||
hbox(s);
|
||||
let vec[ast::ty_param] typarams = vec();
|
||||
let vec[ast::ty_param] typarams = [];
|
||||
maybe_print_comment(s, meth.span.lo);
|
||||
print_fn(s, meth.node.meth.decl, meth.node.ident, typarams);
|
||||
space(s.s);
|
||||
@@ -360,7 +360,7 @@ fn print_literal(ps s, @ast::lit lit) {
|
||||
alt (lit.node) {
|
||||
case (ast::lit_str(?st)) {print_string(s, st);}
|
||||
case (ast::lit_char(?ch)) {
|
||||
wrd(s.s, "'" + escape_str(_str::from_bytes(vec(ch as u8)), '\'')
|
||||
wrd(s.s, "'" + escape_str(_str::from_bytes([ch as u8]), '\'')
|
||||
+ "'");
|
||||
}
|
||||
case (ast::lit_int(?val)) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
fn mk_interner[T](hashfn[T] hasher, eqfn[T] eqer) -> interner[T] {
|
||||
auto m = map::mk_hashmap[T,uint](hasher, eqer);
|
||||
let vec[T] vect = vec();
|
||||
let vec[T] vect = [];
|
||||
ret rec(map=m, mutable vect=vect, hasher=hasher, eqer=eqer);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ fn intern[T](&interner[T] itr, &T val) -> uint {
|
||||
case (none[uint]) {
|
||||
auto new_idx = _vec::len[T](itr.vect);
|
||||
itr.map.insert(val, new_idx);
|
||||
itr.vect += vec(val);
|
||||
itr.vect += [val];
|
||||
ret new_idx;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -141,7 +141,7 @@ fn unsafe_from_bytes(vec[mutable? u8] v) -> str {
|
||||
}
|
||||
|
||||
fn unsafe_from_byte(u8 u) -> str {
|
||||
ret rustrt::str_from_vec(vec(u));
|
||||
ret rustrt::str_from_vec([u]);
|
||||
}
|
||||
|
||||
fn str_from_cstr(sbuf cstr) -> str {
|
||||
@@ -248,7 +248,7 @@ fn char_len(str s) -> uint {
|
||||
}
|
||||
|
||||
fn to_chars(str s) -> vec[char] {
|
||||
let vec[char] buf = vec();
|
||||
let vec[char] buf = [];
|
||||
auto i = 0u;
|
||||
auto len = byte_len(s);
|
||||
while (i < len) {
|
||||
@@ -419,12 +419,12 @@ fn unshift_byte(&mutable str s, u8 b) {
|
||||
}
|
||||
|
||||
fn split(str s, u8 sep) -> vec[str] {
|
||||
let vec[str] v = vec();
|
||||
let vec[str] v = [];
|
||||
let str accum = "";
|
||||
let bool ends_with_sep = false;
|
||||
for (u8 c in s) {
|
||||
if (c == sep) {
|
||||
v += vec(accum);
|
||||
v += [accum];
|
||||
accum = "";
|
||||
ends_with_sep = true;
|
||||
} else {
|
||||
@@ -434,7 +434,7 @@ fn split(str s, u8 sep) -> vec[str] {
|
||||
}
|
||||
if (_str::byte_len(accum) != 0u ||
|
||||
ends_with_sep) {
|
||||
v += vec(accum);
|
||||
v += [accum];
|
||||
}
|
||||
ret v;
|
||||
}
|
||||
@@ -486,5 +486,5 @@ fn to_upper(str s) -> str {
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
|
||||
+17
-17
@@ -75,7 +75,7 @@ fn init_fn[T](&init_op[T] op, uint n_elts) -> vec[T] {
|
||||
let vec[T] v = alloc[T](n_elts);
|
||||
let uint i = 0u;
|
||||
while (i < n_elts) {
|
||||
v += vec(op(i));
|
||||
v += [op(i)];
|
||||
i += 1u;
|
||||
}
|
||||
ret v;
|
||||
@@ -85,7 +85,7 @@ fn init_fn_mut[T](&init_op[T] op, uint n_elts) -> vec[mutable T] {
|
||||
let vec[mutable T] v = alloc_mut[T](n_elts);
|
||||
let uint i = 0u;
|
||||
while (i < n_elts) {
|
||||
v += vec(mutable op(i));
|
||||
v += [mutable op(i)];
|
||||
i += 1u;
|
||||
}
|
||||
ret v;
|
||||
@@ -103,7 +103,7 @@ fn init_elt[T](&T t, uint n_elts) -> vec[T] {
|
||||
let uint i = n_elts;
|
||||
while (i > 0u) {
|
||||
i -= 1u;
|
||||
v += vec(t);
|
||||
v += [t];
|
||||
}
|
||||
ret v;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ fn init_elt_mut[T](&T t, uint n_elts) -> vec[mutable T] {
|
||||
let uint i = n_elts;
|
||||
while (i > 0u) {
|
||||
i -= 1u;
|
||||
v += vec(mutable t);
|
||||
v += [mutable t];
|
||||
}
|
||||
ret v;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
|
||||
auto result = alloc[T](end - start);
|
||||
let uint i = start;
|
||||
while (i < end) {
|
||||
result += vec(v.(i));
|
||||
result += [v.(i)];
|
||||
i += 1u;
|
||||
}
|
||||
ret result;
|
||||
@@ -180,12 +180,12 @@ fn pop[T](&mutable array[T] v) -> T {
|
||||
}
|
||||
|
||||
fn push[T](&mutable array[T] v, &T t) {
|
||||
v += vec(t);
|
||||
v += [t];
|
||||
}
|
||||
|
||||
fn unshift[T](&mutable array[T] v, &T t) {
|
||||
auto res = alloc[T](len[T](v) + 1u);
|
||||
res += vec(t);
|
||||
res += [t];
|
||||
res += v;
|
||||
v = res;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ fn grow[T](&array[T] v, uint n, &T initval) {
|
||||
let uint i = n;
|
||||
while (i > 0u) {
|
||||
i -= 1u;
|
||||
v += vec(initval);
|
||||
v += [initval];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) {
|
||||
fn map[T, U](&option::operator[T,U] f, &array[T] v) -> vec[U] {
|
||||
let vec[U] u = alloc[U](len[T](v));
|
||||
for (T ve in v) {
|
||||
u += vec(f(ve));
|
||||
u += [f(ve)];
|
||||
}
|
||||
ret u;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &array[T] v0, &array[U] v1) -> vec[V] {
|
||||
let vec[V] u = alloc[V](v0_len);
|
||||
auto i = 0u;
|
||||
while (i < v0_len) {
|
||||
u += vec(f(v0.(i), v1.(i)));
|
||||
u += [f(v0.(i), v1.(i))];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
@@ -262,8 +262,8 @@ fn unzip[T, U](&vec[tup(T, U)] v) -> tup(vec[T], vec[U]) {
|
||||
else {
|
||||
auto rest = slice[tup(T, U)](v, 1u, sz);
|
||||
auto tl = unzip[T, U](rest);
|
||||
auto a = vec(v.(0)._0);
|
||||
auto b = vec(v.(0)._1);
|
||||
auto a = [v.(0)._0];
|
||||
auto b = [v.(0)._1];
|
||||
ret tup(a + tl._0, b + tl._1);
|
||||
}
|
||||
}
|
||||
@@ -280,18 +280,18 @@ fn clone[T](&vec[T] v) -> vec[T] {
|
||||
fn plus_option[T](&vec[T] v, &option::t[T] o) -> () {
|
||||
alt (o) {
|
||||
case (none[T]) {}
|
||||
case (some[T](?x)) { v += vec(x); }
|
||||
case (some[T](?x)) { v += [x]; }
|
||||
}
|
||||
}
|
||||
|
||||
fn cat_options[T](&vec[option::t[T]] v) -> vec[T] {
|
||||
let vec[T] res = vec();
|
||||
let vec[T] res = [];
|
||||
|
||||
for (option::t[T] o in v) {
|
||||
alt (o) {
|
||||
case (none[T]) { }
|
||||
case (some[T](?t)) {
|
||||
res += vec(t);
|
||||
res += [t];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,9 +301,9 @@ fn cat_options[T](&vec[option::t[T]] v) -> vec[T] {
|
||||
|
||||
// TODO: Remove in favor of built-in "freeze" operation when it's implemented.
|
||||
fn freeze[T](vec[mutable T] v) -> vec[T] {
|
||||
let vec[T] result = vec();
|
||||
let vec[T] result = [];
|
||||
for (T elem in v) {
|
||||
result += vec(elem);
|
||||
result += [elem];
|
||||
}
|
||||
ret result;
|
||||
}
|
||||
|
||||
+1
-1
@@ -217,6 +217,6 @@ fn eq_vec(&t v0, &vec[uint] v1) -> bool {
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
//
|
||||
|
||||
+10
-10
@@ -122,22 +122,22 @@ fn write_sized_vint(&io::buf_writer w, uint n, uint size) {
|
||||
let vec[u8] buf;
|
||||
alt (size) {
|
||||
case (1u) {
|
||||
buf = vec(0x80u8 | (n as u8));
|
||||
buf = [0x80u8 | (n as u8)];
|
||||
}
|
||||
case (2u) {
|
||||
buf = vec(0x40u8 | ((n >> 8u) as u8),
|
||||
(n & 0xffu) as u8);
|
||||
buf = [0x40u8 | ((n >> 8u) as u8),
|
||||
(n & 0xffu) as u8];
|
||||
}
|
||||
case (3u) {
|
||||
buf = vec(0x20u8 | ((n >> 16u) as u8),
|
||||
buf = [0x20u8 | ((n >> 16u) as u8),
|
||||
((n >> 8u) & 0xffu) as u8,
|
||||
(n & 0xffu) as u8);
|
||||
(n & 0xffu) as u8];
|
||||
}
|
||||
case (4u) {
|
||||
buf = vec(0x10u8 | ((n >> 24u) as u8),
|
||||
buf = [0x10u8 | ((n >> 24u) as u8),
|
||||
((n >> 16u) & 0xffu) as u8,
|
||||
((n >> 8u) & 0xffu) as u8,
|
||||
(n & 0xffu) as u8);
|
||||
(n & 0xffu) as u8];
|
||||
}
|
||||
case (_) {
|
||||
log_err "vint to write too big";
|
||||
@@ -158,7 +158,7 @@ fn write_vint(&io::buf_writer w, uint n) {
|
||||
}
|
||||
|
||||
fn create_writer(&io::buf_writer w) -> writer {
|
||||
let vec[uint] size_positions = vec();
|
||||
let vec[uint] size_positions = [];
|
||||
ret rec(writer=w, mutable size_positions=size_positions);
|
||||
}
|
||||
|
||||
@@ -169,8 +169,8 @@ fn start_tag(&writer w, uint tag_id) {
|
||||
write_vint(w.writer, tag_id);
|
||||
|
||||
// Write a placeholder four-byte size.
|
||||
w.size_positions += vec(w.writer.tell());
|
||||
let vec[u8] zeroes = vec(0u8, 0u8, 0u8, 0u8);
|
||||
w.size_positions += [w.writer.tell()];
|
||||
let vec[u8] zeroes = [0u8, 0u8, 0u8, 0u8];
|
||||
w.writer.write(zeroes);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -79,14 +79,14 @@ mod ct {
|
||||
}
|
||||
|
||||
fn parse_fmt_string(str s) -> vec[piece] {
|
||||
let vec[piece] pieces = vec();
|
||||
let vec[piece] pieces = [];
|
||||
auto lim = _str::byte_len(s);
|
||||
auto buf = "";
|
||||
|
||||
fn flush_buf(str buf, &vec[piece] pieces) -> str {
|
||||
if (_str::byte_len(buf) > 0u) {
|
||||
auto piece = piece_string(buf);
|
||||
pieces += vec(piece);
|
||||
pieces += [piece];
|
||||
}
|
||||
ret "";
|
||||
}
|
||||
@@ -106,7 +106,7 @@ fn flush_buf(str buf, &vec[piece] pieces) -> str {
|
||||
} else {
|
||||
buf = flush_buf(buf, pieces);
|
||||
auto res = parse_conversion(s, i, lim);
|
||||
pieces += vec(res._0);
|
||||
pieces += [res._0];
|
||||
i = res._1;
|
||||
}
|
||||
} else {
|
||||
@@ -180,7 +180,7 @@ fn parse_parameter(str s, uint i, uint lim) -> tup(option::t[int], uint) {
|
||||
}
|
||||
|
||||
fn parse_flags(str s, uint i, uint lim) -> tup(vec[flag], uint) {
|
||||
let vec[flag] noflags = vec();
|
||||
let vec[flag] noflags = [];
|
||||
|
||||
if (i >= lim) {
|
||||
ret tup(noflags, i);
|
||||
@@ -190,7 +190,7 @@ fn more_(flag f, str s, uint i, uint lim) -> tup(vec[flag], uint) {
|
||||
auto next = parse_flags(s, i + 1u, lim);
|
||||
auto rest = next._0;
|
||||
auto j = next._1;
|
||||
let vec[flag] curr = vec(f);
|
||||
let vec[flag] curr = [f];
|
||||
ret tup(curr + rest, j);
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ fn have_precision(&conv cv) -> bool {
|
||||
|| head == '-' as u8
|
||||
|| head == ' ' as u8) {
|
||||
|
||||
auto headstr = _str::unsafe_from_bytes(vec(head));
|
||||
auto headstr = _str::unsafe_from_bytes([head]);
|
||||
auto bytelen = _str::byte_len(s);
|
||||
auto numpart = _str::substr(s, 1u, bytelen - 1u);
|
||||
ret headstr + padstr + numpart;
|
||||
@@ -793,7 +793,7 @@ fn have_precision(&conv cv) -> bool {
|
||||
|| head == '-' as u8
|
||||
|| head == ' ' as u8) {
|
||||
|
||||
auto headstr = _str::unsafe_from_bytes(vec(head));
|
||||
auto headstr = _str::unsafe_from_bytes([head]);
|
||||
auto bytelen = _str::byte_len(s);
|
||||
auto numpart = _str::substr(s, 1u, bytelen - 1u);
|
||||
ret headstr + padstr + numpart;
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ fn list_dir(path p) -> vec[str] {
|
||||
if (pl == 0u || p.(pl - 1u) as char != os_fs::path_sep) {
|
||||
p += path_sep();
|
||||
}
|
||||
let vec[str] full_paths = vec();
|
||||
let vec[str] full_paths = [];
|
||||
for (str filename in os_fs::list_dir(p)) {
|
||||
if (!_str::eq(filename, ".")) {if (!_str::eq(filename, "..")) {
|
||||
_vec::push[str](full_paths, p + filename);
|
||||
|
||||
+5
-5
@@ -106,7 +106,7 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
|
||||
fn empty_(uint x) -> vec[optval]{ret _vec::empty[optval]();}
|
||||
auto f = empty_;
|
||||
auto vals = _vec::init_fn_mut[vec[optval]](f, n_opts);
|
||||
let vec[str] free = vec();
|
||||
let vec[str] free = [];
|
||||
|
||||
auto l = _vec::len[str](args);
|
||||
auto i = 0u;
|
||||
@@ -125,15 +125,15 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
|
||||
auto tail = _str::slice(cur, 2u, curlen);
|
||||
auto eq = _str::index(tail, '=' as u8);
|
||||
if (eq == -1) {
|
||||
names = vec(long(tail));
|
||||
names = [long(tail)];
|
||||
} else {
|
||||
names = vec(long(_str::slice(tail, 0u, eq as uint)));
|
||||
names = [long(_str::slice(tail, 0u, eq as uint))];
|
||||
i_arg = option::some[str]
|
||||
(_str::slice(tail, (eq as uint) + 1u, curlen - 2u));
|
||||
}
|
||||
} else {
|
||||
auto j = 1u;
|
||||
names = vec();
|
||||
names = [];
|
||||
while (j < curlen) {
|
||||
auto range = _str::char_range_at(cur, j);
|
||||
_vec::push[name](names, short(range._0));
|
||||
@@ -221,7 +221,7 @@ fn opt_str(match m, str nm) -> str {
|
||||
}
|
||||
}
|
||||
fn opt_strs(match m, str nm) -> vec[str] {
|
||||
let vec[str] acc = vec();
|
||||
let vec[str] acc = [];
|
||||
for (optval v in opt_vals(m, nm)) {
|
||||
alt (v) {
|
||||
case (val(?s)) { _vec::push[str](acc, s); }
|
||||
|
||||
+9
-9
@@ -120,7 +120,7 @@ fn eof() -> bool {
|
||||
ret rdr.eof();
|
||||
}
|
||||
fn read_line() -> str {
|
||||
let vec[u8] buf = vec();
|
||||
let vec[u8] buf = [];
|
||||
// No break yet in rustc
|
||||
auto go_on = true;
|
||||
while (go_on) {
|
||||
@@ -131,7 +131,7 @@ fn read_line() -> str {
|
||||
ret _str::unsafe_from_bytes(buf);
|
||||
}
|
||||
fn read_c_str() -> str {
|
||||
let vec[u8] buf = vec();
|
||||
let vec[u8] buf = [];
|
||||
auto go_on = true;
|
||||
while (go_on) {
|
||||
auto ch = rdr.read_byte();
|
||||
@@ -172,7 +172,7 @@ fn read_be_uint(uint size) -> uint {
|
||||
ret val;
|
||||
}
|
||||
fn read_whole_stream() -> vec[u8] {
|
||||
let vec[u8] buf = vec();
|
||||
let vec[u8] buf = [];
|
||||
while (!rdr.eof()) {
|
||||
buf += rdr.read(2048u);
|
||||
}
|
||||
@@ -366,9 +366,9 @@ fn file_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
|
||||
};
|
||||
|
||||
fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
|
||||
let vec[u8] bytes = vec();
|
||||
let vec[u8] bytes = [];
|
||||
while (size > 0u) {
|
||||
bytes += vec((n & 255u) as u8);
|
||||
bytes += [(n & 255u) as u8];
|
||||
n >>= 8u;
|
||||
size -= 1u;
|
||||
}
|
||||
@@ -376,10 +376,10 @@ fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
|
||||
}
|
||||
|
||||
fn uint_to_be_bytes(uint n, uint size) -> vec[u8] {
|
||||
let vec[u8] bytes = vec();
|
||||
let vec[u8] bytes = [];
|
||||
auto i = (size - 1u) as int;
|
||||
while (i >= 0) {
|
||||
bytes += vec(((n >> ((i * 8) as uint)) & 255u) as u8);
|
||||
bytes += [((n >> ((i * 8) as uint)) & 255u) as u8];
|
||||
i -= 1;
|
||||
}
|
||||
ret bytes;
|
||||
@@ -466,7 +466,7 @@ fn write(vec[u8] v) {
|
||||
while (vpos < vlen) {
|
||||
auto b = v.(vpos);
|
||||
if (buf.pos == _vec::len(buf.buf)) {
|
||||
buf.buf += vec(mutable b);
|
||||
buf.buf += [mutable b];
|
||||
} else {
|
||||
buf.buf.(buf.pos) = b;
|
||||
}
|
||||
@@ -486,7 +486,7 @@ fn seek(int offset, seek_style whence) {
|
||||
|
||||
fn string_writer() -> str_writer {
|
||||
// FIXME: yikes, this is bad. Needs fixing of mutable syntax.
|
||||
let vec[mutable u8] b = vec(mutable 0u8);
|
||||
let vec[mutable u8] b = [mutable 0u8];
|
||||
_vec::pop(b);
|
||||
|
||||
let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u);
|
||||
|
||||
+2
-2
@@ -65,7 +65,7 @@ fn dylib_filename(str base) -> str {
|
||||
}
|
||||
|
||||
fn pipe() -> tup(int, int) {
|
||||
let vec[mutable int] fds = vec(mutable 0, 0);
|
||||
let vec[mutable int] fds = [mutable 0, 0];
|
||||
assert (os::libc::pipe(_vec::buf(fds)) == 0);
|
||||
ret tup(fds.(0), fds.(1));
|
||||
}
|
||||
@@ -75,7 +75,7 @@ fn fd_FILE(int fd) -> libc::FILE {
|
||||
}
|
||||
|
||||
fn waitpid(int pid) -> int {
|
||||
let vec[mutable int] status = vec(mutable 0);
|
||||
let vec[mutable int] status = [mutable 0];
|
||||
assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
|
||||
ret status.(0);
|
||||
}
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ fn dylib_filename(str base) -> str {
|
||||
}
|
||||
|
||||
fn pipe() -> tup(int, int) {
|
||||
let vec[mutable int] fds = vec(mutable 0, 0);
|
||||
let vec[mutable int] fds = [mutable 0, 0];
|
||||
assert (os::libc::pipe(_vec::buf(fds)) == 0);
|
||||
ret tup(fds.(0), fds.(1));
|
||||
}
|
||||
@@ -72,7 +72,7 @@ fn fd_FILE(int fd) -> libc::FILE {
|
||||
}
|
||||
|
||||
fn waitpid(int pid) -> int {
|
||||
let vec[mutable int] status = vec(mutable 0);
|
||||
let vec[mutable int] status = [mutable 0];
|
||||
assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
|
||||
ret status.(0);
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fn list_dir(str path) -> vec[str] {
|
||||
// TODO ensure this is always closed
|
||||
auto dir = os::libc::opendir(_str::buf(path));
|
||||
assert (dir as uint != 0u);
|
||||
let vec[str] result = vec();
|
||||
let vec[str] result = [];
|
||||
while (true) {
|
||||
auto ent = os::libc::readdir(dir);
|
||||
if (ent as int == 0) {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
fn rust_run_program(vbuf argv, int in_fd, int out_fd, int err_fd) -> int;
|
||||
}
|
||||
|
||||
fn argvec(str prog, vec[str] args) -> vec[sbuf] {
|
||||
auto argptrs = vec(_str::buf(prog));
|
||||
fn arg_vec(str prog, vec[str] args) -> vec[sbuf] {
|
||||
auto argptrs = [_str::buf(prog)];
|
||||
for (str arg in args) {
|
||||
_vec::push[sbuf](argptrs, _str::buf(arg));
|
||||
}
|
||||
@@ -15,7 +15,7 @@ fn argvec(str prog, vec[str] args) -> vec[sbuf] {
|
||||
}
|
||||
|
||||
fn run_program(str prog, vec[str] args) -> int {
|
||||
auto pid = rustrt::rust_run_program(_vec::buf[sbuf](argvec(prog, args)),
|
||||
auto pid = rustrt::rust_run_program(_vec::buf[sbuf](arg_vec(prog, args)),
|
||||
0, 0, 0);
|
||||
ret os::waitpid(pid);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ fn start_program(str prog, vec[str] args) -> @program {
|
||||
auto pipe_input = os::pipe();
|
||||
auto pipe_output = os::pipe();
|
||||
auto pid = rustrt::rust_run_program
|
||||
(_vec::buf[sbuf](argvec(prog, args)),
|
||||
(_vec::buf[sbuf](arg_vec(prog, args)),
|
||||
pipe_input._0, pipe_output._1, 0);
|
||||
if (pid == -1) {fail;}
|
||||
os::libc::close(pipe_input._0);
|
||||
@@ -92,5 +92,5 @@ fn program_output(str prog, vec[str] args)
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
|
||||
+2
-2
@@ -174,13 +174,13 @@ fn mk_result(&sha1state st) -> vec[u8] {
|
||||
st.computed = true;
|
||||
}
|
||||
|
||||
let vec[u8] res = vec();
|
||||
let vec[u8] res = [];
|
||||
for (u32 hpart in st.h) {
|
||||
auto a = (hpart >> 24u32) & 0xFFu32 as u8;
|
||||
auto b = (hpart >> 16u32) & 0xFFu32 as u8;
|
||||
auto c = (hpart >> 8u32) & 0xFFu32 as u8;
|
||||
auto d = (hpart & 0xFFu32 as u8);
|
||||
res += vec(a,b,c,d);
|
||||
res += [a,b,c,d];
|
||||
}
|
||||
ret res;
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,17 +6,17 @@
|
||||
fn merge_sort[T](lteq[T] le, vec[T] v) -> vec[T] {
|
||||
|
||||
fn merge[T](lteq[T] le, vec[T] a, vec[T] b) -> vec[T] {
|
||||
let vec[T] res = vec();
|
||||
let vec[T] res = [];
|
||||
let uint a_len = len[T](a);
|
||||
let uint a_ix = 0u;
|
||||
let uint b_len = len[T](b);
|
||||
let uint b_ix = 0u;
|
||||
while (a_ix < a_len && b_ix < b_len) {
|
||||
if (le(a.(a_ix), b.(b_ix))) {
|
||||
res += vec(a.(a_ix));
|
||||
res += [a.(a_ix)];
|
||||
a_ix += 1u;
|
||||
} else {
|
||||
res += vec(b.(b_ix));
|
||||
res += [b.(b_ix)];
|
||||
b_ix += 1u;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -22,12 +22,12 @@
|
||||
const u8 color_bright_white = 15u8;
|
||||
|
||||
fn esc(io::buf_writer writer) {
|
||||
writer.write(vec(0x1bu8, '[' as u8));
|
||||
writer.write([0x1bu8, '[' as u8]);
|
||||
}
|
||||
|
||||
fn reset(io::buf_writer writer) {
|
||||
esc(writer);
|
||||
writer.write(vec('0' as u8, 'm' as u8));
|
||||
writer.write(['0' as u8, 'm' as u8]);
|
||||
}
|
||||
|
||||
fn color_supported() -> bool {
|
||||
@@ -39,10 +39,10 @@ fn set_color(io::buf_writer writer, u8 first_char, u8 color) {
|
||||
|
||||
esc(writer);
|
||||
if (color >= 8u8) {
|
||||
writer.write(vec('1' as u8, ';' as u8));
|
||||
writer.write(['1' as u8, ';' as u8]);
|
||||
color -= 8u8;
|
||||
}
|
||||
writer.write(vec(first_char, ('0' as u8) + color, 'm' as u8));
|
||||
writer.write([first_char, ('0' as u8) + color, 'm' as u8]);
|
||||
}
|
||||
|
||||
fn fg(io::buf_writer writer, u8 color) {
|
||||
|
||||
+2
-2
@@ -7,14 +7,14 @@
|
||||
type ufind = rec(mutable vec[mutable node] nodes);
|
||||
|
||||
fn make() -> ufind {
|
||||
let vec[mutable node] v = vec(mutable none[uint]);
|
||||
let vec[mutable node] v = [mutable none[uint]];
|
||||
_vec::pop(v); // FIXME: botch
|
||||
ret rec(mutable nodes=v);
|
||||
}
|
||||
|
||||
fn make_set(&ufind ufnd) -> uint {
|
||||
auto idx = _vec::len(ufnd.nodes);
|
||||
ufnd.nodes += vec(mutable none[uint]);
|
||||
ufnd.nodes += [mutable none[uint]];
|
||||
ret idx;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ fn dylib_filename(str base) -> str {
|
||||
}
|
||||
|
||||
fn pipe() -> tup(int, int) {
|
||||
let vec[mutable int] fds = vec(mutable 0, 0);
|
||||
let vec[mutable int] fds = [mutable 0, 0];
|
||||
assert (os::libc::_pipe(_vec::buf(fds), 1024u,
|
||||
libc_constants::O_BINARY()) == 0);
|
||||
ret tup(fds.(0), fds.(1));
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
T
|
||||
T 2011-05-16 ae030c5
|
||||
linux-i386 83a6f52df4029b61ebd628795b0a400265c98179
|
||||
macos-i386 1167e8b782165be738cbd08eeab104ede0d61df6
|
||||
winnt-i386 456bc38c2bc7ebb27fd008e3ccd05f16f6a31fe6
|
||||
|
||||
S 2011-05-12 b1d3364
|
||||
linux-i386 7671ac0de19d9ea981616b3c58c1d48f1b43820a
|
||||
|
||||
@@ -28,10 +28,10 @@ fn next(u32 mx) -> u32 {
|
||||
|
||||
fn make_cumulative(vec[aminoacids] aa) -> vec[aminoacids] {
|
||||
let u32 cp = 0u32;
|
||||
let vec[aminoacids] ans = vec();
|
||||
let vec[aminoacids] ans = [];
|
||||
for (aminoacids a in aa) {
|
||||
cp += a._1;
|
||||
ans += vec(tup(a._0, cp));
|
||||
ans += [tup(a._0, cp)];
|
||||
}
|
||||
ret ans;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ fn make_repeat_fasta(str id, str desc, str s, int n) {
|
||||
}
|
||||
|
||||
fn main(vec[str] args) {
|
||||
let vec[aminoacids] iub = make_cumulative(vec(tup( 'a', 27u32 ),
|
||||
let vec[aminoacids] iub = make_cumulative([tup( 'a', 27u32 ),
|
||||
tup( 'c', 12u32 ),
|
||||
tup( 'g', 12u32 ),
|
||||
tup( 't', 27u32 ),
|
||||
@@ -106,12 +106,12 @@ fn main(vec[str] args) {
|
||||
tup( 'S', 2u32 ),
|
||||
tup( 'V', 2u32 ),
|
||||
tup( 'W', 2u32 ),
|
||||
tup( 'Y', 2u32 )));
|
||||
tup( 'Y', 2u32 )]);
|
||||
|
||||
let vec[aminoacids] homosapiens = make_cumulative(vec(tup( 'a', 30u32 ),
|
||||
let vec[aminoacids] homosapiens = make_cumulative([tup( 'a', 30u32 ),
|
||||
tup( 'c', 20u32 ),
|
||||
tup( 'g', 20u32 ),
|
||||
tup( 't', 30u32 )));
|
||||
tup( 't', 30u32 )]);
|
||||
|
||||
let str alu =
|
||||
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
fn main() {
|
||||
|
||||
let vec[int] inputs = vec(
|
||||
let vec[int] inputs = [
|
||||
50000,
|
||||
500000
|
||||
//
|
||||
@@ -16,7 +16,7 @@ fn main() {
|
||||
// during 'make check' under valgrind
|
||||
// 5000000
|
||||
// 50000000
|
||||
);
|
||||
];
|
||||
|
||||
let vec[Body::props] bodies = NBodySystem::MakeNBodySystem();
|
||||
|
||||
@@ -38,13 +38,13 @@ fn main() {
|
||||
mod NBodySystem {
|
||||
|
||||
fn MakeNBodySystem() -> vec[Body::props] {
|
||||
let vec[Body::props] bodies = vec(
|
||||
let vec[Body::props] bodies = [
|
||||
// these each return a Body::props
|
||||
Body::sun(),
|
||||
Body::jupiter(),
|
||||
Body::saturn(),
|
||||
Body::uranus(),
|
||||
Body::neptune());
|
||||
Body::neptune()];
|
||||
|
||||
let float px = 0.0;
|
||||
let float py = 0.0;
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
type x = vec[x];
|
||||
|
||||
fn main() {
|
||||
let x b = vec();
|
||||
let x b = [];
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
// xfail-stage2
|
||||
// error-pattern: writing to immutable type
|
||||
fn main() {
|
||||
let vec[int] v = vec(1, 2, 3);
|
||||
let vec[int] v = [1, 2, 3];
|
||||
v.(1) = 4;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
// error-pattern:bounds check
|
||||
|
||||
fn main() {
|
||||
let vec[int] v = vec(10);
|
||||
let vec[int] v = [10];
|
||||
let int x = 0;
|
||||
assert (v.(x) == 10);
|
||||
// Bounds-check failure.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// error-pattern:bounds check
|
||||
|
||||
fn main() {
|
||||
let vec[int] v = vec(10, 20);
|
||||
let vec[int] v = [10, 20];
|
||||
let int x = 0;
|
||||
assert (v.(x) == 10);
|
||||
// Bounds-check failure.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
fn foo[T](&option::t[T] y) {
|
||||
let int x;
|
||||
|
||||
let vec[int] res = vec();
|
||||
let vec[int] res = [];
|
||||
|
||||
/* tests that x doesn't get put in the precondition for the
|
||||
entire if expression */
|
||||
@@ -22,7 +22,7 @@ fn foo[T](&option::t[T] y) {
|
||||
x = 42;
|
||||
}
|
||||
}
|
||||
res += vec(x);
|
||||
res += [x];
|
||||
}
|
||||
|
||||
ret;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fn main(vec[str] args) {
|
||||
let vec[str] vs = vec("hi", "there", "this", "is", "a", "vec");
|
||||
let vec[vec[str]] vvs = vec(args, vs);
|
||||
let vec[str] vs = ["hi", "there", "this", "is", "a", "vec"];
|
||||
let vec[vec[str]] vvs = [args, vs];
|
||||
for (vec[str] vs in vvs) {
|
||||
for (str s in vs) {
|
||||
log s;
|
||||
|
||||
@@ -13,7 +13,7 @@ fn main() {
|
||||
} while (i < 30);
|
||||
assert (i == 20);
|
||||
|
||||
for (int x in vec(1, 2, 3, 4, 5, 6)) {
|
||||
for (int x in [1, 2, 3, 4, 5, 6]) {
|
||||
if (x == 3) { break; }
|
||||
assert (x <= 3);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ fn main() {
|
||||
assert (i % 2 != 0);
|
||||
} while (i < 10);
|
||||
|
||||
for (int x in vec(1, 2, 3, 4, 5, 6)) {
|
||||
for (int x in [1, 2, 3, 4, 5, 6]) {
|
||||
if (x % 2 == 0) { cont; }
|
||||
assert (x % 2 != 0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fn main() {
|
||||
let vec[mutable int] v = vec(mutable);
|
||||
let vec[mutable int] v = [mutable];
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ fn compare_vec(&vec[int] v1, &vec[int] v2) -> bool {
|
||||
ret v1 == v2;
|
||||
}
|
||||
auto eq = bind compare_vec(_, _);
|
||||
test_generic[vec[int]](vec(1, 2, 3), eq);
|
||||
test_generic[vec[int]]([1, 2, 3], eq);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -12,7 +12,7 @@ fn compare_vec(&vec[int] v1, &vec[int] v2) -> bool {
|
||||
ret v1 == v2;
|
||||
}
|
||||
auto eq = bind compare_vec(_, _);
|
||||
test_generic[vec[int]](vec(1, 2), eq);
|
||||
test_generic[vec[int]]([1, 2], eq);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -12,7 +12,7 @@ fn compare_vec(&vec[int] v1, &vec[int] v2) -> bool {
|
||||
ret v1 == v2;
|
||||
}
|
||||
auto eq = bind compare_vec(_, _);
|
||||
test_generic[vec[int]](vec(1, 2), vec(2, 3), eq);
|
||||
test_generic[vec[int]]([1, 2], [2, 3], eq);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
fn main() {
|
||||
let vec[mutable int] a =
|
||||
vec(mutable -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
[mutable -1, -1, -1, -1, -1, -1, -1, -1];
|
||||
let int p = 0;
|
||||
|
||||
for each (int i in two()) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let vec[mutable int] a = vec(mutable -1, -1, -1, -1);
|
||||
let vec[mutable int] a = [mutable -1, -1, -1, -1];
|
||||
let int p = 0;
|
||||
|
||||
for each (int i in two()) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
fn main() {
|
||||
|
||||
let vec[int] v = vec(0, 1, 2, 3, 4, 5);
|
||||
let vec[int] v = [0, 1, 2, 3, 4, 5];
|
||||
let str s = "abcdef";
|
||||
assert (v.(3u) == 3);
|
||||
assert (v.(3u8) == 3);
|
||||
|
||||
@@ -16,10 +16,10 @@ fn test_1_element() {
|
||||
auto act;
|
||||
|
||||
act = bitv::create(1u, false);
|
||||
assert (bitv::eq_vec(act, vec(0u)));
|
||||
assert (bitv::eq_vec(act, [0u]));
|
||||
|
||||
act = bitv::create(1u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u)));
|
||||
assert (bitv::eq_vec(act, [1u]));
|
||||
}
|
||||
|
||||
fn test_10_elements() {
|
||||
@@ -27,11 +27,11 @@ fn test_10_elements() {
|
||||
|
||||
// all 0
|
||||
act = bitv::create(10u, false);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// all 1
|
||||
act = bitv::create(10u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(10u, false);
|
||||
@@ -40,7 +40,7 @@ fn test_10_elements() {
|
||||
bitv::set(act, 2u, true);
|
||||
bitv::set(act, 3u, true);
|
||||
bitv::set(act, 4u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u)));
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(10u, false);
|
||||
@@ -49,7 +49,7 @@ fn test_10_elements() {
|
||||
bitv::set(act, 7u, true);
|
||||
bitv::set(act, 8u, true);
|
||||
bitv::set(act, 9u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u)));
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(10u, false);
|
||||
@@ -57,7 +57,7 @@ fn test_10_elements() {
|
||||
bitv::set(act, 3u, true);
|
||||
bitv::set(act, 6u, true);
|
||||
bitv::set(act, 9u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u)));
|
||||
assert (bitv::eq_vec(act, [1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u]));
|
||||
}
|
||||
|
||||
fn test_31_elements() {
|
||||
@@ -65,17 +65,17 @@ fn test_31_elements() {
|
||||
|
||||
// all 0
|
||||
act = bitv::create(31u, false);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// all 1
|
||||
act = bitv::create(31u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u)));
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(31u, false);
|
||||
@@ -87,10 +87,10 @@ fn test_31_elements() {
|
||||
bitv::set(act, 5u, true);
|
||||
bitv::set(act, 6u, true);
|
||||
bitv::set(act, 7u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(31u, false);
|
||||
@@ -102,10 +102,10 @@ fn test_31_elements() {
|
||||
bitv::set(act, 21u, true);
|
||||
bitv::set(act, 22u, true);
|
||||
bitv::set(act, 23u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(31u, false);
|
||||
@@ -116,20 +116,20 @@ fn test_31_elements() {
|
||||
bitv::set(act, 28u, true);
|
||||
bitv::set(act, 29u, true);
|
||||
bitv::set(act, 30u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u)));
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(31u, false);
|
||||
bitv::set(act, 3u, true);
|
||||
bitv::set(act, 17u, true);
|
||||
bitv::set(act, 30u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 1u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 1u]));
|
||||
}
|
||||
|
||||
fn test_32_elements() {
|
||||
@@ -137,17 +137,17 @@ fn test_32_elements() {
|
||||
|
||||
// all 0
|
||||
act = bitv::create(32u, false);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// all 1
|
||||
act = bitv::create(32u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(32u, false);
|
||||
@@ -159,10 +159,10 @@ fn test_32_elements() {
|
||||
bitv::set(act, 5u, true);
|
||||
bitv::set(act, 6u, true);
|
||||
bitv::set(act, 7u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(32u, false);
|
||||
@@ -174,10 +174,10 @@ fn test_32_elements() {
|
||||
bitv::set(act, 21u, true);
|
||||
bitv::set(act, 22u, true);
|
||||
bitv::set(act, 23u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(32u, false);
|
||||
@@ -189,10 +189,10 @@ fn test_32_elements() {
|
||||
bitv::set(act, 29u, true);
|
||||
bitv::set(act, 30u, true);
|
||||
bitv::set(act, 31u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)));
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(32u, false);
|
||||
@@ -200,10 +200,10 @@ fn test_32_elements() {
|
||||
bitv::set(act, 17u, true);
|
||||
bitv::set(act, 30u, true);
|
||||
bitv::set(act, 31u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u)));
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u]));
|
||||
}
|
||||
|
||||
fn test_33_elements() {
|
||||
@@ -211,19 +211,19 @@ fn test_33_elements() {
|
||||
|
||||
// all 0
|
||||
act = bitv::create(33u, false);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u)));
|
||||
0u]));
|
||||
|
||||
// all 1
|
||||
act = bitv::create(33u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
1u)));
|
||||
1u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(33u, false);
|
||||
@@ -235,11 +235,11 @@ fn test_33_elements() {
|
||||
bitv::set(act, 5u, true);
|
||||
bitv::set(act, 6u, true);
|
||||
bitv::set(act, 7u, true);
|
||||
assert (bitv::eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
assert (bitv::eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u)));
|
||||
0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(33u, false);
|
||||
@@ -251,11 +251,11 @@ fn test_33_elements() {
|
||||
bitv::set(act, 21u, true);
|
||||
bitv::set(act, 22u, true);
|
||||
bitv::set(act, 23u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u)));
|
||||
0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(33u, false);
|
||||
@@ -267,11 +267,11 @@ fn test_33_elements() {
|
||||
bitv::set(act, 29u, true);
|
||||
bitv::set(act, 30u, true);
|
||||
bitv::set(act, 31u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u,
|
||||
0u)));
|
||||
0u]));
|
||||
|
||||
// mixed
|
||||
act = bitv::create(33u, false);
|
||||
@@ -280,11 +280,11 @@ fn test_33_elements() {
|
||||
bitv::set(act, 30u, true);
|
||||
bitv::set(act, 31u, true);
|
||||
bitv::set(act, 32u, true);
|
||||
assert (bitv::eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
|
||||
assert (bitv::eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u,
|
||||
1u)));
|
||||
1u]));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -14,7 +14,7 @@ fn test_simple(str tmpfilebase) {
|
||||
log frood;
|
||||
|
||||
{
|
||||
let io::writer out = io::file_writer(tmpfile, vec(io::create));
|
||||
let io::writer out = io::file_writer(tmpfile, [io::create]);
|
||||
out.write_str(frood);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,32 +19,32 @@ fn ltequal(&int a, &int b) -> bool {
|
||||
|
||||
fn main() {
|
||||
{
|
||||
auto v1 = vec(mutable 3,7,4,5,2,9,5,8);
|
||||
auto v2 = vec(mutable 2,3,4,5,5,7,8,9);
|
||||
auto v1 = [mutable 3,7,4,5,2,9,5,8];
|
||||
auto v2 = [mutable 2,3,4,5,5,7,8,9];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
auto v1 = vec(mutable 1,1,1);
|
||||
auto v2 = vec(mutable 1,1,1);
|
||||
auto v1 = [mutable 1,1,1];
|
||||
auto v2 = [mutable 1,1,1];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
let vec[mutable int] v1 = vec(mutable);
|
||||
let vec[mutable int] v2 = vec(mutable);
|
||||
let vec[mutable int] v1 = [mutable];
|
||||
let vec[mutable int] v2 = [mutable];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
auto v1 = vec(mutable 9);
|
||||
auto v2 = vec(mutable 9);
|
||||
auto v1 = [mutable 9];
|
||||
auto v2 = [mutable 9];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
auto v1 = vec(mutable 9,3,3,3,9);
|
||||
auto v2 = vec(mutable 3,3,3,9,9);
|
||||
auto v1 = [mutable 9,3,3,3,9];
|
||||
auto v2 = [mutable 3,3,3,9,9];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,44 +24,44 @@ fn a_million_letter_a() -> str {
|
||||
|
||||
// Test messages from FIPS 180-1
|
||||
let vec[test] fips_180_1_tests =
|
||||
vec(
|
||||
[
|
||||
rec(input = "abc",
|
||||
output = vec(0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8,
|
||||
output = [0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8,
|
||||
0x06u8, 0x81u8, 0x6Au8, 0xBAu8, 0x3Eu8,
|
||||
0x25u8, 0x71u8, 0x78u8, 0x50u8, 0xC2u8,
|
||||
0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8)
|
||||
0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]
|
||||
),
|
||||
rec(input = "abcdbcdecdefdefgefghfghighij"
|
||||
+ "hijkijkljklmklmnlmnomnopnopq",
|
||||
output = vec(0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8,
|
||||
output = [0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8,
|
||||
0x3Bu8, 0xD2u8, 0x6Eu8, 0xBAu8, 0xAEu8,
|
||||
0x4Au8, 0xA1u8, 0xF9u8, 0x51u8, 0x29u8,
|
||||
0xE5u8, 0xE5u8, 0x46u8, 0x70u8, 0xF1u8)
|
||||
0xE5u8, 0xE5u8, 0x46u8, 0x70u8, 0xF1u8]
|
||||
),
|
||||
rec(input = a_million_letter_a(),
|
||||
output = vec(0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, 0xD4u8,
|
||||
output = [0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, 0xD4u8,
|
||||
0xC4u8, 0xDAu8, 0xA4u8, 0xF6u8, 0x1Eu8,
|
||||
0xEBu8, 0x2Bu8, 0xDBu8, 0xADu8, 0x27u8,
|
||||
0x31u8, 0x65u8, 0x34u8, 0x01u8, 0x6Fu8)
|
||||
0x31u8, 0x65u8, 0x34u8, 0x01u8, 0x6Fu8]
|
||||
)
|
||||
);
|
||||
];
|
||||
|
||||
// Examples from wikipedia
|
||||
let vec[test] wikipedia_tests =
|
||||
vec(
|
||||
[
|
||||
rec(input = "The quick brown fox jumps over the lazy dog",
|
||||
output = vec(0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8,
|
||||
output = [0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8,
|
||||
0x2du8, 0x28u8, 0xfcu8, 0xedu8, 0x84u8,
|
||||
0x9eu8, 0xe1u8, 0xbbu8, 0x76u8, 0xe7u8,
|
||||
0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8)
|
||||
0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8]
|
||||
),
|
||||
rec(input = "The quick brown fox jumps over the lazy cog",
|
||||
output = vec(0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8,
|
||||
output = [0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8,
|
||||
0x5eu8, 0x1bu8, 0x3au8, 0xfau8, 0xd3u8,
|
||||
0xe8u8, 0x5au8, 0x0bu8, 0xd1u8, 0x7du8,
|
||||
0x9bu8, 0x10u8, 0x0du8, 0xb4u8, 0xb3u8)
|
||||
0x9bu8, 0x10u8, 0x0du8, 0xb4u8, 0xb3u8]
|
||||
)
|
||||
);
|
||||
];
|
||||
|
||||
auto tests = fips_180_1_tests + wikipedia_tests;
|
||||
|
||||
|
||||
@@ -17,32 +17,32 @@ fn lteq(&int a, &int b) -> bool {
|
||||
|
||||
fn main() {
|
||||
{
|
||||
auto v1 = vec(3,7,4,5,2,9,5,8);
|
||||
auto v2 = vec(2,3,4,5,5,7,8,9);
|
||||
auto v1 = [3,7,4,5,2,9,5,8];
|
||||
auto v2 = [2,3,4,5,5,7,8,9];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
auto v1 = vec(1,1,1);
|
||||
auto v2 = vec(1,1,1);
|
||||
auto v1 = [1,1,1];
|
||||
auto v2 = [1,1,1];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
let vec[int] v1 = vec();
|
||||
let vec[int] v2 = vec();
|
||||
let vec[int] v1 = [];
|
||||
let vec[int] v2 = [];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
auto v1 = vec(9);
|
||||
auto v2 = vec(9);
|
||||
auto v1 = [9];
|
||||
auto v2 = [9];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
{
|
||||
auto v1 = vec(9,3,3,3,9);
|
||||
auto v2 = vec(3,3,3,9,9);
|
||||
auto v1 = [9,3,3,3,9];
|
||||
auto v2 = [3,3,3,9,9];
|
||||
check_sort(v1, v2);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,10 +73,10 @@ fn t(&vec[str] v, &str s) {
|
||||
assert (_str::eq(_str::concat(v), s));
|
||||
}
|
||||
|
||||
t(vec("you", "know", "I'm", "no", "good"), "youknowI'mnogood");
|
||||
let vec[str] v = vec();
|
||||
t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
|
||||
let vec[str] v = [];
|
||||
t(v, "");
|
||||
t(vec("hi"), "hi");
|
||||
t(["hi"], "hi");
|
||||
}
|
||||
|
||||
fn test_connect() {
|
||||
@@ -84,10 +84,10 @@ fn t(&vec[str] v, &str sep, &str s) {
|
||||
assert (_str::eq(_str::connect(v, sep), s));
|
||||
}
|
||||
|
||||
t(vec("you", "know", "I'm", "no", "good"), " ", "you know I'm no good");
|
||||
let vec[str] v = vec();
|
||||
t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good");
|
||||
let vec[str] v = [];
|
||||
t(v, " ", "");
|
||||
t(vec("hi"), " ", "hi");
|
||||
t(["hi"], " ", "hi");
|
||||
}
|
||||
|
||||
fn test_to_upper() {
|
||||
|
||||
@@ -23,7 +23,7 @@ fn test_init_fn() {
|
||||
}
|
||||
|
||||
fn test_slice() {
|
||||
let vec[int] v = vec(1,2,3,4,5);
|
||||
let vec[int] v = [1,2,3,4,5];
|
||||
auto v2 = std::_vec::slice[int](v, 2u, 4u);
|
||||
assert (std::_vec::len[int](v2) == 2u);
|
||||
assert (v2.(0) == 3);
|
||||
@@ -33,7 +33,7 @@ fn test_slice() {
|
||||
fn test_map() {
|
||||
fn square(&int x) -> int { ret x * x; }
|
||||
let std::option::operator[int, int] op = square;
|
||||
let vec[int] v = vec(1, 2, 3, 4, 5);
|
||||
let vec[int] v = [1, 2, 3, 4, 5];
|
||||
let vec[int] s = std::_vec::map[int, int](op, v);
|
||||
let int i = 0;
|
||||
while (i < 5) {
|
||||
@@ -45,8 +45,8 @@ fn test_map() {
|
||||
fn test_map2() {
|
||||
fn times(&int x, &int y) -> int { ret x * y; }
|
||||
auto f = times;
|
||||
auto v0 = vec(1, 2, 3, 4, 5);
|
||||
auto v1 = vec(5, 4, 3, 2, 1);
|
||||
auto v0 = [1, 2, 3, 4, 5];
|
||||
auto v1 = [5, 4, 3, 2, 1];
|
||||
auto u = std::_vec::map2[int,int,int](f, v0, v1);
|
||||
|
||||
auto i = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
auto x = vec(1,2,3);
|
||||
auto x = [1,2,3];
|
||||
auto y = 0;
|
||||
for (int i in x) {
|
||||
log i;
|
||||
|
||||
@@ -9,9 +9,9 @@ fn len(vec[mutable? int] v) -> uint {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
auto v0 = vec(1, 2, 3, 4, 5);
|
||||
auto v0 = [1, 2, 3, 4, 5];
|
||||
log len(v0);
|
||||
auto v1 = vec(mutable 1, 2, 3, 4, 5);
|
||||
auto v1 = [mutable 1, 2, 3, 4, 5];
|
||||
log len(v1);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
use std;
|
||||
|
||||
fn grow(&mutable vec[int] v) {
|
||||
v += vec(1);
|
||||
v += [1];
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let vec[int] v = vec();
|
||||
let vec[int] v = [];
|
||||
grow(v);
|
||||
grow(v);
|
||||
grow(v);
|
||||
|
||||
@@ -2,5 +2,5 @@ fn main() {
|
||||
// This just tests whether the vec leaks its members.
|
||||
|
||||
let vec[mutable @tup(int,int)] pvec =
|
||||
vec(mutable @tup(1,2), @tup(3,4), @tup(5,6));
|
||||
[mutable @tup(1,2), @tup(3,4), @tup(5,6)];
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fn get(int i) -> u8 {
|
||||
ret data.(i);
|
||||
}
|
||||
}
|
||||
auto b = buf(vec(1 as u8, 2 as u8, 3 as u8));
|
||||
auto b = buf([1 as u8, 2 as u8, 3 as u8]);
|
||||
log b.get(1);
|
||||
assert (b.get(1) == (2 as u8));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ fn main() {
|
||||
assert ("hello " > "hello");
|
||||
assert ("hello" != "there");
|
||||
|
||||
assert (vec(1,2,3,4) > vec(1,2,3));
|
||||
assert (vec(1,2,3) < vec(1,2,3,4));
|
||||
assert (vec(1,2,4,4) > vec(1,2,3,4));
|
||||
assert (vec(1,2,3,4) < vec(1,2,4,4));
|
||||
assert (vec(1,2,3) <= vec(1,2,3));
|
||||
assert (vec(1,2,3) <= vec(1,2,3,3));
|
||||
assert (vec(1,2,3,4) > vec(1,2,3));
|
||||
assert (vec(1,2,3) == vec(1,2,3));
|
||||
assert (vec(1,2,3) != vec(1,1,3));
|
||||
assert ([1,2,3,4] > [1,2,3]);
|
||||
assert ([1,2,3] < [1,2,3,4]);
|
||||
assert ([1,2,4,4] > [1,2,3,4]);
|
||||
assert ([1,2,3,4] < [1,2,4,4]);
|
||||
assert ([1,2,3] <= [1,2,3]);
|
||||
assert ([1,2,3] <= [1,2,3,3]);
|
||||
assert ([1,2,3,4] > [1,2,3]);
|
||||
assert ([1,2,3] == [1,2,3]);
|
||||
assert ([1,2,3] != [1,1,3]);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ fn uhoh[T](vec[clam[T]] v) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let vec[clam[int]] v = vec(b[int], b[int], a[int](42, 17));
|
||||
let vec[clam[int]] v = [b[int], b[int], a[int](42, 17)];
|
||||
uhoh[int](v);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ fn test_rec() {
|
||||
fn test_vec() {
|
||||
let port[vec[int]] po = port();
|
||||
let chan[vec[int]] ch = chan(po);
|
||||
let vec[int] v0 = vec(0, 1, 2);
|
||||
let vec[int] v0 = [0, 1, 2];
|
||||
|
||||
ch <| v0;
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ fn test00(bool create_threads) {
|
||||
let int number_of_tasks = 8;
|
||||
|
||||
let int i = 0;
|
||||
let vec[task] tasks = vec();
|
||||
let vec[task] tasks = [];
|
||||
while (i < number_of_tasks) {
|
||||
i = i + 1;
|
||||
if (create_threads) {
|
||||
tasks += vec(spawn thread start(i));
|
||||
tasks += [spawn thread start(i)];
|
||||
} else {
|
||||
tasks += vec(spawn start(i));
|
||||
tasks += [spawn start(i)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,13 @@ fn test00(bool is_multithreaded) {
|
||||
let int i = 0;
|
||||
|
||||
// Create and spawn tasks...
|
||||
let vec[task] tasks = vec();
|
||||
let vec[task] tasks = [];
|
||||
while (i < number_of_tasks) {
|
||||
if (is_multithreaded) {
|
||||
tasks += vec(
|
||||
spawn thread test00_start(ch, i, number_of_messages));
|
||||
tasks += [
|
||||
spawn thread test00_start(ch, i, number_of_messages)];
|
||||
} else {
|
||||
tasks += vec(spawn test00_start(ch, i, number_of_messages));
|
||||
tasks += [spawn test00_start(ch, i, number_of_messages)];
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ fn test00(bool is_multithreaded) {
|
||||
|
||||
let int i = 0;
|
||||
|
||||
let vec[task] tasks = vec();
|
||||
let vec[task] tasks = [];
|
||||
while (i < number_of_tasks) {
|
||||
i = i + 1;
|
||||
if (is_multithreaded) {
|
||||
tasks += vec(
|
||||
spawn thread test00_start(ch, i, number_of_messages));
|
||||
tasks += [
|
||||
spawn thread test00_start(ch, i, number_of_messages)];
|
||||
} else {
|
||||
tasks += vec(spawn test00_start(ch, i, number_of_messages));
|
||||
tasks += [spawn test00_start(ch, i, number_of_messages)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ fn test06() {
|
||||
|
||||
let int i = 0;
|
||||
|
||||
let vec[task] tasks = vec();
|
||||
let vec[task] tasks = [];
|
||||
while (i < number_of_tasks) {
|
||||
i = i + 1;
|
||||
tasks += vec(spawn thread test06_start(i));
|
||||
// tasks += vec(spawn test06_start(i));
|
||||
tasks += [spawn thread test06_start(i)];
|
||||
// tasks += [spawn test06_start(i)];
|
||||
}
|
||||
|
||||
for (task t in tasks) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
fn create_index[T](vec[tup(T, uint)] index, fn(&T) -> uint hash_fn) {
|
||||
for each (uint i in range(0u, 256u)) {
|
||||
let vec[T] bucket = vec();
|
||||
let vec[T] bucket = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
fn main() {
|
||||
// Chars of 1, 2, 3, and 4 bytes
|
||||
let vec[char] chs = vec('e', 'é', '€', 0x10000 as char);
|
||||
let vec[char] chs = ['e', 'é', '€', 0x10000 as char];
|
||||
let str s = _str::from_chars(chs);
|
||||
|
||||
assert (_str::byte_len(s) == 10u);
|
||||
@@ -19,9 +19,9 @@ fn main() {
|
||||
assert (_str::char_at(s, 1u) == 'é');
|
||||
|
||||
assert (_str::is_utf8(_str::bytes(s)));
|
||||
assert (!_str::is_utf8(vec(0x80_u8)));
|
||||
assert (!_str::is_utf8(vec(0xc0_u8)));
|
||||
assert (!_str::is_utf8(vec(0xc0_u8, 0x10_u8)));
|
||||
assert (!_str::is_utf8([0x80_u8]));
|
||||
assert (!_str::is_utf8([0xc0_u8]));
|
||||
assert (!_str::is_utf8([0xc0_u8, 0x10_u8]));
|
||||
|
||||
auto stack = "a×c€";
|
||||
assert (_str::pop_char(stack) == '€');
|
||||
|
||||
@@ -13,5 +13,5 @@ fn slice[T](vec[T] e) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
slice[str](vec("a"));
|
||||
slice[str](["a"]);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
const uint const_refcount = 0x7bad_face_u;
|
||||
|
||||
fn fast_growth() {
|
||||
let vec[int] v = vec(1,2,3,4,5);
|
||||
v += vec(6,7,8,9,0);
|
||||
let vec[int] v = [1,2,3,4,5];
|
||||
v += [6,7,8,9,0];
|
||||
|
||||
log v.(9);
|
||||
assert (v.(0) == 1);
|
||||
@@ -23,9 +23,9 @@ fn fast_growth() {
|
||||
}
|
||||
|
||||
fn slow_growth() {
|
||||
let vec[int] v = vec();
|
||||
let vec[int] v = [];
|
||||
let vec[int] u = v;
|
||||
v += vec(17);
|
||||
v += [17];
|
||||
|
||||
log v.(0);
|
||||
assert (v.(0) == 17);
|
||||
@@ -34,7 +34,7 @@ fn slow_growth() {
|
||||
fn slow_growth2_helper(str s) { // ref up: s
|
||||
|
||||
obj acc(vec[str] v) {
|
||||
fn add(&str s) { v += vec(s); }
|
||||
fn add(&str s) { v += [s]; }
|
||||
}
|
||||
|
||||
let str ss = s; // ref up: s
|
||||
@@ -50,7 +50,7 @@ fn slow_growth2_helper(str s) { // ref up: s
|
||||
* copy of existing elements should increment the ref count of
|
||||
* mumble, the existing str in the originally- shared vec.
|
||||
*/
|
||||
let vec[str] v = vec(mumble); // ref up: v, mumble
|
||||
let vec[str] v = [mumble]; // ref up: v, mumble
|
||||
let acc a = acc(v); // ref up: a, v
|
||||
|
||||
log _vec::refcount[str](v);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// -*- rust -*-
|
||||
|
||||
fn main() {
|
||||
let vec[int] a = vec(1,2,3,4,5);
|
||||
let vec[int] b = vec(6,7,8,9,0);
|
||||
let vec[int] a = [1,2,3,4,5];
|
||||
let vec[int] b = [6,7,8,9,0];
|
||||
let vec[int] v = a + b;
|
||||
log v.(9);
|
||||
assert (v.(0) == 1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fn main() {
|
||||
// This just tests whether the vec leaks its members.
|
||||
let vec[@tup(int,int)] pvec = vec(@tup(1,2),@tup(3,4),@tup(5,6));
|
||||
let vec[@tup(int,int)] pvec = [@tup(1,2),@tup(3,4),@tup(5,6)];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
fn main() {
|
||||
auto v = vec(1);
|
||||
v += vec(2);
|
||||
v += vec(3);
|
||||
v += vec(4);
|
||||
v += vec(5);
|
||||
auto v = [1];
|
||||
v += [2];
|
||||
v += [3];
|
||||
v += [4];
|
||||
v += [5];
|
||||
assert (v.(0) == 1);
|
||||
assert (v.(1) == 2);
|
||||
assert (v.(2) == 3);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fn main() {
|
||||
let tup(mutable vec[int]) i = tup(mutable vec(1,2,3));
|
||||
i._0 = vec(4,5,6);
|
||||
let tup(mutable vec[int]) i = tup(mutable [1,2,3]);
|
||||
i._0 = [4,5,6];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
fn main() {
|
||||
let vec[int] later;
|
||||
if (true) {
|
||||
later = vec(1);
|
||||
later = [1];
|
||||
} else {
|
||||
later = vec(2);
|
||||
later = [2];
|
||||
}
|
||||
log later.(0);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
fn push[T](&mutable vec[mutable? T] v, &T t) {
|
||||
v += vec(t);
|
||||
v += [t];
|
||||
}
|
||||
|
||||
fn main() {
|
||||
auto v = @vec(1, 2, 3);
|
||||
auto v = @[1, 2, 3];
|
||||
push[int](*v, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import std::_vec;
|
||||
|
||||
fn main() {
|
||||
auto v = vec(1, 2, 3);
|
||||
auto v = [1, 2, 3];
|
||||
log_err _vec::refcount[int](v);
|
||||
log_err _vec::refcount[int](v);
|
||||
log_err _vec::refcount[int](v);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// xfail-stage1
|
||||
// xfail-stage2
|
||||
fn main() {
|
||||
let vec[int] v = vec(1,2,3,4,5);
|
||||
let vec[int] v = [1,2,3,4,5];
|
||||
auto v2 = v.(1,2);
|
||||
assert (v2.(0) == 2);
|
||||
assert (v2.(1) == 3);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// -*- rust -*-
|
||||
|
||||
fn main() {
|
||||
let vec[int] v = vec(10, 20);
|
||||
let vec[int] v = [10, 20];
|
||||
assert (v.(0) == 10);
|
||||
assert (v.(1) == 20);
|
||||
let int x = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ fn main() {
|
||||
log i;
|
||||
i = i + 1;
|
||||
if (i == 95) {
|
||||
let vec[int] v = vec(1,2,3,4,5); // we check that it is freed by break
|
||||
let vec[int] v = [1,2,3,4,5]; // we check that it is freed by break
|
||||
log "breaking";
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user