Example #1
0
        public void AddMethod(MessageContext ctxt, CST.MethodDef methodDef)
        {
            var trace = Parent.Parent;
            var name  = methodDef.QualifiedMemberName(trace.Parent.Env.Global, Parent.Assembly, Type);

            if (trace.Parent.FirstOccuranceOfMethod(ctxt, name, trace))
            {
                Methods.Add(methodDef.MethodSignature);
            }
        }
Example #2
0
        public bool CouldBeInlinableBasedOnHeaderAlone(CST.AssemblyDef assemblyDef, CST.TypeDef typeDef, CST.MethodDef methodDef)
        {
            if (methodDef.IsVirtualOrAbstract || typeDef.Style is CST.InterfaceTypeStyle)
            {
                // No virtuals or interface methods
                return(false);
            }

            if (typeDef.Style is CST.MultiDimArrayTypeStyle)
            {
                // Implemented by runtime
                return(false);
            }

            if (typeDef.IsAttributeType(env.Global, assemblyDef))
            {
                // Don't inline attribute property methods since we invoke them directly when building attributes
                return(false);
            }

            var level = default(ReflectionLevel);

            env.AttributeHelper.GetValueFromType
                (assemblyDef,
                typeDef,
                env.AttributeHelper.ReflectionAttributeRef,
                env.AttributeHelper.TheReflectionLevelProperty,
                true,
                true,
                ref level);
            if (level >= ReflectionLevel.Full)
            {
                // No inlining in classes needing full reflection since need to support dynamic invokes
                return(false);
            }

            // NOTE: Method may be used in a delegate, in which case it's fine to inline but we'll still
            //       need to emit the definition

            if (assemblyDef.EntryPoint != null &&
                assemblyDef.EntryPoint.QualifiedMemberName.Equals
                    (methodDef.QualifiedMemberName(env.Global, assemblyDef, typeDef)))
            {
                // Entry points are called directly by startup code
                return(false);
            }

            return(true);
        }
Example #3
0
        public bool IsInlinable(CST.AssemblyDef assemblyDef, CST.TypeDef typeDef, CST.MethodDef methodDef)
        {
            var s = MethodBodySize(methodDef.QualifiedMemberName(env.Global, assemblyDef, typeDef));

            return(s >= 0 && s <= env.InlineThreshold);
        }
Example #4
0
 public string ResolveMethodDefToSlot(CST.AssemblyDef assemblyDef, CST.TypeDef typeDef, CST.MethodDef methodDef)
 {
     return(TypeMappingFor(assemblyDef, typeDef).ResolveMethodToSlot
                (methodDef.QualifiedMemberName(env.Global, assemblyDef, typeDef)));
 }