Skip to content

Commit 80dec5e

Browse files
committed
---
yaml --- r: 4995 b: refs/heads/master c: d7fa754 h: refs/heads/master i: 4993: 1ca12f5 4991: 6bd25f7 v: v3
1 parent 4deab86 commit 80dec5e

File tree

11 files changed

+448
-237
lines changed

11 files changed

+448
-237
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 138973335aba835a451ce7c9914c7ca020bcc753
2+
refs/heads/master: d7fa75413f4c109b9ecadf4b9b3e1edd762e3056

trunk/src/comp/back/link.rs

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ tag output_type {
3434

3535
fn llvm_err(sess: session::session, msg: &istr) {
3636
let buf = llvm::LLVMRustGetLastError();
37-
if buf as uint == 0u {
37+
if buf == std::ptr::null() {
3838
sess.fatal(istr::to_estr(msg));
3939
} else {
4040
sess.fatal(
41-
istr::to_estr(msg) + ": " + str::str_from_cstr(buf));
41+
istr::to_estr(msg + ~": " + istr::str_from_cstr(buf)));
4242
}
4343
}
4444
4545
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
46-
let path = istr::to_estr(
46+
let path =
4747
fs::connect(istr::from_estr(sess.get_opts().sysroot),
48-
~"lib/intrinsics.bc"));
49-
let membuf =
50-
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(str::buf(path));
48+
~"lib/intrinsics.bc");
49+
let membuf = istr::as_buf(path, { |buf|
50+
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
51+
});
5152
if membuf as uint == 0u {
52-
llvm_err(sess, ~"installation problem: couldn't open "
53-
+ istr::from_estr(path));
53+
llvm_err(sess, ~"installation problem: couldn't open " + path);
5454
fail;
5555
}
5656
let llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf);
@@ -104,14 +104,16 @@ mod write {
104104
output_type_bitcode. {
105105
if opts.optimize != 0u {
106106
let filename = mk_intermediate_name(output, ~"no-opt.bc");
107-
let filename = istr::to_estr(filename);
108-
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
107+
istr::as_buf(filename, { |buf|
108+
llvm::LLVMWriteBitcodeToFile(llmod, buf)
109+
});
109110
}
110111
}
111112
_ {
112113
let filename = mk_intermediate_name(output, ~"bc");
113-
let filename = istr::to_estr(filename);
114-
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
114+
istr::as_buf(filename, { |buf|
115+
llvm::LLVMWriteBitcodeToFile(llmod, buf)
116+
});
115117
}
116118
}
117119
}
@@ -183,45 +185,54 @@ mod write {
183185
// Always output the bitcode file with --save-temps
184186

185187
let filename = mk_intermediate_name(output, ~"opt.bc");
186-
let filename = istr::to_estr(filename);
187188
llvm::LLVMRunPassManager(pm.llpm, llmod);
188-
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
189+
istr::as_buf(filename, { |buf|
190+
llvm::LLVMWriteBitcodeToFile(llmod, buf)
191+
});
189192
pm = mk_pass_manager();
190193
// Save the assembly file if -S is used
191194

192195
if opts.output_type == output_type_assembly {
193-
let triple = istr::to_estr(x86::get_target_triple());
194-
let output = istr::to_estr(output);
195-
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
196-
str::buf(triple),
197-
str::buf(output),
198-
LLVMAssemblyFile,
199-
CodeGenOptLevel);
196+
let _: () =
197+
istr::as_buf(x86::get_target_triple(), { |buf_t|
198+
istr::as_buf(output, { |buf_o|
199+
llvm::LLVMRustWriteOutputFile(
200+
pm.llpm, llmod,
201+
buf_t,
202+
buf_o,
203+
LLVMAssemblyFile,
204+
CodeGenOptLevel)
205+
})});
200206
}
201207

202208

203209
// Save the object file for -c or --save-temps alone
204210
// This .o is needed when an exe is built
205211
if opts.output_type == output_type_object ||
206212
opts.output_type == output_type_exe {
207-
let triple = istr::to_estr(x86::get_target_triple());
208-
let output = istr::to_estr(output);
209-
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
210-
str::buf(triple),
211-
str::buf(output),
212-
LLVMObjectFile,
213-
CodeGenOptLevel);
213+
let _: () =
214+
istr::as_buf(x86::get_target_triple(), { |buf_t|
215+
istr::as_buf(output, { |buf_o|
216+
llvm::LLVMRustWriteOutputFile(
217+
pm.llpm, llmod,
218+
buf_t,
219+
buf_o,
220+
LLVMObjectFile,
221+
CodeGenOptLevel)
222+
})});
214223
}
215224
} else {
216225
// If we aren't saving temps then just output the file
217226
// type corresponding to the '-c' or '-S' flag used
218227

219-
let triple = istr::to_estr(x86::get_target_triple());
220-
let output = istr::to_estr(output);
221-
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
222-
str::buf(triple),
223-
str::buf(output), FileType,
224-
CodeGenOptLevel);
228+
let _: () = istr::as_buf(x86::get_target_triple(), { |buf_t|
229+
istr::as_buf(output, { |buf_o|
230+
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
231+
buf_t,
232+
buf_o,
233+
FileType,
234+
CodeGenOptLevel)
235+
})});
225236
}
226237
// Clean up and return
227238

