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.CommonTree
ast
How do we interpret syntax of template? (debug only)int
codeSize
Map<String,FormalArgument>
formalArguments
boolean
hasFormalArgs
List<CompiledST>
implicitlyDefinedTemplates
A list of all regions and subtemplates.byte[]
instrs
boolean
isAnonSubtemplate
boolean
isRegion
Does this template come from a<@region>...<@end>
embedded in another template?String
name
STGroup
nativeGroup
The group that physically defines thisST
definition.int
numberOfArgsWithDefaultValues
String
prefix
Every template knows where it is relative to the group that loaded it.ST.RegionType
regionDefType
If someone refs<@r()>
in template t, an implicitInterval[]
sourceMap
String[]
strings
String
template
The original, immutable pattern (not really used again after initial "compilation").org.antlr.runtime.Token
templateDefStartToken
The token that begins template definition; could be<@r>
of region.org.antlr.runtime.TokenStream
tokens
Overall 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 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.void
addImplicitlyDefinedTemplate(CompiledST sub)
CompiledST
clone()
Cloning theCompiledST
for anST
instance allowsST.add(java.lang.String, java.lang.Object)
to be called safely during interpretation for templates that do not contain formal arguments.void
defineArgDefaultValueTemplates(STGroup group)
void
defineFormalArgs(List<FormalArgument> args)
void
defineImplicitlyDefinedTemplates(STGroup group)
String
disasm()
void
dump()
Interval
getTemplateRange()
String
getTemplateSource()
String
instrs()
-
-
-
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 thisST
definition. We use it to initiate interpretation viaST.toString()
. From there, it becomes fieldInterpreter.group
and 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
isRegion
we 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 theCompiledST
for anST
instance allowsST.add(java.lang.String, java.lang.Object)
to be called safely during interpretation for templates that do not contain formal arguments.- Overrides:
clone
in classObject
- Returns:
- A copy of the current
CompiledST
instance. The copy is a shallow copy, with the exception of theformalArguments
field 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()
-
-