## org.codehaus.groovy.control
Class OptimizerVisitor

    java.lang.Object
      org.codehaus.groovy.ast.CodeVisitorSupport
          org.codehaus.groovy.ast.ClassCodeVisitorSupport
              org.codehaus.groovy.ast.ClassCodeExpressionTransformer
                  org.codehaus.groovy.control.OptimizerVisitor

All Implemented Interfaces:
  ExpressionTransformer, GroovyClassVisitor, GroovyCodeVisitor

    public class OptimizerVisitor

extends ClassCodeExpressionTransformer

Visitor to produce several optimizations - to replace numbered constants with references to static fields

Author:
  Alex Tkachman

Constructor Summary
`OptimizerVisitor(CompilationUnit cu)`

Method Summary
`protected SourceUnit` `getSourceUnit()`
`Expression` `transform(Expression exp)` Transforms the given expression into another expression
`void` `visitClass(ClassNode node, SourceUnit source)`
`void` `visitClosureExpression(ClosureExpression expression)`

Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
`visitAnnotations, visitAssertStatement, visitCaseStatement, visitConstructorOrMethod, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoop`

Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
`addError, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitImports, visitMethod, visitPackage, visitStatement, visitTryCatchFinally, visitVariableExpression`

Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

`visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitDeclarationExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitRegexExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### OptimizerVisitor

    public OptimizerVisitor(CompilationUnit cu)

Method Detail

### visitClass

    public void visitClass(ClassNode node,
                           SourceUnit source)

### transform

    public Expression transform(Expression exp)

  Description copied from interface: `ExpressionTransformer`
  Transforms the given expression into another expression

  Specified by:
    `transform` in interface `ExpressionTransformer`
  Overrides:
    `transform` in class `ClassCodeExpressionTransformer`

### getSourceUnit

    protected SourceUnit getSourceUnit()

  Specified by:
    `getSourceUnit` in class `ClassCodeVisitorSupport`

### visitClosureExpression

    public void visitClosureExpression(ClosureExpression expression)

  Specified by:
    `visitClosureExpression` in interface `GroovyCodeVisitor`
  Overrides:
    `visitClosureExpression` in class `CodeVisitorSupport`

Copyright © 2003-2009 The Codehaus. All rights reserved.