Same as `map_bag` but clones `self`
(&self, bag: &Bag)
| 1232 | |
| 1233 | /// Same as `map_bag` but clones `self` |
| 1234 | pub fn map_clone_bag<Bag: ConstantBag>(&self, bag: &Bag) -> CodeObject<Bag::Constant> { |
| 1235 | let map_names = |
| 1236 | |names: &[C::Name]| names.iter().map(|x| bag.make_name(x.as_ref())).collect(); |
| 1237 | CodeObject { |
| 1238 | constants: self |
| 1239 | .constants |
| 1240 | .iter() |
| 1241 | .map(|x| bag.make_constant(x.borrow_constant())) |
| 1242 | .collect(), |
| 1243 | names: map_names(&self.names), |
| 1244 | varnames: map_names(&self.varnames), |
| 1245 | cellvars: map_names(&self.cellvars), |
| 1246 | freevars: map_names(&self.freevars), |
| 1247 | source_path: bag.make_name(self.source_path.as_ref()), |
| 1248 | obj_name: bag.make_name(self.obj_name.as_ref()), |
| 1249 | qualname: bag.make_name(self.qualname.as_ref()), |
| 1250 | |
| 1251 | instructions: self.instructions.clone(), |
| 1252 | locations: self.locations.clone(), |
| 1253 | flags: self.flags, |
| 1254 | posonlyarg_count: self.posonlyarg_count, |
| 1255 | arg_count: self.arg_count, |
| 1256 | kwonlyarg_count: self.kwonlyarg_count, |
| 1257 | first_line_number: self.first_line_number, |
| 1258 | max_stackdepth: self.max_stackdepth, |
| 1259 | localspluskinds: self.localspluskinds.clone(), |
| 1260 | linetable: self.linetable.clone(), |
| 1261 | exceptiontable: self.exceptiontable.clone(), |
| 1262 | } |
| 1263 | } |
| 1264 | } |
| 1265 | |
| 1266 | impl<C: Constant> fmt::Display for CodeObject<C> { |
no test coverage detected