From 01daee374a299646c595dd245c8e4a4990769002 Mon Sep 17 00:00:00 2001 From: David Li Date: Sun, 26 Nov 2017 19:59:00 -0500 Subject: Translate variable bindings --- src/semantic/analysis.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/semantic/analysis.rs') diff --git a/src/semantic/analysis.rs b/src/semantic/analysis.rs index 973e703..152ede9 100644 --- a/src/semantic/analysis.rs +++ b/src/semantic/analysis.rs @@ -75,7 +75,7 @@ fn trans_decl<'a, 'b, F: frame::Frame>( level: &mut Level<'b, F>, venv: &mut TypeEnvironment<'a>, tenv: &mut TypeEnvironment<'a>, - decl: &WithLocation) -> Result { + decl: &WithLocation) -> Result<(translate::Expression, Ty)> { match decl.declaration { ast::DeclarationBody::Fun { ref ty, ref params, ref body } => { let declared_ty = if let &Some(ref ty) = ty { @@ -103,10 +103,12 @@ fn trans_decl<'a, 'b, F: frame::Frame>( } } - Ok(Ty::Function(arg_types, Box::new(body_ty))) + return err!(decl, TypeError::Unimplemented); + // Ok(Ty::Function(arg_types, Box::new(body_ty))) } ast::DeclarationBody::Ty { ref ty } => { - trans_ty(venv, tenv, ty) + return err!(decl, TypeError::Unimplemented); + // trans_ty(venv, tenv, ty) } ast::DeclarationBody::Var { ref ty, ref value } => { let (var_exp, actual_ty) = @@ -120,7 +122,7 @@ fn trans_decl<'a, 'b, F: frame::Frame>( }); } } - Ok(actual_ty) + Ok((tr.alloc_local(level, frame::Escape::Yes), actual_ty)) } } } @@ -139,7 +141,7 @@ fn trans_exp<'a, 'b, F: frame::Frame>( let mut new_venv = TypeEnvironment::new(Some(venv)); let mut new_tenv = TypeEnvironment::new(Some(tenv)); for decl in decls.iter() { - let decl_ty = trans_decl(tr, level, &mut new_venv, &mut new_tenv, decl)?; + let (decl_exp, decl_ty) = trans_decl(tr, level, &mut new_venv, &mut new_tenv, decl)?; match decl.declaration { ast::DeclarationBody::Fun { .. } | ast::DeclarationBody::Var { .. } => { new_venv.add_binding(decl.name.clone(), decl_ty); -- cgit v1.2.3