public class PlusOperation extends CallableOperation
Operation that represents the addition operator (+). It is used to
perform addition on two numeric values or characters.
As an Operation, a call to the plus operation with two arguments is formally
represented as:
+ : [t, t] -> t
where both operands are of type t (one of: byte, short, char, int, long, float, or
double). Two operands can have different types. The output type t is determined by the
Java language rules for numeric promotion.| Constructor and Description |
|---|
PlusOperation()
Creates a plus operation that performs addition.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendCode(Type declaringType,
TypeTuple inputTypes,
Type outputType,
java.util.List<Variable> inputVars,
java.lang.StringBuilder b)
Produces a Java source code representation of this statement and appends it to the given
StringBuilder.
|
boolean |
equals(@Nullable java.lang.Object obj) |
ExecutionOutcome |
execute(java.lang.Object[] input)
Performs this operation using the array of input values.
|
java.lang.String |
getName()
Returns the name for the operation.
|
int |
hashCode() |
private double |
toDouble(java.lang.Object x)
Converts the given object to a double.
|
private float |
toFloat(java.lang.Object x)
Converts the given object to a float.
|
private int |
toInt(java.lang.Object x)
Converts the given object to an int.
|
private long |
toLong(java.lang.Object x)
Converts the given object to a long.
|
java.lang.String |
toParsableString(Type declaringType,
TypeTuple inputTypes,
Type outputType)
Returns a string representation of this Operation (not an invocation of this Operation), which
can be read by the static parse method for the class in which the method is defined.
|
java.lang.String |
toString() |
getArgumentString, getReflectionObject, getValue, isConstantField, isConstructorCall, isMessage, isMethodCall, isNonreceivingValue, isStatic, isUncheckedCast, satisfiespublic PlusOperation()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(@Nullable java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic ExecutionOutcome execute(java.lang.Object[] input)
CallableOperationexecute in class CallableOperationinput - array containing appropriate inputs to operationprivate int toInt(java.lang.Object x)
x - the object to convertprivate long toLong(java.lang.Object x)
x - the object to convertprivate float toFloat(java.lang.Object x)
x - the object to convertprivate double toDouble(java.lang.Object x)
x - the object to convertpublic void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, java.util.List<Variable> inputVars, java.lang.StringBuilder b)
CallableOperationappendCode in class CallableOperationdeclaringType - the declaring type for this operationinputTypes - the input types for this operationoutputType - the output type for this operationinputVars - the list of variables that are inputs to operationb - the StringBuilder to which code is addedpublic java.lang.String toParsableString(Type declaringType, TypeTuple inputTypes, Type outputType)
CallableOperationtoParsableString in class CallableOperationdeclaringType - the declaring type for this operationinputTypes - the input types for this operationoutputType - the output type for this operationpublic java.lang.String getName()
Operation