java.lang.Object
com.maroontress.intexpr.impl.Operator
- All Implemented Interfaces:
Instruction
The instruction that pops the operand(s) from the stack, executes the
function with the operand(s), and pushes the return value to the stack.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(Deque<SyntaxNode> stack) Interacts with the specified stack of theSyntaxNode
object to build aSyntaxTree
object.int
apply
(int[] stack, int offset) Interacts with the specified stack of an integer.getSpec()
Returns theOperatorSpec
object of this operator.of
(com.maroontress.clione.Token token, OperatorType type) Creates a newOperator
object corresponding to the specified token andOperatorType
.toString()
-
Method Details
-
of
Creates a newOperator
object corresponding to the specified token andOperatorType
.- Parameters:
token
- The token corresponding to the operator.type
- The operator type (OperatorType.UNARY
orOperatorType.BINARY
).- Returns:
- The new operator.
-
getSpec
Returns theOperatorSpec
object of this operator.- Returns:
- The
OperatorSpec
object.
-
accept
Interacts with the specified stack of theSyntaxNode
object to build aSyntaxTree
object.- Specified by:
accept
in interfaceInstruction
- Parameters:
stack
- The stack of aSyntaxNode
object.
-
apply
public int apply(int[] stack, int offset) Interacts with the specified stack of an integer.- Specified by:
apply
in interfaceInstruction
- Parameters:
stack
- The stack of an integer.offset
- The position of the top of the stack.- Returns:
- The new offset of the top of the stack.
-
toString
-