From 21976eb952f0abec93dcc8abdd9455d1ab9a6d86 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 8 Aug 2016 00:05:07 +0800 Subject: HIR - Store the binding types for an expression for use in later stages --- src/hir/expr_ptr.hpp | 5 +++++ src/hir_expand/closures.cpp | 4 ++-- src/hir_typeck/expr_cs.cpp | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/hir/expr_ptr.hpp b/src/hir/expr_ptr.hpp index 12ebddd2..a4c04d2b 100644 --- a/src/hir/expr_ptr.hpp +++ b/src/hir/expr_ptr.hpp @@ -2,6 +2,7 @@ */ #pragma once #include +#include namespace MIR { class Function; @@ -9,12 +10,16 @@ class Function; namespace HIR { +class TypeRef; class ExprNode; class ExprPtr { ::HIR::ExprNode* node; +public: + ::std::vector< ::HIR::TypeRef> m_bindings; + public: ExprPtr(); ExprPtr(::std::unique_ptr< ::HIR::ExprNode> _); diff --git a/src/hir_expand/closures.cpp b/src/hir_expand/closures.cpp index aa63861a..f0d10015 100644 --- a/src/hir_expand/closures.cpp +++ b/src/hir_expand/closures.cpp @@ -445,6 +445,7 @@ namespace { if( !m_closure_stack.empty() ) { // If attempting to use a Copy type by value, it can just be a Borrow of the inner type + assert(m_usage.size() > 0); if( m_usage.back() == Usage::Move && type_is_copy(node.m_res_type) ) { m_usage.push_back(Usage::Borrow); node.m_value->visit( *this ); @@ -702,9 +703,8 @@ namespace { if( item.m_code ) { DEBUG("Function code " << p); - ::std::vector< ::HIR::TypeRef> tmp; //ExprVisitor_Extract ev(item.m_code.binding_types); - ExprVisitor_Extract ev(m_resolve, tmp, m_new_trait_impls, m_new_types); + ExprVisitor_Extract ev(m_resolve, item.m_code.m_bindings, m_new_trait_impls, m_new_types); ev.visit_root( *item.m_code ); } else diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 33109fa0..978333d7 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -3964,5 +3964,8 @@ void Typecheck_Code_CS(const typeck::ModuleState& ms, t_args& args, const ::HIR: visitor.visit_node_ptr( root_ptr ); } expr = ::HIR::ExprPtr( mv$(root_ptr) ); + expr.m_bindings.reserve( context.m_bindings.size() ); + for(auto& binding : context.m_bindings) + expr.m_bindings.push_back( mv$(binding.ty) ); } -- cgit v1.2.3