MCPcopy Create free account
hub / github.com/python/mypy / vec_pop

Function vec_pop

mypyc/irbuild/vec.py:470–506  ·  view source on GitHub ↗
(builder: LowLevelIRBuilder, base: Value, index: Value, line: int)

Source from the content-addressed store, hash-verified

468
469
470def vec_pop(builder: LowLevelIRBuilder, base: Value, index: Value, line: int) -> Value:
471 assert isinstance(base.type, RVec)
472 vec_type = base.type
473 item_type = vec_type.item_type
474 index = as_platform_int(builder, index, line)
475
476 api_name = vec_api_by_item_type.get(item_type)
477 if api_name is not None:
478 name = f"{api_name}.pop"
479 elif vec_type.depth() == 0:
480 name = "VecTApi.pop"
481 else:
482 name = "VecNestedApi.pop"
483 # Nested vecs return a generic vec struct.
484 item_type = VecNestedBufItem
485 result = builder.add(
486 CallC(
487 name,
488 [base, index],
489 RTuple([vec_type, item_type]),
490 steals=[True, False],
491 is_borrowed=False,
492 error_kind=ERR_MAGIC,
493 line=line,
494 )
495 )
496 if vec_type.depth() > 0:
497 orig = result
498 x = builder.add(TupleGet(result, 0, borrow=True))
499 x = builder.add(Unborrow(x))
500 y = builder.add(TupleGet(result, 1, borrow=True))
501 y = builder.add(Unborrow(y))
502 assert isinstance(vec_type.item_type, RVec)
503 z = convert_from_t_ext_item(builder, y, vec_type.item_type)
504 result = builder.add(TupleSet([x, z], line))
505 builder.keep_alive([orig], line, steal=True)
506 return result
507
508
509def vec_remove(builder: LowLevelIRBuilder, vec: Value, item: Value, line: int) -> Value:

Callers 1

translate_vec_popFunction · 0.90

Calls 12

CallCClass · 0.90
RTupleClass · 0.90
TupleGetClass · 0.90
UnborrowClass · 0.90
TupleSetClass · 0.90
isinstanceFunction · 0.85
as_platform_intFunction · 0.85
convert_from_t_ext_itemFunction · 0.85
depthMethod · 0.80
keep_aliveMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…