Class StringConcatHandler


  • public final class StringConcatHandler
    extends Object
    Interpreter-side implementation of StringConcatFactory call sites, expanding recipe strings into concatenated results.
    • Constructor Detail

      • StringConcatHandler

        public StringConcatHandler()
    • 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 stack
        recipe - the concat recipe, or null or empty for plain concatenation
        constants - 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