Exemplo n.º 1
0
def translate_set_from_generator_call(builder: IRBuilder, expr: CallExpr,
                                      callee: RefExpr) -> Optional[Value]:
    # Special case for set creation from a generator:
    #     set(f(...) for ... in iterator/nested_generators...)
    if (len(expr.args) == 1 and expr.arg_kinds[0] == ARG_POS
            and isinstance(expr.args[0], GeneratorExpr)):
        return translate_set_comprehension(builder, expr.args[0])
    return None
Exemplo n.º 2
0
def transform_set_comprehension(builder: IRBuilder, o: SetComprehension) -> Value:
    if any(o.generator.is_async):
        builder.error('async comprehensions are unimplemented', o.line)
    return translate_set_comprehension(builder, o.generator)
Exemplo n.º 3
0
def transform_set_comprehension(builder: IRBuilder,
                                o: SetComprehension) -> Value:
    return translate_set_comprehension(builder, o.generator)