Class FixedType

  • All Implemented Interfaces:
    FunctionTyper

    public class FixedType
    extends Object
    implements FunctionTyper
    A typer for functions which return a fixed, known type.
    • Constructor Detail

      • FixedType

        public FixedType​(ScalarTokenType type)
        Creates a typer which always returns the given type.
        Parameters:
        type - the return type of the function. This must not be an abstract type.
        Throws:
        IllegalArgumentException - if the type is not a valid return type for functions
    • Method Detail

      • computeUpperBound

        public ScalarTokenType computeUpperBound​(FunctionContext ctx)
        Description copied from interface: FunctionTyper
        Calculates the upper bound for the function given the provided context.

        The context contains the upper bounds on the types of all arguments to the function. If a argument is not a subclass of ScalarValuedFunction, its type is null.

        Specified by:
        computeUpperBound in interface FunctionTyper
        Parameters:
        ctx - the context of the function being processed
        Returns:
        the upper bound on the function
      • computeResultType

        public ScalarTokenType computeResultType​(FunctionContext ctx)
        Description copied from interface: FunctionTyper
        Calculates the result type for the function given the provided context.

        The context contains the actual result types of all arguments to the function. If a argument is not a subclass of ScalarValuedFunction, its type is null.

        Specified by:
        computeResultType in interface FunctionTyper
        Parameters:
        ctx - the context of the function being processed
        Returns:
        the result type of the function