STGroup. To execute the byte codes, we need an output stream and a
reference to an ST instance. That instance's ST#impl field
points at a CompiledST, which contains all of the byte codes and
other information relevant to execution.
This interpreter is a stack-based bytecode interpreter. All operands go onto an operand stack.
If debug set, we track interpreter events. For now, I am only
tracking instance creation events. These are used by STViz to pair up
output chunks with the template expressions that generate them.
We create a new interpreter for each invocation of
ST#render, ST#inspect, or ST#getEvents.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | |
| protected static class | |
| public static enum |
| Modifier and Type | Field and Description |
|---|---|
| public boolean | |
| public static final int | |
| pack-priv ErrorManager | |
| protected List | |
| protected List | executeTrace
If |
| pack-priv STGroup | group
Render template with respect to this group. |
| pack-priv Locale | locale
For renderers, we have to pass in the locale. |
| pack-priv int | nwline
The number of characters written on this template line so far. |
| pack-priv Object[] | operands
Operand stack, grows upwards. |
| public static final Set | |
| pack-priv int | sp
Stack pointer register. |
| public static boolean | trace
Dump bytecode instructions as they are executed. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected int | |
| protected void | |
| public Object | |
| public Iterator | |
| public int | Returns: the number of characters written tooutExecute template |
| public Object | first(InstanceScope scope, Object v)
Return the first attribute if multi-valued, or the attribute itself if single-valued. |
| public Object | getAttribute(InstanceScope scope, String name)
Find an attribute via dynamic scoping up enclosing scope chain. |
| public Object | |
| public static List | |
| public static String | getEnclosingInstanceStackString(InstanceScope scope)
If an instance of x is enclosed in a y which is in a
z, return a |
| public static List | |
| public List | |
| public List | |
| protected int | |
| protected int | |
| protected Object | |
| public static List | |
| public static int | |
| protected void | |
| public Object | last(InstanceScope scope, Object v)
Return the last attribute if multi-valued, or the attribute itself if single-valued. |
| public Object | |
| pack-priv void | |
| protected void | |
| pack-priv void | |
| protected void | |
| private <T> String | |
| public Object | rest(InstanceScope scope, Object v)
Return everything but the first attribute if multi-valued, or
|
| public Object | reverse(InstanceScope scope, Object v)
Return a list with the same elements as |
| protected void | rot_map(InstanceScope scope, Object attr, List<ST> prototypes)
Renders expressions of the form |
| protected List | |
| public void | setDefaultArguments(STWriter out, InstanceScope scope)
Set any default argument values that were not set by the invoking
template or by |
| protected void | |
| pack-priv void | |
| pack-priv void | |
| public Object | |
| pack-priv void | |
| pack-priv void | |
| protected boolean | |
| protected String | |
| protected void | |
| protected void | trackDebugEvent(InstanceScope scope, InterpEvent e)
For every event, we track in overall |
| public Object | |
| protected int | |
| protected int | writeObject(STWriter out, InstanceScope scope, Object o, String[] options)
Generic method to emit text for an object. |
| protected int | writeObjectNoOptions(STWriter out, InstanceScope scope, Object o)
Write out an expression result that doesn't use expression options. |
| protected int | writeObjectWithOptions(STWriter out, InstanceScope scope, Object o, Object[] options)
Write out an expression result that uses expression options. |
| protected int | |
| protected ST. | zip_map(InstanceScope scope, List<Object> exprs, ST prototype)
Renders expressions of the form |
| debug | back to summary |
|---|---|
| public boolean debug When | |
| DEFAULT_OPERAND_STACK_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_OPERAND_STACK_SIZE | |
| errMgr | back to summary |
|---|---|
| pack-priv ErrorManager errMgr | |
| events | back to summary |
|---|---|
| protected List<InterpEvent> events Track everything happening in interpreter across all templates if
| |
| executeTrace | back to summary |
|---|---|
| protected List<String> executeTrace If | |
| group | back to summary |
|---|---|
| pack-priv STGroup group Render template with respect to this group. | |
| locale | back to summary |
|---|---|
| pack-priv Locale locale For renderers, we have to pass in the locale. | |
| nwline | back to summary |
|---|---|
| pack-priv int nwline The number of characters written on this template line so far. | |
| operands | back to summary |
|---|---|
| pack-priv Object[] operands Operand stack, grows upwards. | |
| predefinedAnonSubtemplateAttributes | back to summary |
|---|---|
| public static final Set<String> predefinedAnonSubtemplateAttributes | |
| sp | back to summary |
|---|---|
| pack-priv int sp Stack pointer register. | |
| trace | back to summary |
|---|---|
| public static boolean trace Dump bytecode instructions as they are executed. This field is mostly for StringTemplate development. | |
| Interpreter | back to summary |
|---|---|
| public Interpreter(STGroup group, boolean debug) | |
| Interpreter | back to summary |
|---|---|
| public Interpreter(STGroup group, Locale locale, boolean debug) | |
| Interpreter | back to summary |
|---|---|
| public Interpreter(STGroup group, ErrorManager errMgr, boolean debug) | |
| Interpreter | back to summary |
|---|---|
| public Interpreter(STGroup group, Locale locale, ErrorManager errMgr, boolean debug) | |
| _exec | back to summary |
|---|---|
| protected int _exec(STWriter out, InstanceScope scope) | |
| addToList | back to summary |
|---|---|
| protected void addToList(InstanceScope scope, List<Object> list, Object o) | |
| convertAnythingIteratableToIterator | back to summary |
|---|---|
| public Object convertAnythingIteratableToIterator(InstanceScope scope, Object o) | |
| convertAnythingToIterator | back to summary |
|---|---|
| public Iterator | |
| exec | back to summary |
|---|---|
| public int exec(STWriter out, InstanceScope scope) Execute template
| |
| first | back to summary |
|---|---|
| public Object first(InstanceScope scope, Object v) Return the first attribute if multi-valued, or the attribute itself if single-valued.
This method is used for rendering expressions of the form
| |
| getAttribute | back to summary |
|---|---|
| public Object getAttribute(InstanceScope scope, String name) Find an attribute via dynamic scoping up enclosing scope chain. Only look for a dictionary definition if the attribute is not found, so attributes sent in to a template override dictionary names.
Return | |
| getDictionary | back to summary |
|---|---|
| public Object getDictionary(STGroup g, String name) | |
| getEnclosingInstanceStack | back to summary |
|---|---|
| public static List | |
| getEnclosingInstanceStackString | back to summary |
|---|---|
| public static String getEnclosingInstanceStackString(InstanceScope scope) If an instance of x is enclosed in a y which is in a
z, return a | |
| getEvalTemplateEventStack | back to summary |
|---|---|
| public static List | |
| getEvents | back to summary |
|---|---|
| public List | |
| getExecutionTrace | back to summary |
|---|---|
| public List | |
| getExprStartChar | back to summary |
|---|---|
| protected int getExprStartChar(InstanceScope scope) | |
| getExprStopChar | back to summary |
|---|---|
| protected int getExprStopChar(InstanceScope scope) | |
| getObjectProperty | back to summary |
|---|---|
| protected Object getObjectProperty(STWriter out, InstanceScope scope, Object o, Object property) | |
| getScopeStack | back to summary |
|---|---|
| public static List | |
| getShort | back to summary |
|---|---|
| public static int getShort(byte[] memory, int index) | |
| indent | back to summary |
|---|---|
| protected void indent(STWriter out, InstanceScope scope, int strIndex) | |
| last | back to summary |
|---|---|
| public Object last(InstanceScope scope, Object v) Return the last attribute if multi-valued, or the attribute itself if
single-valued. Unless it's a
This method is used for rendering expressions of the form
| |
| length | back to summary |
|---|---|
| public Object length(Object v) Return the length of a multi-valued attribute or 1 if it is a single
attribute. If The implementation treats several common collections and arrays as special cases for speed. | |
| load_str | back to summary |
|---|---|
| pack-priv void load_str(ST self, int ip) | |
| map | back to summary |
|---|---|
| protected void map(InstanceScope scope, Object attr, final ST st) | |
| passthru | back to summary |
|---|---|
| pack-priv void passthru(InstanceScope scope, String templateName, Map<String, Object> attrs) | |
| printForTrace | back to summary |
|---|---|
| protected void printForTrace(StringBuilder tr, InstanceScope scope, Object o) | |
| renderObject | back to summary |
|---|---|
| private <T> String renderObject(InstanceScope scope, String formatString, Object o, Class<T> attributeType) | |
| rest | back to summary |
|---|---|
| public Object rest(InstanceScope scope, Object v) Return everything but the first attribute if multi-valued, or
| |
| reverse | back to summary |
|---|---|
| public Object reverse(InstanceScope scope, Object v) Return a list with the same elements as
Note that | |
| rot_map | back to summary |
|---|---|
| protected void rot_map(InstanceScope scope, Object attr, List<ST> prototypes) Renders expressions of the form | |
| rot_map_iterator | back to summary |
|---|---|
| protected List | |
| setDefaultArguments | back to summary |
|---|---|
| public void setDefaultArguments(STWriter out, InstanceScope scope) Set any default argument values that were not set by the invoking
template or by
The evaluation context is the | |
| setFirstArgument | back to summary |
|---|---|
| protected void setFirstArgument(InstanceScope scope, ST st, Object attr) | |
| storeArgs | back to summary |
|---|---|
| pack-priv void storeArgs(InstanceScope scope, Map<String, Object> attrs, ST st) | |
| storeArgs | back to summary |
|---|---|
| pack-priv void storeArgs(InstanceScope scope, int nargs, ST st) | |
| strip | back to summary |
|---|---|
| public Object strip(InstanceScope scope, Object v) Return a new list without | |
| super_new | back to summary |
|---|---|
| pack-priv void super_new(InstanceScope scope, String name, int nargs) | |
| super_new | back to summary |
|---|---|
| pack-priv void super_new(InstanceScope scope, String name, Map<String, Object> attrs) | |
| testAttributeTrue | back to summary |
|---|---|
| protected boolean testAttributeTrue(Object a) | |
| toString | back to summary |
|---|---|
| protected String toString(STWriter out, InstanceScope scope, Object value) | |
| trace | back to summary |
|---|---|
| protected void trace(InstanceScope scope, int ip) | |
| trackDebugEvent | back to summary |
|---|---|
| protected void trackDebugEvent(InstanceScope scope, InterpEvent e) For every event, we track in overall | |
| trunc | back to summary |
|---|---|
| public Object trunc(InstanceScope scope, Object v) Return all but the last element. | |
| writeIterator | back to summary |
|---|---|
| protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException | |
| writeObject | back to summary |
|---|---|
| protected int writeObject(STWriter out, InstanceScope scope, Object o, String[] options) Generic method to emit text for an object. It differentiates between templates, iterable objects, and plain old Java objects (POJOs) | |
| writeObjectNoOptions | back to summary |
|---|---|
| protected int writeObjectNoOptions(STWriter out, InstanceScope scope, Object o) Write out an expression result that doesn't use expression options.
E.g., | |
| writeObjectWithOptions | back to summary |
|---|---|
| protected int writeObjectWithOptions(STWriter out, InstanceScope scope, Object o, Object[] options) Write out an expression result that uses expression options.
E.g., | |
| writePOJO | back to summary |
|---|---|
| protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException | |
| zip_map | back to summary |
|---|---|
| protected ST. Renders expressions of the form | |
| Access | Constructor and Description |
|---|---|
| protected |
| ArgumentsMap | back to summary |
|---|---|
| protected ArgumentsMap() | |
| Access | Constructor and Description |
|---|---|
| protected |
| ObjectList | back to summary |
|---|---|
| protected ObjectList() | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Interpreter. | |
| public static final Interpreter. | |
| public static final Interpreter. | |
| public static final Interpreter. | |
| public static final Interpreter. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Interpreter. | |
| public static Interpreter. |
| ANCHOR | back to summary |
|---|---|
| public static final Interpreter. | |
| FORMAT | back to summary |
|---|---|
| public static final Interpreter. | |
| NULL | back to summary |
|---|---|
| public static final Interpreter. | |
| SEPARATOR | back to summary |
|---|---|
| public static final Interpreter. | |
| WRAP | back to summary |
|---|---|
| public static final Interpreter. | |
| Option | back to summary |
|---|---|
| private Option() | |
| valueOf | back to summary |
|---|---|
| public static Interpreter. | |
| values | back to summary |
|---|---|
| public static Interpreter. | |