Class ExecutionContext


  • public class ExecutionContext
    extends java.lang.Object
    Makes up the execution context, holding the available operators and the execution stack.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Operators operators  
      private java.util.Stack<java.lang.Object> stack  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExecutionContext​(Operators operatorSet)
      Creates a new execution context.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Operators getOperators()
      Returns the operator set used by this execution context.
      java.util.Stack<java.lang.Object> getStack()
      Returns the stack used by this execution context.
      int popInt()
      Pops a value of type int from the stack.
      java.lang.Number popNumber()
      Pops a number (int or real) from the stack.
      float popReal()
      Pops a number from the stack and returns it as a real value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • operators

        private final Operators operators
      • stack

        private final java.util.Stack<java.lang.Object> stack
    • Constructor Detail

      • ExecutionContext

        public ExecutionContext​(Operators operatorSet)
        Creates a new execution context.
        Parameters:
        operatorSet - the operator set
    • Method Detail

      • getStack

        public java.util.Stack<java.lang.Object> getStack()
        Returns the stack used by this execution context.
        Returns:
        the stack
      • getOperators

        public Operators getOperators()
        Returns the operator set used by this execution context.
        Returns:
        the operator set
      • popNumber

        public java.lang.Number popNumber()
        Pops a number (int or real) from the stack. If it's neither data type, a ClassCastException is thrown.
        Returns:
        the number
      • popInt

        public int popInt()
        Pops a value of type int from the stack. If the value is not of type int, a ClassCastException is thrown.
        Returns:
        the int value
      • popReal

        public float popReal()
        Pops a number from the stack and returns it as a real value. If the value is not of a numeric type, a ClassCastException is thrown.
        Returns:
        the real value