Package gnu.mapping

Class MethodProc

    • Field Detail

      • argTypes

        protected Object argTypes
        The parameter types. Usually either an Type[] or a String encoding.
      • NO_MATCH

        public static final int NO_MATCH
        Return code from match: Unspecified failure.
        See Also:
        Constant Field Values
      • NO_MATCH_TOO_FEW_ARGS

        public static final int NO_MATCH_TOO_FEW_ARGS
        Return code from match: Too few actual arguments. The lower half is the minimum number of arguments (if not 0xffff).
        See Also:
        Constant Field Values
      • NO_MATCH_TOO_MANY_ARGS

        public static final int NO_MATCH_TOO_MANY_ARGS
        Return code from match: Too many actual arguments. The lower half is the maximum number of arguments (if not 0xffff).
        See Also:
        Constant Field Values
      • NO_MATCH_AMBIGUOUS

        public static final int NO_MATCH_AMBIGUOUS
        Return code from match: Ambigious which method to select.
        See Also:
        Constant Field Values
      • NO_MATCH_BAD_TYPE

        public static final int NO_MATCH_BAD_TYPE
        Return code from match: Invalid argument type. In that case the lower half is the 1-origin index of the first argument that does not match.
        See Also:
        Constant Field Values
      • NO_MATCH_UNUSED_KEYWORD

        public static final int NO_MATCH_UNUSED_KEYWORD
        Return code from match: Unused keyword argument. I.e. a keyword in the call doesn't match a keyword parameter. In that case the lower half is the 1-origin index of the first keyword argument that does not match.
        See Also:
        Constant Field Values
      • applyToConsumerDefaultMP

        public static final MethodHandle applyToConsumerDefaultMP
    • Constructor Detail

      • MethodProc

        public MethodProc()
      • MethodProc

        public MethodProc​(boolean resultGoesToConsumer,
                          MethodHandle applyMethod)
    • Method Detail

      • isApplicable

        public int isApplicable​(Type[] argTypes,
                                Type restType)
        Test if method is applicable to an invocation with given arguments.
        Parameters:
        argTypes - array of known "single" arguments.
        restType - If null, the arguments are fully specified by argTypes. If non-null, there may be an unknown number of extra arguments of the given restType. This is used for splices, where we usually don't know at compile-time how many argument values we have.
        Returns:
        -1 if no; 1 if yes; 0 if need to check at run-time.
      • numParameters

        public int numParameters()
        Return number of parameters, including optional and rest arguments.
      • resolveParameterTypes

        protected void resolveParameterTypes()
        Figure out or decode the parameter types, setting argTypes.
      • getParameterType

        public Type getParameterType​(int index)
      • matchFailAsException

        public static RuntimeException matchFailAsException​(int code,
                                                            Procedure proc,
                                                            ArgList args)
        Helper method to throw an exception if a matchX method fails.
      • mostSpecific

        public static MethodProc mostSpecific​(MethodProc proc1,
                                              MethodProc proc2)
        Return the more specific of the arguments.
        Returns:
        null if neither is more specific.
      • overrideEquivalent

        public static boolean overrideEquivalent​(MethodProc proc1,
                                                 MethodProc proc2)
        An approximation of "override-equivalent" as defined in the JLS.