Class AbstractJBlockOptimizer

All Implemented Interfaces:
IPlugin, IJOptimizer

public abstract class AbstractJBlockOptimizer extends AbstractJOptimizer
A specialized skeleton implementation for a method AST optimizer meant to run on every block of AST code of the method, recursively. This optimizer may be used to optimize AST methods only, not AST classes.

Refer to the javadoc of the parent types for more information.

  • Constructor Details

    • AbstractJBlockOptimizer

      public AbstractJBlockOptimizer()
      Create a standard optimizer.
    • AbstractJBlockOptimizer

      public AbstractJBlockOptimizer(JOptimizerType type)
      Create an optimizer.
      Parameters:
      type -
    • AbstractJBlockOptimizer

      public AbstractJBlockOptimizer(JOptimizerType type, String name)
      Create an optimizer.
      Parameters:
      type -
      name -
  • Method Details

    • perform

      public int perform()
      The default implementation calls performInternal(IJavaBlock, IJavaElement) on the input AST method, if the element to be optimized is a method.

      It may be overridden, although it is not recommended.

      Specified by:
      perform in class AbstractJOptimizer
      Returns:
      the number of optimizations performed, 0 if none
    • performInternal

      protected int performInternal(IJavaBlock b, IJavaElement parent)
      The default implementation calls optimizeBlock(IJavaBlock, IJavaElement) on all blocks of the AST method to be optimized. The method tree is visited in depth, blocks are optimized post-visit.

      It may be overridden, although it is not recommended.

      Parameters:
      b - the current block to optimize
      parent - the parent of the block to be optimized(
      Returns:
      number of optimizations performed
    • optimizeBlock

      public abstract int optimizeBlock(IJavaBlock b, IJavaElement parent)
      Optimize a block of AST code. Optimizers must implement this method.
      Parameters:
      b - block to be optimized
      parent - the parent element of the block to be optimized
      Returns:
      number of optimizations performed