Package org.stringtemplate.v4.compiler
Class CompiledST
- java.lang.Object
-
- org.stringtemplate.v4.compiler.CompiledST
-
-
Field Summary
Fields Modifier and Type Field Description org.antlr.runtime.tree.CommonTreeastHow do we interpret syntax of template? (debug only)intcodeSizeMap<String,FormalArgument>formalArgumentsbooleanhasFormalArgsList<CompiledST>implicitlyDefinedTemplatesA list of all regions and subtemplates.byte[]instrsbooleanisAnonSubtemplatebooleanisRegionDoes this template come from a<@region>...<@end>embedded in another template?StringnameSTGroupnativeGroupThe group that physically defines thisSTdefinition.intnumberOfArgsWithDefaultValuesStringprefixEvery template knows where it is relative to the group that loaded it.ST.RegionTyperegionDefTypeIf someone refs<@r()>in template t, an implicitInterval[]sourceMapString[]stringsStringtemplateThe 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(List<FormalArgument> args)voiddefineImplicitlyDefinedTemplates(STGroup group)Stringdisasm()voiddump()IntervalgetTemplateRange()StringgetTemplateSource()Stringinstrs()
-
-
-
Field Detail
-
name
public String name
-
prefix
public 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 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 Map<String,FormalArgument> formalArguments
-
hasFormalArgs
public boolean hasFormalArgs
-
numberOfArgsWithDefaultValues
public int numberOfArgsWithDefaultValues
-
implicitlyDefinedTemplates
public 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 String[] strings
-
instrs
public byte[] instrs
-
codeSize
public int codeSize
-
sourceMap
public Interval[] sourceMap
-
-
Method Detail
-
clone
public CompiledST clone() throws 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 classObject- Returns:
- A copy of the current
CompiledSTinstance. The copy is a shallow copy, with the exception of theformalArgumentsfield which is also cloned. - Throws:
CloneNotSupportedException- If the current instance cannot be cloned.
-
addImplicitlyDefinedTemplate
public void addImplicitlyDefinedTemplate(CompiledST sub)
-
defineArgDefaultValueTemplates
public void defineArgDefaultValueTemplates(STGroup group)
-
defineFormalArgs
public void defineFormalArgs(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 String getTemplateSource()
-
getTemplateRange
public Interval getTemplateRange()
-
instrs
public String instrs()
-
dump
public void dump()
-
disasm
public String disasm()
-
-