def extend_path_id( path_id: irast.PathId, *, ptrcls: s_pointers.PointerLike, direction: s_pointers.PointerDirection = ( s_pointers.PointerDirection.Outbound), ns: AbstractSet[str] = frozenset(), ctx: context.ContextLevel, ) -> irast.PathId: """A wrapper over :meth:`ir.pathid.PathId.extend` that also ensures the cardinality of *ptrcls* is known at the end of compilation. """ ptrref = irtyputils.ptrref_from_ptrcls( schema=ctx.env.schema, ptrcls=ptrcls, direction=direction, cache=ctx.env.ptr_ref_cache, typeref_cache=ctx.env.type_ref_cache, ) stmtctx.ensure_ptrref_cardinality(ptrcls, ptrref, ctx=ctx) return path_id.extend(ptrref=ptrref, direction=direction, ns=ns, schema=ctx.env.schema)
def get_tuple_indirection_path_id(tuple_path_id: irast.PathId, element_name: str, element_type: s_types.Type, *, ctx: context.ContextLevel) -> irast.PathId: return tuple_path_id.extend( ptrcls=irast.TupleIndirectionLink(element_name), direction=s_pointers.PointerDirection.Outbound, target=element_type, schema=ctx.env.schema)
def get_type_indirection_path_id(path_id: irast.PathId, target_type: s_types.Type, *, optional: bool, ancestral: bool, cardinality: qltypes.Cardinality, ctx: context.ContextLevel) -> irast.PathId: return path_id.extend(ptrcls=irast.TypeIndirectionLink( path_id.target, target_type, optional=optional, ancestral=ancestral, cardinality=cardinality), direction=s_pointers.PointerDirection.Outbound, target=target_type, schema=ctx.env.schema)
def extend_path_id(path_id: irast.PathId, *, ptrcls, direction=None, target=None, ns=None, ctx: context.ContextLevel) -> irast.PathId: result = path_id.extend(ptrcls=ptrcls, direction=direction, target=target, ns=ns, schema=ctx.env.schema) ptrref = result.rptr() stmtctx.ensure_ptrref_cardinality(ptrcls, ptrref, ctx=ctx) return result
def get_tuple_indirection_path_id( tuple_path_id: irast.PathId, element_name: str, element_type: s_types.Type, *, ctx: context.ContextLevel) -> irast.PathId: ptrcls = irast.TupleIndirectionLink( irtyputils.ir_typeref_to_type(ctx.env.schema, tuple_path_id.target), element_type, element_name=element_name, ) ptrref = irtyputils.ptrref_from_ptrcls( schema=ctx.env.schema, ptrcls=ptrcls, # FIXME: caching disabled here since it breaks tests # cache=ctx.env.ptr_ref_cache, # typeref_cache=ctx.env.type_ref_cache, ) return tuple_path_id.extend(schema=ctx.env.schema, ptrref=ptrref)