Class SyntheticMapRemoval
java.lang.Object
org.apache.sling.scripting.sightly.impl.compiler.visitor.UniformVisitor
org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor<MapLiteral>
org.apache.sling.scripting.sightly.impl.compiler.optimization.SyntheticMapRemoval
- All Implemented Interfaces:
CommandVisitor
,EmitterVisitor
public final class SyntheticMapRemoval
extends TrackingVisitor<MapLiteral>
implements EmitterVisitor
This optimization handles variables initialized to map literals. It initially assigns the values in the map to variables and wherever
the map literal is accessed, the property access is replaced with the value variable, thus removing the need for a map lookup.
-
Field Summary
Fields inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor
tracker
-
Method Summary
Modifier and TypeMethodDescriptionprotected MapLiteral
assignDefault
(Command command) Get the output streamvoid
void
visit
(VariableBinding.End variableBindingEnd) Process aVariableBinding.End
command.void
visit
(VariableBinding.Start variableBindingStart) Process aVariableBinding.Start
command.Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor
visit, visit
Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.UniformVisitor
visit, visit, visit, visit, visit, visit, visit, visit
-
Field Details
-
TRANSFORMER
-
-
Method Details
-
visit
Description copied from interface:CommandVisitor
Process aVariableBinding.Start
command.- Specified by:
visit
in interfaceCommandVisitor
- Overrides:
visit
in classTrackingVisitor<MapLiteral>
- Parameters:
variableBindingStart
- the command
-
visit
Description copied from interface:CommandVisitor
Process aVariableBinding.End
command.- Specified by:
visit
in interfaceCommandVisitor
- Overrides:
visit
in classTrackingVisitor<MapLiteral>
- Parameters:
variableBindingEnd
- the command
-
assignDefault
- Specified by:
assignDefault
in classTrackingVisitor<MapLiteral>
-
onCommand
- Specified by:
onCommand
in classUniformVisitor
-
getOutputStream
Description copied from interface:EmitterVisitor
Get the output stream- Specified by:
getOutputStream
in interfaceEmitterVisitor
- Returns:
- the output stream of this visitor
-