public void FindExceptionHandlingConstructs()
        {
            //The CLR searchese top to bottom through the EH table at the end of the method declaration looking for a CATCH or FILTER handlers
            //which guarded(try) block encompasses the spot where the exception occurred (FAULT and FINALLY handlers are compeltely ignored at this pass,
            //no matter whether the exception falls in their guarded(try) blocks). Assuming that CATCH/FILTER handler was found at row N of the EH table
            // the CLR marks it (but it does NOT execute it at this point) and does a second pass through the EH table searching ONLY rows 1 to N this time.
            //On hte second pass only FAULT/FINALLY handlers are considered. Any FAULT/FILTER handler found which guarded block encompasses the instruction causing
            //the exception gets executed at this pass. Only then the CATCH/FILTER handler at row N gets executed.
            //That means that the order in which handlers appear in the EH table has precedence over their hierarchical structure in the IL (i.e. which try block is inside another try block) when determineing
            //their order of execution. Hence given a FAULT/FINALLY handler that completely contains a CATCH/FILTER handler in the IL but whose EH table entry occurs before
            // the CATCH/FILTER  handler EH table entry in the LogicalConstruct tree the CATCH/FILTER handler will be parent of the FAULT/FINALLY handler (complete reverse of theri relationship in the IL)
            //since the FAULT/FINALLY handler will be executed before the CATCH/FILTER one.


            foreach (ExceptionHandler handler in context.CFG.RawExceptionHandlers)
            {
                BlockRange tryBlockRange = GetBlockRangeFromInstructions(handler.TryStart, handler.TryEnd);

                ExceptionHandlingLogicalConstruct tryBlockExistingHandler = null;
                if (tryBlocksFound.TryGetValue(tryBlockRange, out tryBlockExistingHandler))
                {
                    AddHandlerToTryBlock(tryBlockExistingHandler, handler);
                }
                else
                {
                    BlockLogicalConstruct             theTryBlock  = CreateExceptionhandlingBlock(tryBlockRange);
                    ExceptionHandlingLogicalConstruct guardedBlock = null;

                    switch (handler.HandlerType)
                    {
                    case ExceptionHandlerType.Catch:
                        guardedBlock = new TryCatchFilterLogicalConstruct(theTryBlock, CreateCatchHandler(handler));
                        break;

                    case ExceptionHandlerType.Filter:
                        guardedBlock = new TryCatchFilterLogicalConstruct(theTryBlock, CreateFilterHandler(handler));
                        break;

                    case ExceptionHandlerType.Fault:
                        BlockRange faultBlockRange = GetBlockRangeFromInstructions(handler.HandlerStart, handler.HandlerEnd);
                        guardedBlock = new TryFaultLogicalConstruct(theTryBlock, CreateExceptionhandlingBlock(faultBlockRange));
                        break;

                    case ExceptionHandlerType.Finally:
                        BlockRange finallyBlockRange = GetBlockRangeFromInstructions(handler.HandlerStart, handler.HandlerEnd);
                        guardedBlock = new TryFinallyLogicalConstruct(theTryBlock, CreateExceptionhandlingBlock(finallyBlockRange));
                        break;
                    }

                    tryBlocksFound.Add(tryBlockRange, guardedBlock);
                }
            }
        }
		public void FindExceptionHandlingConstructs()
		{
			//The CLR searchese top to bottom through the EH table at the end of the method declaration looking for a CATCH or FILTER handlers
			//which guarded(try) block encompasses the spot where the exception occurred (FAULT and FINALLY handlers are compeltely ignored at this pass,
			//no matter whether the exception falls in their guarded(try) blocks). Assuming that CATCH/FILTER handler was found at row N of the EH table
			// the CLR marks it (but it does NOT execute it at this point) and does a second pass through the EH table searching ONLY rows 1 to N this time.
			//On hte second pass only FAULT/FINALLY handlers are considered. Any FAULT/FILTER handler found which guarded block encompasses the instruction causing
			//the exception gets executed at this pass. Only then the CATCH/FILTER handler at row N gets executed.
			//That means that the order in which handlers appear in the EH table has precedence over their hierarchical structure in the IL (i.e. which try block is inside another try block) when determineing
			//their order of execution. Hence given a FAULT/FINALLY handler that completely contains a CATCH/FILTER handler in the IL but whose EH table entry occurs before 
			// the CATCH/FILTER  handler EH table entry in the LogicalConstruct tree the CATCH/FILTER handler will be parent of the FAULT/FINALLY handler (complete reverse of theri relationship in the IL)
			//since the FAULT/FINALLY handler will be executed before the CATCH/FILTER one.


			foreach (ExceptionHandler handler in context.CFG.RawExceptionHandlers)
			{
                BlockRange tryBlockRange = GetBlockRangeFromInstructions(handler.TryStart, handler.TryEnd);

				ExceptionHandlingLogicalConstruct tryBlockExistingHandler = null;
				if (tryBlocksFound.TryGetValue(tryBlockRange, out tryBlockExistingHandler))
				{
					AddHandlerToTryBlock(tryBlockExistingHandler, handler);
				}
				else
				{
					BlockLogicalConstruct theTryBlock = CreateExceptionhandlingBlock(tryBlockRange);
					ExceptionHandlingLogicalConstruct guardedBlock = null;

					switch (handler.HandlerType)
					{
						case ExceptionHandlerType.Catch:	
							guardedBlock = new TryCatchFilterLogicalConstruct(theTryBlock, CreateCatchHandler(handler));
						break;
						case ExceptionHandlerType.Filter:		
							guardedBlock = new TryCatchFilterLogicalConstruct(theTryBlock, CreateFilterHandler(handler));
						break;
						case ExceptionHandlerType.Fault:
                            BlockRange faultBlockRange = GetBlockRangeFromInstructions(handler.HandlerStart, handler.HandlerEnd);
						    guardedBlock = new TryFaultLogicalConstruct(theTryBlock, CreateExceptionhandlingBlock(faultBlockRange));							
						break;
						case ExceptionHandlerType.Finally:
                            BlockRange finallyBlockRange = GetBlockRangeFromInstructions(handler.HandlerStart, handler.HandlerEnd);
						    guardedBlock = new TryFinallyLogicalConstruct(theTryBlock, CreateExceptionhandlingBlock(finallyBlockRange));	
						break;
					}

					tryBlocksFound.Add(tryBlockRange, guardedBlock);
				}
			}
		}
        /// <summary>
        /// Generates the try/finally construct that is represented by the specifed exception handler info and attaches it to the logical tree.
        /// </summary>
        /// <param name="handlerInfo"></param>
        private void GenerateTryFinallyHandler(YieldExceptionHandlerInfo handlerInfo)
        {
            finallyBlocks = new HashSet<ILogicalConstruct>();

            entryOfTry = GetStateBeginBlockConstruct(handlerInfo.TryBeginState);

            BuildTryBody(handlerInfo);

            BlockLogicalConstruct newFinally;
            if (handlerInfo.HandlerType == YieldExceptionHandlerType.Method)
            {
                if (newFinallyBody == null)
                {
                    throw new Exception("Could not determine the end ot the try block");
                }

                RemoveExcessNodesFromTheTryBlock();

                ProcessFinallyNodes();

                newFinally = new BlockLogicalConstruct(newFinallyBody, new ILogicalConstruct[] { newFinallyBody });
            }
            else
            {
                newFinally = GenerateFinallyBlock();
            }

            BlockLogicalConstruct newTry = new BlockLogicalConstruct(entryOfTry, newTryBody);
            TryFinallyLogicalConstruct newTryFinallyConstruct = new TryFinallyLogicalConstruct(newTry, newFinally);

            createdConstructsToIntervalMap[newTryFinallyConstruct] = handlerInfo;

            CleanUpOrderedNodes(newTryFinallyConstruct);
        }
 /// <summary>
 /// Removes the nodes added to the new try construct from the orderedCFGNodes collection.
 /// </summary>
 /// <param name="theNewTryConstruct"></param>
 private void CleanUpOrderedNodes(TryFinallyLogicalConstruct theNewTryConstruct)
 {
     foreach (CFGBlockLogicalConstruct cfgChild in theNewTryConstruct.CFGBlocks)
     {
         orderedCFGNodes.Remove(cfgChild);
     }
 }
        public void FindExceptionHandlingConstructs()
        {
            V_0 = this.context.get_CFG().get_RawExceptionHandlers().GetEnumerator();
            try
            {
                while (V_0.MoveNext())
                {
                    V_1 = V_0.get_Current();
                    V_2 = this.GetBlockRangeFromInstructions(V_1.get_TryStart(), V_1.get_TryEnd());
                    V_3 = null;
                    if (!this.tryBlocksFound.TryGetValue(V_2, out V_3))
                    {
                        V_4 = this.CreateExceptionhandlingBlock(V_2);
                        V_5 = null;
                        switch (V_1.get_HandlerType())
                        {
                        case 0:
                        {
                            V_5 = new TryCatchFilterLogicalConstruct(V_4, this.CreateCatchHandler(V_1));
                            goto Label0;
                        }

                        case 1:
                        {
                            V_5 = new TryCatchFilterLogicalConstruct(V_4, this.CreateFilterHandler(V_1));
                            goto Label0;
                        }

                        case 2:
                        {
                            V_7 = this.GetBlockRangeFromInstructions(V_1.get_HandlerStart(), V_1.get_HandlerEnd());
                            V_5 = new TryFinallyLogicalConstruct(V_4, this.CreateExceptionhandlingBlock(V_7));
                            goto Label0;
                        }

                        case 3:
                        {
Label0:
                            this.tryBlocksFound.Add(V_2, V_5);
                            continue;
                        }

                        case 4:
                        {
                            V_6 = this.GetBlockRangeFromInstructions(V_1.get_HandlerStart(), V_1.get_HandlerEnd());
                            V_5 = new TryFaultLogicalConstruct(V_4, this.CreateExceptionhandlingBlock(V_6));
                            goto Label0;
                        }

                        default:
                        {
                            goto Label0;
                        }
                        }
                    }
                    else
                    {
                        this.AddHandlerToTryBlock(V_3, V_1);
                    }
                }
            }
            finally
            {
                V_0.Dispose();
            }
            return;
        }