public class PushLocalEmitter extends Emitter
startOfBlock| Constructor and Description |
|---|
PushLocalEmitter(parsii.tokenizer.Position startOfBlock,
int localIndex,
Expression expression)
Creates a new instance at the given position which writes the value of the given expression into the given local
location.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
Expression |
getExpression()
Contains the expression to evaluate and save to the stack location.
|
int |
getLocalIndex()
Contains the stack index being written to.
|
Emitter |
propagateVisitor(EmitterVisitor visitor)
Invokes the visitor on all sub emitters and on this emitter itself.
|
Emitter |
reduce()
Performs static optimizations at compile time.
|
void |
setLocalIndex(int localIndex)
Updates the stack index being written to.
|
String |
toString() |
void |
visitExpressions(Function<parsii.tokenizer.Position,ExpressionVisitor> visitorSupplier)
Visits all expressions contained in this emitter or its children.
|
emit, getStartOfBlockpublic PushLocalEmitter(parsii.tokenizer.Position startOfBlock,
int localIndex,
Expression expression)
startOfBlock - the position where the statement was createdlocalIndex - the local index within the LocalRenderContext to store the value toexpression - the expression to evaluate at runtimepublic Emitter copy()
EmitterWhen 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()
EmitterCertain emitters can perform optimizations (evaluate constant expressions, combine constant outputs etc.) to create more efficient templates. This is especially important when a template is inlined, as this most probably provides a higher level of optimizations.
public Emitter propagateVisitor(EmitterVisitor visitor)
EmitterpropagateVisitor in class Emittervisitor - the visitor to invokepublic void visitExpressions(Function<parsii.tokenizer.Position,ExpressionVisitor> visitorSupplier)
EmittervisitExpressions in class EmittervisitorSupplier - a function which generates an ExpressionVisitor while supplying the current position (for
improved error messages).protected void emitToContext(LocalRenderContext context) throws Exception
EmitteremitToContext in class Emittercontext - 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 RenderExceptionpublic Expression getExpression()
public int getLocalIndex()
public void setLocalIndex(int localIndex)
When inlining a template, the stack has to be transferred to the callee and therefore the stack indices might change.
localIndex - the new stack index to useCopyright © 2018. All rights reserved.