Beispiel #1
0
    // build the array all_blocks: the original blocks + the block clones (if any) + special blocks
    private void BuildAllBlockCollection (
      Method method, 
      IList/*<CfgBlock>*/ new_blocks, 
      ISet/*<CfgBlock>*/ filterblocks,
      NormalFlowBlockNavigator nfnav
      ) {
      IMutableSet reach = new HashSet();
      FindReachable(reach, (CfgBlock)method.Body.Statements[0], nfnav);

      int nb_blocks = reach.Count + 2; // entry and exit
      if (!reach.Contains(this.normal_exit_point)) {
        nb_blocks++;
      }
      if (!reach.Contains(this.excp_exit_point)) {
        nb_blocks++;
      }

      CfgBlock[] all_blocks;
      this.all_blocks = all_blocks = new CfgBlock[nb_blocks];

      int index = 0;

      AddBlock(this.entry_point, all_blocks, ref index);

      foreach (CfgBlock block in reach) {
        AddBlock(block, all_blocks, ref index);
      }

#if false
      int nb_blocks = method.Body.Statements.Count - filterblocks.Count + 4;

      nb_blocks += new_blocks.Count;

      CfgBlock[] all_blocks;
      this.all_blocks = all_blocks = new CfgBlock[nb_blocks];
      StatementList blocks = method.Body.Statements;
      int index = 0;

      AddBlock(this.entry_point, all_blocks, ref index);
      for(int i = 0 ; i < blocks.Count; i++) {
        if ( ! filterblocks.Contains(blocks[i])) {
          AddBlock((CfgBlock)blocks[i], all_blocks, ref index);
        }
      }
      if (new_blocks != null) {
        // adding the block clones to all_blocks
        foreach(CfgBlock block in new_blocks) {
          AddBlock(block, all_blocks, ref index);
        }
      }
#endif

      // adding the three special blocks
      if (!reach.Contains(this.normal_exit_point)) {
        AddBlock(this.normal_exit_point, all_blocks, ref index);
      }
      if (!reach.Contains(this.excp_exit_point)) {
        AddBlock(this.excp_exit_point, all_blocks, ref index);
      }
      AddBlock(this.exit_point, all_blocks, ref index);
    }