From 4be8e3955de42210e01ca90373e28690fee762c0 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Mon, 19 Jan 2015 20:13:46 +0800 Subject: Fiddle --- src/convert/typecheck_expr.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/convert/typecheck_expr.cpp b/src/convert/typecheck_expr.cpp index 83becce1..60a63a5b 100644 --- a/src/convert/typecheck_expr.cpp +++ b/src/convert/typecheck_expr.cpp @@ -10,13 +10,37 @@ class CTypeChecker: public CASTIterator { public: - virtual void handle_function(AST::Path& path, AST::Function& fcn) override; + virtual void handle_function(AST::Path path, AST::Function& fcn) override; + // - Ignore all non-function items on this pass + virtual void handle_enum(AST::Path path, AST::Enum& ) override {} + virtual void handle_struct(AST::Path path, AST::Struct& str) override {} + virtual void handle_alias(AST::Path path, AST::TypeAlias& ) override {} +}; +class CNodeVisitor: + public AST::NodeVisitor +{ + CTypeChecker& m_tc; +public: + CNodeVisitor(CTypeChecker& tc): + m_tc(tc) + {} + + void visit(AST::ExprNode_LetBinding& node) override; }; -void CTypeChecker::handle_function(AST::Path& path, AST::Function& fcn) +void CTypeChecker::handle_function(AST::Path path, AST::Function& fcn) { - + CNodeVisitor nv(*this); + if( fcn.code().is_valid() ) + { + fcn.code().visit_nodes(nv); + } +} + +void CNodeVisitor::visit(AST::ExprNode_LetBinding& node) +{ + // TODO: } void Typecheck_Expr(AST::Crate& crate) -- cgit v1.2.3