Example #1
0
        /// <summary>
        /// Стартовые настройки алгоритма
        /// </summary>
        private void StartSettings()
        {
            IN     = new Dictionary <Guid, ActiveVar>();
            OUT    = new Dictionary <Guid, ActiveVar>();
            DefSet = new Dictionary <Guid, DSet>();
            UseSet = new Dictionary <Guid, USet>();

            foreach (var B in CFG.CFGNodes)
            {
                IN.Add(B.BlockId, new ActiveVar());
                OUT.Add(B.BlockId, new ActiveVar());

                var duSets = new DUSets(B);

                DefSet.Add(B.BlockId, duSets.DSet);
                UseSet.Add(B.BlockId, duSets.USet);
            }
        }
Example #2
0
        /// <summary>
        /// ---- Test 3
        /// </summary>
        /// <returns></returns>
        public bool Test3()
        {
            // -------------------------------------------------------------------
            // Создание базового блока
            // -------------------------------------------------------------------
            var i = new Var("i");
            var j = new Var("j");
            var k = new Var("k");
            var l = new Var("l");

            BasicBlock B = new BasicBlock(new List <Node> {
                AssignC(i, k, new IntConst(1), OpCode.Plus),     // 0: i = k + 1
                AssignC(j, l, new IntConst(1), OpCode.Plus),     // 1: j = l + 1
                AssignC(k, i),                                   // 2: k = i
                AssignC(l, j)                                    // 3: l = j
            });

            // -------------------------------------------------------------------
            // Тест для DefUse множеств
            // -------------------------------------------------------------------

            DUSets DS   = new DUSets(B);
            var    defS = DS.DSet;
            var    useS = DS.USet;

            B = new BasicBlock(new List <Node> {
                AssignC(i, i, new IntConst(1), OpCode.Plus),     // 0: i = i + 1
                AssignC(j, j, new IntConst(1), OpCode.Plus),     // 1: j = j + 1
            });

            // -------------------------------------------------------------------
            // Тест для DefUse множеств
            // -------------------------------------------------------------------

            DS   = new DUSets(B);
            defS = DS.DSet;
            useS = DS.USet;

            // Должна получиться истина
            return(true);
        }