Emits a bytecode.
(&mut self, bc: Bytecode)
| 142 | |
| 143 | /// Emits a bytecode. |
| 144 | pub fn emit(&mut self, bc: Bytecode) { |
| 145 | use Bytecode::*; |
| 146 | let no_fallthrough_jump_removal = self.options.no_fallthrough_jump_removal; |
| 147 | // Perform some minimal peephole optimization |
| 148 | match (self.data.code.last(), &bc) { |
| 149 | // jump L; L: .. |
| 150 | (Some(Jump(_, label1)), Label(_, label2)) |
| 151 | if !no_fallthrough_jump_removal && label1 == label2 => |
| 152 | { |
| 153 | *self.data.code.last_mut().unwrap() = bc; |
| 154 | } |
| 155 | _ => { |
| 156 | self.data.code.push(bc); |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /// Emits a sequence of bytecodes. |
| 162 | pub fn emit_vec(&mut self, bcs: Vec<Bytecode>) { |