Class AbstractCBlockOptimizer

All Implemented Interfaces:
IPlugin, ICOptimizer, IOptimizer<ICMethod>
Direct Known Subclasses:
AbstractCElementOptimizer, AbstractCStatementOptimizer

public abstract class AbstractCBlockOptimizer extends AbstractCOptimizer
Perform a recursive optimizer on ICBlock. The policy is recurse first, so optimizer is done as post-treatment.
  • Constructor Details

    • AbstractCBlockOptimizer

      public AbstractCBlockOptimizer()
      Create a block optimizer.
  • Method Details

    • perform

      protected int perform()
      Can be overridden. The default implementation simply calls performOnMethoBlocksRecursivively().
      Specified by:
      perform in class AbstractCOptimizer
      Returns:
      the number of optimizations performed
    • performOnMethoBlocksRecursivively

      public final int performOnMethoBlocksRecursivively()
      Recursively process the method body blocks.
      Returns:
      the number of optimizations performed
    • getNextSiblingStatement

      protected ICStatement getNextSiblingStatement(int statementIndex, ICBlock block, ICStatement blockNextSiblingStm)
      Retrieve the statement following a child block in its parent block.
      Parameters:
      statementIndex - index of the current statement in block
      block - block containing the current statement
      blockNextSiblingStm - next sibling statement of block, if any
      Returns:
      the next sibling statement, or null if none exists
    • optimizeBlock

      protected abstract int optimizeBlock(ICBlock b)
      Attempt to optimize CBlock. Sub-expressions may be examined. The implementor should not attempt to modify parent or siblings CBlocks.
      Parameters:
      b - CBlock
      Returns:
      the number of optimizations done
    • optimizeBlock

      protected int optimizeBlock(ICBlock b, ICCompound parent, ICStatement blockNextStm)
      Attempt to optimize CBlock, with some contextual information provided. Sub-expressions may be examined. The implementor should not attempt to modify parent or siblings CBlocks.
      Parameters:
      b - CBlock
      parent - the parent compound statement
      blockNextStm - the next statement (i.e. the next sibling statement in the AST, not control-flow related)
      Returns:
      the number of optimizations done