From 2dad77ba326e5266d6447c69824896d1b458c08f Mon Sep 17 00:00:00 2001 From: Marcel Keller Date: Tue, 24 May 2022 16:54:30 +0200 Subject: [PATCH] More flexible conversion. --- Compiler/GC/types.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Compiler/GC/types.py b/Compiler/GC/types.py index 6c3abad0a..b34e68c82 100644 --- a/Compiler/GC/types.py +++ b/Compiler/GC/types.py @@ -154,9 +154,15 @@ def load_other(self, other): self.set_length(self.n or util.int_len(other)) self.load_int(other) elif isinstance(other, regint): - assert(other.size == math.ceil(self.n / self.unit)) - for i, (x, y) in enumerate(zip(self, other)): + assert self.unit == 64 + n_units = int(math.ceil(self.n / self.unit)) + n_convs = min(other.size, n_units) + for i in range(n_convs): + x = self[i] + y = other[i] self.conv_regint(min(self.unit, self.n - i * self.unit), x, y) + for i in range(n_convs, n_units): + inst.ldbits(self[i], min(self.unit, self.n - i * self.unit), 0) elif (isinstance(self, type(other)) or isinstance(other, type(self))) \ and self.n == other.n: for i in range(math.ceil(self.n / self.unit)):