diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-04-28 15:23:37 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-04-28 15:23:37 +0800 |
commit | 406fe84b2c663e5b1a31448baefe09b847cb635c (patch) | |
tree | fdd62cca2e5e010eb3416e534475b32a56b1807d /src/trans/codegen_c.cpp | |
parent | 2aaec20f9f4f8fc002086cb1117126dd6ac53b22 (diff) | |
download | mrust-406fe84b2c663e5b1a31448baefe09b847cb635c.tar.gz |
Trans Monomorph - Associated constants left as Defer
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r-- | src/trans/codegen_c.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 373a36a8..08b4f2de 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -5288,8 +5288,21 @@ namespace { auto v = m_resolve.get_value(m_mir_res->sp, path, params); if( const auto* e = v.opt_Constant() ) { - ty = params.monomorph(m_mir_res->sp, (*e)->m_type); - return (*e)->m_value_res; + const auto& hir_const = **e; + ty = params.monomorph(m_mir_res->sp, hir_const.m_type); + if( hir_const.m_value_res.is_Defer() ) + { + // Do some form of lookup of a pre-cached evaluated monomorphised constant + // - Maybe on the `Constant` entry there can be a list of pre-monomorphised values + auto it = hir_const.m_monomorph_cache.find(path); + if( it == hir_const.m_monomorph_cache.end() ) + { + MIR_BUG(*m_mir_res, "Constant with Defer literal and no cached monomorphisation - " << path); + // TODO: Can do the consteval here? + } + return it->second; + } + return hir_const.m_value_res; } else { |