ir: convert version fields to OFTypeMembers
The frontend gets a new OFVersionMember field type, which is lowered to
OFTypeMember when generating the IR (which is when the version is first known).
diff --git a/loxi_ir/ir.py b/loxi_ir/ir.py
index 8553f62..3785a6f 100644
--- a/loxi_ir/ir.py
+++ b/loxi_ir/ir.py
@@ -33,6 +33,7 @@
from collections import namedtuple, OrderedDict
from generic_utils import find, memoize, OrderedSet
from loxi_ir import ir_offset
+import loxi_front_end.frontend_ir as frontend_ir
logger = logging.getLogger(__name__)
@@ -356,11 +357,18 @@
return { name if name != "length" else "pad_length" : value for name, value in props.items() }
def build_member(of_class, fe_member, length_info):
- ir_class = globals()[type(fe_member).__name__]
- member = ir_class(offset = length_info.offset,
- base_length = length_info.base_length,
- is_fixed_length=length_info.is_fixed_length,
- **convert_member_properties(fe_member._asdict()))
+ if isinstance(fe_member, frontend_ir.OFVersionMember):
+ member = OFTypeMember(offset = length_info.offset,
+ base_length = length_info.base_length,
+ is_fixed_length=length_info.is_fixed_length,
+ value = version.wire_version,
+ **convert_member_properties(fe_member._asdict()))
+ else:
+ ir_class = globals()[type(fe_member).__name__]
+ member = ir_class(offset = length_info.offset,
+ base_length = length_info.base_length,
+ is_fixed_length=length_info.is_fixed_length,
+ **convert_member_properties(fe_member._asdict()))
member.of_class = of_class
return member