pub fn instructions_as_string(chunk: Rc<Chunk>, source_lines: &[&str]) -> String {
        let mut result = String::new();
        let mut reader = InstructionReader::new(chunk);
        let mut ip = reader.ip;
        let mut span: Option<Span> = None;
        let mut first = true;

        while let Some(instruction) = reader.next() {
            let instruction_span = reader
                .chunk
                .debug_info
                .get_source_span(ip)
                .expect("Missing source span");

            let print_source_lines = if let Some(span) = span {
                instruction_span.start.line != span.start.line
            } else {
                true
            };

            if print_source_lines && !source_lines.is_empty() {
                if !first {
                    result += "\n";
                }
                first = false;

                let line = instruction_span
                    .start
                    .line
                    .min(source_lines.len() as u32)
                    .max(1) as usize;
                result += &format!("|{}| {}\n", line, source_lines[line - 1]);
                span = Some(instruction_span);
            }

            result += &format!("{}\t{:?}\n", ip, &instruction);
            ip = reader.ip;
        }

        result
    }
/// Returns a [String] displaying the annotated instructions contained in the compiled [Chunk]
Returns a [String] displaying the annotated instructions contained in the compiled [Chunk]
Returns a [ String ] displaying the annotated instructions contained in the compiled [ Chunk ]
pub fn instructions_as_string(chunk: Rc<Chunk>, source_lines: &[&str]) -> String {
        let mut result = String::new();
        let mut reader = InstructionReader::new(chunk);
        let mut ip = reader.ip;
        let mut span: Option<Span> = None;
        let mut first = true;
        while let Some(instruction) = reader.next() {
            let instruction_span = reader
                .chunk
                .debug_info
                .get_source_span(ip)
                .expect("Missing source span");
            let print_source_lines = if let Some(span) = span {
                instruction_span.start.line != span.start.line
            } else {
                true
            };
            if print_source_lines && !source_lines.is_empty() {
                if !first {
                    result += "\n";
                }
                first = false;
                let line = instruction_span
                    .start
                    .line
                    .min(source_lines.len() as u32)
                    .max(1) as usize;
                result += &format!("|{}| {}\n", line, source_lines[line - 1]);
                span = Some(instruction_span);
            }
            result += &format!("{}\t{:?}\n", ip, &instruction);
            ip = reader.ip;
        }
        result
    }
pub fn instructions_as_string ( chunk : Rc < Chunk > , source_lines : & [ & str ] ) -> String { let mut result = String :: new ( ) ; let mut reader = InstructionReader :: new ( chunk ) ; let mut ip = reader . ip ; let mut span : Option < Span > = None ; let mut first = true ; while let Some ( instruction ) = reader . next ( ) { let instruction_span = reader . chunk . debug_info . get_source_span ( ip ) . expect ( " " ) ; let print_source_lines = if let Some ( span ) = span { instruction_span . start . line != span . start . line } else { true } ; if print_source_lines && ! source_lines . is_empty ( ) { if ! first { result += " \n " ; } first = false ; let line = instruction_span . start . line . min ( source_lines . len ( ) as u32 ) . max ( 1 ) as usize ; result += & format ! ( " \n " line source_lines [ line 1 ] ) ; span = Some ( instruction_span ) ; } result += & format ! ( " \t \n " ip instruction ) ; ip = reader . ip ; } result }
Returns a [String] displaying the annotated instructions contained in the compiled [Chunk]
Returns a [ String ] displaying the annotated instructions contained in the compiled [ Chunk ]
chunk
Rc<Chunk>
source_lines
&[&str]
chunk
Rc<Chunk>
source_lines
&[&str]