From b67512a9e1724ee75f4d6b277fba59f6aea5f697 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 20 May 2018 23:05:41 -0700 Subject: [PATCH] Add Infer struct --- schala-lang/src/typechecking.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index 41eb8b1..e832dfb 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -13,16 +13,6 @@ use parsing; type TypeName = Rc; -pub struct TypeContext { - environment: TypeEnvironment, -} - -impl TypeContext { - pub fn new() -> TypeContext { - TypeContext { environment: TypeEnvironment::default() } - } -} - pub type TypeResult = Result; #[derive(Debug, PartialEq, Clone)] @@ -141,12 +131,33 @@ impl TypeEnvironment { } } +pub struct TypeContext { + environment: TypeEnvironment, +} + impl TypeContext { + pub fn new() -> TypeContext { + TypeContext { environment: TypeEnvironment::default() } + } + pub fn type_check_ast(&mut self, ast: &parsing::AST) -> TypeResult { + let ref block = ast.0; + let mut infer = Infer { env: &mut self.environment }; + /* + let output = infer.infer_block(block, &env); + match output { + Ok(s) => Ok(format!("{:?}", s)), + Err(s) => Err(format!("Error: {:?}", s)) + } + */ Ok(format!("SUCKA")) } } +struct Infer<'a> { + env: &'a TypeEnvironment +} +