pub fn emit_string(&mut self, string: &str) {
      let start = self.len();

      // I don't know of any 128-bit targets so this cast should be OK. Also, it isn't physically
      // possible to store a string as large as 2^64 bytes.
      let len = string.len() as u64;
      let len_bytes: [u8; 8] = len.to_le_bytes();
      self.bytes.extend_from_slice(&len_bytes);
      self.bytes.extend(string.as_bytes());
      let padded_len = (string.len() + 3) & !3;
      let padding = padded_len - string.len();
      for _ in 0..padding {
         self.bytes.push(0);
      }

      let end = self.len();
      for _ in (0..end - start).step_by(4) {
         self.locations.push(self.codegen_location);
      }
   }
/// Pushes a string into the chunk.
///
/// The string is padded with zeroes such that opcodes are aligned to four bytes.
Pushes a string into the chunk.
The string is padded with zeroes such that opcodes are aligned to four bytes.
Pushes a string into the chunk . The string is padded with zeroes such that opcodes are aligned to four bytes .
pub fn emit_string(&mut self, string: &str) {
      let start = self.len();
      // I don't know of any 128-bit targets so this cast should be OK. Also, it isn't physically
      // possible to store a string as large as 2^64 bytes.
      let len = string.len() as u64;
      let len_bytes: [u8; 8] = len.to_le_bytes();
      self.bytes.extend_from_slice(&len_bytes);
      self.bytes.extend(string.as_bytes());
      let padded_len = (string.len() + 3) & !3;
      let padding = padded_len - string.len();
      for _ in 0..padding {
         self.bytes.push(0);
      }
      let end = self.len();
      for _ in (0..end - start).step_by(4) {
         self.locations.push(self.codegen_location);
      }
   }
pub fn emit_string ( & mut self , string : & str ) { let start = self . len ( ) ; // I don't know of any 128-bit targets so this cast should be OK. Also, it isn't physically // possible to store a string as large as 2^64 bytes. let len = string . len ( ) as u64 ; let len_bytes : [ u8 ; 8 ] = len . to_le_bytes ( ) ; self . bytes . extend_from_slice ( & len_bytes ) ; self . bytes . extend ( string . as_bytes ( ) ) ; let padded_len = ( string . len ( ) + 3 ) & ! 3 ; let padding = padded_len - string . len ( ) ; for _ in 0 .. padding { self . bytes . push ( 0 ) ; } let end = self . len ( ) ; for _ in ( 0 .. end - start ) . step_by ( 4 ) { self . locations . push ( self . codegen_location ) ; } }
Pushes a string into the chunk.
Pushes a string into the chunk .
&mut self
string
&str