Exemplo n.º 1
0
def extract_tuple_eltypes(tuple_type, n):
    """
    Extract the element types from the (static) tuple type and return them
    in a tuple.
    """
    if typematch(tuple_type, StaticTuple):
        return extract_statictuple_eltypes(tuple_type)
    else:
        assert typematch(tuple_type, GenericTuple), tuple_type
        base_type = tuple_type.parameters[0]
        return (base_type, ) * n
Exemplo n.º 2
0
def extract_tuple_eltypes(tuple_type, n):
    """
    Extract the element types from the (static) tuple type and return them
    in a tuple.
    """
    if typematch(tuple_type, StaticTuple):
        return extract_statictuple_eltypes(tuple_type)
    else:
        assert typematch(tuple_type, GenericTuple), tuple_type
        base_type = tuple_type.parameters[0]
        return (base_type,) * n
Exemplo n.º 3
0
def extract_statictuple_eltypes(tuple_type):
    if typematch(tuple_type, EmptyTuple):
        return ()

    hd, tl = tuple_type.parameters
    return (hd, ) + extract_statictuple_eltypes(tl)
Exemplo n.º 4
0
def extract_statictuple_eltypes(tuple_type):
    if typematch(tuple_type, EmptyTuple):
        return ()

    hd, tl = tuple_type.parameters
    return (hd,) + extract_statictuple_eltypes(tl)