]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/trans/builder.rs
librustc: Permit by-value-self methods to be invoked on objects
[rust.git] / src / librustc / middle / trans / builder.rs
index 278e586c6ac161b8074083d2b3356c70bf231935..a9c1adac3d7cf01e07c3926d4706708e8a087367 100644 (file)
@@ -19,9 +19,9 @@
 use middle::trans::common::*;
 use middle::trans::machine::llalign_of_pref;
 use middle::trans::type_::Type;
-use collections::HashMap;
+use std::collections::HashMap;
 use libc::{c_uint, c_ulonglong, c_char};
-use std::strbuf::StrBuf;
+use std::string::String;
 use syntax::codemap::Span;
 
 pub struct Builder<'a> {
@@ -31,9 +31,9 @@ pub struct Builder<'a> {
 
 // This is a really awful way to get a zero-length c-string, but better (and a
 // lot more efficient) than doing str::as_c_str("", ...) every time.
-pub fn noname() -> *c_char {
+pub fn noname() -> *const c_char {
     static cnull: c_char = 0;
-    &cnull as *c_char
+    &cnull as *const c_char
 }
 
 impl<'a> Builder<'a> {
@@ -69,7 +69,7 @@ pub fn count_insn(&self, category: &str) {
                 // Pass 2: concat strings for each elt, skipping
                 // forwards over any cycles by advancing to rightmost
                 // occurrence of each element in path.
-                let mut s = StrBuf::from_str(".");
+                let mut s = String::from_str(".");
                 i = 0u;
                 while i < len {
                     i = *mm.get(&v[i]);
@@ -159,6 +159,14 @@ pub fn invoke(&self,
                   attributes: &[(uint, u64)])
                   -> ValueRef {
         self.count_insn("invoke");
+
+        debug!("Invoke {} with args ({})",
+               self.ccx.tn.val_to_str(llfn),
+               args.iter()
+                   .map(|&v| self.ccx.tn.val_to_str(v))
+                   .collect::<Vec<String>>()
+                   .connect(", "));
+
         unsafe {
             let v = llvm::LLVMBuildInvoke(self.llbuilder,
                                           llfn,
@@ -564,14 +572,14 @@ pub fn struct_gep(&self, ptr: ValueRef, idx: uint) -> ValueRef {
         }
     }
 
-    pub fn global_string(&self, _str: *c_char) -> ValueRef {
+    pub fn global_string(&self, _str: *const c_char) -> ValueRef {
         self.count_insn("globalstring");
         unsafe {
             llvm::LLVMBuildGlobalString(self.llbuilder, _str, noname())
         }
     }
 
-    pub fn global_string_ptr(&self, _str: *c_char) -> ValueRef {
+    pub fn global_string_ptr(&self, _str: *const c_char) -> ValueRef {
         self.count_insn("globalstringptr");
         unsafe {
             llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _str, noname())
@@ -761,7 +769,8 @@ pub fn add_span_comment(&self, sp: Span, text: &str) {
     pub fn add_comment(&self, text: &str) {
         if self.ccx.sess().asm_comments() {
             let sanitized = text.replace("$", "");
-            let comment_text = format!("\\# {}", sanitized.replace("\n", "\n\t# "));
+            let comment_text = format!("{} {}", "#",
+                                       sanitized.replace("\n", "\n\t# "));
             self.count_insn("inlineasm");
             let asm = comment_text.as_slice().with_c_str(|c| {
                 unsafe {
@@ -773,7 +782,7 @@ pub fn add_comment(&self, text: &str) {
         }
     }
 
-    pub fn inline_asm_call(&self, asm: *c_char, cons: *c_char,
+    pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
                          inputs: &[ValueRef], output: Type,
                          volatile: bool, alignstack: bool,
                          dia: AsmDialect) -> ValueRef {
@@ -806,7 +815,7 @@ pub fn call(&self, llfn: ValueRef, args: &[ValueRef],
                self.ccx.tn.val_to_str(llfn),
                args.iter()
                    .map(|&v| self.ccx.tn.val_to_str(v))
-                   .collect::<Vec<StrBuf>>()
+                   .collect::<Vec<String>>()
                    .connect(", "));
 
         unsafe {