Beispiel #1
0
        /// <summary>
        ///     Provides the states used in an expression
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static List <State> GetStates(Expression expression)
        {
            List <State> retval = new List <State>();

            if (expression != null)
            {
                foreach (IValue value in expression.GetLiterals())
                {
                    State state = value as State;
                    if (state != null)
                    {
                        retval.Add(state);
                    }
                }

                Call call = expression as Call;
                if (call != null)
                {
                    Function function = call.Called.GetStaticCallable() as Function;
                    if (function != null)
                    {
                        foreach (IValue value in function.GetLiterals())
                        {
                            State state = value as State;
                            if (state != null)
                            {
                                retval.Add(state);
                            }
                        }
                    }
                }
            }

            return(retval);
        }