Class StringConcatHandler
- java.lang.Object
-
- com.tonic.analysis.execution.invoke.StringConcatHandler
-
public final class StringConcatHandler extends Object
Interpreter-side implementation of StringConcatFactory call sites, expanding recipe strings into concatenated results.
-
-
Constructor Summary
Constructors Constructor Description StringConcatHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountConstants(String recipe)Counts the constant markers in a recipe.intcountDynamicArgs(String recipe)Counts the dynamic-argument markers in a recipe.StringexecuteConcat(ConcreteValue[] stackArgs)Concatenates the stack arguments in order for a recipe-less call site.StringexecuteConcat(ConcreteValue[] stackArgs, String recipe, Object[] constants)Builds the concatenated string, expanding the recipe's argument and constant markers in order.intgetExpectedArgCount(String descriptor)Counts the parameters declared in a call site descriptor.booleanhasRecipe(InvokeDynamicInfo info)Checks whether the call site variant carries a recipe constant.booleanisStringConcat(InvokeDynamicInfo info)Checks whether the call site's bootstrap method is a StringConcatFactory entry point.StringparseRecipe(String recipe)Renders a recipe readably, replacing tag characters with {arg} and {const} markers.
-
-
-
Field Detail
-
TAG_ARG
public static final char TAG_ARG
- See Also:
- Constant Field Values
-
TAG_CONST
public static final char TAG_CONST
- See Also:
- Constant Field Values
-
-
Method Detail
-
executeConcat
public String executeConcat(ConcreteValue[] stackArgs, String recipe, Object[] constants)
Builds the concatenated string, expanding the recipe's argument and constant markers in order.- Parameters:
stackArgs- the dynamic argument values popped from the stackrecipe- the concat recipe, or null or empty for plain concatenationconstants- the bootstrap constant arguments, may be null- Returns:
- the concatenated string
-
executeConcat
public String executeConcat(ConcreteValue[] stackArgs)
Concatenates the stack arguments in order for a recipe-less call site.- Parameters:
stackArgs- the dynamic argument values popped from the stack- Returns:
- the concatenated string
-
isStringConcat
public boolean isStringConcat(InvokeDynamicInfo info)
Checks whether the call site's bootstrap method is a StringConcatFactory entry point.- Parameters:
info- the invokedynamic call site information, may be null- Returns:
- true if the bootstrap is makeConcat or makeConcatWithConstants
-
hasRecipe
public boolean hasRecipe(InvokeDynamicInfo info)
Checks whether the call site variant carries a recipe constant.- Parameters:
info- the invokedynamic call site information- Returns:
- true if the bootstrap is makeConcatWithConstants
-
getExpectedArgCount
public int getExpectedArgCount(String descriptor)
Counts the parameters declared in a call site descriptor.- Parameters:
descriptor- the call site method descriptor, may be null- Returns:
- the parameter count, or 0 for a malformed descriptor
-
parseRecipe
public String parseRecipe(String recipe)
Renders a recipe readably, replacing tag characters with {arg} and {const} markers.- Parameters:
recipe- the concat recipe, may be null- Returns:
- the readable form, or an empty string for null
-
countDynamicArgs
public int countDynamicArgs(String recipe)
Counts the dynamic-argument markers in a recipe.- Parameters:
recipe- the concat recipe, may be null- Returns:
- the number of argument slots
-
countConstants
public int countConstants(String recipe)
Counts the constant markers in a recipe.- Parameters:
recipe- the concat recipe, may be null- Returns:
- the number of constant slots
-
-