@@ -233,8 +244,9 @@ mod write {
233244
// flag, then output it here
234245

235246
llvm::LLVMRunPassManager(pm.llpm, llmod);
236-
let output = istr::to_estr(output);
237-
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(output));
247+
istr::as_buf(output, { |buf|
248+
llvm::LLVMWriteBitcodeToFile(llmod, buf)
249+
});
238250
llvm::LLVMDisposeModule(llmod);
239251
if opts.time_llvm_passes { llvm::LLVMRustPrintPassTimings(); }
240252
}

trunk/src/comp/driver/rustc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ fn get_default_sysroot(binary: str) -> str {
325325
}
326326

327327
fn build_target_config() -> @session::config {
328-
let triple: str =
329-
std::str::rustrt::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple());
328+
let triple: str = istr::to_estr(
329+
istr::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple()));
330330
let target_cfg: @session::config =
331331
@{os: get_os(triple),
332332
arch: get_arch(triple),

trunk/src/comp/lib/llvm.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import std::vec;
2-
import std::str;
32
import std::istr;
4-
import std::str::rustrt::sbuf;
3+
import std::istr::sbuf;
54

65
import llvm::ModuleRef;
76
import llvm::ContextRef;
@@ -1070,7 +1069,9 @@ resource target_data_res(TD: TargetDataRef) {
10701069
type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
10711070

10721071
fn mk_target_data(string_rep: str) -> target_data {
1073-
let lltd = llvm::LLVMCreateTargetData(str::buf(string_rep));
1072+
let lltd = istr::as_buf(istr::from_estr(string_rep), { |buf|
1073+
llvm::LLVMCreateTargetData(buf)
1074+
});
10741075
ret {lltd: lltd, dtor: @target_data_res(lltd)};
10751076
}
10761077

trunk/src/comp/metadata/creader.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,16 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
192192
}
193193

194194
fn get_metadata_section(filename: str) -> option::t<@[u8]> {
195-
let b = str::buf(filename);
196-
let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(b);
195+
let mb = istr::as_buf(istr::from_estr(filename), { |buf|
196+
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
197+
});
197198
if mb as int == 0 { ret option::none::<@[u8]>; }
198199
let of = mk_object_file(mb);
199200
let si = mk_section_iter(of.llof);
200201
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
201202
let name_buf = llvm::LLVMGetSectionName(si.llsi);
202-
let name = str::str_from_cstr(name_buf);
203-
if str::eq(name, istr::to_estr(x86::get_meta_sect_name())) {
203+
let name = istr::str_from_cstr(name_buf);
204+
if istr::eq(name, x86::get_meta_sect_name()) {
204205
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
205206
let csz = llvm::LLVMGetSectionSize(si.llsi);
206207
let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf);

trunk/src/comp/middle/gc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import std::option::none;
1111
import std::option::some;
1212
import std::ptr;
1313
import std::str;
14+
import std::istr;
1415
import std::unsafe;
1516
import std::vec;
1617

@@ -22,8 +23,9 @@ type ctxt = @{mutable next_tydesc_num: uint};
2223
fn mk_ctxt() -> ctxt { ret @{mutable next_tydesc_num: 0u}; }
2324

2425
fn add_global(ccx: &@crate_ctxt, llval: ValueRef, name: str) -> ValueRef {
25-
let llglobal =
26-
lll::LLVMAddGlobal(ccx.llmod, val_ty(llval), str::buf(name));
26+
let llglobal = istr::as_buf(istr::from_estr(name), { |buf|
27+
lll::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
28+
});
2729
lll::LLVMSetInitializer(llglobal, llval);
2830
lll::LLVMSetGlobalConstant(llglobal, True);
2931
ret llglobal;

trunk/src/comp/middle/shape.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import std::map::hashmap;
3131
import std::option::none;
3232
import std::option::some;
3333
import std::str;
34+
import std::istr;
3435

3536
import ty_ctxt = middle::ty::ctxt;
3637

@@ -86,9 +87,9 @@ fn eq_res_info(a: &res_info, b: &res_info) -> bool {
8687

8788
fn mk_global(ccx: &@crate_ctxt, name: &str, llval: ValueRef,
8889
internal: bool) -> ValueRef {
89-
let llglobal =
90-
lib::llvm::llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval),
91-
str::buf(name));
90+
let llglobal = istr::as_buf(istr::from_estr(name), { |buf|
91+
lib::llvm::llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
92+
});
9293
lib::llvm::llvm::LLVMSetInitializer(llglobal, llval);
9394
lib::llvm::llvm::LLVMSetGlobalConstant(llglobal, True);
9495

@@ -248,9 +249,9 @@ fn s_float(_tcx: &ty_ctxt) -> u8 {
248249

249250
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
250251
let llshapetablesty = trans_common::T_named_struct("shapes");
251-
let llshapetables =
252-
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty,
253-
str::buf("shapes"));
252+
let llshapetables = istr::as_buf(~"shapes", { |buf|
253+
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
254+
});
254255

255256
ret {mutable next_tag_id: 0u16,
256257
pad: 0u16,

0 commit comments

Comments
 (0)