Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhuijzer committed Dec 21, 2024
1 parent a773ab5 commit ca9c641
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions xrcf/src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ fn test_llvm_string_to_bytes() {

/// Convert a vector of bytes to a string while handling LLVM escape sequences.
///
// Explicitly print the null byte too or else the vector length will not match
// the text that is shown.

// A backslash with two hex characters defines the byte in LLVM IR in hex, so
// \00 is the null byte in LLVM IR.
/// Explicitly print the null byte too or else the vector length will not match
/// the text that is shown.
///
/// A backslash with two hex characters defines the byte in LLVM IR in hex, so A
/// backslash with two hex characters defines the byte in LLVM IR in hex, so \00
/// is the null byte in LLVM IR.
pub fn bytes_to_llvm_string(bytes: &[u8]) -> String {
let src = String::from_utf8(bytes.to_vec()).unwrap();
src.replace("\0", "\\00").replace("\n", "\\0A")
Expand All @@ -104,13 +105,11 @@ fn test_bytes_to_llvm_string() {
}

pub fn escape(src: &str) -> String {
let src = src.replace("\n", "\\n");
src
src.replace("\n", "\\n")
}

pub fn unescape(src: &str) -> String {
let src = src.replace("\\n", "\n");
src
src.replace("\\n", "\n")
}

/// Generate a new name as part of printing.
Expand Down
4 changes: 2 additions & 2 deletions xrcf/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub struct Parser<T: ParserDispatch> {
src: String,
tokens: Vec<Token>,
current: usize,
parse_op: std::marker::PhantomData<T>,
_marker: std::marker::PhantomData<T>,
}

#[allow(dead_code)]
Expand Down Expand Up @@ -357,7 +357,7 @@ impl<T: ParserDispatch> Parser<T> {
src: src.to_string(),
tokens: Scanner::scan(src)?,
current: 0,
parse_op: std::marker::PhantomData,
_marker: std::marker::PhantomData,
};
let op = T::parse_op(&mut parser, None)?;
let op_rd = op.clone();
Expand Down

0 comments on commit ca9c641

Please sign in to comment.