def veval_ast_return(astc : 'AstContext', local_field : 'values.Field', graph : 'Graph') -> 'None':
    assert(isinstance(astc.nast, gast.gast.Return))

    value = veval_ast(astc.c(astc.nast.value), local_field, graph)

    if not value.has_value():
        if config.show_warnings:
            print('Returned values are not found. in L.{}'.format(astc.lineno))
        return None

    node = nodes.NodeReturn(value.get_value(),astc.lineno)
    graph.add_node(node)
    return value.get_value()
示例#2
0
def veval_ast_return(astc: 'AstContext', local_field: 'values.Field',
                     graph: 'Graph') -> 'None':
    assert (isinstance(astc.nast, gast.gast.Return))
    lineprop = utils.LineProperty(astc.lineno)

    value = veval_ast(astc.c(astc.nast.value), local_field, graph)
    value_obj = try_get_ref(value, 'return', lineprop)
    value_value = try_get_value(value, 'return', lineprop)

    if value_value is None:
        if config.show_warnings:
            print('Returned values are not found. in L.{}'.format(astc.lineno))
        return None

    node = nodes.NodeReturn(value_value, astc.lineno)
    graph.add_node(node)
    return value_obj