From e7c89ed84074e9ca111b75ac4bc359088becf870 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 15 May 2018 22:08:37 -0700 Subject: [PATCH] Some more refactoring --- schala-lang/src/typechecking.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index 1990485..051a65a 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -138,6 +138,8 @@ impl TypeContext { } impl TypeContext { + /* note: this adds names for *forward reference* but doesn't actually create any types. solve that problem + * later */ pub fn add_top_level_types(&mut self, ast: &parsing::AST) -> TypeResult<()> { use self::parsing::{Statement, TypeName, Variant, TypeSingletonName, TypeBody}; use self::parsing::Declaration::*; @@ -188,21 +190,20 @@ impl TypeContext { pub fn type_check_ast(&mut self, ast: &parsing::AST) -> TypeResult { let ref block = ast.0; - Ok(self.type_check_block(block)?) + Ok(self.infer_block(block)?) } } impl TypeContext { - - fn type_check_block(&mut self, statements: &Vec) -> TypeResult { + fn infer_block(&mut self, statements: &Vec) -> TypeResult { let mut ret_type = Type::Const(TConst::Unit); for statement in statements { - ret_type = self.type_check_statement(statement)?; + ret_type = self.infer_statement(statement)?; } Ok(ret_type) } - fn type_check_statement(&mut self, statement: &parsing::Statement) -> TypeResult { + fn infer_statement(&mut self, statement: &parsing::Statement) -> TypeResult { use self::parsing::Statement::*; match statement { ExpressionStatement(expr) => self.infer(expr),