summaryrefslogtreecommitdiff
path: root/src/mir/mir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir/mir.cpp')
-rw-r--r--src/mir/mir.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mir/mir.cpp b/src/mir/mir.cpp
index f7a5f3e8..c878950f 100644
--- a/src/mir/mir.cpp
+++ b/src/mir/mir.cpp
@@ -84,6 +84,53 @@ namespace MIR {
)
return os;
}
+ bool operator==(const LValue& a, const LValue& b)
+ {
+ if( a.tag() != b.tag() )
+ return false;
+ TU_MATCHA( (a, b), (ea, eb),
+ (Variable,
+ return ea == eb;
+ ),
+ (Temporary,
+ return ea.idx == eb.idx;
+ ),
+ (Argument,
+ return ea.idx == eb.idx;
+ ),
+ (Static,
+ return ea == eb;
+ ),
+ (Return,
+ return true;
+ ),
+ (Field,
+ if( *ea.val != *eb.val )
+ return false;
+ if( ea.field_index != eb.field_index )
+ return false;
+ return true;
+ ),
+ (Deref,
+ return *ea.val == *eb.val;
+ ),
+ (Index,
+ if( *ea.val != *eb.val )
+ return false;
+ if( *ea.idx != *eb.idx )
+ return false;
+ return true;
+ ),
+ (Downcast,
+ if( *ea.val != *eb.val )
+ return false;
+ if( ea.variant_index != eb.variant_index )
+ return false;
+ return true;
+ )
+ )
+ throw "";
+ }
::std::ostream& operator<<(::std::ostream& os, const RValue& x)
{