diff options
author | John Hodge <tpg@ucc.asn.au> | 2018-09-22 16:25:01 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2018-09-22 16:25:01 +0800 |
commit | 5c63b46f8dca1d65c1906c77169555229ab07412 (patch) | |
tree | 5580be06c7a535c3b46bdc3ae9f766697aa1158b /src/hir/expr_ptr.cpp | |
parent | dd4e3c887fa2eef2db6fa2795d4283636a1cc26e (diff) | |
download | mrust-5c63b46f8dca1d65c1906c77169555229ab07412.tar.gz |
All - Generate MIR for constant evaluation (has too many const_cast calls, but it's less ugly)
- Also includes some MIR optimisation changes to reduce some compile times (hopefully)
- Removed duplicated MIR consteval and now-unused HIR consteval
Diffstat (limited to 'src/hir/expr_ptr.cpp')
-rw-r--r-- | src/hir/expr_ptr.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/hir/expr_ptr.cpp b/src/hir/expr_ptr.cpp index 1f4cb1c3..fcef34bd 100644 --- a/src/hir/expr_ptr.cpp +++ b/src/hir/expr_ptr.cpp @@ -7,6 +7,7 @@ */ #include <hir/expr_ptr.hpp> #include <hir/expr.hpp> +#include <hir/expr_state.hpp> ::HIR::ExprPtr::ExprPtr(::std::unique_ptr< ::HIR::ExprNode> v): node( mv$(v) ) @@ -32,3 +33,56 @@ this->ptr = nullptr; return rv; } + +::HIR::ExprStatePtr::ExprStatePtr(ExprState x): + ptr(new ExprState( ::std::move(x) )) +{ +} +::HIR::ExprStatePtr::~ExprStatePtr() +{ + delete ptr; + ptr = nullptr; +} + + +const ::MIR::Function* HIR::ExprPtr::get_mir_opt() const +{ + if(!this->m_mir) + return nullptr; + return &*this->m_mir; +} +const ::MIR::Function& HIR::ExprPtr::get_mir_or_error(const Span& sp) const +{ + if(!this->m_mir) + BUG(sp, "No MIR"); + return *this->m_mir; +} +::MIR::Function& HIR::ExprPtr::get_mir_or_error_mut(const Span& sp) +{ + if(!this->m_mir) + BUG(sp, "No MIR"); + return *this->m_mir; +} +const ::MIR::Function* HIR::ExprPtr::get_ext_mir() const +{ + if(this->node) + return nullptr; + if(!this->m_mir) + return nullptr; + return &*this->m_mir; +} +::MIR::Function* HIR::ExprPtr::get_ext_mir_mut() +{ + if(this->node) + return nullptr; + if(!this->m_mir) + return nullptr; + return &*this->m_mir; +} +void HIR::ExprPtr::set_mir(::MIR::FunctionPointer mir) +{ + assert( !this->m_mir ); + m_mir = ::std::move(mir); +} + + |