ir: add discriminator method to OFClass
Also fixed the broken member_by_name.
diff --git a/loxi_ir.py b/loxi_ir.py
index ae89207..ec8056f 100644
--- a/loxi_ir.py
+++ b/loxi_ir.py
@@ -79,7 +79,11 @@
"""
class OFClass(namedtuple('OFClass', ['name', 'superclass', 'members', 'virtual', 'params'])):
def member_by_name(self, name):
- return find(self.members, lambda m: hasattr(m, "name") and m.name == name)
+ return find(lambda m: hasattr(m, "name") and m.name == name, self.members)
+
+ @property
+ def discriminator(self):
+ return find(lambda m: type(m) == OFDiscriminatorMember, self.members)
"""
Normal field