Esempio n. 1
0
 public PopTreeList Build(ICollection instructions)
 {
     foreach (Instruction i in instructions)
     {
         PopTree p    = new PopTree(i);
         int     pops = InstructionInfo.Pops(i, _machineStack.Count);
         if (pops > _machineStack.Count)
         {
             // can happen with exception blocks whose support is flaky.
             //Console.WriteLine("Attempting to pop more than machine has: " + i.OpCode.ToString() + " " + i.Operand);
             return(null);
         }
         for (int x = 0; x < pops; x++)
         {
             p.Consume(Pop());
         }
         if (InstructionInfo.Pushes(i))
         {
             Push(p);
         }
         else
         {
             _popTreeList.Add(p);
         }
     }
     return(_popTreeList);
 }
Esempio n. 2
0
        string VisitPopTree(PopTree parent, string name)
        {
            // support elements?  foo().Field[i].method()
            if (name != "Test1")
            {
                return(null);
            }
            int d = MaxChain(parent);

            if (d > 5)
            {
                return(name + ":" + d);
            }

            return(null);
        }
Esempio n. 3
0
            public ArrayList FilteredTops(params OpCode[] opcodes)
            {
                ArrayList tops    = new ArrayList();
                PopTree   current = this;

                while (current != null)
                {
                    // Want Continous Chain.
                    if (!IsOpCode(opcodes, current._instruction.OpCode))
                    {
                        return(tops);
                    }
                    tops.Add(current);
                    current = current.LastChild;
                }
                return(tops);
            }
Esempio n. 4
0
        int MaxChain(PopTree tree)
        {
            if (tree._PopList.Count == 0)
            {
                return(0);
            }
            int max = 0;

            foreach (PopTree t in tree._PopList)
            {
                //int d = t.Depth;
                ArrayList tops = t.FilteredTops(OpCodes.Call, OpCodes.Calli, OpCodes.Callvirt, OpCodes.Ldfld,
                                                OpCodes.Ldsfld);
                if (tops.Count > max)
                {
                    max = tops.Count;
                }
            }
            return(max + 1);
        }
Esempio n. 5
0
 public void Push(PopTree t)
 {
     _machineStack.Push(t);
 }
Esempio n. 6
0
 public void Consume(PopTree t)
 {
     _PopList.Add(t);
 }
Esempio n. 7
0
 public void Add(PopTree tree)
 {
     PopTrees.Add(tree);
 }
Esempio n. 8
0
        string VisitPopTree( PopTree parent, string name )
        {
            // support elements?  foo().Field[i].method()
            if (name != "Test1")
                return null;
            int d = MaxChain( parent );
            if( d > 5 )
            {
                return name + ":" + d; 
            }

            return null;
        }
Esempio n. 9
0
 public void Push( PopTree t)
 {
     _machineStack.Push( t );
 }
Esempio n. 10
0
 public PopTreeList Build( ICollection instructions )
 {
     foreach (Instruction i in instructions)
     {
         PopTree p = new PopTree(i);
         int pops = InstructionInfo.Pops(i,_machineStack.Count);
         if (pops > _machineStack.Count)
         {
             // can happen with exception blocks whose support is flaky.
             //Console.WriteLine("Attempting to pop more than machine has: " + i.OpCode.ToString() + " " + i.Operand);
             return null;
         }
         for (int x = 0; x < pops; x++)
         {
             p.Consume(Pop());
         }
         if (InstructionInfo.Pushes(i))
         {
             Push(p);
         }
         else
         {
             _popTreeList.Add(p);
         }
     }
     return _popTreeList;
 }
Esempio n. 11
0
 public void Consume(PopTree t)
 {
     _PopList.Add(t);
 }
Esempio n. 12
0
 public void Add( PopTree tree )
 {
     PopTrees.Add( tree );
 }
Esempio n. 13
0
 int MaxChain(PopTree tree)
 {
     if (tree._PopList.Count == 0)
         return 0;
     int max = 0;
     foreach (PopTree t in tree._PopList)
     {
         //int d = t.Depth;
         ArrayList tops = t.FilteredTops(OpCodes.Call, OpCodes.Calli, OpCodes.Callvirt, OpCodes.Ldfld,
                      OpCodes.Ldsfld);
         if (tops.Count > max)
             max = tops.Count;
     }
     return max + 1;
 }