コード例 #1
0
ファイル: VariableMapLattice.cs プロジェクト: omaragb/tlp182
        public override string /*!*/ ToString(Element /*!*/ element)
        {
            //Contract.Requires(element != null);
            Contract.Ensures(Contract.Result <string>() != null);
            Elt e = (Elt)element;

            if (IsTop(e))
            {
                return("<top>");
            }
            if (IsBottom(e))
            {
                return("<bottom>");
            }

            int k = 0;

            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
            foreach (IVariable /*!*/ key in e.SortedVariables(variableComparer))
            {
                Contract.Assert(key != null);
                if (k++ > 0)
                {
                    buffer.Append("; ");
                }
                buffer.AppendFormat("{0} = {1}", key, e[key]);
            }
            return(buffer.ToString());
        }
コード例 #2
0
ファイル: VariableMapLattice.cs プロジェクト: omaragb/tlp182
        public override IExpr /*!*/ ToPredicate(Element /*!*/ element)
        {
            //Contract.Requires(element != null);
            Contract.Ensures(Contract.Result <IExpr>() != null);
            if (IsTop(element))
            {
                return(propExprFactory.True);
            }
            if (IsBottom(element))
            {
                return(propExprFactory.False);
            }

            Elt   e      = (Elt)element;
            IExpr truth  = propExprFactory.True;
            IExpr result = truth;

            foreach (IVariable /*!*/ variable in e.SortedVariables(variableComparer))
            {
                Contract.Assert(variable != null);
                Element value = (Element)e[variable];

                if (value == null || this.microLattice.IsTop(value))
                {
                    continue;
                } // Skip variables about which we know nothing.
                if (this.microLattice.IsBottom(value))
                {
                    return(propExprFactory.False);
                }

                IExpr conjunct = this.microLattice.ToPredicate(variable, value);

                result = (result == truth) ? (IExpr)conjunct : (IExpr)propExprFactory.And(result, conjunct);
            }
            return(result);
        }