Top Description Fields Constructors Methods
org.stringtemplate.v4.compiler

public Class CompiledST

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
org.antlr.runtime.*, org.antlr.runtime.tree.CommonTree, org.stringtemplate.v4.*, org.stringtemplate.v4.misc.*, java.io.*, java.util.*

The result of compiling an ST. Contains all the bytecode instructions, string table, bytecode address to source code map, and other bookkeeping info. It's the implementation of an ST you might say. All instances of the same template share a single implementation (ST#impl field).

Field Summary

Modifier and TypeField and Description
public CommonTree
ast

How do we interpret syntax of template?

public int
public Map<String, FormalArgument>
public boolean
public List<CompiledST>
implicitlyDefinedTemplates

A list of all regions and subtemplates.

public byte[]
public boolean
public boolean
isRegion

Does this template come from a <@region>...

public String
public STGroup
nativeGroup

The group that physically defines this ST definition.

public int
public String
prefix

Every template knows where it is relative to the group that loaded it.

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.

public Interval[]
public String[]
public String
template

The original, immutable pattern (not really used again after initial "compilation").

public Token
templateDefStartToken

The token that begins template definition; could be <@r> of region.

public TokenStream
tokens

Overall token stream for template (debug only).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addArg(FormalArgument a)

Used by ST#add to add args one by one without turning on full formal args definition signal.

public void
public CompiledST

Returns:

A copy of the current CompiledST instance. The copy is a shallow copy, with the exception of the formalArguments field which is also cloned.
clone
()

Overrides java.lang.Object.clone.

Cloning the CompiledST for an ST instance allows ST#add to be called safely during interpretation for templates that do not contain formal arguments.
public void
public void
public void
public String
public void
dump()

public Interval
public String
public String
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

astback to summary
public CommonTree ast

How do we interpret syntax of template? (debug only)

codeSizeback to summary
public int codeSize
formalArgumentsback to summary
public Map<String, FormalArgument> formalArguments
hasFormalArgsback to summary
public boolean hasFormalArgs
implicitlyDefinedTemplatesback to summary
public List<CompiledST> implicitlyDefinedTemplates

A list of all regions and subtemplates.

instrsback to summary
public byte[] instrs
isAnonSubtemplateback to summary
public boolean isAnonSubtemplate
isRegionback to summary
public boolean isRegion

Does this template come from a <@region>...<@end> embedded in another template?

nameback to summary
public String name
nativeGroupback to summary
public STGroup nativeGroup

The group that physically defines this ST definition. We use it to initiate interpretation via ST#toString. From there, it becomes field Interpreter#group and is fixed until rendering completes.

numberOfArgsWithDefaultValuesback to summary
public int numberOfArgsWithDefaultValues
prefixback to summary
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 to STGroup#getInstanceOf 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 "/".

regionDefTypeback to summary
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.

sourceMapback to summary
public Interval[] sourceMap
stringsback to summary
public String[] strings
templateback to summary
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.

templateDefStartTokenback to summary
public Token templateDefStartToken

The token that begins template definition; could be <@r> of region.

tokensback to summary
public TokenStream tokens

Overall token stream for template (debug only).

Constructor Detail

CompiledSTback to summary
public CompiledST()

Method Detail

addArgback to summary
public void addArg(FormalArgument a)

Used by ST#add to add args one by one without turning on full formal args definition signal.

addImplicitlyDefinedTemplateback to summary
public void addImplicitlyDefinedTemplate(CompiledST sub)
cloneback to summary
public CompiledST clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Cloning the CompiledST for an ST instance allows ST#add to be called safely during interpretation for templates that do not contain formal arguments.

Returns:CompiledST

A copy of the current CompiledST instance. The copy is a shallow copy, with the exception of the formalArguments field which is also cloned.

Annotations
@Override
Exceptions
CloneNotSupportedException:
If the current instance cannot be cloned.
defineArgDefaultValueTemplatesback to summary
public void defineArgDefaultValueTemplates(STGroup group)
defineFormalArgsback to summary
public void defineFormalArgs(List<FormalArgument> args)
defineImplicitlyDefinedTemplatesback to summary
public void defineImplicitlyDefinedTemplates(STGroup group)
disasmback to summary
public String disasm()
dumpback to summary
public void dump()
getTemplateRangeback to summary
public Interval getTemplateRange()
getTemplateSourceback to summary
public String getTemplateSource()
instrsback to summary
public String instrs()