コード例 #1
0
        public void EmitEquation(TextWriter where, InvariantQuery <APC> invariantDB)
        {
            string head = this.parent.Head(); // bn(... )

            StringBuilder bodyAsString = new StringBuilder();

            foreach (string s in this.to.FormalParameters)
            {
                string actualParameter = this.renamings[s];

                if (actualParameter == null)
                {
                    actualParameter = s; // if it is not there, it means that it is not renamed, i.e. it is the identity
                }
                bodyAsString.Append(actualParameter + BenigniMain.SEPPARAM);
            }

            if (bodyAsString.Length > BenigniMain.SEPPARAM.Length)
            {
                bodyAsString.Remove(bodyAsString.Length - BenigniMain.SEPPARAM.Length, BenigniMain.SEPPARAM.Length); // remove the last ", "
            }
            else if (this.parent.Condition != null)
            { // no successors, so I just write down the parameters,
                bodyAsString.Append(BenigniMain.FormalParametersAsString(this.parent.FormalParameters));
            }
            else
            {
                bodyAsString.Append(BenigniMain.EMPTY);
            }

            string succ = BenigniMain.BLOCKPREFIX + this.To.Block.Index;

            string result = String.Format("{0} {1} {2}( {3} ) ", head, BenigniMain.TRANS, succ, bodyAsString.ToString());

            string postState = invariantDB(this.To.Block.First);

            if (this.parent.Condition != null) // Is there a condition on the rewriting rule?
            {
                result = String.Format("{0} | {1} -> 1", result, this.parent.Condition);

                if (postState != null && postState.Length > 0)
                {
                    result += string.Format(", {0}", postState);
                }
            }
            else if (postState != null && postState.Length > 0)
            {
                result = String.Format("{0} | {1}", result, postState);
            }

            result = BenigniMain.SanitizeString(result);

            // Here we output the equation
            where.WriteLine(result);
        }
コード例 #2
0
 internal string Head()
 {
     return(string.Format("{0}{1} ({2})", BenigniMain.BLOCKPREFIX, this.id.Index, BenigniMain.FormalParametersAsString(this.FormalParameters)));
 }