2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-28 20:53:35 +08:00

transforms.llvm_ir_generator: quote recrusive objects correctly (fixes #213).

This commit is contained in:
whitequark 2016-01-07 19:52:31 +00:00
parent 027d54ca94
commit f2f1deb9db

View File

@ -1123,21 +1123,23 @@ class LLVMIRGenerator:
llty = self.llty_of_type(typ)
if types.is_constructor(typ) or types.is_instance(typ):
llglobal = None
llfields = []
for attr in typ.attributes:
if attr == "__objectid__":
objectid = self.object_map.store(value)
llfields.append(ll.Constant(lli32, objectid))
global_name = "object.{}".format(objectid)
assert llglobal is None
llglobal = ll.GlobalVariable(self.llmodule, llty.pointee,
name="object.{}".format(objectid))
self.llobject_map[value_id] = llglobal
else:
llfields.append(self._quote(getattr(value, attr), typ.attributes[attr],
lambda: path() + [attr]))
llconst = ll.Constant(llty.pointee, llfields)
llglobal = ll.GlobalVariable(self.llmodule, llconst.type, global_name)
llglobal.initializer = llconst
llglobal.initializer = ll.Constant(llty.pointee, llfields)
llglobal.linkage = "private"
self.llobject_map[value_id] = llglobal
return llglobal
elif builtins.is_none(typ):
assert value is None