forked from M-Labs/nac3
cleanup
This commit is contained in:
parent
44199781dc
commit
1eac111d4c
@ -496,12 +496,7 @@ pub fn gen_constructor<'ctx, 'a, G: CodeGenerator>(
|
|||||||
match def {
|
match def {
|
||||||
TopLevelDef::Class { methods, .. } => {
|
TopLevelDef::Class { methods, .. } => {
|
||||||
// TODO: what about other fields that require alloca?
|
// TODO: what about other fields that require alloca?
|
||||||
let mut fun_id = None;
|
let fun_id = methods.iter().find(|method| method.0 == "__init__".into()).and_then(|method| Some(method.2));
|
||||||
for (name, _, id) in methods.iter() {
|
|
||||||
if name == &"__init__".into() {
|
|
||||||
fun_id = Some(*id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let ty = ctx.get_llvm_type(generator, signature.ret).into_pointer_type();
|
let ty = ctx.get_llvm_type(generator, signature.ret).into_pointer_type();
|
||||||
let zelf_ty: BasicTypeEnum = ty.get_element_type().try_into().unwrap();
|
let zelf_ty: BasicTypeEnum = ty.get_element_type().try_into().unwrap();
|
||||||
let zelf: BasicValueEnum<'ctx> = ctx.builder.build_alloca(zelf_ty, "alloca").into();
|
let zelf: BasicValueEnum<'ctx> = ctx.builder.build_alloca(zelf_ty, "alloca").into();
|
||||||
@ -1005,13 +1000,7 @@ pub fn gen_binop_expr<'ctx, 'a, G: CodeGenerator>(
|
|||||||
let defs = ctx.top_level.definitions.read();
|
let defs = ctx.top_level.definitions.read();
|
||||||
let obj_def = defs.get(id.0).unwrap().read();
|
let obj_def = defs.get(id.0).unwrap().read();
|
||||||
if let TopLevelDef::Class { methods, .. } = &*obj_def {
|
if let TopLevelDef::Class { methods, .. } = &*obj_def {
|
||||||
let mut fun_id = None;
|
methods.iter().find(|method| method.0 == op_name).unwrap().2
|
||||||
for (name, _, id) in methods.iter() {
|
|
||||||
if name == &op_name {
|
|
||||||
fun_id = Some(*id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun_id.unwrap()
|
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
@ -1409,13 +1398,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>(
|
|||||||
let defs = ctx.top_level.definitions.read();
|
let defs = ctx.top_level.definitions.read();
|
||||||
let obj_def = defs.get(id.0).unwrap().read();
|
let obj_def = defs.get(id.0).unwrap().read();
|
||||||
if let TopLevelDef::Class { methods, .. } = &*obj_def {
|
if let TopLevelDef::Class { methods, .. } = &*obj_def {
|
||||||
let mut fun_id = None;
|
methods.iter().find(|method| method.0 == *attr).unwrap().2
|
||||||
for (name, _, id) in methods.iter() {
|
|
||||||
if name == attr {
|
|
||||||
fun_id = Some(*id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun_id.unwrap()
|
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
@ -205,13 +205,14 @@ fn main() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// still needs to skip this `from __future__ import annotations` because this seems to be
|
// allow (and ignore) "from __future__ import annotations"
|
||||||
// magic in python and there seems no way to patch it from another module..
|
|
||||||
if matches!(
|
if matches!(
|
||||||
&stmt.node,
|
&stmt.node,
|
||||||
StmtKind::ImportFrom { module, names, .. }
|
StmtKind::ImportFrom { module, names, .. }
|
||||||
if module == &Some("__future__".into()) && names[0].name == "annotations".into()
|
if module == &Some("__future__".into()) && names.len() == 1 && names[0].name == "annotations".into()
|
||||||
) { continue; }
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let (name, def_id, ty) =
|
let (name, def_id, ty) =
|
||||||
composer.register_top_level(stmt, Some(resolver.clone()), "__main__".into()).unwrap();
|
composer.register_top_level(stmt, Some(resolver.clone()), "__main__".into()).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user