コード例 #1
0
        internal virtual LambdaForm CollectArgumentsForm(int pos, MethodType collectorType)
        {
            int  collectorArity = collectorType.ParameterCount();
            bool dropResult     = (collectorType.ReturnType() == typeof(void));

            if (collectorArity == 1 && !dropResult)
            {
                return(FilterArgumentForm(pos, basicType(collectorType.ParameterType(0))));
            }
            BasicType[]    newTypes = BasicType.basicTypes(collectorType.ParameterList());
            Transform.Kind kind     = (dropResult ? Transform.Kind.COLLECT_ARGS_TO_VOID : Transform.Kind.COLLECT_ARGS);
            if (dropResult && collectorArity == 0)             // pure side effect
            {
                pos = 1;
            }
            Transform  key  = Transform.Of(kind, pos, collectorArity, BasicType.basicTypesOrd(newTypes));
            LambdaForm form = GetInCache(key);

            if (form != null)
            {
                assert(form.Arity_Renamed == LambdaForm.Arity_Renamed - (dropResult ? 0 : 1) + collectorArity);
                return(form);
            }
            form = MakeArgumentCombinationForm(pos, collectorType, false, dropResult);
            return(PutInCache(key, form));
        }