Skip to content

Commit 96f79cc

Browse files
committed
Clean up
1 parent b9c7f1e commit 96f79cc

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

mypyc/irbuild/ll_builder.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
from mypyc.primitives.generic_ops import (
140140
generic_len_op,
141141
generic_ssize_t_len_op,
142-
not_op,
143142
py_call_op,
144143
py_call_with_kwargs_op,
145144
py_call_with_posargs_op,
@@ -1659,13 +1658,15 @@ def _non_specialized_unary_op(self, value: Value, op: str, line: int) -> Value:
16591658
return target
16601659

16611660
def unary_not(self, value: Value, line: int) -> Value:
1661+
"""Perform unary 'not'."""
16621662
typ = value.type
16631663
if is_bool_or_bit_rprimitive(typ):
16641664
mask = Integer(1, value.type, line)
16651665
return self.int_op(value.type, value, mask, IntOp.XOR, line)
16661666
return self._non_specialized_unary_op(value, "not", line)
16671667

16681668
def unary_minus(self, value: Value, line: int) -> Value:
1669+
"""Perform unary '-'."""
16691670
typ = value.type
16701671
if isinstance(value, Integer):
16711672
# TODO: Overflow? Unsigned?
@@ -1680,6 +1681,7 @@ def unary_minus(self, value: Value, line: int) -> Value:
16801681
return self._non_specialized_unary_op(value, "-", line)
16811682

16821683
def unary_plus(self, value: Value, line: int) -> Value:
1684+
"""Perform unary '+'."""
16831685
typ = value.type
16841686
if (
16851687
is_tagged(typ)
@@ -1691,6 +1693,7 @@ def unary_plus(self, value: Value, line: int) -> Value:
16911693
return self._non_specialized_unary_op(value, "+", line)
16921694

16931695
def unary_invert(self, value: Value, line: int) -> Value:
1696+
"""Perform unary '~'."""
16941697
typ = value.type
16951698
if is_fixed_width_rtype(typ):
16961699
if typ.is_signed:
@@ -1702,16 +1705,17 @@ def unary_invert(self, value: Value, line: int) -> Value:
17021705
return self.int_op(typ, value, Integer(mask, typ), IntOp.XOR, line)
17031706
return self._non_specialized_unary_op(value, "~", line)
17041707

1705-
def unary_op(self, value: Value, expr_op: str, line: int) -> Value:
1706-
if expr_op == "not":
1708+
def unary_op(self, value: Value, op: str, line: int) -> Value:
1709+
"""Perform a unary operation."""
1710+
if op == "not":
17071711
return self.unary_not(value, line)
1708-
elif expr_op == "-":
1712+
elif op == "-":
17091713
return self.unary_minus(value, line)
1710-
elif expr_op == "+":
1714+
elif op == "+":
17111715
return self.unary_plus(value, line)
1712-
elif expr_op == "~":
1716+
elif op == "~":
17131717
return self.unary_invert(value, line)
1714-
raise RuntimeError("Unsupported unary operation: %s" % expr_op)
1718+
raise RuntimeError("Unsupported unary operation: %s" % op)
17151719

17161720
def make_dict(self, key_value_pairs: Sequence[DictEntry], line: int) -> Value:
17171721
result: Value | None = None

mypyc/primitives/generic_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
priority=0,
159159
)
160160

161-
not_op = unary_op(
161+
unary_op(
162162
name="not",
163163
arg_type=object_rprimitive,
164164
return_type=c_int_rprimitive,

0 commit comments

Comments
 (0)