1
1
import llvmlite .ir as ll
2
2
3
3
from artiq .py2llvm .values import VGeneric
4
- from artiq .py2llvm .base_types import VInt
4
+ from artiq .py2llvm .base_types import VInt , VNone
5
5
6
6
7
7
class VList (VGeneric ):
@@ -12,9 +12,12 @@ def __init__(self, el_type, alloc_count):
12
12
13
13
def get_llvm_type (self ):
14
14
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 )])
18
21
19
22
def __repr__ (self ):
20
23
return "<VList:{} x{}>" .format (
@@ -52,7 +55,7 @@ def o_len(self, builder):
52
55
53
56
def o_subscript (self , index , builder ):
54
57
r = self .el_type .new ()
55
- if builder is not None :
58
+ if builder is not None and not isinstance ( r , VNone ) :
56
59
index = index .o_int (builder ).auto_load (builder )
57
60
ssa_r = builder .gep (self .llvm_value , [
58
61
ll .Constant (ll .IntType (32 ), 0 ),
0 commit comments