hm-inference #6

Merged
sb10q merged 136 commits from hm-inference into master 2021-08-19 11:46:50 +08:00
1 changed files with 7 additions and 5 deletions
Showing only changes of commit cc0692a34c - Show all commits

View File

@ -9,12 +9,8 @@ use rustpython_parser::ast::{Expr, ExprKind, Stmt, StmtKind};
impl<'ctx> CodeGenContext<'ctx> { impl<'ctx> CodeGenContext<'ctx> {
fn gen_var(&mut self, ty: Type) -> PointerValue<'ctx> { fn gen_var(&mut self, ty: Type) -> PointerValue<'ctx> {
// should we build the alloca in an initial block?
let ty = self.get_llvm_type(ty); let ty = self.get_llvm_type(ty);
let ty = if let BasicTypeEnum::PointerType(ty) = ty {
ty.get_element_type().try_into().unwrap()
} else {
ty
};
self.builder.build_alloca(ty, "tmp") self.builder.build_alloca(ty, "tmp")
} }
@ -76,6 +72,12 @@ impl<'ctx> CodeGenContext<'ctx> {
StmtKind::Expr { value } => { StmtKind::Expr { value } => {
self.gen_expr(&value); self.gen_expr(&value);
} }
StmtKind::AnnAssign { target, value, .. } => {
if let Some(value) = value {
let value = self.gen_expr(&value);
self.gen_assignment(target, value);
}
}
StmtKind::Assign { targets, value, .. } => { StmtKind::Assign { targets, value, .. } => {
let value = self.gen_expr(&value); let value = self.gen_expr(&value);
for target in targets.iter() { for target in targets.iter() {