diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-02-25 12:07:12 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-02-25 12:07:12 +0800 |
commit | 8068936c1900453fdcbb74c34ed228519ac4e06b (patch) | |
tree | 2e0847a2b7a0378f49153e035bf8f7ca135ab4ce /src/mir/helpers.cpp | |
parent | cb04e0ba3611deff03566eb035b2c35b4b8890f9 (diff) | |
download | mrust-8068936c1900453fdcbb74c34ed228519ac4e06b.tar.gz |
MIR Gen - Use MIR::Param (and associated changes)
Diffstat (limited to 'src/mir/helpers.cpp')
-rw-r--r-- | src/mir/helpers.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mir/helpers.cpp b/src/mir/helpers.cpp index 9750b978..9c2107ab 100644 --- a/src/mir/helpers.cpp +++ b/src/mir/helpers.cpp @@ -225,6 +225,45 @@ const ::HIR::TypeRef& ::MIR::TypeResolve::get_lvalue_type(::HIR::TypeRef& tmp, c ) throw ""; } + +::HIR::TypeRef MIR::TypeResolve::get_const_type(const ::MIR::Constant& c) const +{ + TU_MATCHA( (c), (e), + (Int, + return e.t; + ), + (Uint, + return e.t; + ), + (Float, + return e.t; + ), + (Bool, + return ::HIR::CoreType::Bool; + ), + (Bytes, + return ::HIR::TypeRef::new_borrow( ::HIR::BorrowType::Shared, ::HIR::TypeRef::new_array( ::HIR::CoreType::U8, e.size() ) ); + ), + (StaticString, + return ::HIR::TypeRef::new_borrow( ::HIR::BorrowType::Shared, ::HIR::CoreType::Str ); + ), + (Const, + MonomorphState p; + auto v = m_resolve.get_value(this->sp, e.p, p, /*signature_only=*/true); + if( const auto* ve = v.opt_Constant() ) { + const auto& ty = (*ve)->m_type; + MIR_TODO(*this, "Monomorphise type " << ty); + } + else { + MIR_BUG(*this, ""); + } + ), + (ItemAddr, + MIR_TODO(*this, "Get type for constant `" << c << "`"); + ) + ) + throw ""; +} const ::HIR::TypeRef* ::MIR::TypeResolve::is_type_owned_box(const ::HIR::TypeRef& ty) const { return m_resolve.is_type_owned_box(ty); |