Package jadex.javaparser.javaccimpl
Class MathNode
java.lang.Object
jadex.javaparser.javaccimpl.SimpleNode
jadex.javaparser.javaccimpl.ExpressionNode
jadex.javaparser.javaccimpl.MathNode
- All Implemented Interfaces:
IParsedExpression,Node,Serializable
Math node performs mathematical operations on it's (one or two) child nodes.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe plus operator.static final intThe bitwise and operator.static final intThe divide operator.static final intThe left shift operator.static final intThe modula operator.static final intThe multiply operator.static final intThe bitwise not operator (unary).protected intThe operation.static final intThe bitwise or operator.static final intThe right shift operator.static final intThe minus operator.static final intThe unsinged right shift operator.static final intThe bitwise xor operator.Fields inherited from class jadex.javaparser.javaccimpl.ExpressionNode
constant, constant_value, expressiontext, imports, static_type, textFields inherited from class jadex.javaparser.javaccimpl.SimpleNode
children, id, parent -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest if two nodes are equal.static intfromString(String operator) Convert an operator from a string representation.getUnaryValue(jadex.common.IValueFetcher fetcher) Evaluate the term.getValue(jadex.common.IValueFetcher fetcher) Evaluate the expression in the given state with respect to given parameters.inthashCode()Get the hash code for the node.voidPrecompute the static type and constant value if possible.protected voidPrecompile unary node.voidSet the token text.Create a string representation of this node and its subnodes.static StringtoString(int operator) Convert an operator to a string representation.Methods inherited from class jadex.javaparser.javaccimpl.ExpressionNode
appendText, getConstantValue, getExpressionText, getParameters, getStaticType, getText, getUnboundParameterNodes, isConstant, precompileTree, setConstant, setConstantValue, setExpressionText, setStaticType, subnodeToString, throwEvaluationException, throwParseException, toString, toStringMethods inherited from class jadex.javaparser.javaccimpl.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
-
Field Details
-
ADD
public static final int ADDThe plus operator.- See Also:
-
SUBSTRACT
public static final int SUBSTRACTThe minus operator.- See Also:
-
MULTIPLY
public static final int MULTIPLYThe multiply operator.- See Also:
-
DIVIDE
public static final int DIVIDEThe divide operator.- See Also:
-
MODULO
public static final int MODULOThe modula operator.- See Also:
-
AND
public static final int ANDThe bitwise and operator.- See Also:
-
OR
public static final int ORThe bitwise or operator.- See Also:
-
XOR
public static final int XORThe bitwise xor operator.- See Also:
-
NOT
public static final int NOTThe bitwise not operator (unary).- See Also:
-
LSHIFT
public static final int LSHIFTThe left shift operator.- See Also:
-
RSHIFT
public static final int RSHIFTThe right shift operator.- See Also:
-
URSHIFT
public static final int URSHIFTThe unsinged right shift operator.- See Also:
-
op
protected int opThe operation.
-
-
Constructor Details
-
MathNode
public MathNode(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create a node.- Parameters:
p- The parser.id- The id.
-
-
Method Details
-
setText
Set the token text.- Overrides:
setTextin classExpressionNode- Parameters:
text- The token text.
-
precompile
public void precompile()Precompute the static type and constant value if possible.- Overrides:
precompilein classExpressionNode
-
getValue
Evaluate the expression in the given state with respect to given parameters.- Specified by:
getValuein interfaceIParsedExpression- Specified by:
getValuein classExpressionNode- Parameters:
params- The parameters (string, value pairs), if any.- Returns:
- The value of the term.
-
precompileUnary
protected void precompileUnary()Precompile unary node. -
getUnaryValue
Evaluate the term.- Parameters:
params- The parameters (string, value).- Returns:
- The value of the term.
-
toPlainString
Create a string representation of this node and its subnodes.- Specified by:
toPlainStringin interfaceNode- Overrides:
toPlainStringin classExpressionNode- Returns:
- A string representation of this node.
-
toString
Convert an operator to a string representation.- Parameters:
operator- The operator- Returns:
- A string representation of the operator.
-
fromString
Convert an operator from a string representation.- Parameters:
operator- The operator as string.- Returns:
- The int value of the operator.
-
equals
Test if two nodes are equal.- Overrides:
equalsin classExpressionNode
-
hashCode
public int hashCode()Get the hash code for the node.- Overrides:
hashCodein classExpressionNode
-