public abstract class

AbstractJBlockOptimizer

extends AbstractJOptimizer
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.AbstractPlugin
     ↳ com.pnfsoftware.jeb.core.units.code.java.AbstractJOptimizer
       ↳ com.pnfsoftware.jeb.core.units.code.java.AbstractJBlockOptimizer

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.core.units.code.java.AbstractJOptimizer
Public Constructors
AbstractJBlockOptimizer()
Create a standard optimizer.
AbstractJBlockOptimizer(JOptimizerType type)
Create an optimizer.
AbstractJBlockOptimizer(JOptimizerType type, String name)
Create an optimizer.
Public Methods
abstract int optimizeBlock(IJavaBlock b, IJavaElement parent)
Optimize a block of AST code.
int perform()
The default implementation calls performInternal(IJavaBlock, IJavaElement) on the input AST method, if the element to be optimized is a method.
Protected Methods
int performInternal(IJavaBlock b, IJavaElement parent)
The default implementation calls optimizeBlock(IJavaBlock, IJavaElement) on all blocks of the AST method to be optimized.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.core.units.code.java.AbstractJOptimizer
From class com.pnfsoftware.jeb.core.AbstractPlugin
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.IPlugin
From interface com.pnfsoftware.jeb.core.units.code.java.IJOptimizer

Public Constructors

public AbstractJBlockOptimizer ()

Create a standard optimizer.

public AbstractJBlockOptimizer (JOptimizerType type)

Create an optimizer.

public AbstractJBlockOptimizer (JOptimizerType type, String name)

Create an optimizer.

Public Methods

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

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.

Returns
  • the number of optimizations performed, 0 if none

Protected Methods

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