コード例 #1
0
        /// <summary>
        /// Replaces all variables not found in a guard with one.
        /// </summary>
        /// <param name="gate"></param>
        /// <param name="monitor"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private IGate ReplaceNonGuardVariables(IGate gate, Guard monitor)
        {
            // get variables referenced in the condition
            var variables = monitor.PreCondition
                            .SelectAll(e => e is IVariableCondition)
                            .OfType <IVariableCondition>()
                            .Select(u => u.Variable)
                            .Distinct();

            var vset = new HashSet <Variable>(variables);

            // TraceDependencies("monitor variables: {0}", variables.ToSeparatorList());

            IGate r = gate
                      .Replace(g =>
            {
                if (g is IVariableCondition)
                {
                    var vc = (IVariableCondition)g;
                    if (!vset.Contains(vc.Variable))
                    {
                        g = Gate.Constant(true);
                    }
                }

                return(g);
            })
                      .Simplify();

            return(r);
        }
コード例 #2
0
        private IGate ReplaceTransitionVariablesHandler(TransitionSet tset, IGate q, bool value)
        {
            var result = q;

            if (result is IVariableCondition)
            {
                var vc = ((IVariableCondition)result);
                if (!tset.Contains(vc.Variable))
                {
                    result = Gate.Constant(value);
                }
            }

            return(result);
        }