Class CompiledST

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class CompiledST
    extends java.lang.Object
    implements java.lang.Cloneable
    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 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 to STGroup.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 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.
      • 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 java.lang.String[] strings
      • instrs

        public byte[] instrs
      • codeSize

        public int codeSize
      • sourceMap

        public Interval[] sourceMap
    • Constructor Detail

      • CompiledST

        public CompiledST()
    • Method Detail

      • clone

        public CompiledST clone()
                         throws java.lang.CloneNotSupportedException
        Cloning the CompiledST for an ST instance allows ST.add(java.lang.String, java.lang.Object) to be called safely during interpretation for templates that do not contain formal arguments.
        Overrides:
        clone in class java.lang.Object
        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.
        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)
      • 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()