Ejemplo n.º 1
0
def tuple_indirection_set(path_tip: irast.Set,
                          *,
                          source: s_types.Type,
                          ptr_name: str,
                          source_context: Optional[
                              parsing.ParserContext] = None,
                          ctx: context.ContextLevel) -> irast.Set:

    assert isinstance(source, s_types.Tuple)

    el_name = ptr_name
    el_norm_name = source.normalize_index(ctx.env.schema, el_name)
    el_type = source.get_subtype(ctx.env.schema, el_name)

    path_id = pathctx.get_tuple_indirection_path_id(path_tip.path_id,
                                                    el_norm_name,
                                                    el_type,
                                                    ctx=ctx)

    ti_set = new_set(stype=el_type, path_id=path_id, ctx=ctx)

    ptr = irast.TupleIndirectionPointer(
        source=path_tip,
        target=ti_set,
        ptrref=path_id.rptr(),
        direction=path_id.rptr_dir(),
    )

    ti_set.rptr = ptr

    return ti_set
Ejemplo n.º 2
0
def tuple_indirection_set(path_tip: irast.Set, *, source: s_types.Type,
                          ptr_name: str, source_context: parsing.ParserContext,
                          ctx: context.ContextLevel) -> irast.Set:

    assert isinstance(source, s_types.Tuple)

    el_name = ptr_name
    el_norm_name = source.normalize_index(ctx.env.schema, el_name)
    el_type = source.get_subtype(ctx.env.schema, el_name)

    path_id = pathctx.get_tuple_indirection_path_id(path_tip.path_id,
                                                    el_norm_name,
                                                    el_type,
                                                    ctx=ctx)
    expr = irast.TupleIndirection(expr=path_tip,
                                  name=el_norm_name,
                                  path_id=path_id,
                                  context=source_context)

    return expression_set(expr, ctx=ctx)