(
builder: IRBuilder,
items: list[Expression],
constructor_op: Callable[[list[Value], int], Value],
append_op: PrimitiveDescription,
extend_op: PrimitiveDescription,
line: int,
is_list: bool,
)
| 1217 | |
| 1218 | |
| 1219 | def _visit_display( |
| 1220 | builder: IRBuilder, |
| 1221 | items: list[Expression], |
| 1222 | constructor_op: Callable[[list[Value], int], Value], |
| 1223 | append_op: PrimitiveDescription, |
| 1224 | extend_op: PrimitiveDescription, |
| 1225 | line: int, |
| 1226 | is_list: bool, |
| 1227 | ) -> Value: |
| 1228 | accepted_items = [] |
| 1229 | for item in items: |
| 1230 | if isinstance(item, StarExpr): |
| 1231 | accepted_items.append((True, builder.accept(item.expr))) |
| 1232 | else: |
| 1233 | accepted_items.append((False, builder.accept(item))) |
| 1234 | |
| 1235 | result: Value | None = None |
| 1236 | initial_items = [] |
| 1237 | for starred, value in accepted_items: |
| 1238 | if result is None and not starred and is_list: |
| 1239 | initial_items.append(value) |
| 1240 | continue |
| 1241 | |
| 1242 | if result is None: |
| 1243 | result = constructor_op(initial_items, line) |
| 1244 | |
| 1245 | builder.primitive_op(extend_op if starred else append_op, [result, value], line) |
| 1246 | |
| 1247 | if result is None: |
| 1248 | result = constructor_op(initial_items, line) |
| 1249 | |
| 1250 | return result |
| 1251 | |
| 1252 | |
| 1253 | # Comprehensions |
no test coverage detected
searching dependent graphs…