Package org.apache.sling.scripting.sightly.impl.compiler.optimization

## Class DeadCodeRemoval

- java.lang.Object
- - org.apache.sling.scripting.sightly.impl.compiler.visitor.UniformVisitor
  - - org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor<Boolean>
    - - org.apache.sling.scripting.sightly.impl.compiler.optimization.DeadCodeRemoval

All Implemented Interfaces:
  `CommandVisitor`, `EmitterVisitor`

    public class DeadCodeRemoval
    extends TrackingVisitor<Boolean>
    implements EmitterVisitor

Removes code under conditionals which are proven to fail. It is probably a good idea to run this optimization after running `ConstantFolding`

### Field Summary

### Fields inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor

`tracker`

### Constructor Summary

Constructors
`DeadCodeRemoval​(StatefulVisitor.StateControl stateControl)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected Boolean` `assignDefault​(Command command)`
`PushStream` `getOutputStream()` Get the output stream
`protected void` `onCommand​(Command command)`
`static StreamTransformer` `transformer()`
`void` `visit​(Conditional.End conditionalEnd)` Process a `Conditional.End` command.
`void` `visit​(Conditional.Start conditionalStart)` Process a `Conditional.Start` command.
`void` `visit​(VariableBinding.Start variableBindingStart)` Process a `VariableBinding.Start` command.

### Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor

`visit, visit, visit`

### Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.UniformVisitor

`visit, visit, visit, visit, visit, visit`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.sling.scripting.sightly.compiler.commands.CommandVisitor

`visit, visit, visit, visit, visit, visit, visit, visit, visit`

### Constructor Detail

#### DeadCodeRemoval

    public DeadCodeRemoval​(StatefulVisitor.StateControl stateControl)

### Method Detail

#### transformer

    public static StreamTransformer transformer()

#### visit

    public void visit​(VariableBinding.Start variableBindingStart)

Description copied from interface: `CommandVisitor`
Process a `VariableBinding.Start` command.

Specified by:
  `visit` in interface `CommandVisitor`
Overrides:
  `visit` in class `TrackingVisitor<Boolean>`
Parameters:
  `variableBindingStart` - the command

#### visit

    public void visit​(Conditional.Start conditionalStart)

Description copied from interface: `CommandVisitor`
Process a `Conditional.Start` command.

Specified by:
  `visit` in interface `CommandVisitor`
Overrides:
  `visit` in class `UniformVisitor`
Parameters:
  `conditionalStart` - the command

#### visit

    public void visit​(Conditional.End conditionalEnd)

Description copied from interface: `CommandVisitor`
Process a `Conditional.End` command.

Specified by:
  `visit` in interface `CommandVisitor`
Overrides:
  `visit` in class `UniformVisitor`
Parameters:
  `conditionalEnd` - the command

#### getOutputStream

    public PushStream getOutputStream()

Description copied from interface: `EmitterVisitor`
Get the output stream

Specified by:
  `getOutputStream` in interface `EmitterVisitor`
Returns:
  the output stream of this visitor

#### assignDefault

    protected Boolean assignDefault​(Command command)

Specified by:
  `assignDefault` in class `TrackingVisitor<Boolean>`

#### onCommand

    protected void onCommand​(Command command)

Specified by:
  `onCommand` in class `UniformVisitor`