summaryrefslogtreecommitdiff
path: root/src/trans/codegen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/trans/codegen.cpp')
-rw-r--r--src/trans/codegen.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/trans/codegen.cpp b/src/trans/codegen.cpp
index 9256054f..bda64d02 100644
--- a/src/trans/codegen.cpp
+++ b/src/trans/codegen.cpp
@@ -9,6 +9,7 @@
#include "trans_list.hpp"
#include <hir/hir.hpp>
#include <mir/mir.hpp>
+#include <mir/operations.hpp>
#include "codegen.hpp"
#include "monomorphise.hpp"
@@ -236,9 +237,18 @@ void Trans_Codegen(const ::std::string& outfile, const ::HIR::Crate& crate, cons
const auto& fcn = *ent.second->ptr;
// TODO: If this is a provided trait method, it needs to be monomorphised too.
bool is_method = ( fcn.m_args.size() > 0 && visit_ty_with(fcn.m_args[0].second, [&](const auto& x){return x == ::HIR::TypeRef("Self",0xFFFF);}) );
- if( ent.second->pp.has_types() || is_method ) {
+ if( ent.second->pp.has_types() || is_method )
+ {
+ ::StaticTraitResolve resolve { crate };
+ auto ret_type = ent.second->pp.monomorph(crate, fcn.m_return);
+ ::HIR::Function::args_t args;
+ for(const auto& a : fcn.m_args)
+ args.push_back(::std::make_pair( ::HIR::Pattern{}, ent.second->pp.monomorph(crate, a.second) ));
auto mir = Trans_Monomorphise(crate, ent.second->pp, fcn.m_code.m_mir);
+ MIR_Validate(resolve, ::HIR::ItemPath(), *mir, args, ret_type);
+ MIR_Cleanup(resolve, ::HIR::ItemPath(), *mir, args, ret_type);
// TODO: MIR Optimisation
+ MIR_Validate(resolve, ::HIR::ItemPath(), *mir, args, ret_type);
codegen->emit_function_code(ent.first, fcn, ent.second->pp, mir);
}
else {