public class CompositeEmitter extends Emitter
Modifier and Type | Field and Description |
---|---|
protected List<Emitter> |
children |
startOfBlock
Constructor and Description |
---|
CompositeEmitter(parsii.tokenizer.Position startOfBlock)
Creates a new emitter at the given position.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(Emitter child)
Adds a new child emitter and the end of the children list.
|
Emitter |
copy()
Creates a deep copy of this emitter.
|
protected void |
emitToContext(LocalRenderContext context)
Actually produces the output while relying on the caller to properly handle any exception.
|
Emitter |
propagateVisitor(EmitterVisitor visitor)
Invokes the visitor on all sub emitters and on this emitter itself.
|
Emitter |
reduce()
Tries to optimize the list of child emitters.
|
String |
toString() |
void |
visitExpressions(Function<parsii.tokenizer.Position,ExpressionVisitor> visitorSupplier)
Visits all expressions contained in this emitter or its children.
|
emit, getStartOfBlock
public CompositeEmitter(parsii.tokenizer.Position startOfBlock)
startOfBlock
- the start of the definitionpublic void addChild(@Nonnull Emitter child)
child
- the emitter to addprotected void emitToContext(LocalRenderContext context) throws Exception
Emitter
emitToContext
in class Emitter
context
- the render context which provides access to the local and global environment and also the target
for the generated textException
- all thrown exceptions are caught and converted into a RenderException
public Emitter copy()
Emitter
When templates are inlined, the parameters are propagated and constant expressions and conditions are evaluated at compile time. This yields faster and more efficient templates. In order to perform these optimizations, we need a copy of the template and all its emitters which can safely be modified.
public Emitter reduce()
Two actual optimizations are attempted:
constant emitters
are joined into one.Both of these optimizations are very efficient when a template is inlined into another one.
public Emitter propagateVisitor(EmitterVisitor visitor)
Emitter
propagateVisitor
in class Emitter
visitor
- the visitor to invokepublic void visitExpressions(Function<parsii.tokenizer.Position,ExpressionVisitor> visitorSupplier)
Emitter
visitExpressions
in class Emitter
visitorSupplier
- a function which generates an ExpressionVisitor
while supplying the current position (for
improved error messages).Copyright © 2018. All rights reserved.