diff options
Diffstat (limited to 'src/semantic/analysis.rs')
-rw-r--r-- | src/semantic/analysis.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/semantic/analysis.rs b/src/semantic/analysis.rs index edc229f..cf19351 100644 --- a/src/semantic/analysis.rs +++ b/src/semantic/analysis.rs @@ -5,6 +5,7 @@ use ::ast::{self, WithLocation}; use super::environment; +use super::frame; use super::translate::{self, Translate}; use super::types::{self, Ty}; @@ -25,8 +26,10 @@ pub enum TypeError { type TypeEnvironment<'a> = environment::Environment<'a, String, Ty>; pub type Result<T> = ::std::result::Result<T, WithLocation<TypeError>>; -pub fn translate(translate: &mut Translate, program: &ast::Program) - -> Result<(translate::Expression, Ty)> { +pub fn translate<F: frame::Frame>( + translate: &mut Translate<F>, + program: &ast::Program) + -> Result<(translate::Expression, Ty)> { let mut venv = TypeEnvironment::new(None); let mut tenv = TypeEnvironment::new(None); tenv.add_binding("int".into(), Ty::Int); @@ -65,8 +68,8 @@ fn trans_ty<'a>( } } -fn trans_decl<'a>( - tr: &mut Translate, +fn trans_decl<'a, F: frame::Frame>( + tr: &mut Translate<F>, venv: &mut TypeEnvironment<'a>, tenv: &mut TypeEnvironment<'a>, decl: &WithLocation<ast::Declaration>) -> Result<Ty> { @@ -119,8 +122,8 @@ fn trans_decl<'a>( } } -fn trans_exp<'a>( - tr: &mut Translate, +fn trans_exp<'a, F: frame::Frame>( + tr: &mut Translate<F>, venv: &mut TypeEnvironment<'a>, tenv: &mut TypeEnvironment<'a>, exp: &WithLocation<ast::Expression>) |