Skip to content

Commit

Permalink
Additional functionality in binary circuits.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed May 2, 2024
1 parent 6ce15d4 commit 59a4e83
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Compiler/GC/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,14 @@ def _xor(self, other):
else:
return self.clear_op(other, None, inst.xorcbi, operator.xor)
def _and(self, other):
return NotImplemented
try:
return cbits.get_type(self.n)(regint(self) & regint(other))
except CompilerError:
return NotImplemented
__radd__ = __add__
def __mul__(self, other):
if isinstance(other, cbits):
return NotImplemented
return cbits.get_type(self.n)(regint(self) * regint(other))
else:
try:
res = cbits.get_type(min(self.max_length,
Expand Down Expand Up @@ -539,6 +542,13 @@ def __add__(self, other):
def __mul__(self, other):
if isinstance(other, int):
return self.mul_int(other)
elif isinstance(other, cint):
try:
other = cbits.get_type(self.unit)(regint(other))
except CompilerError:
return NotImplemented
if self.n == 1:
return self.bit_compose([self] * self.unit) & other
try:
if (self.n, other.n) == (1, 1):
return self & other
Expand Down

0 comments on commit 59a4e83

Please sign in to comment.