Emits a bytecode via a function which takes a freshly generated attribute id.
(&mut self, f: F)
| 167 | |
| 168 | /// Emits a bytecode via a function which takes a freshly generated attribute id. |
| 169 | pub fn emit_with<F>(&mut self, f: F) |
| 170 | where |
| 171 | F: FnOnce(AttrId) -> Bytecode, |
| 172 | { |
| 173 | let attr_id = self.new_attr(); |
| 174 | if let Some(info) = std::mem::take(&mut self.next_vc_info) { |
| 175 | self.data.vc_infos.insert(attr_id, info); |
| 176 | } |
| 177 | if let Some(comment) = std::mem::take(&mut self.next_debug_comment) { |
| 178 | self.data.debug_comments.insert(attr_id, comment); |
| 179 | } |
| 180 | self.emit(f(attr_id)) |
| 181 | } |
| 182 | |
| 183 | /// Emits a Bytecode::Prop based on given kind and expression. |
| 184 | pub fn emit_prop(&mut self, kind: PropKind, exp: Exp) { |