Commit 87bc8ba6 authored by dbarbera's avatar dbarbera
Browse files

Fix code generation for built-in length operator

parent 9162d67f
......@@ -893,12 +893,14 @@ def _primary_call(prim):
def generate_length(params):
''' Generate the code for the built-in length operation'''
seq_ptr = reference(params[0])
arr_ty = seq_ptr.type.pointee.elements[0]
if arr_ty.kind != core.TYPE_ARRAY:
# If is not an array this is a pointer to a variable size SeqOf
# The array is in the second field of the struct
arr_ty = seq_ptr.type.pointee.elements[1]
return, arr_ty.count)
bty = find_basic_type(params[0].exprType)
if bty.Min != bty.Max:
len_ptr = ctx.builder.gep(seq_ptr, [,])
return ctx.builder.zext(ctx.builder.load(len_ptr), ctx.i64)
arr_ty = seq_ptr.type.pointee.elements[0]
return, arr_ty.count)
def generate_present(params):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment