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

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

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

            return(retval);
        }
예제 #2
0
        /// <summary>
        /// Indicates whether this preCondition reads the variable
        /// </summary>
        /// <param name="variable"></param>
        /// <returns></returns>
        public bool Reads(Types.ITypedElement variable)
        {
            bool retVal = false;

            if (ExpressionTree != null)
            {
                foreach (Types.ITypedElement el in ExpressionTree.GetVariables())
                {
                    if (el == variable)
                    {
                        retVal = true;
                        break;
                    }
                }

                if (!retVal)
                {
                    Interpreter.Call call = ExpressionTree as Interpreter.Call;
                    if (call != null)
                    {
                        retVal = call.Reads(variable);
                    }
                }
            }

            return(retVal);
        }
예제 #3
0
        /// <summary>
        /// Indicates that the expression is a function call using the parameter as argument value
        /// </summary>
        /// <param name="expression">The expression to evaluate</param>
        /// <param name="parameter">The parameter</param>
        /// <returns></returns>
        private bool FunctionCallOnParameter(Interpreter.Expression expression, Parameter parameter)
        {
            bool retVal = false;

            Interpreter.Call call = expression as Interpreter.Call;
            if (call != null)
            {
                foreach (Interpreter.Expression expr in call.AllParameters)
                {
                    foreach (Types.ITypedElement element in expr.GetRightSides())
                    {
                        if (element == parameter)
                        {
                            retVal = true;
                            break;
                        }
                    }
                }
            }

            return(retVal);
        }