fxconv: copy elements in += ObjectData instead of referencing subobject
This way, after o1 += o2, when o1 is linked all the outer data of o2 is linked alongside the outer data of o1, and the inner data remains contiguous. This is important for arrays, where we don't want the outer data of o2 to appear before the next inner field of o1. With this commit, an update to o2 after o1 += o2 no longer updates o1. This wasn't a feature in the first place.
This commit is contained in:
parent
82027e1057
commit
cf3ab5d5e0
|
@ -250,7 +250,7 @@ class ObjectData:
|
|||
elif isinstance(other, Sym):
|
||||
self.inner.append(other)
|
||||
elif isinstance(other, ObjectData):
|
||||
self.inner.append(other)
|
||||
self.inner += other.inner
|
||||
return self
|
||||
|
||||
@staticmethod
|
||||
|
@ -273,22 +273,10 @@ class ObjectData:
|
|||
return padding
|
||||
|
||||
def link(self, symbol):
|
||||
inner = []
|
||||
inner = self.inner
|
||||
outer = []
|
||||
elements = []
|
||||
size = 0
|
||||
|
||||
# First unfold all structures within [inner] as we accumulate the total
|
||||
# size of the inner data
|
||||
for el in self.inner:
|
||||
if isinstance(el, ObjectData):
|
||||
size += self.align(size, el.alignment, inner)
|
||||
code, code_size = el.link(f"{symbol} + {size}")
|
||||
inner.append((code, code_size))
|
||||
size += code_size
|
||||
else:
|
||||
inner.append(el)
|
||||
size += self.element_size(el)
|
||||
size = sum(self.element_size(el) for el in inner)
|
||||
|
||||
# Then replace complex references with unfolded data appended at the
|
||||
# end of the structure
|
||||
|
|
Loading…
Reference in New Issue