Skip to content
Browse files

Reformat for new syntax

  • Loading branch information...
1 parent 0e3ee39 commit df7f21db093b0f206048b18e977161f91b7c28f1 @marijnh marijnh committed Jul 27, 2011
Showing with 12,132 additions and 12,673 deletions.
  1. +58 −58 src/comp/back/abi.rs
  2. +171 −188 src/comp/back/link.rs
  3. +112 −109 src/comp/back/upcall.rs
  4. +6 −6 src/comp/back/x86.rs
  5. +333 −348 src/comp/driver/rustc.rs
  6. +47 −54 src/comp/driver/session.rs
  7. +96 −120 src/comp/front/attr.rs
  8. +74 −78 src/comp/front/config.rs
  9. +224 −235 src/comp/front/test.rs
  10. +867 −875 src/comp/lib/llvm.rs
  11. +33 −33 src/comp/metadata/common.rs
  12. +142 −158 src/comp/metadata/creader.rs
  13. +31 −33 src/comp/metadata/csearch.rs
  14. +40 −44 src/comp/metadata/cstore.rs
  15. +220 −222 src/comp/metadata/decoder.rs
  16. +343 −353 src/comp/metadata/encoder.rs
  17. +267 −297 src/comp/metadata/tydecode.rs
  18. +176 −195 src/comp/metadata/tyencode.rs
  19. +444 −448 src/comp/middle/alias.rs
  20. +41 −44 src/comp/middle/ast_map.rs
  21. +35 −35 src/comp/middle/check_alt.rs
  22. +86 −95 src/comp/middle/freevars.rs
  23. +823 −873 src/comp/middle/resolve.rs
  24. +4,323 −4,497 src/comp/middle/trans.rs
  25. +265 −290 src/comp/middle/trans_alt.rs
  26. +107 −116 src/comp/middle/trans_comm.rs
  27. +361 −356 src/comp/middle/trans_common.rs
  28. +286 −272 src/comp/middle/trans_dps.rs
  29. +79 −80 src/comp/middle/trans_vec.rs
  30. +63 −73 src/comp/middle/tstate/ann.rs
  31. +38 −41 src/comp/middle/tstate/annotate.rs
  32. +476 −529 src/comp/middle/tstate/auxiliary.rs
  33. +99 −117 src/comp/middle/tstate/bitvectors.rs
  34. +57 −55 src/comp/middle/tstate/ck.rs
  35. +69 −74 src/comp/middle/tstate/collect_locals.rs
  36. +524 −548 src/comp/middle/tstate/pre_post_conditions.rs
  37. +548 −566 src/comp/middle/tstate/states.rs
  38. +168 −158 src/comp/middle/tstate/tritv.rs
