public static Block FindCommonParent(Block a, Block b) { Block result = a; while (! (result == null || result == b || b.IsChildTo(result))) result = result.Parent; return result; }
public bool IsChildTo(Block block) { return (Parent == block) || (Parent != null ? Parent.IsChildTo(block) : false); }
protected Node(int nextCount) { parent = null; options = new OptionsHash(); prevArray = new NodeArray(); prevIndexes = new ArrayList(); nextArray = new NextNodeArray(this,nextCount); }
protected internal virtual void setParent(Block parent) { if (this.parent != null) this.parent.removeChild(this); this.parent = parent; if (parent != null) parent.addChild(this); }
protected internal override void setParent(Block parent) { if (parent == null) ResetNextArray(0); else if (! (parent is MethodBodyBlock) && ! (parent is FinallyBlock) && ! (parent is FilterBlock)) ResetNextArray(1); base.setParent(parent); }
protected internal override void setParent(Block parent) { base.setParent(parent); setVarByIndex(); }
public DummyNode(Block parent) : base() { this.setParent(parent); }
protected void SiftBlocks(Block node, object data) { BasicBlock basicBlock = data as BasicBlock; basicBlock.AddNode(node); if (node is ProtectedBlock) { foreach (EHBlock block in (node as ProtectedBlock)) { if (block.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION)) basicBlock.AddLink(block.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock); else { BasicBlock newBlock = createBasicBlock(); basicBlock.AddLink(newBlock); AddTask(block,newBlock); } } } else if (node is UserFilteredBlock) { FilterBlock block = (node as UserFilteredBlock).Filter; if (block.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION)) basicBlock.AddLink(block.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock); else { BasicBlock newBlock = createBasicBlock(); basicBlock.AddLink(newBlock); AddTask(block,newBlock); } } if (node.Next.Options.ContainsOption(BasicBlock.BASIC_BLOCK_OPTION)) basicBlock.AddNextBasicBlock(node.Next.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock); else { BasicBlock nextBlock = createBasicBlock(); basicBlock.AddNextBasicBlock(nextBlock); AddTask(node.Next,nextBlock); } }
protected internal override void VisitProtectedBlock(ProtectedBlock node, object data) { generator.BeginExceptionBlock(); currentBlock = node; tasks.Suspend(); AddTask(node.Next,null); }
protected internal override void VisitMethodBodyBlock(MethodBodyBlock node, object data) { currentBlock = node; AddTask(node.Next,null); }
protected internal override void VisitFinallyBlock(FinallyBlock node, object data) { generator.BeginFinallyBlock(); currentBlock = node; tasks.Suspend(); AddTask(node.Next,null); }
protected internal override void VisitCatchBlock(CatchBlock node, object data) { generator.BeginCatchBlock(node.Type); currentBlock = node; tasks.Suspend(); AddTask(node.Next,null); }
internal void OnResume() { if(currentBlock is ProtectedBlock) { ProtectedBlock node = currentBlock as ProtectedBlock; for(int i = node.Count - 1; i>=0; i--) AddTask(node[i],null); } else if(currentBlock is EHBlock) { EHBlock block = currentBlock as EHBlock; if(block.TryBlock[block.TryBlock.Count - 1] == block) { // The last handler generator.EndExceptionBlock(); tasks.TryResume(); } } else throw new EmissionException(); currentBlock = currentBlock.Parent; }