Skip to content

Commit 44e7b99

Browse files
committedDec 19, 2014
py2llvm/VNone: bugfixes
1 parent f31386d commit 44e7b99

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
 

‎artiq/py2llvm/base_types.py

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ def get_llvm_type(self):
1010
def alloca(self, builder, name):
1111
pass
1212

13+
def set_const_value(self, builder, v):
14+
assert v is None
15+
16+
def set_value(self, builder, other):
17+
if not isinstance(other, VNone):
18+
raise TypeError
19+
1320
def o_bool(self, builder):
1421
r = VBool()
1522
if builder is not None:

‎artiq/py2llvm/lists.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import llvmlite.ir as ll
22

33
from artiq.py2llvm.values import VGeneric
4-
from artiq.py2llvm.base_types import VInt
4+
from artiq.py2llvm.base_types import VInt, VNone
55

66

77
class VList(VGeneric):
@@ -12,9 +12,12 @@ def __init__(self, el_type, alloc_count):
1212

1313
def get_llvm_type(self):
1414
count = 0 if self.alloc_count is None else self.alloc_count
15-
return ll.LiteralStructType([ll.IntType(32),
16-
ll.ArrayType(self.el_type.get_llvm_type(),
17-
count)])
15+
if isinstance(self.el_type, VNone):
16+
return ll.LiteralStructType([ll.IntType(32)])
17+
else:
18+
return ll.LiteralStructType([
19+
ll.IntType(32), ll.ArrayType(self.el_type.get_llvm_type(),
20+
count)])
1821

1922
def __repr__(self):
2023
return "<VList:{} x{}>".format(
@@ -52,7 +55,7 @@ def o_len(self, builder):
5255

5356
def o_subscript(self, index, builder):
5457
r = self.el_type.new()
55-
if builder is not None:
58+
if builder is not None and not isinstance(r, VNone):
5659
index = index.o_int(builder).auto_load(builder)
5760
ssa_r = builder.gep(self.llvm_value, [
5861
ll.Constant(ll.IntType(32), 0),

0 commit comments

Comments
 (0)
Please sign in to comment.