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 int
The plus operator.static final int
The bitwise and operator.static final int
The divide operator.static final int
The left shift operator.static final int
The modula operator.static final int
The multiply operator.static final int
The bitwise not operator (unary).protected int
The operation.static final int
The bitwise or operator.static final int
The right shift operator.static final int
The minus operator.static final int
The unsinged right shift operator.static final int
The bitwise xor operator.Fields inherited from class jadex.javaparser.javaccimpl.ExpressionNode
constant, constant_value, expressiontext, imports, static_type, text
Fields inherited from class jadex.javaparser.javaccimpl.SimpleNode
children, id, parent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test if two nodes are equal.static int
fromString
(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.int
hashCode()
Get the hash code for the node.void
Precompute the static type and constant value if possible.protected void
Precompile unary node.void
Set the token text.Create a string representation of this node and its subnodes.static String
toString
(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, toString
Methods 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:
setText
in classExpressionNode
- Parameters:
text
- The token text.
-
precompile
public void precompile()Precompute the static type and constant value if possible.- Overrides:
precompile
in classExpressionNode
-
getValue
Evaluate the expression in the given state with respect to given parameters.- Specified by:
getValue
in interfaceIParsedExpression
- Specified by:
getValue
in 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:
toPlainString
in interfaceNode
- Overrides:
toPlainString
in 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:
equals
in classExpressionNode
-
hashCode
public int hashCode()Get the hash code for the node.- Overrides:
hashCode
in classExpressionNode
-