/// <summary>
 /// Push list of operands onto the operands stack
 /// </summary>
 public static void PushFromList(this EpsStack <Operand> stack, List <Operand> operands)
 {
     foreach (var operand in operands)
     {
         stack.Push(operand);
     }
 }
        /// <summary>
        /// Move top of operands stack into a list
        /// </summary>
        public static List <Operand> PopToList(this EpsStack <Operand> stack, int count)
        {
            var operands = new List <Operand>();

            for (int i = 0; i < count; i++)
            {
                operands.Add(stack.Pop());
            }

            operands.Reverse();

            return(operands);
        }
Пример #3
0
        /// <summary>
        /// Find the dictionary within the dictionary stack that holds the given key
        /// </summary>
        /// <param name="dictionaryStack"></param>
        /// <param name="key"></param>
        /// <returns>the found dictionary or null</returns>
        public static EpsDictionary FindDictionary(EpsStack <EpsDictionary> dictionaryStack, Operand key)
        {
            for (int i = dictionaryStack.Count - 1; i >= 0; i--)
            {
                var dict = dictionaryStack[i];
                var op   = dict.TryFind(key);

                if (op != null)
                {
                    return(dict);
                }
            }

            return(null);
        }
Пример #4
0
        /// <summary>
        /// Remove all non-permanet dictionaries from the dictionary stack
        /// </summary>
        /// <param name="dictionaryStack"></param>
        public static void RemoveNonPermanentDictionaries(EpsStack <EpsDictionary> dictionaryStack)
        {
            int i = 0;

            while (i < dictionaryStack.Count)
            {
                var dict = dictionaryStack[i];

                if (!dict.IsPermanent)
                {
                    dictionaryStack.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
        }
 /// <summary>
 /// Pop a string value from the stack
 /// </summary>
 public static string PopStringValue(this EpsStack <Operand> stack)
 {
     return(OperandHelper.GetStringValue(stack.Pop()));
 }
 /// <summary>
 /// Pop a file operand from the stack
 /// </summary>
 public static FileOperand PopFile(this EpsStack <Operand> stack)
 {
     return((FileOperand)stack.Pop());
 }
 /// <summary>
 /// Pop a Dictionary operand from the stack
 /// </summary>
 public static DictionaryOperand PopDictionary(this EpsStack <Operand> stack)
 {
     return((DictionaryOperand)stack.Pop());
 }
 /// <summary>
 /// Peek an array operand from the stack
 /// </summary>
 public static ArrayOperand PeekArray(this EpsStack <Operand> stack)
 {
     return((ArrayOperand)stack.Peek());
 }
 /// <summary>
 /// Pop an integer operand from the stack
 /// </summary>
 public static IntegerOperand PopInteger(this EpsStack <Operand> stack)
 {
     return((IntegerOperand)stack.Pop());
 }
Пример #10
0
 /// <summary>
 /// Pop a name operand from the stack
 /// </summary>
 public static NameOperand PopName(this EpsStack <Operand> stack)
 {
     return((NameOperand)stack.Pop());
 }
Пример #11
0
 /// <summary>
 /// Pop a string operand from the stack
 /// </summary>
 public static StringOperand PopString(this EpsStack <Operand> stack)
 {
     return((StringOperand)stack.Pop());
 }
Пример #12
0
 /// <summary>
 /// Pop a boolean operand from the stack
 /// </summary>
 public static BooleanOperand PopBoolean(this EpsStack <Operand> stack)
 {
     return((BooleanOperand)stack.Pop());
 }
Пример #13
0
 /// <summary>
 /// Pop a real or integer operand from the stack and return
 /// its value as double.
 /// </summary>
 /// <returns>a double value</returns>
 public static double PopRealValue(this EpsStack <Operand> stack)
 {
     return(OperandHelper.GetRealValue(stack.Pop()));
 }
Пример #14
0
 /// <summary>
 /// Pop an integer value from the stack
 /// </summary>
 public static int PopIntegerValue(this EpsStack <Operand> stack)
 {
     return(((IntegerOperand)stack.Pop()).Value);
 }