Beispiel #1
0
        internal AnnotatedMethod AnnotateMethod(AnnotatedMethod method)
        {
            int count = 0;

            foreach (AnnotatedMethod key in this.getMethods())
            {
                if (method.SourceMethod == key.SourceMethod)
                {
                    count++;
                    if (AnnotatedMethod.EqualMethods(method, key))
                    {
                        return(key);
                    }
                }
            }

            if (count > AnnotatedAssemblyHolder.NUMBER_FOR_MERGE)
            {
                AnnotatedMethod keyMethod         = null;
                int             keyMethodCreators = 0;

                foreach (AnnotatedMethod key in this.getMethods())
                {
                    if (method.SourceMethod == key.SourceMethod)
                    {
                        int keyCreators = AnnotatedMethod.PseudoMergeMethods(method, key).Count;
                        if (keyMethod == null || keyMethodCreators > keyCreators)
                        {
                            keyMethod         = key;
                            keyMethodCreators = keyCreators;
                        }
                    }
                }

                if (keyMethod != null && (keyMethodCreators == 0 || count > AnnotatedAssemblyHolder.NUMBER_FOR_LIFT))
                {
                    Creators crtrs = AnnotatedMethod.MergeMethods(method, keyMethod);
                    if (!crtrs.IsEmpty)
                    {
                        throw new AnnotatingVisitor.LiftException(crtrs);
                    }

                    return(keyMethod);
                }
            }

            MethodBodyBlock mbbUp = Annotation.AnnotateMethod(this, method);

            this.addMethodBody(method, mbbUp);
            return(method);
        }