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
FieldsFields inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor
tracker -
Method Summary
Modifier and TypeMethodDescriptionprotected MapLiteralassignDefault(Command command) Get the output streamvoidvoidvisit(VariableBinding.End variableBindingEnd) Process aVariableBinding.Endcommand.voidvisit(VariableBinding.Start variableBindingStart) Process aVariableBinding.Startcommand.Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor
visit, visitMethods 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:CommandVisitorProcess aVariableBinding.Startcommand.- Specified by:
visitin interfaceCommandVisitor- Overrides:
visitin classTrackingVisitor<MapLiteral>- Parameters:
variableBindingStart- the command
-
visit
Description copied from interface:CommandVisitorProcess aVariableBinding.Endcommand.- Specified by:
visitin interfaceCommandVisitor- Overrides:
visitin classTrackingVisitor<MapLiteral>- Parameters:
variableBindingEnd- the command
-
assignDefault
- Specified by:
assignDefaultin classTrackingVisitor<MapLiteral>
-
onCommand
- Specified by:
onCommandin classUniformVisitor
-
getOutputStream
Description copied from interface:EmitterVisitorGet the output stream- Specified by:
getOutputStreamin interfaceEmitterVisitor- Returns:
- the output stream of this visitor
-