Skip to content

Commit

Permalink
transforms.llvm_ir_generator: quote recrusive objects correctly (fixes
Browse files Browse the repository at this point in the history
whitequark committed Jan 7, 2016
1 parent 027d54c commit f2f1deb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -1123,21 +1123,23 @@ def _quote(self, value, typ, path):
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

0 comments on commit f2f1deb

Please sign in to comment.