Package org.stringtemplate.v4.compiler
Class CompiledST
- java.lang.Object
-
- org.stringtemplate.v4.compiler.CompiledST
-
- All Implemented Interfaces:
java.lang.Cloneable
public class CompiledST extends java.lang.Object implements java.lang.Cloneable
-
-
Field Summary
Fields Modifier and Type Field Description org.antlr.runtime.tree.CommonTreeastHow do we interpret syntax of template? (debug only)intcodeSizejava.util.Map<java.lang.String,FormalArgument>formalArgumentsbooleanhasFormalArgsjava.util.List<CompiledST>implicitlyDefinedTemplatesA list of all regions and subtemplates.byte[]instrsbooleanisAnonSubtemplatebooleanisRegionDoes this template come from a<@region>...<@end>embedded in another template?java.lang.StringnameSTGroupnativeGroupThe group that physically defines thisSTdefinition.intnumberOfArgsWithDefaultValuesjava.lang.StringprefixEvery template knows where it is relative to the group that loaded it.ST.RegionTyperegionDefTypeIf someone refs<@r()>in template t, an implicitInterval[]sourceMapjava.lang.String[]stringsjava.lang.StringtemplateThe original, immutable pattern (not really used again after initial "compilation").org.antlr.runtime.TokentemplateDefStartTokenThe token that begins template definition; could be<@r>of region.org.antlr.runtime.TokenStreamtokensOverall token stream for template (debug only).
-
Constructor Summary
Constructors Constructor Description CompiledST()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArg(FormalArgument a)Used byST.add(java.lang.String, java.lang.Object)to add args one by one without turning on full formal args definition signal.voidaddImplicitlyDefinedTemplate(CompiledST sub)CompiledSTclone()Cloning theCompiledSTfor anSTinstance allowsST.add(java.lang.String, java.lang.Object)to be called safely during interpretation for templates that do not contain formal arguments.voiddefineArgDefaultValueTemplates(STGroup group)voiddefineFormalArgs(java.util.List<FormalArgument> args)voiddefineImplicitlyDefinedTemplates(STGroup group)java.lang.Stringdisasm()voiddump()IntervalgetTemplateRange()java.lang.StringgetTemplateSource()java.lang.Stringinstrs()
-
-
-
Field Detail
-
name
public java.lang.String name
-
prefix
public java.lang.String prefix
Every template knows where it is relative to the group that loaded it. The prefix is the relative path from the root."/prefix/name"is the fully qualified name of this template. All calls toSTGroup.getInstanceOf(java.lang.String)calls must use fully qualified names. A"/"is added to the front if you don't specify one. Template references within template code, however, uses relative names, unless of course the name starts with"/".This has nothing to do with the outer filesystem path to the group dir or group file.
We set this as we load/compile the template.
Always ends with
"/".
-
template
public java.lang.String template
The original, immutable pattern (not really used again after initial "compilation"). Useful for debugging. Even for subtemplates, this is entire overall template.
-
templateDefStartToken
public org.antlr.runtime.Token templateDefStartToken
The token that begins template definition; could be<@r>of region.
-
tokens
public org.antlr.runtime.TokenStream tokens
Overall token stream for template (debug only).
-
ast
public org.antlr.runtime.tree.CommonTree ast
How do we interpret syntax of template? (debug only)
-
formalArguments
public java.util.Map<java.lang.String,FormalArgument> formalArguments
-
hasFormalArgs
public boolean hasFormalArgs
-
numberOfArgsWithDefaultValues
public int numberOfArgsWithDefaultValues
-
implicitlyDefinedTemplates
public java.util.List<CompiledST> implicitlyDefinedTemplates
A list of all regions and subtemplates.
-
nativeGroup
public STGroup nativeGroup
The group that physically defines thisSTdefinition. We use it to initiate interpretation viaST.toString(). From there, it becomes fieldInterpreter.groupand is fixed until rendering completes.
-
isRegion
public boolean isRegion
Does this template come from a<@region>...<@end>embedded in another template?
-
regionDefType
public ST.RegionType regionDefType
If someone refs<@r()>in template t, an implicit@t.r() ::= ""is defined, but you can overwrite this def by defining your own. We need to prevent more than one manual def though. Between this var and
isRegionwe can determine these cases.
-
isAnonSubtemplate
public boolean isAnonSubtemplate
-
strings
public java.lang.String[] strings
-
instrs
public byte[] instrs
-
codeSize
public int codeSize
-
sourceMap
public Interval[] sourceMap
-
-
Method Detail
-
clone
public CompiledST clone() throws java.lang.CloneNotSupportedException
Cloning theCompiledSTfor anSTinstance allowsST.add(java.lang.String, java.lang.Object)to be called safely during interpretation for templates that do not contain formal arguments.- Overrides:
clonein classjava.lang.Object- Returns:
- A copy of the current
CompiledSTinstance. The copy is a shallow copy, with the exception of theformalArgumentsfield which is also cloned. - Throws:
java.lang.CloneNotSupportedException- If the current instance cannot be cloned.
-
addImplicitlyDefinedTemplate
public void addImplicitlyDefinedTemplate(CompiledST sub)
-
defineArgDefaultValueTemplates
public void defineArgDefaultValueTemplates(STGroup group)
-
defineFormalArgs
public void defineFormalArgs(java.util.List<FormalArgument> args)
-
addArg
public void addArg(FormalArgument a)
Used byST.add(java.lang.String, java.lang.Object)to add args one by one without turning on full formal args definition signal.
-
defineImplicitlyDefinedTemplates
public void defineImplicitlyDefinedTemplates(STGroup group)
-
getTemplateSource
public java.lang.String getTemplateSource()
-
getTemplateRange
public Interval getTemplateRange()
-
instrs
public java.lang.String instrs()
-
dump
public void dump()
-
disasm
public java.lang.String disasm()
-
-