nac3core: coding style change
This commit is contained in:
parent
2ec449545e
commit
ead8b6f68d
|
@ -156,37 +156,30 @@ impl TopLevelComposer {
|
||||||
let base_class_lookup: HashMap<StrRef, StrRef> = HashMap::from_iter(
|
let base_class_lookup: HashMap<StrRef, StrRef> = HashMap::from_iter(
|
||||||
classes.iter().filter_map(|(class_name, bases, _)| {
|
classes.iter().filter_map(|(class_name, bases, _)| {
|
||||||
// Get the first base class in the Vector of bases is good enough, since we only support single inheritance
|
// Get the first base class in the Vector of bases is good enough, since we only support single inheritance
|
||||||
let base_class = bases.get(0).and_then(|ast::Located { node, .. }| {
|
bases
|
||||||
|
.get(0)
|
||||||
|
.and_then(|ast::Located { node, .. }| {
|
||||||
if let ast::ExprKind::Name { id, .. } = node {
|
if let ast::ExprKind::Name { id, .. } = node {
|
||||||
Some(*id)
|
Some(*id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.and_then(|base_class_name| Some((**class_name, base_class_name)))
|
||||||
if let Some(base_class) = base_class {
|
|
||||||
Some((**class_name, base_class))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
let constructor_lookup: HashMap<StrRef, ast::Located<ast::StmtKind>> = HashMap::from_iter(
|
let constructor_lookup: HashMap<StrRef, ast::Located<ast::StmtKind>> = HashMap::from_iter(
|
||||||
classes.iter().filter_map(|(class_name, _, body)| {
|
classes.iter().filter_map(|(class_name, _, body)| {
|
||||||
for stmt in body.iter() {
|
body.iter().find_map(|stmt| {
|
||||||
let func_name = if let ast::StmtKind::FunctionDef { name, .. } = &stmt.node {
|
if let ast::StmtKind::FunctionDef { name, .. } = &stmt.node {
|
||||||
name
|
if name == &"__init__".into() {
|
||||||
} else {
|
return Some((**class_name, stmt.clone()));
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
if func_name == &"__init__".into() {
|
|
||||||
return Some((**class_name, stmt.clone()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
for (class, _, _) in classes
|
for (class, _, _) in classes
|
||||||
|
|
Loading…
Reference in New Issue