public class Arithmetic extends Function
expressions, maxOperandsfactory, type| Constructor and Description |
|---|
Arithmetic()
Creates a default Arithmetic expression.
|
Arithmetic(java.lang.String name)
Creates a named Arithmetic expression.
|
Arithmetic(java.lang.String name,
java.lang.String type)
Creates a named and typed Arithmetic expression.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Number |
divide(java.lang.Object first,
java.lang.Object second)
Computes the quotient of two numerical values.
|
java.lang.Number |
evaluate()
Executes this Arithmetic on its operands.
|
protected java.lang.Number |
minus(java.lang.Object first,
java.lang.Object second)
Computes the difference of two numerical values.
|
protected java.lang.Number |
modulo(java.lang.Object first,
java.lang.Object second)
Computes the modulo of two numerical values.
|
protected void |
nameCheck()
Checks the name of an Arithmetic expression and sets the expected
number of operands.
|
protected java.lang.Number |
negate(java.lang.Object value)
Computes the negation of a numerical value.
|
protected java.lang.Number |
plus(java.lang.Object first,
java.lang.Object second)
Computes the sum of two numerical values.
|
void |
rebind(java.lang.Object result)
Rebinds the unbound operands of this Arithmetic expression, so that it
yields the given expected result.
|
protected java.lang.Number |
times(java.lang.Object first,
java.lang.Object second)
Computes the product of two numerical values.
|
protected void |
typeCheck()
Checks the types of the operands of this Arithmetic expression.
|
addExpression, assign, equals, getExpressions, getType, hashCode, isAssignable, isBound, operand, rebind, resolve, setName, toString, unbindgetName, isBottom, isOrdered, setTypesafeEquals, safeHashCode, semanticErrorpublic Arithmetic()
public Arithmetic(java.lang.String name)
name - the arithmetic operator name.public Arithmetic(java.lang.String name,
java.lang.String type)
name - the name of the arithmetic operator.type - the result type of the expression.protected void nameCheck()
protected void typeCheck()
public java.lang.Number evaluate()
evaluate in class Expressionpublic void rebind(java.lang.Object result)
rebind in class Expressionresult - the expected result of this Arithmetic expression.protected java.lang.Number negate(java.lang.Object value)
value - a numerical value.protected java.lang.Number plus(java.lang.Object first,
java.lang.Object second)
first - the first numerical value.second - the second numerical value.protected java.lang.Number minus(java.lang.Object first,
java.lang.Object second)
first - the first numerical value.second - the second numerical value.protected java.lang.Number times(java.lang.Object first,
java.lang.Object second)
first - the first numerical value.second - the second numerical value.protected java.lang.Number divide(java.lang.Object first,
java.lang.Object second)
first - the first numerical value.second - the second numerical value.protected java.lang.Number modulo(java.lang.Object first,
java.lang.Object second)
first - the first numerical value.second - the second numerical value.