pub fn flatten(&self) -> Vec<Op<T>> {
        let mut code = vec![];
        let mut symbol_map = Vec::with_capacity(self.blocks.len());

        let mut code_len = 0;
        for block in &self.blocks {
            code.extend(block.ops().iter().cloned());
            symbol_map.push(code_len);
            code_len += block.ops().len();
        }

        for op in &mut code {
            match op {
                Op::JumpMatches { on_success: loc, .. }
                | Op::JumpNotMatches { on_failure: loc, ..}
                | Op::Jump(loc) =>
                    *loc = symbol_map[*loc],
                _ => (),
            }
        }

        code
    }
/// Convert IR to the code suitable for VM execution
Convert IR to the code suitable for VM execution
Convert IR to the code suitable for VM execution
pub fn flatten(&self) -> Vec<Op<T>> {
        let mut code = vec![];
        let mut symbol_map = Vec::with_capacity(self.blocks.len());
        let mut code_len = 0;
        for block in &self.blocks {
            code.extend(block.ops().iter().cloned());
            symbol_map.push(code_len);
            code_len += block.ops().len();
        }
        for op in &mut code {
            match op {
                Op::JumpMatches { on_success: loc, .. }
                | Op::JumpNotMatches { on_failure: loc, ..}
                | Op::Jump(loc) =>
                    *loc = symbol_map[*loc],
                _ => (),
            }
        }
        code
    }
pub fn flatten ( & self ) -> Vec < Op < T > > { let mut code = vec ! [ ] ; let mut symbol_map = Vec :: with_capacity ( self . blocks . len ( ) ) ; let mut code_len = 0 ; for block in & self . blocks { code . extend ( block . ops ( ) . iter ( ) . cloned ( ) ) ; symbol_map . push ( code_len ) ; code_len += block . ops ( ) . len ( ) ; } for op in & mut code { match op { Op :: JumpMatches { on_success : loc , .. } | Op :: JumpNotMatches { on_failure : loc , .. } | Op :: Jump ( loc ) => * loc = symbol_map [ * loc ] , _ => ( ) , } } code }
Convert IR to the code suitable for VM execution
Convert IR to the code suitable for VM execution
&self
&self