Exemple #1
0
 internal void MustHaveADefinition(QualifiedMemberName name)
 {
     if (mustHaveADefinitionCache == null)
     {
         mustHaveADefinitionCache = new Set <QualifiedMemberName>();
     }
     mustHaveADefinitionCache.Add(name);
 }
Exemple #2
0
 internal void UsedBy(QualifiedMemberName name)
 {
     if (usedByMembers == null)
     {
         usedByMembers = new Set <QualifiedMemberName>();
     }
     usedByMembers.Add(name);
 }
Exemple #3
0
 internal void ImplementedBy(QualifiedMemberName name)
 {
     if (implementors == null)
     {
         implementors = new Seq <QualifiedMemberName>();
     }
     implementors.Add(name);
 }
Exemple #4
0
        public bool ExtraUsedMethod(QualifiedMemberName name)
        {
            var assemblyDef = default(AssemblyDef);
            var typeDef     = default(TypeDef);
            var memberDef   = default(MemberDef);

            if (name.PrimTryResolve(Global, out assemblyDef, out typeDef, out memberDef))
            {
                return(memberDef.MarkAsUsed(this, assemblyDef, typeDef));
            }
            return(false);
        }
Exemple #5
0
        private static void FriendlyMemberName(StringBuilder sb, CST.QualifiedMemberName name)
        {
            var types = name.DefiningType.Type.Types;

            JST.Lexemes.AppendStringToFriendlyIdentifier(sb, types[types.Count - 1], 15);
            sb.Append('_');
            var i  = name.Signature.Name.LastIndexOf('.');
            var nm = i >= 0 && i < name.Signature.Name.Length - 1
                         ? name.Signature.Name.Substring(i + 1)
                         : name.Signature.Name;

            JST.Lexemes.AppendStringToFriendlyIdentifier(sb, nm, 15);
        }
Exemple #6
0
        private int MethodBodySize(CST.QualifiedMemberName name)
        {
            var s = default(int);

            if (bodySizeCache.TryGetValue(name, out s))
            {
                // Already determined
                return(s);
            }

            var assemblyDef = default(CST.AssemblyDef);
            var typeDef     = default(CST.TypeDef);
            var memberDef   = default(CST.MemberDef);

            if (name.PrimTryResolve(env.Global, out assemblyDef, out typeDef, out memberDef))
            {
                var methodDef = (CST.MethodDef)memberDef;

                if (PrimIsInlinable(assemblyDef, typeDef, methodDef))
                {
                    // Local method size, ignoring inlining
                    var instructions = methodDef.Instructions(env.Global);
                    s = instructions.Size;

                    // Collect calls
                    foreach (var call in methodDef.UsedMembers.Where(n => n.Signature.Flavor == CST.MemberDefFlavor.Method))
                    {
                        var t = MethodBodySize(call);
                        if (t >= 0)
                        {
                            // Inlinable method, replace call with body
                            s += t - 1;
                        }
                    }
                }
                else
                {
                    // Obviously non-inlinable method
                    s = -1;
                }
            }
            else
            {
                s = -1;
            }

            bodySizeCache.Add(name, s);
            return(s);
        }
Exemple #7
0
        public bool FirstOccuranceOfMethod(MessageContext ctxt, CST.QualifiedMemberName name, Trace trace)
        {
            var prev = default(Trace);

            if (MethodToTrace.TryGetValue(name, out prev))
            {
                Env.Log(new DuplicateTraceEntryMessage(ctxt, prev.Name, trace.Name));
                return(false);
            }
            else
            {
                MethodToTrace.Add(name, trace);
                return(true);
            }
        }
Exemple #8
0
 public bool IsMustHaveADefinition(QualifiedMemberName name)
 {
     return(mustHaveADefinitionCache == null ? false : mustHaveADefinitionCache.Contains(name));
 }
Exemple #9
0
 public InvalidMemberName(MessageContext ctxt, QualifiedMemberName name, string message)
     : base(ctxt, Severity.Warning, "1021")
 {
     Name    = name;
     Message = message;
 }
Exemple #10
0
 public string ResolvePropertyToSlot(CST.QualifiedMemberName name)
 {
     return(propSlots.For(ctxt, name));
 }
Exemple #11
0
 public string ResolveEventToSlot(CST.QualifiedMemberName name)
 {
     return(eventSlots.For(ctxt, name));
 }
Exemple #12
0
 public string ResolveFieldToSlot(CST.QualifiedMemberName name)
 {
     return(fieldSlots.For(ctxt, name));
 }
Exemple #13
0
 public string ResolveMethodToSlot(CST.QualifiedMemberName name)
 {
     return(methodSlots.For(ctxt, name));
 }