public abstract static class ArithmeticOpTable.BinaryOp<T> extends ArithmeticOpTable.Op
| Modifier and Type | Class and Description |
|---|---|
static class |
ArithmeticOpTable.BinaryOp.Add |
static class |
ArithmeticOpTable.BinaryOp.And |
static class |
ArithmeticOpTable.BinaryOp.Div |
static class |
ArithmeticOpTable.BinaryOp.Max |
static class |
ArithmeticOpTable.BinaryOp.Min |
static class |
ArithmeticOpTable.BinaryOp.Mul |
static class |
ArithmeticOpTable.BinaryOp.MulHigh |
static class |
ArithmeticOpTable.BinaryOp.Or |
static class |
ArithmeticOpTable.BinaryOp.Rem |
static class |
ArithmeticOpTable.BinaryOp.Sub |
static class |
ArithmeticOpTable.BinaryOp.UMulHigh |
static class |
ArithmeticOpTable.BinaryOp.Xor |
| Modifier | Constructor and Description |
|---|---|
protected |
BinaryOp(String operation,
boolean associative,
boolean commutative) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
abstract Constant |
foldConstant(Constant a,
Constant b)
Applies this operation to
a and b. |
abstract Stamp |
foldStamp(Stamp a,
Stamp b)
Apply the operation to two Stamps.
|
Constant |
getZero(Stamp stamp)
Check whether this operation has a zero {@code z == a .
|
int |
hashCode() |
boolean |
isAssociative()
Checks whether this operation is associative.
|
boolean |
isCommutative()
Checks whether this operation is commutative.
|
boolean |
isNeutral(Constant n)
Check whether a
Constant is a neutral element for this operation. |
String |
toString() |
ArithmeticOpTable.BinaryOp<T> |
unwrap() |
protected BinaryOp(String operation, boolean associative, boolean commutative)
public abstract Constant foldConstant(Constant a,
Constant b)
a and b.null if applying it would raise
an exception (e.g., ArithmeticException for dividing by 0)public final boolean isAssociative()
(a . b) . c == a . (b . c) for all a, b, c. Note that you still have to be
careful with inverses. For example the integer subtraction operation will report
true here, since you can still reassociate as long as the correct negations are
inserted.public final boolean isCommutative()
a . b == b . a for all a, b.public boolean isNeutral(Constant n)
Constant is a neutral element for this operation. A neutral
element is any element n where a . n == a for all a.n - the Constant that should be testeda: a . n == apublic Constant getZero(Stamp stamp)
z == a . a for each a. Examples of
operations having such an element are subtraction and exclusive-or. Note that this may be
different from the numbers tested by ArithmeticOpTable.BinaryOp.isNeutral(Constant).stamp - a Stampz such that z == a . a for each a in
stamp if it exists, otherwise nullpublic ArithmeticOpTable.BinaryOp<T> unwrap()
public int hashCode()
hashCode in class ArithmeticOpTable.Oppublic boolean equals(Object obj)
equals in class ArithmeticOpTable.Oppublic String toString()
toString in class ArithmeticOpTable.Op