Ejemplo n.º 1
0
def env_gen(env_type, depth):

    # copy tuple, then add a fresh row type variable
    var = row.Var(depth)
    if type(env_type) is row.Empty:
        gen_type = var
    else:
        gen_type = row.record( *tuple(iter(env_type) ) )
        gen_type.set_terminator(var)
    
    return gen_type
Ejemplo n.º 2
0
def row_gen(state, node):

    # this will row-generalize type for node
    node_type = expr(state, node.expr)
    assert type(node_type) in row.types, "closure env should be a record: {0}".format(node_type.show())

    # copy tuple, then add a fresh row type variable
    var = row.Var(state.depth)
    if type(node_type) is row.Empty:
        gen_type = var
    else:
        gen_type = row.record(*tuple(iter(node_type)))
        gen_type.set_terminator(var)

    tool.debug("gen_type:", gen_type.show())

    return gen_type