Compare commits
2 Commits
master
...
feature/su
Author | SHA1 | Date | |
---|---|---|---|
ef53c7a2cb | |||
7ad72b7eea |
@ -1516,9 +1516,20 @@ impl SymbolResolver for Resolver {
|
|||||||
_: &mut CodeGenContext<'ctx, '_>,
|
_: &mut CodeGenContext<'ctx, '_>,
|
||||||
_: &mut dyn CodeGenerator,
|
_: &mut dyn CodeGenerator,
|
||||||
) -> Option<ValueEnum<'ctx>> {
|
) -> Option<ValueEnum<'ctx>> {
|
||||||
|
let (resolved_id, is_dunder) = if id.starts_with("__") && !id.ends_with("__") && !id.to_string().contains('.') {
|
||||||
|
if let Some(class_name) = self.get_class_name() {
|
||||||
|
let stripped_class_name = class_name.trim_start_matches('_');
|
||||||
|
let mangled_id: StrRef = format!("_{}{}", stripped_class_name, id).into();
|
||||||
|
(mangled_id, true)
|
||||||
|
} else {
|
||||||
|
(id, false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(id, false)
|
||||||
|
};
|
||||||
let sym_value = {
|
let sym_value = {
|
||||||
let id_to_val = self.0.id_to_pyval.read();
|
let id_to_val = self.0.id_to_pyval.read();
|
||||||
id_to_val.get(&id).cloned()
|
id_to_val.get(&resolved_id).cloned()
|
||||||
}
|
}
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
Python::with_gil(|py| -> PyResult<Option<(u64, PyObject)>> {
|
Python::with_gil(|py| -> PyResult<Option<(u64, PyObject)>> {
|
||||||
@ -1527,14 +1538,14 @@ impl SymbolResolver for Resolver {
|
|||||||
let members: &PyDict = obj.getattr("__dict__").unwrap().downcast().unwrap();
|
let members: &PyDict = obj.getattr("__dict__").unwrap().downcast().unwrap();
|
||||||
for (key, val) in members {
|
for (key, val) in members {
|
||||||
let key: &str = key.extract()?;
|
let key: &str = key.extract()?;
|
||||||
if key == id.to_string() {
|
if key == resolved_id.to_string() {
|
||||||
let id = self.0.helper.id_fn.call1(py, (val,))?.extract(py)?;
|
let pyid = self.0.helper.id_fn.call1(py, (val,))?.extract(py)?;
|
||||||
sym_value = Some((id, val.extract()?));
|
sym_value = Some((pyid, val.extract()?));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some((pyid, val)) = &sym_value {
|
if let Some((pyid, val)) = &sym_value {
|
||||||
self.0.id_to_pyval.write().insert(id, (*pyid, val.clone()));
|
self.0.id_to_pyval.write().insert(resolved_id, (*pyid, val.clone()));
|
||||||
}
|
}
|
||||||
Ok(sym_value)
|
Ok(sym_value)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user