/* * MRustC - Rust Compiler * - By John Hodge (Mutabah/thePowersGang) * * mir/mir.cpp * - MIR (Middle Intermediate Representation) definitions */ #include namespace MIR { ::std::ostream& operator<<(::std::ostream& os, const Constant& v) { TU_MATCHA( (v), (e), (Int, os << (e < 0 ? "-" : "+"); os << (e < 0 ? -e : e); ), (Uint, os << e; ), (Float, os << e; ), (Bool, os << (e ? "true" : "false"); ), (Bytes, os << "[" << e << "]"; ), (StaticString, os << "\"" << e << "\""; ), (ItemAddr, os << "&" << e; ) ) return os; } } ::MIR::LValue MIR::LValue::clone() const { TU_MATCHA( (*this), (e), (Variable, return LValue(e); ), (Temporary, return LValue(e); ), (Argument, return LValue(e); ), (Static, return LValue(e.clone()); ), (Return, return LValue(e); ), (Field, return LValue::make_Field({ box$( e.val->clone() ), e.field_index }); ), (Deref, return LValue::make_Deref({ box$( e.val->clone() ) }); ), (Index, return LValue::make_Index({ box$( e.val->clone() ), box$( e.idx->clone() ) }); ), (Downcast, return LValue::make_Downcast({ box$( e.val->clone() ), e.variant_index }); ) ) throw ""; }