Skip to content

Commit ee1348f

Browse files
committed
All done! hehee operation refractored
1 parent 2464591 commit ee1348f

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

scripts/gen_dispatch_stubs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,14 @@ def print_cast(operand, varname, t, ctype):
289289
continue
290290

291291
elif opname in ("band", "bor", "bxor"):
292-
if is_integral(left) and is_integral(right):
292+
if left == 'bool' and right == 'bool':
293+
if opname == "band":
294+
print(f" return var(a.var_get<bool>() & b.var_get<bool>());")
295+
elif opname == "bor":
296+
print(f" return var(a.var_get<bool>() | b.var_get<bool>());")
297+
elif opname == "bxor":
298+
print(f" return var(a.var_get<bool>() ^ b.var_get<bool>());")
299+
elif is_integral(left) and is_integral(right):
293300
ctype = get_common_integral_bitwise(left, right)
294301
print_cast('a', 'la', left, ctype)
295302
print_cast('b', 'lb', right, ctype)

src/pythonicDispatchStubs.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20315,9 +20315,7 @@ var band__bool__string(const var& a, const var& b, pythonic::overflow::Overflow
2031520315
throw pythonic::PythonicTypeError("TypeError: unsupported operand type(s) for &: 'bool' and 'string'");
2031620316
}
2031720317
var band__bool__bool(const var& a, const var& b, pythonic::overflow::Overflow policy, bool smallest_fit) {
20318-
int la = static_cast<int>(a.var_get<bool>());
20319-
int lb = static_cast<int>(b.var_get<bool>());
20320-
return var(la & lb);
20318+
return var(a.var_get<bool>() & b.var_get<bool>());
2032120319
}
2032220320
var band__bool__double(const var& a, const var& b, pythonic::overflow::Overflow policy, bool smallest_fit) {
2032320321
throw pythonic::PythonicTypeError("TypeError: unsupported operand type(s) for &: 'bool' and 'double'");
@@ -21436,9 +21434,7 @@ var bor__bool__string(const var& a, const var& b, pythonic::overflow::Overflow p
2143621434
throw pythonic::PythonicTypeError("TypeError: unsupported operand type(s) for |: 'bool' and 'string'");
2143721435
}
2143821436
var bor__bool__bool(const var& a, const var& b, pythonic::overflow::Overflow policy, bool smallest_fit) {
21439-
int la = static_cast<int>(a.var_get<bool>());
21440-
int lb = static_cast<int>(b.var_get<bool>());
21441-
return var(la | lb);
21437+
return var(a.var_get<bool>() | b.var_get<bool>());
2144221438
}
2144321439
var bor__bool__double(const var& a, const var& b, pythonic::overflow::Overflow policy, bool smallest_fit) {
2144421440
throw pythonic::PythonicTypeError("TypeError: unsupported operand type(s) for |: 'bool' and 'double'");
@@ -22556,9 +22552,7 @@ var bxor__bool__string(const var& a, const var& b, pythonic::overflow::Overflow
2255622552
throw pythonic::PythonicTypeError("TypeError: unsupported operand type(s) for ^: 'bool' and 'string'");
2255722553
}
2255822554
var bxor__bool__bool(const var& a, const var& b, pythonic::overflow::Overflow policy, bool smallest_fit) {
22559-
int la = static_cast<int>(a.var_get<bool>());
22560-
int lb = static_cast<int>(b.var_get<bool>());
22561-
return var(la ^ lb);
22555+
return var(a.var_get<bool>() ^ b.var_get<bool>());
2256222556
}
2256322557
var bxor__bool__double(const var& a, const var& b, pythonic::overflow::Overflow policy, bool smallest_fit) {
2256422558
throw pythonic::PythonicTypeError("TypeError: unsupported operand type(s) for ^: 'bool' and 'double'");

0 commit comments

Comments
 (0)