public bool IsBranchTarget(ActionBlock block)
        {
            if (null == block)
            {
                throw new ArgumentNullException("block");
            }
            foreach (ActionBlock p in block.Predecessors)
            {
                switch (p.ActionType)
                {
                case ActionType.Branch:
                    BranchActionBlock br = (BranchActionBlock)p;
                    if (br.Target == block)
                    {
                        return(true);
                    }
                    break;

                case ActionType.ConditionalBranch:
                    ConditionalBranchActionBlock cbr = (ConditionalBranchActionBlock)p;
                    if (cbr.Then == block)
                    {
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }
Exemple #2
0
        void ConnectActionBlocks()
        {
            for (int i = 0; i < _blocks.Count; ++i)
            {
                ActionBlock block = _blocks [i];
                switch (block.ActionType)
                {
                case ActionType.Branch:
                    BranchActionBlock br = (BranchActionBlock)block;
                    br.SetTarget(GetBranchTarget(br.SourceInstruction));
                    break;

                case ActionType.ConditionalBranch:
                    ConditionalBranchActionBlock cbr = (ConditionalBranchActionBlock)block;
                    cbr.SetTargets(GetBranchTarget(cbr.SourceInstruction), GetBlockAtOrNull(i + 1));
                    break;

                case ActionType.Return:
                    break;

                default:
                    AbstractFallThroughActionBlock ftb = (AbstractFallThroughActionBlock)block;
                    ftb.SetNext(GetBlockAtOrNull(i + 1));
                    break;
                }
            }
        }
		private ActionBlock OnBranch(BranchActionBlock block)
		{
			return block.Target;
		}
			void WriteBranch (ActionFlowGraph afg,  BranchActionBlock block)
			{
				WriteGoto (afg, block.Target);
			}