Sorry, we could not display the entire diff because too many files (723) changed.
View
116 src/comp/back/abi.rs
@@ -2,126 +2,126 @@
// FIXME: Most of these should be uints.
-const int rc_base_field_refcnt = 0;
+const rc_base_field_refcnt: int = 0;
// FIXME: import from std::dbg when imported consts work.
-const uint const_refcount = 0x7bad_face_u;
+const const_refcount: uint = 0x7bad_face_u;
-const int task_field_refcnt = 0;
+const task_field_refcnt: int = 0;
-const int task_field_stk = 2;
+const task_field_stk: int = 2;
-const int task_field_runtime_sp = 3;
+const task_field_runtime_sp: int = 3;
-const int task_field_rust_sp = 4;
+const task_field_rust_sp: int = 4;
-const int task_field_gc_alloc_chain = 5;
+const task_field_gc_alloc_chain: int = 5;
-const int task_field_dom = 6;
+const task_field_dom: int = 6;
-const int n_visible_task_fields = 7;
+const n_visible_task_fields: int = 7;
-const int dom_field_interrupt_flag = 1;
+const dom_field_interrupt_flag: int = 1;
-const int frame_glue_fns_field_mark = 0;
+const frame_glue_fns_field_mark: int = 0;
-const int frame_glue_fns_field_drop = 1;
+const frame_glue_fns_field_drop: int = 1;
-const int frame_glue_fns_field_reloc = 2;
+const frame_glue_fns_field_reloc: int = 2;
-const int box_rc_field_refcnt = 0;
+const box_rc_field_refcnt: int = 0;
-const int box_rc_field_body = 1;
+const box_rc_field_body: int = 1;
-const int general_code_alignment = 16;
+const general_code_alignment: int = 16;
-const int vec_elt_rc = 0;
+const vec_elt_rc: int = 0;
-const int vec_elt_alloc = 1;
+const vec_elt_alloc: int = 1;
-const int vec_elt_fill = 2;
+const vec_elt_fill: int = 2;
-const int vec_elt_pad = 3;
+const vec_elt_pad: int = 3;
-const int vec_elt_data = 4;
+const vec_elt_data: int = 4;
-const int tydesc_field_first_param = 0;
+const tydesc_field_first_param: int = 0;
-const int tydesc_field_size = 1;
+const tydesc_field_size: int = 1;
-const int tydesc_field_align = 2;
+const tydesc_field_align: int = 2;
-const int tydesc_field_copy_glue = 3;
+const tydesc_field_copy_glue: int = 3;
-const int tydesc_field_drop_glue = 4;
+const tydesc_field_drop_glue: int = 4;
-const int tydesc_field_free_glue = 5;
+const tydesc_field_free_glue: int = 5;
-const int tydesc_field_sever_glue = 6;
+const tydesc_field_sever_glue: int = 6;
-const int tydesc_field_mark_glue = 7;
+const tydesc_field_mark_glue: int = 7;
// FIXME no longer used in rustc, drop when rustboot is gone
-const int tydesc_field_obj_drop_glue = 8;
+const tydesc_field_obj_drop_glue: int = 8;
-const int tydesc_field_is_stateful = 9;
+const tydesc_field_is_stateful: int = 9;
-const int tydesc_field_cmp_glue = 10;
+const tydesc_field_cmp_glue: int = 10;
-const int n_tydesc_fields = 11;
+const n_tydesc_fields: int = 11;
-const uint cmp_glue_op_eq = 0u;
+const cmp_glue_op_eq: uint = 0u;
-const uint cmp_glue_op_lt = 1u;
+const cmp_glue_op_lt: uint = 1u;
-const uint cmp_glue_op_le = 2u;
+const cmp_glue_op_le: uint = 2u;
-const int obj_field_vtbl = 0;
+const obj_field_vtbl: int = 0;
-const int obj_field_box = 1;
+const obj_field_box: int = 1;
-const int obj_body_elt_tydesc = 0;
+const obj_body_elt_tydesc: int = 0;
-const int obj_body_elt_typarams = 1;
+const obj_body_elt_typarams: int = 1;
-const int obj_body_elt_fields = 2;
+const obj_body_elt_fields: int = 2;
// The base object to which an anonymous object is attached.
-const int obj_body_elt_with_obj = 3;
+const obj_body_elt_with_obj: int = 3;
// The two halves of a closure: code and environment.
-const int fn_field_code = 0;
-const int fn_field_box = 1;
+const fn_field_code: int = 0;
+const fn_field_box: int = 1;
-const int closure_elt_tydesc = 0;
+const closure_elt_tydesc: int = 0;
-const int closure_elt_target = 1;
+const closure_elt_target: int = 1;
-const int closure_elt_bindings = 2;
+const closure_elt_bindings: int = 2;
-const int closure_elt_ty_params = 3;
+const closure_elt_ty_params: int = 3;
-const uint ivec_default_length = 4u;
+const ivec_default_length: uint = 4u;
-const uint ivec_elt_len = 0u;
+const ivec_elt_len: uint = 0u;
-const uint ivec_elt_alen = 1u;
+const ivec_elt_alen: uint = 1u;
-const uint ivec_elt_elems = 2u;
+const ivec_elt_elems: uint = 2u;
-const uint ivec_heap_stub_elt_zero = 0u;
+const ivec_heap_stub_elt_zero: uint = 0u;
-const uint ivec_heap_stub_elt_alen = 1u;
+const ivec_heap_stub_elt_alen: uint = 1u;
-const uint ivec_heap_stub_elt_ptr = 2u;
+const ivec_heap_stub_elt_ptr: uint = 2u;
-const uint ivec_heap_elt_len = 0u;
+const ivec_heap_elt_len: uint = 0u;
-const uint ivec_heap_elt_elems = 1u;
+const ivec_heap_elt_elems: uint = 1u;
-const int worst_case_glue_call_args = 7;
+const worst_case_glue_call_args: int = 7;
fn memcpy_glue_name() -> str { ret "rust_memcpy_glue"; }
View
359 src/comp/back/link.rs
@@ -31,167 +31,156 @@ tag output_type {
output_type_exe;
}
-fn llvm_err(session::session sess, str msg) {
- auto buf = llvm::LLVMRustGetLastError();
- if (buf as uint == 0u) {
+fn llvm_err(sess: session::session, msg: str) {
+ let buf = llvm::LLVMRustGetLastError();
+ if buf as uint == 0u {
sess.fatal(msg);
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
fail;
}
-fn link_intrinsics(session::session sess, ModuleRef llmod) {
- auto path = fs::connect(sess.get_opts().sysroot, "lib/intrinsics.bc");
- auto membuf =
+fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
+ let path = fs::connect(sess.get_opts().sysroot, "lib/intrinsics.bc");
+ let membuf =
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(str::buf(path));
- if (membuf as uint == 0u) {
+ if membuf as uint == 0u {
llvm_err(sess, "installation problem: couldn't open " + path);
fail;
}
- auto llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf);
+ let llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf);
llvm::LLVMDisposeMemoryBuffer(membuf);
- if (llintrinsicsmod as uint == 0u) {
+ if llintrinsicsmod as uint == 0u {
llvm_err(sess, "installation problem: couldn't parse intrinsics.bc");
fail;
}
- auto linkres = llvm::LLVMLinkModules(llmod, llintrinsicsmod);
+ let linkres = llvm::LLVMLinkModules(llmod, llintrinsicsmod);
llvm::LLVMDisposeModule(llintrinsicsmod);
- if (linkres == False) {
+ if linkres == False {
llvm_err(sess, "couldn't link the module with the intrinsics");
fail;
}
}
mod write {
- fn is_object_or_assembly_or_exe(output_type ot) -> bool {
- if (ot == output_type_assembly || ot == output_type_object ||
- ot == output_type_exe) {
+ fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
+ if ot == output_type_assembly || ot == output_type_object ||
+ ot == output_type_exe {
ret true;
}
ret false;
}
// Decides what to call an intermediate file, given the name of the output
// and the extension to use.
- fn mk_intermediate_name(str output_path, str extension) -> str {
- auto dot_pos = str::index(output_path, '.' as u8);
- auto stem;
- if (dot_pos < 0) {
+ fn mk_intermediate_name(output_path: str, extension: str) -> str {
+ let dot_pos = str::index(output_path, '.' as u8);
+ let stem;
+ if dot_pos < 0 {
stem = output_path;
} else { stem = str::substr(output_path, 0u, dot_pos as uint); }
ret stem + "." + extension;
}
- fn run_passes(session::session sess, ModuleRef llmod, str output) {
- auto opts = sess.get_opts();
- if (opts.time_llvm_passes) { llvm::LLVMRustEnableTimePasses(); }
+ fn run_passes(sess: session::session, llmod: ModuleRef, output: str) {
+ let opts = sess.get_opts();
+ if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); }
link_intrinsics(sess, llmod);
- auto pm = mk_pass_manager();
- auto td = mk_target_data(x86::get_data_layout());
+ let pm = mk_pass_manager();
+ let td = mk_target_data(x86::get_data_layout());
llvm::LLVMAddTargetData(td.lltd, pm.llpm);
// TODO: run the linter here also, once there are llvm-c bindings for
// it.
// Generate a pre-optimization intermediate file if -save-temps was
// specified.
- if (opts.save_temps) {
- alt (opts.output_type) {
- case (output_type_bitcode) {
- if (opts.optimize != 0u) {
- auto filename =
- mk_intermediate_name(output, "no-opt.bc");
- llvm::LLVMWriteBitcodeToFile(llmod,
- str::buf(filename));
- }
- }
- case (_) {
- auto filename = mk_intermediate_name(output, "bc");
+ if opts.save_temps {
+ alt opts.output_type {
+ output_type_bitcode. {
+ if opts.optimize != 0u {
+ let filename = mk_intermediate_name(output, "no-opt.bc");
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
}
+ }
+ _ {
+ let filename = mk_intermediate_name(output, "bc");
+ llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
+ }
}
}
- if (opts.verify) { llvm::LLVMAddVerifierPass(pm.llpm); }
+ if opts.verify { llvm::LLVMAddVerifierPass(pm.llpm); }
// FIXME: This is mostly a copy of the bits of opt's -O2 that are
// available in the C api.
// FIXME2: We might want to add optimization levels like -O1, -O2,
// -Os, etc
// FIXME3: Should we expose and use the pass lists used by the opt
// tool?
- if (opts.optimize != 0u) {
- auto fpm = mk_pass_manager();
+ if opts.optimize != 0u {
+ let fpm = mk_pass_manager();
llvm::LLVMAddTargetData(td.lltd, fpm.llpm);
llvm::LLVMAddStandardFunctionPasses(fpm.llpm, 2u);
llvm::LLVMRunPassManager(fpm.llpm, llmod);
- let uint threshold = 225u;
- if (opts.optimize == 3u) { threshold = 275u; }
+ let threshold: uint = 225u;
+ if opts.optimize == 3u { threshold = 275u; }
llvm::LLVMAddStandardModulePasses(pm.llpm,
// optimization level
opts.optimize,
False, // optimize for size
- True, // unit-at-a-time
- True, // unroll loops
- True, // simplify lib calls
- threshold); // inline threshold
+ True, // unit-at-a-time
+ True, // unroll loops
+ True, // simplify lib calls
+ threshold); // inline threshold
}
- if (opts.verify) { llvm::LLVMAddVerifierPass(pm.llpm); }
- if (is_object_or_assembly_or_exe(opts.output_type)) {
- let int LLVMAssemblyFile = 0;
- let int LLVMObjectFile = 1;
- let int LLVMOptNone = 0; // -O0
- let int LLVMOptLess = 1; // -O1
- let int LLVMOptDefault = 2; // -O2, -Os
- let int LLVMOptAggressive = 3; // -O3
-
- auto CodeGenOptLevel;
- alt (opts.optimize) {
- case (0u) {
- CodeGenOptLevel = LLVMOptNone;
- }
- case (1u) {
- CodeGenOptLevel = LLVMOptLess;
- }
- case (2u) {
- CodeGenOptLevel = LLVMOptDefault;
- }
- case (3u) {
- CodeGenOptLevel = LLVMOptAggressive;
- }
- case (_) {
- fail;
- }
+ if opts.verify { llvm::LLVMAddVerifierPass(pm.llpm); }
+ if is_object_or_assembly_or_exe(opts.output_type) {
+ let LLVMAssemblyFile: int = 0;
+ let LLVMObjectFile: int = 1;
+ let LLVMOptNone: int = 0; // -O0
+ let LLVMOptLess: int = 1; // -O1
+ let LLVMOptDefault: int = 2; // -O2, -Os
+ let LLVMOptAggressive: int = 3; // -O3
+
+ let CodeGenOptLevel;
+ alt opts.optimize {
+ 0u { CodeGenOptLevel = LLVMOptNone; }
+ 1u { CodeGenOptLevel = LLVMOptLess; }
+ 2u { CodeGenOptLevel = LLVMOptDefault; }
+ 3u { CodeGenOptLevel = LLVMOptAggressive; }
+ _ { fail; }
}
- auto FileType;
- if (opts.output_type == output_type_object ||
- opts.output_type == output_type_exe) {
+ let FileType;
+ if opts.output_type == output_type_object ||
+ opts.output_type == output_type_exe {
FileType = LLVMObjectFile;
} else { FileType = LLVMAssemblyFile; }
// Write optimized bitcode if --save-temps was on.
- if (opts.save_temps) {
+ if opts.save_temps {
// Always output the bitcode file with --save-temps
- auto filename = mk_intermediate_name(output, "opt.bc");
+ let filename = mk_intermediate_name(output, "opt.bc");
llvm::LLVMRunPassManager(pm.llpm, llmod);
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
pm = mk_pass_manager();
// Save the assembly file if -S is used
- if (opts.output_type == output_type_assembly) {
- auto triple = x86::get_target_triple();
+ if opts.output_type == output_type_assembly {
+ let triple = x86::get_target_triple();
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
str::buf(triple),
str::buf(output),
LLVMAssemblyFile,
CodeGenOptLevel);
}
+
// Save the object file for -c or --save-temps alone
// This .o is needed when an exe is built
- if (opts.output_type == output_type_object ||
- opts.output_type == output_type_exe) {
- auto triple = x86::get_target_triple();
+ if opts.output_type == output_type_object ||
+ opts.output_type == output_type_exe {
+ let triple = x86::get_target_triple();
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
str::buf(triple),
str::buf(output),
@@ -202,7 +191,7 @@ mod write {
// If we aren't saving temps then just output the file
// type corresponding to the '-c' or '-S' flag used
- auto triple = x86::get_target_triple();
+ let triple = x86::get_target_triple();
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
str::buf(triple),
str::buf(output), FileType,
@@ -211,7 +200,7 @@ mod write {
// Clean up and return
llvm::LLVMDisposeModule(llmod);
- if (opts.time_llvm_passes) { llvm::LLVMRustPrintPassTimings(); }
+ if opts.time_llvm_passes { llvm::LLVMRustPrintPassTimings(); }
ret;
}
// If only a bitcode file is asked for by using the '--emit-llvm'
@@ -220,7 +209,7 @@ mod write {
llvm::LLVMRunPassManager(pm.llpm, llmod);
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(output));
llvm::LLVMDisposeModule(llmod);
- if (opts.time_llvm_passes) { llvm::LLVMRustPrintPassTimings(); }
+ if opts.time_llvm_passes { llvm::LLVMRustPrintPassTimings(); }
}
}
@@ -276,132 +265,128 @@ mod write {
*
*/
-type link_meta = rec(str name,
- str vers,
- str extras_hash);
+type link_meta = {name: str, vers: str, extras_hash: str};
-fn build_link_meta(&session::session sess, &ast::crate c,
- &str output, sha1 sha) -> link_meta {
+fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
+ sha: sha1) -> link_meta {
- type provided_metas = rec(option::t[str] name,
- option::t[str] vers,
- (@ast::meta_item)[] cmh_items);
+ type provided_metas =
+ {name: option::t[str],
+ vers: option::t[str],
+ cmh_items: (@ast::meta_item)[]};
- fn provided_link_metas(&session::session sess,
- &ast::crate c) -> provided_metas {
- let option::t[str] name = none;
- let option::t[str] vers = none;
- let (@ast::meta_item)[] cmh_items = ~[];
- auto linkage_metas = attr::find_linkage_metas(c.node.attrs);
+ fn provided_link_metas(sess: &session::session, c: &ast::crate) ->
+ provided_metas {
+ let name: option::t[str] = none;
+ let vers: option::t[str] = none;
+ let cmh_items: (@ast::meta_item)[] = ~[];
+ let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess, linkage_metas);
- for (@ast::meta_item meta in linkage_metas) {
- if (attr::get_meta_item_name(meta) == "name") {
- alt (attr::get_meta_item_value_str(meta)) {
- case (some(?v)) { name = some(v); }
- case (none) { cmh_items += ~[meta]; }
+ for meta: @ast::meta_item in linkage_metas {
+ if attr::get_meta_item_name(meta) == "name" {
+ alt attr::get_meta_item_value_str(meta) {
+ some(v) { name = some(v); }
+ none. { cmh_items += ~[meta]; }
}
} else if (attr::get_meta_item_name(meta) == "vers") {
- alt (attr::get_meta_item_value_str(meta)) {
- case (some(?v)) { vers = some(v); }
- case (none) { cmh_items += ~[meta]; }
+ alt attr::get_meta_item_value_str(meta) {
+ some(v) { vers = some(v); }
+ none. { cmh_items += ~[meta]; }
}
- } else {
- cmh_items += ~[meta];
- }
+ } else { cmh_items += ~[meta]; }
}
- ret rec(name = name,
- vers = vers,
- cmh_items = cmh_items);
+ ret {name: name, vers: vers, cmh_items: cmh_items};
}
// This calculates CMH as defined above
- fn crate_meta_extras_hash(sha1 sha, &ast::crate crate,
- &provided_metas metas) -> str {
- fn len_and_str(&str s) -> str {
+ fn crate_meta_extras_hash(sha: sha1, crate: &ast::crate,
+ metas: &provided_metas) -> str {
+ fn len_and_str(s: &str) -> str {
ret #fmt("%u_%s", str::byte_len(s), s);
}
- fn len_and_str_lit(&ast::lit l) -> str {
+ fn len_and_str_lit(l: &ast::lit) -> str {
ret len_and_str(pprust::lit_to_str(@l));
}
- auto cmh_items = attr::sort_meta_items(metas.cmh_items);
+ let cmh_items = attr::sort_meta_items(metas.cmh_items);
sha.reset();
- for (@ast::meta_item m_ in cmh_items) {
- auto m = m_;
- alt (m.node) {
- case (ast::meta_name_value(?key, ?value)) {
- sha.input_str(len_and_str(key));
- sha.input_str(len_and_str_lit(value));
- }
- case (ast::meta_word(?name)) {
- sha.input_str(len_and_str(name));
- }
- case (ast::meta_list(_, _)) {
- // FIXME (#607): Implement this
- fail "unimplemented meta_item variant";
- }
+ for m_: @ast::meta_item in cmh_items {
+ let m = m_;
+ alt m.node {
+ ast::meta_name_value(key, value) {
+ sha.input_str(len_and_str(key));
+ sha.input_str(len_and_str_lit(value));
+ }
+ ast::meta_word(name) { sha.input_str(len_and_str(name)); }
+ ast::meta_list(_, _) {
+ // FIXME (#607): Implement this
+ fail "unimplemented meta_item variant";
+ }
}
}
ret truncated_sha1_result(sha);
}
- fn warn_missing(&session::session sess, str name, str default) {
- if (!sess.get_opts().library) { ret; }
+ fn warn_missing(sess: &session::session, name: str, default: str) {
+ if !sess.get_opts().library { ret; }
sess.warn(#fmt("missing crate link meta '%s', using '%s' as default",
name, default));
}
- fn crate_meta_name(&session::session sess, &ast::crate crate,
- &str output, &provided_metas metas) -> str {
- ret alt (metas.name) {
- case (some(?v)) { v }
- case (none) {
- auto name = {
- auto os_vec = str::split(fs::basename(output), '.' as u8);
+ fn crate_meta_name(sess: &session::session, crate: &ast::crate,
+ output: &str, metas: &provided_metas) -> str {
+ ret alt metas.name {
+ some(v) { v }
+ none. {
+ let
// FIXME: Remove this vec->ivec conversion.
- auto os = ~[];
- for (str s in os_vec) { os += ~[s]; }
- assert (ivec::len(os) >= 2u);
- ivec::pop(os);
- str::connect_ivec(os, ".")
- };
+ name =
+ {
+ let os_vec =
+ str::split(fs::basename(output), '.' as u8);
+ let os = ~[];
+ for s: str in os_vec { os += ~[s]; }
+ assert (ivec::len(os) >= 2u);
+ ivec::pop(os);
+ str::connect_ivec(os, ".")
+ };
warn_missing(sess, "name", name);
name
- }
- };
+ }
+ };
}
- fn crate_meta_vers(&session::session sess, &ast::crate crate,
- &provided_metas metas) -> str {
- ret alt (metas.vers) {
- case (some(?v)) { v }
- case (none) {
- auto vers = "0.0";
+ fn crate_meta_vers(sess: &session::session, crate: &ast::crate,
+ metas: &provided_metas) -> str {
+ ret alt metas.vers {
+ some(v) { v }
+ none. {
+ let vers = "0.0";
warn_missing(sess, "vers", vers);
vers
- }
- };
+ }
+ };
}
- auto provided_metas = provided_link_metas(sess, c);
- auto name = crate_meta_name(sess, c, output, provided_metas);
- auto vers = crate_meta_vers(sess, c, provided_metas);
- auto extras_hash = crate_meta_extras_hash(sha, c, provided_metas);
+ let provided_metas = provided_link_metas(sess, c);
+ let name = crate_meta_name(sess, c, output, provided_metas);
+ let vers = crate_meta_vers(sess, c, provided_metas);
+ let extras_hash = crate_meta_extras_hash(sha, c, provided_metas);
- ret rec(name = name, vers = vers, extras_hash = extras_hash);
+ ret {name: name, vers: vers, extras_hash: extras_hash};
}
-fn truncated_sha1_result(sha1 sha) -> str {
+fn truncated_sha1_result(sha: sha1) -> str {
ret str::substr(sha.result_str(), 0u, 16u);
}
// This calculates STH for a symbol, as defined above
-fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
- &link_meta link_meta) -> str {
+fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: &ty::t, link_meta: &link_meta) ->
+ str {
// NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate.
@@ -412,66 +397,64 @@ fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
sha.input_str(link_meta.name);
sha.input_str("-");
sha.input_str(encoder::encoded_ty(tcx, t));
- auto hash = truncated_sha1_result(sha);
+ let hash = truncated_sha1_result(sha);
// Prefix with _ so that it never blends into adjacent digits
ret "_" + hash;
}
-fn get_symbol_hash(&@crate_ctxt ccx, &ty::t t) -> str {
- auto hash = "";
- alt (ccx.type_sha1s.find(t)) {
- case (some(?h)) { hash = h; }
- case (none) {
- hash =
- symbol_hash(ccx.tcx, ccx.sha, t,
- ccx.link_meta);
- ccx.type_sha1s.insert(t, hash);
- }
+fn get_symbol_hash(ccx: &@crate_ctxt, t: &ty::t) -> str {
+ let hash = "";
+ alt ccx.type_sha1s.find(t) {
+ some(h) { hash = h; }
+ none. {
+ hash = symbol_hash(ccx.tcx, ccx.sha, t, ccx.link_meta);
+ ccx.type_sha1s.insert(t, hash);
+ }
}
ret hash;
}
-fn mangle(&str[] ss) -> str {
+fn mangle(ss: &str[]) -> str {
// Follow C++ namespace-mangling style
- auto n = "_ZN"; // Begin name-sequence.
+ let n = "_ZN"; // Begin name-sequence.
- for (str s in ss) { n += #fmt("%u%s", str::byte_len(s), s); }
+ for s: str in ss { n += #fmt("%u%s", str::byte_len(s), s); }
n += "E"; // End name-sequence.
ret n;
}
-fn exported_name(&str[] path, &str hash, &str vers) -> str {
+fn exported_name(path: &str[], hash: &str, vers: &str) -> str {
// FIXME: versioning isn't working yet
ret mangle(path + ~[hash]); // + "@" + vers;
}
-fn mangle_exported_name(&@crate_ctxt ccx, &str[] path, &ty::t t) -> str {
- auto hash = get_symbol_hash(ccx, t);
+fn mangle_exported_name(ccx: &@crate_ctxt, path: &str[], t: &ty::t) -> str {
+ let hash = get_symbol_hash(ccx, t);
ret exported_name(path, hash, ccx.link_meta.vers);
}
-fn mangle_internal_name_by_type_only(&@crate_ctxt ccx, &ty::t t, &str name) ->
- str {
- auto s = util::ppaux::ty_to_short_str(ccx.tcx, t);
- auto hash = get_symbol_hash(ccx, t);
+fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: &ty::t, name: &str)
+ -> str {
+ let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
+ let hash = get_symbol_hash(ccx, t);
ret mangle(~[name, s, hash]);
}
-fn mangle_internal_name_by_path_and_seq(&@crate_ctxt ccx, &str[] path,
- &str flav) -> str {
+fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &str[],
+ flav: &str) -> str {
ret mangle(path + ~[ccx.names.next(flav)]);
}
-fn mangle_internal_name_by_path(&@crate_ctxt ccx, &str[] path) -> str {
+fn mangle_internal_name_by_path(ccx: &@crate_ctxt, path: &str[]) -> str {
ret mangle(path);
}
-fn mangle_internal_name_by_seq(&@crate_ctxt ccx, &str flav) -> str {
+fn mangle_internal_name_by_seq(ccx: &@crate_ctxt, flav: &str) -> str {
ret ccx.names.next(flav);
}
//
View
221 src/comp/back/upcall.rs
@@ -24,121 +24,124 @@ import lib::llvm::llvm::ValueRef;
import lib::llvm::llvm::TypeRef;
type upcalls =
- rec(ValueRef grow_task,
- ValueRef log_int,
- ValueRef log_float,
- ValueRef log_double,
- ValueRef log_str,
- ValueRef log_istr,
- ValueRef trace_word,
- ValueRef trace_str,
- ValueRef new_port,
- ValueRef del_port,
- ValueRef new_chan,
- ValueRef flush_chan,
- ValueRef del_chan,
- ValueRef clone_chan,
- ValueRef chan_target_task,
- ValueRef _yield,
- ValueRef sleep,
- ValueRef send,
- ValueRef recv,
- ValueRef _fail,
- ValueRef kill,
- ValueRef exit,
- ValueRef malloc,
- ValueRef free,
- ValueRef shared_malloc,
- ValueRef shared_free,
- ValueRef mark,
- ValueRef new_str,
- ValueRef dup_str,
- ValueRef new_vec,
- ValueRef vec_append,
- ValueRef get_type_desc,
- ValueRef new_task,
- ValueRef start_task,
- ValueRef ivec_resize,
- ValueRef ivec_spill,
- ValueRef ivec_resize_shared,
- ValueRef ivec_spill_shared);
+ {grow_task: ValueRef,
+ log_int: ValueRef,
+ log_float: ValueRef,
+ log_double: ValueRef,
+ log_str: ValueRef,
+ log_istr: ValueRef,
+ trace_word: ValueRef,
+ trace_str: ValueRef,
+ new_port: ValueRef,
+ del_port: ValueRef,
+ new_chan: ValueRef,
+ flush_chan: ValueRef,
+ del_chan: ValueRef,
+ clone_chan: ValueRef,
+ chan_target_task: ValueRef,
+ _yield: ValueRef,
+ sleep: ValueRef,
+ send: ValueRef,
+ recv: ValueRef,
+ _fail: ValueRef,
+ kill: ValueRef,
+ exit: ValueRef,
+ malloc: ValueRef,
+ free: ValueRef,
+ shared_malloc: ValueRef,
+ shared_free: ValueRef,
+ mark: ValueRef,
+ new_str: ValueRef,
+ dup_str: ValueRef,
+ new_vec: ValueRef,
+ vec_append: ValueRef,
+ get_type_desc: ValueRef,
+ new_task: ValueRef,
+ start_task: ValueRef,
+ ivec_resize: ValueRef,
+ ivec_spill: ValueRef,
+ ivec_resize_shared: ValueRef,
+ ivec_spill_shared: ValueRef};
-fn declare_upcalls(type_names tn, TypeRef tydesc_type, TypeRef taskptr_type,
- ModuleRef llmod)
- -> @upcalls {
- fn decl(type_names tn, TypeRef tydesc_type, TypeRef taskptr_type,
- ModuleRef llmod, str name, TypeRef[] tys,
- TypeRef rv) -> ValueRef {
- let TypeRef[] arg_tys = ~[taskptr_type];
- for (TypeRef t in tys) { arg_tys += ~[t]; }
- auto fn_ty = T_fn(arg_tys, rv);
+fn declare_upcalls(tn: type_names, tydesc_type: TypeRef,
+ taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls {
+ fn decl(tn: type_names, tydesc_type: TypeRef, taskptr_type: TypeRef,
+ llmod: ModuleRef, name: str, tys: TypeRef[], rv: TypeRef) ->
+ ValueRef {
+ let arg_tys: TypeRef[] = ~[taskptr_type];
+ for t: TypeRef in tys { arg_tys += ~[t]; }
+ let fn_ty = T_fn(arg_tys, rv);
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
}
- auto dv = bind decl(tn, tydesc_type, taskptr_type, llmod, _, _, T_void());
- auto d = bind decl(tn, tydesc_type, taskptr_type, llmod, _, _, _);
+ let dv = bind decl(tn, tydesc_type, taskptr_type, llmod, _, _, T_void());
+ let d = bind decl(tn, tydesc_type, taskptr_type, llmod, _, _, _);
// FIXME: Sigh:.. remove this when I fix the typechecker pushdown.
// --pcwalton
- let TypeRef[] empty_vec = ~[];
- ret @rec(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())]),
- log_istr=dv("log_istr", ~[T_i32(), T_ptr(T_ivec(T_i8()))]),
- 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", ~[taskptr_type, T_opaque_chan_ptr()],
- T_opaque_chan_ptr()),
- chan_target_task=d("chan_target_task",
- ~[T_opaque_chan_ptr()],
- taskptr_type),
- _yield=dv("yield", empty_vec),
- sleep=dv("sleep", ~[T_size_t()]),
- 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", ~[taskptr_type]),
- exit=dv("exit", empty_vec),
- malloc=d("malloc", ~[T_size_t(), T_ptr(tydesc_type)],
- T_ptr(T_i8())),
- free=dv("free", ~[T_ptr(T_i8()), T_int()]),
- shared_malloc=d("shared_malloc",
- ~[T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
- shared_free=dv("shared_free", ~[T_ptr(T_i8())]),
- 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())),
- dup_str=d("dup_str", ~[taskptr_type, T_ptr(T_str())],
- T_ptr(T_str())),
- new_vec=d("new_vec", ~[T_size_t(), T_ptr(tydesc_type)],
- T_opaque_vec_ptr()),
- vec_append=d("vec_append",
- ~[T_ptr(tydesc_type), T_ptr(tydesc_type),
- T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(),
- T_bool()], T_void()),
- get_type_desc=d("get_type_desc",
- ~[T_ptr(T_nil()), T_size_t(), T_size_t(),
- T_size_t(), T_ptr(T_ptr(tydesc_type))],
- T_ptr(tydesc_type)),
- new_task=d("new_task", ~[T_ptr(T_str())], taskptr_type),
- start_task=d("start_task",
- ~[taskptr_type, T_int(), T_int(), T_size_t()],
- taskptr_type),
- ivec_resize=d("ivec_resize", ~[T_ptr(T_opaque_ivec()), T_int()],
- T_void()),
- ivec_spill=d("ivec_spill", ~[T_ptr(T_opaque_ivec()), T_int()],
- T_void()),
- ivec_resize_shared=d("ivec_resize_shared",
- ~[T_ptr(T_opaque_ivec()), T_int()], T_void()),
- ivec_spill_shared=d("ivec_spill_shared",
- ~[T_ptr(T_opaque_ivec()), T_int()], T_void()));
+ let empty_vec: TypeRef[] = ~[];
+ ret @{grow_task: dv("grow_task", ~[T_size_t()]),
+ log_int: dv("log_int", ~[T_i32(), T_i32()]),
+ log_float: dv("log_float", ~[T_i32(), T_f32()]),
+ log_double: dv("log_double", ~[T_i32(), T_ptr(T_f64())]),
+ log_str: dv("log_str", ~[T_i32(), T_ptr(T_str())]),
+ log_istr: dv("log_istr", ~[T_i32(), T_ptr(T_ivec(T_i8()))]),
+ 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", ~[taskptr_type, T_opaque_chan_ptr()],
+ T_opaque_chan_ptr()),
+ chan_target_task:
+ d("chan_target_task", ~[T_opaque_chan_ptr()], taskptr_type),
+ _yield: dv("yield", empty_vec),
+ sleep: dv("sleep", ~[T_size_t()]),
+ 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", ~[taskptr_type]),
+ exit: dv("exit", empty_vec),
+ malloc:
+ d("malloc", ~[T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
+ free: dv("free", ~[T_ptr(T_i8()), T_int()]),
+ shared_malloc:
+ d("shared_malloc", ~[T_size_t(), T_ptr(tydesc_type)],
+ T_ptr(T_i8())),
+ shared_free: dv("shared_free", ~[T_ptr(T_i8())]),
+ 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())),
+ dup_str:
+ d("dup_str", ~[taskptr_type, T_ptr(T_str())], T_ptr(T_str())),
+ new_vec:
+ d("new_vec", ~[T_size_t(), T_ptr(tydesc_type)],
+ T_opaque_vec_ptr()),
+ vec_append:
+ d("vec_append",
+ ~[T_ptr(tydesc_type), T_ptr(tydesc_type),
+ T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(), T_bool()],
+ T_void()),
+ get_type_desc:
+ d("get_type_desc",
+ ~[T_ptr(T_nil()), T_size_t(), T_size_t(), T_size_t(),
+ T_ptr(T_ptr(tydesc_type))], T_ptr(tydesc_type)),
+ new_task: d("new_task", ~[T_ptr(T_str())], taskptr_type),
+ start_task:
+ d("start_task", ~[taskptr_type, T_int(), T_int(), T_size_t()],
+ taskptr_type),
+ ivec_resize:
+ d("ivec_resize", ~[T_ptr(T_opaque_ivec()), T_int()], T_void()),
+ ivec_spill:
+ d("ivec_spill", ~[T_ptr(T_opaque_ivec()), T_int()], T_void()),
+ ivec_resize_shared:
+ d("ivec_resize_shared", ~[T_ptr(T_opaque_ivec()), T_int()],
+ T_void()),
+ ivec_spill_shared:
+ d("ivec_spill_shared", ~[T_ptr(T_opaque_ivec()), T_int()],
+ T_void())};
}
//
// Local Variables:
View
12 src/comp/back/x86.rs
@@ -7,26 +7,26 @@ import std::os::target_os;
fn get_module_asm() -> str { ret ""; }
fn get_meta_sect_name() -> str {
- if (str::eq(target_os(), "macos")) { ret "__DATA,__note.rustc"; }
- if (str::eq(target_os(), "win32")) { ret ".note.rustc"; }
+ if str::eq(target_os(), "macos") { ret "__DATA,__note.rustc"; }
+ if str::eq(target_os(), "win32") { ret ".note.rustc"; }
ret ".note.rustc";
}
fn get_data_layout() -> str {
- if (str::eq(target_os(), "macos")) {
+ if str::eq(target_os(), "macos") {
ret "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" +
"-f32:32:32-f64:32:64-v64:64:64" +
"-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32";
}
- if (str::eq(target_os(), "win32")) {
+ if str::eq(target_os(), "win32") {
ret "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32";
}
ret "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
}
fn get_target_triple() -> str {
- if (str::eq(target_os(), "macos")) { ret "i686-apple-darwin"; }
- if (str::eq(target_os(), "win32")) { ret "i686-pc-mingw32"; }
+ if str::eq(target_os(), "macos") { ret "i686-apple-darwin"; }
+ if str::eq(target_os(), "win32") { ret "i686-pc-mingw32"; }
ret "i686-unknown-linux-gnu";
}
//
View
681 src/comp/driver/rustc.rs
@@ -40,198 +40,191 @@ import back::link::output_type;
tag pp_mode { ppm_normal; ppm_typed; ppm_identified; }
-fn default_configuration(session::session sess, str argv0, str input) ->
- ast::crate_cfg {
- auto libc =
- alt (sess.get_targ_cfg().os) {
- case (session::os_win32) { "msvcrt.dll" }
- case (session::os_macos) { "libc.dylib" }
- case (session::os_linux) { "libc.so.6" }
- case (_) { "libc.so" }
+fn default_configuration(sess: session::session, argv0: str, input: str) ->
+ ast::crate_cfg {
+ let libc =
+ alt sess.get_targ_cfg().os {
+ session::os_win32. { "msvcrt.dll" }
+ session::os_macos. { "libc.dylib" }
+ session::os_linux. { "libc.so.6" }
+ _ { "libc.so" }
};
- auto mk = attr::mk_name_value_item_str;
+ let mk = attr::mk_name_value_item_str;
ret ~[ // Target bindings.
- mk("target_os", std::os::target_os()),
- mk("target_arch", "x86"),
+ mk("target_os", std::os::target_os()), mk("target_arch", "x86"),
mk("target_libc", libc),
// Build bindings.
- mk("build_compiler", argv0),
- mk("build_input", input)];
+ mk("build_compiler", argv0), mk("build_input", input)];
}
-fn build_configuration(session::session sess, str argv0,
- str input) -> ast::crate_cfg {
+fn build_configuration(sess: session::session, argv0: str, input: str) ->
+ ast::crate_cfg {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items
- auto default_cfg = default_configuration(sess, argv0, input);
- auto user_cfg = sess.get_opts().cfg;
- auto gen_cfg = {
+ let default_cfg = default_configuration(sess, argv0, input);
+ let user_cfg = sess.get_opts().cfg;
+ let
// If the user wants a test runner, then add the test cfg
- if (sess.get_opts().test
- && !attr::contains_name(user_cfg, "test")) {
- ~[attr::mk_word_item("test")]
- } else {
- ~[]
- }
- };
+ gen_cfg =
+ {
+ if sess.get_opts().test && !attr::contains_name(user_cfg, "test")
+ {
+ ~[attr::mk_word_item("test")]
+ } else { ~[] }
+ };
ret user_cfg + gen_cfg + default_cfg;
}
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
-fn parse_cfgspecs(&vec[str] cfgspecs) -> ast::crate_cfg {
+fn parse_cfgspecs(cfgspecs: &vec[str]) -> ast::crate_cfg {
// FIXME: It would be nice to use the parser to parse all varieties of
// meta_item here. At the moment we just support the meta_word variant.
- auto words = ~[];
- for (str s in cfgspecs) { words += ~[attr::mk_word_item(s)]; }
+ let words = ~[];
+ for s: str in cfgspecs { words += ~[attr::mk_word_item(s)]; }
ret words;
}
-fn parse_input(session::session sess, &ast::crate_cfg cfg, str input)
- -> @ast::crate {
- ret if (str::ends_with(input, ".rc")) {
- parser::parse_crate_from_crate_file
- (input, cfg, sess.get_parse_sess())
+fn parse_input(sess: session::session, cfg: &ast::crate_cfg, input: str) ->
+ @ast::crate {
+ ret if str::ends_with(input, ".rc") {
+ parser::parse_crate_from_crate_file(input, cfg,
+ sess.get_parse_sess())
} else if (str::ends_with(input, ".rs")) {
- parser::parse_crate_from_source_file
- (input, cfg, sess.get_parse_sess())
+ parser::parse_crate_from_source_file(input, cfg,
+ sess.get_parse_sess())
} else { sess.fatal("unknown input file type: " + input); fail };
}
-fn time[T](bool do_it, str what, fn() -> T thunk) -> T {
- if (!do_it) { ret thunk(); }
- auto start = std::time::get_time();
- auto rv = thunk();
- auto end = std::time::get_time();
+fn time[T](do_it: bool, what: str, thunk: fn() -> T ) -> T {
+ if !do_it { ret thunk(); }
+ let start = std::time::get_time();
+ let rv = thunk();
+ let end = std::time::get_time();
// FIXME: Actually do timeval math.
log_err #fmt("time: %s took %u s", what, end.sec - start.sec as uint);
ret rv;
}
-fn compile_input(session::session sess, ast::crate_cfg cfg, str input,
- str output) {
- auto time_passes = sess.get_opts().time_passes;
- auto crate =
+fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
+ output: str) {
+ let time_passes = sess.get_opts().time_passes;
+ let crate =
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
- if (sess.get_opts().output_type == link::output_type_none) { ret; }
- crate = time(time_passes, "configuration",
- bind front::config::strip_unconfigured_items(crate));
- if (sess.get_opts().test) {
- crate = time(time_passes, "building test harness",
- bind front::test::modify_for_testing(crate));
+ if sess.get_opts().output_type == link::output_type_none { ret; }
+ crate =
+ time(time_passes, "configuration",
+ bind front::config::strip_unconfigured_items(crate));
+ if sess.get_opts().test {
+ crate =
+ time(time_passes, "building test harness",
+ bind front::test::modify_for_testing(crate));
}
- crate = time(time_passes, "expansion",
- bind syntax::ext::expand::expand_crate(sess, crate));
+ crate =
+ time(time_passes, "expansion",
+ bind syntax::ext::expand::expand_crate(sess, crate));
- auto ast_map = time(time_passes, "ast indexing",
- bind middle::ast_map::map_crate(*crate));
+ let ast_map =
+ time(time_passes, "ast indexing",
+ bind middle::ast_map::map_crate(*crate));
time(time_passes, "external crate/lib resolution",
bind creader::read_crates(sess, *crate));
- auto d =
+ let d =
time(time_passes, "resolution",
bind resolve::resolve_crate(sess, ast_map, crate));
- auto freevars =
+ let freevars =
time(time_passes, "freevar finding",
bind freevars::annotate_freevars(sess, d, crate));
- auto ty_cx = ty::mk_ctxt(sess, d, ast_map, freevars);
+ let ty_cx = ty::mk_ctxt(sess, d, ast_map, freevars);
time[()](time_passes, "typechecking",
bind typeck::check_crate(ty_cx, crate));
time[()](time_passes, "alt checking",
bind middle::check_alt::check_crate(ty_cx, crate));
- if (sess.get_opts().run_typestate) {
+ if sess.get_opts().run_typestate {
time(time_passes, "typestate checking",
bind middle::tstate::ck::check_crate(ty_cx, crate));
}
time(time_passes, "alias checking",
bind middle::alias::check_crate(ty_cx, crate));
- auto llmod =
+ let llmod =
time[llvm::llvm::ModuleRef](time_passes, "translation",
- bind trans::trans_crate
- (sess, crate, ty_cx, output, ast_map));
+ bind trans::trans_crate(sess, crate,
+ ty_cx, output,
+ ast_map));
time[()](time_passes, "LLVM passes",
bind link::write::run_passes(sess, llmod, output));
}
-fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
- str input, pp_mode ppm, bool expand) {
- fn ann_paren_for_expr(&pprust::ann_node node) {
- alt (node) {
- case (pprust::node_expr(?s, ?expr)) {
- pprust::popen(s);
- }
- case (_) {}
- }
+fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
+ ppm: pp_mode, expand: bool) {
+ fn ann_paren_for_expr(node: &pprust::ann_node) {
+ alt node { pprust::node_expr(s, expr) { pprust::popen(s); } _ { } }
}
- fn ann_typed_post(&ty::ctxt tcx, &pprust::ann_node node) {
- alt (node) {
- case (pprust::node_expr(?s, ?expr)) {
- pp::space(s.s);
- pp::word(s.s, "as");
- pp::space(s.s);
- pp::word(s.s, ppaux::ty_to_str(tcx, ty::expr_ty(tcx, expr)));
- pprust::pclose(s);
- }
- case (_) {}
+ fn ann_typed_post(tcx: &ty::ctxt, node: &pprust::ann_node) {
+ alt node {
+ pprust::node_expr(s, expr) {
+ pp::space(s.s);
+ pp::word(s.s, "as");
+ pp::space(s.s);
+ pp::word(s.s, ppaux::ty_to_str(tcx, ty::expr_ty(tcx, expr)));
+ pprust::pclose(s);
+ }
+ _ { }
}
}
- fn ann_identified_post(&pprust::ann_node node) {
- alt (node) {
- case (pprust::node_item(?s, ?item)) {
- pp::space(s.s);
- pprust::synth_comment(s, int::to_str(item.id, 10u));
- }
- case (pprust::node_block(?s, ?blk)) {
- pp::space(s.s);
- pprust::synth_comment(s, "block " +
- int::to_str(blk.node.id, 10u));
- }
- case (pprust::node_expr(?s, ?expr)) {
- pp::space(s.s);
- pprust::synth_comment(s, int::to_str(expr.id, 10u));
- pprust::pclose(s);
- }
- case (_) {}
+ fn ann_identified_post(node: &pprust::ann_node) {
+ alt node {
+ pprust::node_item(s, item) {
+ pp::space(s.s);
+ pprust::synth_comment(s, int::to_str(item.id, 10u));
+ }
+ pprust::node_block(s, blk) {
+ pp::space(s.s);
+ pprust::synth_comment(s,
+ "block " + int::to_str(blk.node.id, 10u));
+ }
+ pprust::node_expr(s, expr) {
+ pp::space(s.s);
+ pprust::synth_comment(s, int::to_str(expr.id, 10u));
+ pprust::pclose(s);
+ }
+ _ { }
}
}
- auto crate = parse_input(sess, cfg, input);
- if(expand) { crate = syntax::ext::expand::expand_crate(sess, crate); }
- auto ann;
- alt (ppm) {
- case (ppm_typed) {
- auto amap = middle::ast_map::map_crate(*crate);
- auto d = resolve::resolve_crate(sess, amap, crate);
- auto freevars = freevars::annotate_freevars(sess, d, crate);
- auto ty_cx = ty::mk_ctxt(sess, d, amap, freevars);
- typeck::check_crate(ty_cx, crate);
- ann = rec(pre=ann_paren_for_expr,
- post=bind ann_typed_post(ty_cx, _));
- }
- case (ppm_identified) {
- ann = rec(pre=ann_paren_for_expr,
- post=ann_identified_post);
- }
- case (ppm_normal) {
- ann = pprust::no_ann();
- }
+ let crate = parse_input(sess, cfg, input);
+ if expand { crate = syntax::ext::expand::expand_crate(sess, crate); }
+ let ann;
+ alt ppm {
+ ppm_typed. {
+ let amap = middle::ast_map::map_crate(*crate);
+ let d = resolve::resolve_crate(sess, amap, crate);
+ let freevars = freevars::annotate_freevars(sess, d, crate);
+ let ty_cx = ty::mk_ctxt(sess, d, amap, freevars);
+ typeck::check_crate(ty_cx, crate);
+ ann = {pre: ann_paren_for_expr, post: bind ann_typed_post(ty_cx, _)};
+ }
+ ppm_identified. {
+ ann = {pre: ann_paren_for_expr, post: ann_identified_post};
+ }
+ ppm_normal. { ann = pprust::no_ann(); }
}
pprust::print_crate(sess.get_codemap(), crate, input,
- ioivec::file_reader(input),
- ioivec::stdout(), ann);
+ ioivec::file_reader(input), ioivec::stdout(), ann);
}
-fn version(str argv0) {
- auto vers = "unknown version";
- auto env_vers = #env("CFG_VERSION");
- if (str::byte_len(env_vers) != 0u) { vers = env_vers; }
+fn version(argv0: str) {
+ let vers = "unknown version";
+ let env_vers = #env("CFG_VERSION");
+ if str::byte_len(env_vers) != 0u { vers = env_vers; }
ioivec::stdout().write_str(#fmt("%s %s\n", argv0, vers));
}
-fn usage(str argv0) {
+fn usage(argv0: str) {
ioivec::stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) +
- "
+ "
options:
-h --help display this message
@@ -267,9 +260,9 @@ options:
");
}
-fn get_os(str triple) -> session::os {
- ret if (str::find(triple, "win32") >= 0 ||
- str::find(triple, "mingw32") >= 0) {
+fn get_os(triple: str) -> session::os {
+ ret if str::find(triple, "win32") >= 0 ||
+ str::find(triple, "mingw32") >= 0 {
session::os_win32
} else if (str::find(triple, "darwin") >= 0) {
session::os_macos
@@ -278,11 +271,11 @@ fn get_os(str triple) -> session::os {
} else { log_err "Unknown operating system!"; fail };
}
-fn get_arch(str triple) -> session::arch {
- ret if (str::find(triple, "i386") >= 0 || str::find(triple, "i486") >= 0
- || str::find(triple, "i586") >= 0 ||
- str::find(triple, "i686") >= 0 ||
- str::find(triple, "i786") >= 0) {
+fn get_arch(triple: str) -> session::arch {
+ ret if str::find(triple, "i386") >= 0 || str::find(triple, "i486") >= 0 ||
+ str::find(triple, "i586") >= 0 ||
+ str::find(triple, "i686") >= 0 ||
+ str::find(triple, "i786") >= 0 {
session::arch_x86
} else if (str::find(triple, "x86_64") >= 0) {
session::arch_x64
@@ -292,36 +285,36 @@ fn get_arch(str triple) -> session::arch {
} else { log_err "Unknown architecture! " + triple; fail };
}
-fn get_default_sysroot(str binary) -> str {
- auto dirname = fs::dirname(binary);
- if (str::eq(dirname, binary)) { ret "."; }
+fn get_default_sysroot(binary: str) -> str {
+ let dirname = fs::dirname(binary);
+ if str::eq(dirname, binary) { ret "."; }
ret dirname;
}
fn build_target_config() -> @session::config {
- let str triple =
+ let triple: str =
std::str::rustrt::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple());
- let @session::config target_cfg =
- @rec(os=get_os(triple),
- arch=get_arch(triple),
- int_type=ast::ty_i32,
- uint_type=ast::ty_u32,
- float_type=ast::ty_f64);
+ let target_cfg: @session::config =
+ @{os: get_os(triple),
+ arch: get_arch(triple),
+ int_type: ast::ty_i32,
+ uint_type: ast::ty_u32,
+ float_type: ast::ty_f64};
ret target_cfg;
}
-fn build_session_options(str binary, getopts::match match, str binary_dir) ->
- @session::options {
- auto library = opt_present(match, "lib");
- auto static = opt_present(match, "static");
+fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
+ -> @session::options {
+ let library = opt_present(match, "lib");
+ let static = opt_present(match, "static");
- auto library_search_paths = ~[binary_dir + "/lib"];
+ let library_search_paths = ~[binary_dir + "/lib"];
// FIXME: Remove this vec->ivec conversion.
- auto lsp_vec = getopts::opt_strs(match, "L");
- for (str lsp in lsp_vec) { library_search_paths += ~[lsp]; }
+ let lsp_vec = getopts::opt_strs(match, "L");
+ for lsp: str in lsp_vec { library_search_paths += ~[lsp]; }
- auto output_type =
- if (opt_present(match, "parse-only")) {
+ let output_type =
+ if opt_present(match, "parse-only") {
link::output_type_none
} else if (opt_present(match, "S")) {
link::output_type_assembly
@@ -330,78 +323,78 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
} else if (opt_present(match, "emit-llvm")) {
link::output_type_bitcode
} else { link::output_type_exe };
- auto verify = !opt_present(match, "noverify");
- auto save_temps = opt_present(match, "save-temps");
- auto debuginfo = opt_present(match, "g");
- auto stats = opt_present(match, "stats");
- auto time_passes = opt_present(match, "time-passes");
- auto time_llvm_passes = opt_present(match, "time-llvm-passes");
- auto run_typestate = !opt_present(match, "no-typestate");
- auto sysroot_opt = getopts::opt_maybe_str(match, "sysroot");
- let uint opt_level =
- if (opt_present(match, "O")) {
- if (opt_present(match, "OptLevel")) {
+ let verify = !opt_present(match, "noverify");
+ let save_temps = opt_present(match, "save-temps");
+ let debuginfo = opt_present(match, "g");
+ let stats = opt_present(match, "stats");
+ let time_passes = opt_present(match, "time-passes");
+ let time_llvm_passes = opt_present(match, "time-llvm-passes");
+ let run_typestate = !opt_present(match, "no-typestate");
+ let sysroot_opt = getopts::opt_maybe_str(match, "sysroot");
+ let opt_level: uint =
+ if opt_present(match, "O") {
+ if opt_present(match, "OptLevel") {
log_err "error: -O and --OptLevel both provided";
fail;
}
2u
} else if (opt_present(match, "OptLevel")) {
- alt (getopts::opt_str(match, "OptLevel")) {
- case ("0") { 0u }
- case ("1") { 1u }
- case ("2") { 2u }
- case ("3") { 3u }
- case (_) {
- log_err "error: optimization level needs " +
- "to be between 0-3";
- fail
- }
+ alt getopts::opt_str(match, "OptLevel") {
+ "0" { 0u }
+ "1" { 1u }
+ "2" { 2u }
+ "3" { 3u }
+ _ {
+ log_err "error: optimization level needs " +
+ "to be between 0-3";
+ fail
+ }
}
} else { 0u };
- auto sysroot =
- alt (sysroot_opt) {
- case (none) { get_default_sysroot(binary) }
- case (some(?s)) { s }
+ let sysroot =
+ alt sysroot_opt {
+ none. { get_default_sysroot(binary) }
+ some(s) { s }
};
- auto cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
- auto test = opt_present(match, "test");
- auto dps = opt_present(match, "dps");
- let @session::options sopts =
- @rec(library=library,
- static=static,
- optimize=opt_level,
- debuginfo=debuginfo,
- verify=verify,
- run_typestate=run_typestate,
- save_temps=save_temps,
- stats=stats,
- time_passes=time_passes,
- time_llvm_passes=time_llvm_passes,
- output_type=output_type,
- library_search_paths=library_search_paths,
- sysroot=sysroot,
- cfg=cfg,
- test=test,
- dps=dps);
+ let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
+ let test = opt_present(match, "test");
+ let dps = opt_present(match, "dps");
+ let sopts: @session::options =
+ @{library: library,
+ static: static,
+ optimize: opt_level,
+ debuginfo: debuginfo,
+ verify: verify,
+ run_typestate: run_typestate,
+ save_temps: save_temps,
+ stats: stats,
+ time_passes: time_passes,
+ time_llvm_passes: time_llvm_passes,
+ output_type: output_type,
+ library_search_paths: library_search_paths,
+ sysroot: sysroot,
+ cfg: cfg,
+ test: test,
+ dps: dps};
ret sopts;
}
-fn build_session(@session::options sopts) -> session::session {
- auto target_cfg = build_target_config();
- auto cstore = cstore::mk_cstore();
+fn build_session(sopts: @session::options) -> session::session {
+ let target_cfg = build_target_config();
+ let cstore = cstore::mk_cstore();
ret session::session(target_cfg, sopts, cstore,
- @rec(cm=codemap::new_codemap(), mutable next_id=0),
+ @{cm: codemap::new_codemap(), mutable next_id: 0},
none, 0u);
}
-fn parse_pretty(session::session sess, &str name) -> pp_mode {
- if (str::eq(name, "normal")) {
+fn parse_pretty(sess: session::session, name: &str) -> pp_mode {
+ if str::eq(name, "normal") {
ret ppm_normal;
} else if (str::eq(name, "typed")) {
ret ppm_typed;
} else if (str::eq(name, "identified")) { ret ppm_identified; }
- sess.fatal("argument to `pretty` or `expand` must be one of `normal`, "
- + "`typed`, or `identified`");
+ sess.fatal("argument to `pretty` or `expand` must be one of `normal`, " +
+ "`typed`, or `identified`");
}
fn opts() -> vec[getopts::opt] {
@@ -416,205 +409,196 @@ fn opts() -> vec[getopts::opt] {
optflag("lib"), optflag("static"), optflag("dps")];
}
-fn main(vec[str] args) {
- auto binary = vec::shift(args);
- auto binary_dir = fs::dirname(binary);
- auto match =
- alt (getopts::getopts(args, opts())) {
- case (getopts::success(?m)) { m }
- case (getopts::failure(?f)) {
- log_err #fmt("error: %s", getopts::fail_str(f));
- fail
- }
+fn main(args: vec[str]) {
+ let binary = vec::shift(args);
+ let binary_dir = fs::dirname(binary);
+ let match =
+ alt getopts::getopts(args, opts()) {
+ getopts::success(m) { m }
+ getopts::failure(f) {
+ log_err #fmt("error: %s", getopts::fail_str(f));
+ fail
+ }
};
- if (opt_present(match, "h") || opt_present(match, "help")) {
+ if opt_present(match, "h") || opt_present(match, "help") {
usage(binary);
ret;
}
- if (opt_present(match, "v") || opt_present(match, "version")) {
+ if opt_present(match, "v") || opt_present(match, "version") {
version(binary);
ret;
}
- auto sopts = build_session_options(binary, match, binary_dir);
- auto sess = build_session(sopts);
- auto n_inputs = vec::len[str](match.free);
- auto output_file = getopts::opt_maybe_str(match, "o");
- auto glue = opt_present(match, "glue");
- if (glue) {
- if (n_inputs > 0u) {
+ let sopts = build_session_options(binary, match, binary_dir);
+ let sess = build_session(sopts);
+ let n_inputs = vec::len[str](match.free);
+ let output_file = getopts::opt_maybe_str(match, "o");
+ let glue = opt_present(match, "glue");
+ if glue {
+ if n_inputs > 0u {
sess.fatal("No input files allowed with --glue.");
}
- auto out = option::from_maybe[str]("glue.bc", output_file);
+ let out = option::from_maybe[str]("glue.bc", output_file);
middle::trans::make_common_glue(sess, out);
ret;
}
- if (n_inputs == 0u) {
+ if n_inputs == 0u {
sess.fatal("No input filename given.");
} else if (n_inputs > 1u) {
sess.fatal("Multiple input filenames provided.");
}
- auto ifile = match.free.(0);
- let str saved_out_filename = "";
- auto cfg = build_configuration(sess, binary, ifile);
- auto expand =
+ let ifile = match.free.(0);
+ let saved_out_filename: str = "";
+ let cfg = build_configuration(sess, binary, ifile);
+ let expand =
option::map[str,
pp_mode](bind parse_pretty(sess, _),
getopts::opt_default(match, "expand", "normal"));
- alt (expand) {
- case (some[pp_mode](?ppm)) {
- pretty_print_input(sess, cfg, ifile, ppm, true);
- ret;
- }
- case (none[pp_mode]) {/* continue */ }
+ alt expand {
+ some[pp_mode](ppm) {
+ pretty_print_input(sess, cfg, ifile, ppm, true);
+ ret;
+ }
+ none[pp_mode]. {/* continue */ }
}
- auto pretty =
+ let pretty =
option::map[str,
pp_mode](bind parse_pretty(sess, _),
getopts::opt_default(match, "pretty", "normal"));
- alt (pretty) {
- case (some[pp_mode](?ppm)) {
- pretty_print_input(sess, cfg, ifile, ppm, false);
- ret;
- }
- case (none[pp_mode]) {/* continue */ }
+ alt pretty {
+ some[pp_mode](ppm) {
+ pretty_print_input(sess, cfg, ifile, ppm, false);
+ ret;
+ }
+ none[pp_mode]. {/* continue */ }
}
- auto ls = opt_present(match, "ls");
- if (ls) {
+ let ls = opt_present(match, "ls");
+ if ls {
metadata::creader::list_file_metadata(ifile, ioivec::stdout());
ret;
}
- auto stop_after_codegen = sopts.output_type != link::output_type_exe ||
- (sopts.static && sopts.library);
-
- alt (output_file) {
- case (none) {
- let vec[str] parts = str::split(ifile, '.' as u8);
- vec::pop[str](parts);
- saved_out_filename = parts.(0);
- alt (sopts.output_type) {
- case (link::output_type_none) { parts += ["pp"]; }
- case (link::output_type_bitcode) { parts += ["bc"]; }
- case (link::output_type_assembly) { parts += ["s"]; }
- case (
- // Object and exe output both use the '.o' extension here
- link::output_type_object) {
- parts += ["o"];
- }
- case (link::output_type_exe) { parts += ["o"]; }
- }
- auto ofile = str::connect(parts, ".");
- compile_input(sess, cfg, ifile, ofile);
- }
- case (some(?ofile)) {
- // FIXME: what about windows? This will create a foo.exe.o.
-
- saved_out_filename = ofile;
- auto temp_filename;
- if (!stop_after_codegen) {
- temp_filename = ofile + ".o";
- } else {
- temp_filename = ofile;
- }
- compile_input(sess, cfg, ifile, temp_filename);
+ let stop_after_codegen =
+ sopts.output_type != link::output_type_exe ||
+ sopts.static && sopts.library;
+
+ alt output_file {
+ none. {
+ let parts: vec[str] = str::split(ifile, '.' as u8);
+ vec::pop[str](parts);
+ saved_out_filename = parts.(0);
+ alt sopts.output_type {
+ link::output_type_none. { parts += ["pp"]; }
+ link::output_type_bitcode. { parts += ["bc"]; }
+ link::output_type_assembly. { parts += ["s"]; }
+
+ // Object and exe output both use the '.o' extension here
+ link::output_type_object. {
+ parts += ["o"];
+ }
+ link::output_type_exe. { parts += ["o"]; }
}
+ let ofile = str::connect(parts, ".");
+ compile_input(sess, cfg, ifile, ofile);
+ }
+ some(ofile) {
+ // FIXME: what about windows? This will create a foo.exe.o.
+
+ saved_out_filename = ofile;
+ let temp_filename;
+ if !stop_after_codegen {
+ temp_filename = ofile + ".o";
+ } else { temp_filename = ofile; }
+ compile_input(sess, cfg, ifile, temp_filename);
+ }
}
// If the user wants an exe generated we need to invoke
// gcc to link the object file with some libs
//
// TODO: Factor this out of main.
- if (stop_after_codegen) {
- ret;
- }
+ if stop_after_codegen { ret; }
- let str glu = binary_dir + "/lib/glue.o";
- let str main = binary_dir + "/lib/main.o";
- let str stage = "-L" + binary_dir + "/lib";
- let str prog = "gcc";
+ let glu: str = binary_dir + "/lib/glue.o";
+ let main: str = binary_dir + "/lib/main.o";
+ let stage: str = "-L" + binary_dir + "/lib";
+ let prog: str = "gcc";
// The invocations of gcc share some flags across platforms
- let vec[str] gcc_args =
- [stage, "-Lrt", "-lrustrt", glu, "-m32", "-o",
- saved_out_filename, saved_out_filename + ".o"];
- auto lib_cmd;
+ let gcc_args: vec[str] =
+ [stage, "-Lrt", "-lrustrt", glu, "-m32", "-o", saved_out_filename,
+ saved_out_filename + ".o"];
+ let lib_cmd;
- auto os = sess.get_targ_cfg().os;
- if (os == session::os_macos) {
- lib_cmd = "-dynamiclib";
- } else {
- lib_cmd = "-shared";
- }
+ let os = sess.get_targ_cfg().os;
+ if os == session::os_macos {
+ lib_cmd = "-dynamiclib";
+ } else { lib_cmd = "-shared"; }
// Converts a library file name into a gcc -l argument
- fn unlib(@session::config config, str filename) -> str {
- auto rmlib = bind fn(@session::config config,
- str filename) -> str {
- if (config.os == session::os_macos
- || config.os == session::os_linux
- && str::find(filename, "lib") == 0) {
- ret str::slice(filename, 3u, str::byte_len(filename));
- } else {
- ret filename;
- }
- } (config, _);
- fn rmext(str filename) -> str {
- auto parts = str::split(filename, '.' as u8);
+ fn unlib(config: @session::config, filename: str) -> str {
+ let rmlib =
+ bind fn (config: @session::config, filename: str) -> str {
+ if config.os == session::os_macos ||
+ config.os == session::os_linux &&
+ str::find(filename, "lib") == 0 {
+ ret str::slice(filename, 3u,
+ str::byte_len(filename));
+ } else { ret filename; }
+ }(config, _);
+ fn rmext(filename: str) -> str {
+ let parts = str::split(filename, '.' as u8);
vec::pop(parts);
ret str::connect(parts, ".");
}
- ret alt (config.os) {
- case (session::os_macos) { rmext(rmlib(filename)) }
- case (session::os_linux) { rmext(rmlib(filename)) }
- case (_) { rmext(filename) }
- };
+ ret alt config.os {
+ session::os_macos. { rmext(rmlib(filename)) }
+ session::os_linux. { rmext(rmlib(filename)) }
+ _ { rmext(filename) }
+ };
}
- auto cstore = sess.get_cstore();
- for (str cratepath in cstore::get_used_crate_files(cstore)) {
- if (str::ends_with(cratepath, ".rlib")) {
+ let cstore = sess.get_cstore();
+ for cratepath: str in cstore::get_used_crate_files(cstore) {
+ if str::ends_with(cratepath, ".rlib") {
gcc_args += [cratepath];
cont;
}
- auto dir = fs::dirname(cratepath);
- if (dir != "") {
- gcc_args += ["-L" + dir];
- }
- auto libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
+ let dir = fs::dirname(cratepath);
+ if dir != "" { gcc_args += ["-L" + dir]; }
+ let libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
gcc_args += ["-l" + libarg];
}
// FIXME: Remove this ivec->vec conversion.
- auto ula = cstore::get_used_link_args(cstore);
- for (str arg in ula) { gcc_args += [arg]; }
+ let ula = cstore::get_used_link_args(cstore);
+ for arg: str in ula { gcc_args += [arg]; }
- auto used_libs = cstore::get_used_libraries(cstore);
- for (str l in used_libs) {
- gcc_args += ["-l" + l];
- }
+ let used_libs = cstore::get_used_libraries(cstore);
+ for l: str in used_libs { gcc_args += ["-l" + l]; }
- if (sopts.library) {
+ if sopts.library {
gcc_args += [lib_cmd];
} else {
// FIXME: why do we hardcode -lm?
gcc_args += ["-lm", main];
}
// We run 'gcc' here
- auto err_code = run::run_program(prog, gcc_args);
- if (0 != err_code) {
+ let err_code = run::run_program(prog, gcc_args);
+ if 0 != err_code {
sess.err(#fmt("linking with gcc failed with code %d", err_code));
sess.note(#fmt("gcc arguments: %s", str::connect(gcc_args, " ")));
sess.abort_if_errors();
}
// Clean up on Darwin
- if (sess.get_targ_cfg().os == session::os_macos) {
+ if sess.get_targ_cfg().os == session::os_macos {
run::run_program("dsymutil", [saved_out_filename]);
}
+
// Remove the temporary object file if we aren't saving temps
- if (!sopts.save_temps) {
+ if !sopts.save_temps {
run::run_program("rm", [saved_out_filename + ".o"]);
}
}
@@ -627,28 +611,29 @@ mod test {
// When the user supplies --test we should implicitly supply --cfg test
#[test]
fn test_switch_implies_cfg_test() {
- auto match = alt (getopts::getopts(["--test"], opts())) {
- getopts::success(?m) { m }
- };
- auto sessopts = build_session_options("whatever", match, "whatever");
- auto sess = build_session(sessopts);
- auto cfg = build_configuration(sess, "whatever", "whatever");
- assert attr::contains_name(cfg, "test");
+ let match =
+ alt getopts::getopts(["--test"], opts()) {
+ getopts::success(m) { m }
+ };
+ let sessopts = build_session_options("whatever", match, "whatever");
+ let sess = build_session(sessopts);
+ let cfg = build_configuration(sess, "whatever", "whatever");
+ assert (attr::contains_name(cfg, "test"));
}
// When the user supplies --test and --cfg test, don't implicitly add
// another --cfg test
#[test]
fn test_switch_implies_cfg_test_unless_cfg_test() {
- auto match = alt (getopts::getopts(["--test",
- "--cfg=test"], opts())) {
- getopts::success(?m) { m }
- };
- auto sessopts = build_session_options("whatever", match, "whatever");
- auto sess = build_session(sessopts);
- auto cfg = build_configuration(sess, "whatever", "whatever");
- auto test_items = attr::find_meta_items_by_name(cfg, "test");
- assert ivec::len(test_items) == 1u;
+ let match =
+ alt getopts::getopts(["--test", "--cfg=test"], opts()) {
+ getopts::success(m) { m }
+ };
+ let sessopts = build_session_options("whatever", match, "whatever");
+ let sess = build_session(sessopts);
+ let cfg = build_configuration(sess, "whatever", "whatever");
+ let test_items = attr::find_meta_items_by_name(cfg, "test");
+ assert (ivec::len(test_items) == 1u);
}
}
View
101