diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-24 15:05:05 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-24 15:05:05 +0800 |
commit | 9724284d3498a2ac54e89a13cb49f481853c9ffb (patch) | |
tree | b3959a7c9bb44f37a89f60c591f34bf60307fec5 /src | |
parent | a335b211799647611591ebba1edef364411c0205 (diff) | |
download | mrust-9724284d3498a2ac54e89a13cb49f481853c9ffb.tar.gz |
MIR Gen - Use argument types
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/hir.hpp | 4 | ||||
-rw-r--r-- | src/mir/from_hir.cpp | 4 | ||||
-rw-r--r-- | src/mir/from_hir.hpp | 3 | ||||
-rw-r--r-- | src/mir/mir_builder.cpp | 6 |
4 files changed, 11 insertions, 6 deletions
diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp index 1eeb5f2f..86573c31 100644 --- a/src/hir/hir.hpp +++ b/src/hir/hir.hpp @@ -86,6 +86,8 @@ public: //PointerConst, }; + typedef ::std::vector< ::std::pair< ::HIR::Pattern, ::HIR::TypeRef> > args_t; + Receiver m_receiver; ::std::string m_abi; bool m_unsafe; @@ -93,7 +95,7 @@ public: GenericParams m_params; - ::std::vector< ::std::pair< Pattern, TypeRef > > m_args; + args_t m_args; TypeRef m_return; ExprPtr m_code; diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 33104822..07fb2ade 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -1407,7 +1407,7 @@ namespace { } -::MIR::FunctionPointer LowerMIR(const StaticTraitResolve& resolve, const ::HIR::ExprPtr& ptr, const ::std::vector< ::std::pair< ::HIR::Pattern, ::HIR::TypeRef> >& args) +::MIR::FunctionPointer LowerMIR(const StaticTraitResolve& resolve, const ::HIR::ExprPtr& ptr, const ::HIR::Function::args_t& args) { TRACE_FUNCTION; @@ -1418,7 +1418,7 @@ namespace { // Scope ensures that builder cleanup happens before `fcn` is moved { - MirBuilder builder { ptr->span(), resolve, fcn }; + MirBuilder builder { ptr->span(), resolve, args, fcn }; ExprVisitor_Conv ev { builder, ptr.m_bindings }; // 1. Apply destructuring to arguments diff --git a/src/mir/from_hir.hpp b/src/mir/from_hir.hpp index 6153ac9f..c5106bd0 100644 --- a/src/mir/from_hir.hpp +++ b/src/mir/from_hir.hpp @@ -75,6 +75,7 @@ class MirBuilder const Span& m_root_span; const StaticTraitResolve& m_resolve; + const ::HIR::Function::args_t& m_args; ::MIR::Function& m_output; unsigned int m_current_block; @@ -107,7 +108,7 @@ class MirBuilder ::std::vector<unsigned int> m_scope_stack; ScopeHandle m_fcn_scope; public: - MirBuilder(const Span& sp, const StaticTraitResolve& resolve, ::MIR::Function& output); + MirBuilder(const Span& sp, const StaticTraitResolve& resolve, const ::HIR::Function::args_t& args, ::MIR::Function& output); ~MirBuilder(); const ::HIR::Crate& crate() const { return m_resolve.m_crate; } diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index b847b31d..89141042 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -11,9 +11,10 @@ // -------------------------------------------------------------------- // MirBuilder // -------------------------------------------------------------------- -MirBuilder::MirBuilder(const Span& sp, const StaticTraitResolve& resolve, ::MIR::Function& output): +MirBuilder::MirBuilder(const Span& sp, const StaticTraitResolve& resolve, const ::HIR::Function::args_t& args, ::MIR::Function& output): m_root_span(sp), m_resolve(resolve), + m_args(args), m_output(output), m_block_active(false), m_result_valid(false), @@ -575,7 +576,8 @@ void MirBuilder::with_val_type(const Span& sp, const ::MIR::LValue& val, ::std:: cb( m_output.temporaries.at(e.idx) ); ), (Argument, - TODO(sp, "Argument"); + ASSERT_BUG(sp, e.idx < m_args.size(), "Argument number out of range"); + cb( m_args.at(e.idx).second ); ), (Static, TU_MATCHA( (e.m_data), (pe), |