private bool performLeaveReproduction() { bool result = false; ArrayList leaveBlocks = new ArrayList(); foreach (BasicBlock block in blockList) { int count = block.Body.Count; if (count > 0 && count <= 2) { Node lastNode = block.Body[count-1]; if (lastNode is Leave && lastNode.Parent is MethodBodyBlock) leaveBlocks.Add(block); } } ArrayList leaveBlocksToRemove = new ArrayList(); foreach (BasicBlock block in leaveBlocks) { Node opt = (block.Body.Count == 2) ? block.Body[0] : null; ArrayList prevBlocksToRemove = new ArrayList(); foreach (BasicBlock b in block.Prev) if (b.Next.Count == 1 && b.Body.Count > 0) { NodeArray body = b.Body; Node lastNode = body[body.Count-1]; if (! (lastNode is Branch)) { result = true; prevBlocksToRemove.Add(b); if (opt != null) { Node n = opt.Clone(); n.Options[BasicBlock.BASIC_BLOCK_OPTION] = b; body.Add(n); lastNode = lastNode.Next = n; } Node l = new Leave(); l.Options[BasicBlock.BASIC_BLOCK_OPTION] = b; body.Add(l); lastNode.Next = l; } } foreach (BasicBlock b in prevBlocksToRemove) { b.Next.Remove(block); block.Prev.Remove(b); } if (block.Prev.Count == 0) leaveBlocksToRemove.Add(block); } foreach (BasicBlock block in leaveBlocksToRemove) blockList.Remove(block); return result; }
protected internal override void VisitLeave(Leave node, object data) { StackTypes stack = data as StackTypes; if(node.Parent is FilterBlock) Verifier.ProcessEndFilter(stack); else if(node.Parent is MethodBodyBlock) Verifier.ProcessRet(new TypeEx((node.Parent as MethodBodyBlock).ReturnType) , stack); else //CatchBlock || ProtectedBlock || UserFilteredBlock => stack should be empty Verifier.ProcessLeave(stack); if(node.Next != null) AddTask(node.Next,stack); }
protected override void VisitLeave(Leave node, object data) { if (node.Parent is ProtectedBlock) AddTask(node.Next); else if (node.Parent is CatchBlock) AddTask(node.Next); else if (! (node.Parent is MethodBodyBlock)) throw new NodeNotSupportedException(node); }
protected internal virtual void VisitLeave(Leave node, object data) { throw new NodeNotSupportedException(node); }
protected override void VisitLeave(Leave downNode, object o) { this.exitData.Add(o); }
protected override void VisitLeave(Leave upNode, object o) { State state = o as State; MethodBodyBlock mbbUpNode = upNode.Parent as MethodBodyBlock; if (mbbUpNode.ReturnType != typeof(void)) { Creators crtrs = BTValue.Merge((state.Stack.Pop() as BTValue).FromStack(), this.ret); if (! crtrs.IsEmpty) throw new LiftException(crtrs); } Annotation.SetNodeBTType(upNode, BTType.eXclusive); }
protected override void VisitLeave(Leave upNode, object o) { throw new InternalException(); }
protected internal override void VisitLeave(Leave node, object data) { prevHasNext = false; if(node.Parent is MethodBodyBlock) generator.Emit(OpCodes.Ret); else if(node.Parent is ProtectedBlock || node.Parent is CatchBlock) { generator.Emit(OpCodes.Leave, GetLabel(node.Next) ); tasks.Burrow(node.Next,null); } else if(node.Parent is FinallyBlock) generator.Emit(OpCodes.Endfinally); else throw new EmissionException(); }