Skip to content

Commit 35e300e

Browse files
committed
Fix some call_c call sites
1 parent f72480e commit 35e300e

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

mypyc/irbuild/builder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
from mypyc.primitives.generic_ops import iter_op, next_op, py_setattr_op
135135
from mypyc.primitives.list_ops import list_get_item_unsafe_op, list_pop_last, to_list
136136
from mypyc.primitives.misc_ops import check_unpack_count_op, get_module_dict_op, import_op
137-
from mypyc.primitives.registry import CFunctionDescription, function_ops
137+
from mypyc.primitives.registry import CFunctionDescription, PrimitiveDescription, function_ops
138138

139139
# These int binary operations can borrow their operands safely, since the
140140
# primitives take this into consideration.
@@ -381,6 +381,9 @@ def load_module(self, name: str) -> Value:
381381
def call_c(self, desc: CFunctionDescription, args: list[Value], line: int) -> Value:
382382
return self.builder.call_c(desc, args, line)
383383

384+
def primitive_op(self, desc: PrimitiveDescription, args: list[Value], line: int) -> Value:
385+
return self.builder.primitive_op(desc, args, line)
386+
384387
def int_op(self, type: RType, lhs: Value, rhs: Value, op: int, line: int) -> Value:
385388
return self.builder.int_op(type, lhs, rhs, op, line)
386389

mypyc/irbuild/classdef.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def add_attr(self, lvalue: NameExpr, stmt: AssignmentStmt) -> None:
292292
return
293293
typ = self.builder.load_native_type_object(self.cdef.fullname)
294294
value = self.builder.accept(stmt.rvalue)
295-
self.builder.call_c(
295+
self.builder.primitive_op(
296296
py_setattr_op, [typ, self.builder.load_str(lvalue.name), value], stmt.line
297297
)
298298
if self.builder.non_function_scope() and stmt.is_final_def:
@@ -452,7 +452,7 @@ def allocate_class(builder: IRBuilder, cdef: ClassDef) -> Value:
452452
)
453453
)
454454
# Populate a '__mypyc_attrs__' field containing the list of attrs
455-
builder.call_c(
455+
builder.primitive_op(
456456
py_setattr_op,
457457
[
458458
tp,
@@ -483,7 +483,7 @@ def make_generic_base_class(
483483
for tv, type_param in zip(tvs, type_args):
484484
if type_param.kind == TYPE_VAR_TUPLE_KIND:
485485
# Evaluate *Ts for a TypeVarTuple
486-
it = builder.call_c(iter_op, [tv], line)
486+
it = builder.primitive_op(iter_op, [tv], line)
487487
tv = builder.call_c(next_op, [it], line)
488488
args.append(tv)
489489

@@ -603,7 +603,7 @@ def setup_non_ext_dict(
603603
This class dictionary is passed to the metaclass constructor.
604604
"""
605605
# Check if the metaclass defines a __prepare__ method, and if so, call it.
606-
has_prepare = builder.call_c(
606+
has_prepare = builder.primitive_op(
607607
py_hasattr_op, [metaclass, builder.load_str("__prepare__")], cdef.line
608608
)
609609

mypyc/irbuild/expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,12 +1045,12 @@ def get_arg(arg: Expression | None) -> Value:
10451045
return builder.accept(arg)
10461046

10471047
args = [get_arg(expr.begin_index), get_arg(expr.end_index), get_arg(expr.stride)]
1048-
return builder.call_c(new_slice_op, args, expr.line)
1048+
return builder.primitive_op(new_slice_op, args, expr.line)
10491049

10501050

10511051
def transform_generator_expr(builder: IRBuilder, o: GeneratorExpr) -> Value:
10521052
builder.warning("Treating generator comprehension as list", o.line)
1053-
return builder.call_c(iter_op, [translate_list_comprehension(builder, o)], o.line)
1053+
return builder.primitive_op(iter_op, [translate_list_comprehension(builder, o)], o.line)
10541054

10551055

10561056
def transform_assignment_expr(builder: IRBuilder, o: AssignmentExpr) -> Value:

0 commit comments

Comments
 (0)