MCPcopy Index your code
hub / github.com/RustPython/RustPython / map_clone_bag

Method map_clone_bag

crates/compiler-core/src/bytecode.rs:1234–1263  ·  view source on GitHub ↗

Same as `map_bag` but clones `self`

(&self, bag: &Bag)

Source from the content-addressed store, hash-verified

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
1266impl<C: Constant> fmt::Display for CodeObject<C> {

Callers 2

make_constantMethod · 0.80
to_ownedMethod · 0.80

Calls 8

collectMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
make_nameMethod · 0.45
as_refMethod · 0.45
make_constantMethod · 0.45
borrow_constantMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected