mirror of https://github.com/m-labs/artiq.git
py2llvm/VNone: bugfixes
This commit is contained in:
parent
f31386d15d
commit
44e7b99792
|
@ -10,6 +10,13 @@ class VNone(VGeneric):
|
|||
def alloca(self, builder, name):
|
||||
pass
|
||||
|
||||
def set_const_value(self, builder, v):
|
||||
assert v is None
|
||||
|
||||
def set_value(self, builder, other):
|
||||
if not isinstance(other, VNone):
|
||||
raise TypeError
|
||||
|
||||
def o_bool(self, builder):
|
||||
r = VBool()
|
||||
if builder is not None:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import llvmlite.ir as ll
|
||||
|
||||
from artiq.py2llvm.values import VGeneric
|
||||
from artiq.py2llvm.base_types import VInt
|
||||
from artiq.py2llvm.base_types import VInt, VNone
|
||||
|
||||
|
||||
class VList(VGeneric):
|
||||
|
@ -12,8 +12,11 @@ class VList(VGeneric):
|
|||
|
||||
def get_llvm_type(self):
|
||||
count = 0 if self.alloc_count is None else self.alloc_count
|
||||
return ll.LiteralStructType([ll.IntType(32),
|
||||
ll.ArrayType(self.el_type.get_llvm_type(),
|
||||
if isinstance(self.el_type, VNone):
|
||||
return ll.LiteralStructType([ll.IntType(32)])
|
||||
else:
|
||||
return ll.LiteralStructType([
|
||||
ll.IntType(32), ll.ArrayType(self.el_type.get_llvm_type(),
|
||||
count)])
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -52,7 +55,7 @@ class VList(VGeneric):
|
|||
|
||||
def o_subscript(self, index, builder):
|
||||
r = self.el_type.new()
|
||||
if builder is not None:
|
||||
if builder is not None and not isinstance(r, VNone):
|
||||
index = index.o_int(builder).auto_load(builder)
|
||||
ssa_r = builder.gep(self.llvm_value, [
|
||||
ll.Constant(ll.IntType(32), 0),
|
||||
|
|
Loading…
Reference in New Issue