summaryrefslogtreecommitdiff
path: root/src/trans/codegen_c.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-02-22 20:45:43 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-02-22 20:45:43 +0800
commit0b672c4325967ade9a8f9bd8a06071cca09c4276 (patch)
treea5cc6d90a59a4aa4b06e1a8a77d874670653f94a /src/trans/codegen_c.cpp
parent1e8376b6bc4289832112a70323f8c1f0f0722392 (diff)
downloadmrust-0b672c4325967ade9a8f9bd8a06071cca09c4276.tar.gz
MIR - Add types to integer constants
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r--src/trans/codegen_c.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 5f87e126..b02769a0 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -2788,56 +2788,54 @@ namespace {
{
TU_MATCHA( (ve), (c),
(Int,
- if( c == INT64_MIN )
+ if( c.v == INT64_MIN )
m_of << "INT64_MIN";
else
- m_of << c;
+ m_of << c.v;
),
(Uint,
- ::HIR::TypeRef tmp;
- const auto& ty = dst_ptr ? m_mir_res->get_lvalue_type(tmp, *dst_ptr) : tmp = ::HIR::CoreType::U128;
- switch(ty.m_data.as_Primitive())
+ switch(c.t)
{
case ::HIR::CoreType::U8:
- m_of << ::std::hex << "0x" << (c & 0xFF) << ::std::dec;
+ m_of << ::std::hex << "0x" << (c.v & 0xFF) << ::std::dec;
break;
case ::HIR::CoreType::U16:
- m_of << ::std::hex << "0x" << (c & 0xFFFF) << ::std::dec;
+ m_of << ::std::hex << "0x" << (c.v & 0xFFFF) << ::std::dec;
break;
case ::HIR::CoreType::U32:
- m_of << ::std::hex << "0x" << (c & 0xFFFFFFFF) << ::std::dec;
+ m_of << ::std::hex << "0x" << (c.v & 0xFFFFFFFF) << ::std::dec;
break;
case ::HIR::CoreType::U64:
case ::HIR::CoreType::U128:
case ::HIR::CoreType::Usize:
- m_of << ::std::hex << "0x" << c << ::std::dec;
+ m_of << ::std::hex << "0x" << c.v << ::std::dec;
break;
case ::HIR::CoreType::Char:
- assert(0 <= c && c <= 0x10FFFF);
- if( c < 256 ) {
- m_of << c;
+ assert(0 <= c.v && c.v <= 0x10FFFF);
+ if( c.v < 256 ) {
+ m_of << c.v;
}
else {
- m_of << ::std::hex << "0x" << c << ::std::dec;
+ m_of << ::std::hex << "0x" << c.v << ::std::dec;
}
break;
default:
- MIR_BUG(*m_mir_res, "Invalid type for UInt literal - " << ty);
+ MIR_BUG(*m_mir_res, "Invalid type for UInt literal - " << c.t);
}
),
(Float,
- if( ::std::isnan(c) ) {
+ if( ::std::isnan(c.v) ) {
m_of << "NAN";
}
- else if( ::std::isinf(c) ) {
+ else if( ::std::isinf(c.v) ) {
m_of << "INFINITY";
}
else {
- m_of << c;
+ m_of << c.v;
}
),
(Bool,
- m_of << (c ? "true" : "false");
+ m_of << (c.v ? "true" : "false");
),
(Bytes,
// TODO: Need to know the desired value for this