MCPcopy Index your code
hub / github.com/python/mypy / inline_fixed_width_mod

Method inline_fixed_width_mod

mypyc/irbuild/ll_builder.py:2626–2642  ·  view source on GitHub ↗
(self, type: RType, lhs: Value, rhs: Value, line: int)

Source from the content-addressed store, hash-verified

2624 return res
2625
2626 def inline_fixed_width_mod(self, type: RType, lhs: Value, rhs: Value, line: int) -> Value:
2627 # Perform floor modulus
2628 res = Register(type)
2629 mod = self.int_op(type, lhs, rhs, IntOp.MOD, line)
2630 self.add(Assign(res, mod))
2631 same_signs = self.is_same_native_int_signs(type, lhs, rhs, line)
2632 tricky, adjust, done = BasicBlock(), BasicBlock(), BasicBlock()
2633 self.add(Branch(same_signs, done, tricky, Branch.BOOL))
2634 self.activate_block(tricky)
2635 is_zero = self.add(ComparisonOp(res, Integer(0, type), ComparisonOp.EQ, line))
2636 self.add(Branch(is_zero, done, adjust, Branch.BOOL))
2637 self.activate_block(adjust)
2638 adj = self.int_op(type, res, rhs, IntOp.ADD, line)
2639 self.add(Assign(res, adj))
2640 self.add(Goto(done))
2641 self.activate_block(done)
2642 return res
2643
2644 def is_same_native_int_signs(self, type: RType, a: Value, b: Value, line: int) -> Value:
2645 neg1 = self.add(ComparisonOp(a, Integer(0, type), ComparisonOp.SLT, line))

Callers 1

fixed_width_int_opMethod · 0.95

Calls 11

int_opMethod · 0.95
addMethod · 0.95
activate_blockMethod · 0.95
RegisterClass · 0.90
AssignClass · 0.90
BasicBlockClass · 0.90
BranchClass · 0.90
ComparisonOpClass · 0.90
IntegerClass · 0.90
GotoClass · 0.90

Tested by

no test coverage detected