Add co_names to PyCode

This commit is contained in:
Gyubong
2022-09-21 17:14:21 +09:00
parent ac2532822b
commit cf0ee0c0a5

View File

@@ -215,6 +215,18 @@ impl PyRef<PyCode> {
self.code.obj_name.to_owned()
}
#[pygetset]
fn co_names(self, vm: &VirtualMachine) -> PyTupleRef {
let names = self
.code
.names
.deref()
.iter()
.map(|name| name.to_pyobject(vm))
.collect();
vm.ctx.new_tuple(names)
}
#[pygetset]
fn co_flags(self) -> u16 {
self.code.flags.bits()