diff options
Diffstat (limited to 'src/hir')
-rw-r--r-- | src/hir/expr.cpp | 33 | ||||
-rw-r--r-- | src/hir/hir.cpp | 3 | ||||
-rw-r--r-- | src/hir/type.cpp | 11 |
3 files changed, 40 insertions, 7 deletions
diff --git a/src/hir/expr.cpp b/src/hir/expr.cpp index fdeff6b5..4fb79470 100644 --- a/src/hir/expr.cpp +++ b/src/hir/expr.cpp @@ -23,6 +23,7 @@ DEF_VISIT(ExprNode_Return, node, visit_node_ptr(node.m_value); ) DEF_VISIT(ExprNode_Let, node, + visit_type(node.m_type); if( node.m_value ) { visit_node_ptr(node.m_value); } @@ -76,19 +77,39 @@ DEF_VISIT(ExprNode_Deref, node, ) DEF_VISIT(ExprNode_TupleVariant, node, + visit_generic_path(::HIR::Visitor::PathContext::VALUE, node.m_path); + + for(auto& ty : node.m_arg_types) + visit_type(ty); + for(auto& arg : node.m_args) visit_node_ptr(arg); ) DEF_VISIT(ExprNode_CallPath, node, + for(auto& ty : node.m_cache.m_arg_types) + visit_type(ty); + visit_path_params(node.m_cache.m_ty_impl_params); + + DEBUG("DEF _CallPath: " << node.m_path); + visit_path(::HIR::Visitor::PathContext::VALUE, node.m_path); for(auto& arg : node.m_args) visit_node_ptr(arg); ) DEF_VISIT(ExprNode_CallValue, node, + for(auto& ty : node.m_arg_types) + visit_type(ty); + visit_node_ptr(node.m_value); for(auto& arg : node.m_args) visit_node_ptr(arg); ) DEF_VISIT(ExprNode_CallMethod, node, + for(auto& ty : node.m_cache.m_arg_types) + visit_type(ty); + visit_path_params(node.m_cache.m_ty_impl_params); + + visit_path(::HIR::Visitor::PathContext::VALUE, node.m_method_path); + visit_node_ptr(node.m_value); for(auto& arg : node.m_args) visit_node_ptr(arg); @@ -98,10 +119,15 @@ DEF_VISIT(ExprNode_Field, node, ) DEF_VISIT(ExprNode_Literal, , ) -DEF_VISIT(ExprNode_UnitVariant, , ) -DEF_VISIT(ExprNode_PathValue, , ) +DEF_VISIT(ExprNode_UnitVariant, node, + visit_generic_path(::HIR::Visitor::PathContext::VALUE, node.m_path); +) +DEF_VISIT(ExprNode_PathValue, node, + visit_path(::HIR::Visitor::PathContext::VALUE, node.m_path); +) DEF_VISIT(ExprNode_Variable, , ) DEF_VISIT(ExprNode_StructLiteral, node, + visit_generic_path(::HIR::Visitor::PathContext::VALUE, node.m_path); if( node.m_base_value ) visit_node_ptr(node.m_base_value); for(auto& val : node.m_values) @@ -121,6 +147,9 @@ DEF_VISIT(ExprNode_ArraySized, node, ) DEF_VISIT(ExprNode_Closure, node, + for(auto& arg : node.m_args) + visit_type(arg.second); + visit_type(node.m_return); if(node.m_code) { visit_node_ptr(node.m_code); diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index e090b795..4ff909aa 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -148,8 +148,7 @@ namespace { return false; ), (Closure, - DEBUG("TODO: Compare " << left << " and " << right); - return false; + return le.node == re.node; ) ) return false; diff --git a/src/hir/type.cpp b/src/hir/type.cpp index 45b47519..c4dfb9c3 100644 --- a/src/hir/type.cpp +++ b/src/hir/type.cpp @@ -140,10 +140,13 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const os << ") -> " << *e.m_rettype; ), (Closure, - os << "closure["<<e.node<<"]("; + os << "closure["<<e.node<<"]"; + #if 0 + os << "("; for(const auto& t : e.m_arg_types) os << t << ", "; os << ") -> " << *e.m_rettype; + #endif ) ) } @@ -217,7 +220,7 @@ bool ::HIR::TypeRef::operator==(const ::HIR::TypeRef& x) const if( xe.size_val != te.size_val ) return false; if( te.size_val == ~0u ) - assert(!"TOD: Compre array types with non-resolved sizes"); + assert(!"TODO: Compre array types with non-resolved sizes"); return true; ), (Slice, @@ -586,7 +589,9 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x TODO(sp, "Function"); ), (Closure, - TODO(sp, "Closure"); + if( te.node != xe.node ) + return Compare::Unequal; + return Compare::Equal; ) ) throw ""; |