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); }
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); }
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); }
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); }
public void Push(PopTree t) { _machineStack.Push(t); }
public void Consume(PopTree t) { _PopList.Add(t); }
public void Add(PopTree tree) { PopTrees.Add(tree); }
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; }
public void Push( PopTree t) { _machineStack.Push( t ); }
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; }
public void Add( PopTree tree ) { PopTrees.Add( tree ); }
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; }