Lib.Krakatau.ssa.ssa_ops.truncate.py Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of krakatau-lib Show documentation
Show all versions of krakatau-lib Show documentation
Assembler, disassebmler, decompiler and compiler tools library for Java.
from .base import BaseOp
from ..constraints import IntConstraint
from . import bitwise_util
class Truncate(BaseOp):
def __init__(self, parent, arg, signed, width):
super(Truncate, self).__init__(parent, [arg])
self.signed, self.width = signed, width
self.rval = parent.makeVariable(arg.type, origin=self)
def propagateConstraints(self, x):
#get range of target type
w = self.width
intw = x.width
assert(w < intw)
M = 1<>1
parts = [(i-M if i>=HM else i) for i in (x.min, x.max)]
if x.min <= HM-1 <= x.max:
parts.append(HM-1)
if x.min <= HM <= x.max:
parts.append(-HM)
assert(-HM <= min(parts) <= max(parts) <= HM-1)
return IntConstraint.range(intw, min(parts), max(parts)), None, None
else:
return x, None, None
© 2015 - 2025 Weber Informatics LLC | Privacy Policy