Exemplo n.º 1
0
 internal void MustHaveADefinition(QualifiedMemberName name)
 {
     if (mustHaveADefinitionCache == null)
     {
         mustHaveADefinitionCache = new Set <QualifiedMemberName>();
     }
     mustHaveADefinitionCache.Add(name);
 }
Exemplo n.º 2
0
 internal void UsedBy(QualifiedMemberName name)
 {
     if (usedByMembers == null)
     {
         usedByMembers = new Set <QualifiedMemberName>();
     }
     usedByMembers.Add(name);
 }
Exemplo n.º 3
0
 internal void ImplementedBy(QualifiedMemberName name)
 {
     if (implementors == null)
     {
         implementors = new Seq <QualifiedMemberName>();
     }
     implementors.Add(name);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 8
0
 public bool IsMustHaveADefinition(QualifiedMemberName name)
 {
     return(mustHaveADefinitionCache == null ? false : mustHaveADefinitionCache.Contains(name));
 }
Exemplo n.º 9
0
 public InvalidMemberName(MessageContext ctxt, QualifiedMemberName name, string message)
     : base(ctxt, Severity.Warning, "1021")
 {
     Name    = name;
     Message = message;
 }
Exemplo n.º 10
0
 public string ResolvePropertyToSlot(CST.QualifiedMemberName name)
 {
     return(propSlots.For(ctxt, name));
 }
Exemplo n.º 11
0
 public string ResolveEventToSlot(CST.QualifiedMemberName name)
 {
     return(eventSlots.For(ctxt, name));
 }
Exemplo n.º 12
0
 public string ResolveFieldToSlot(CST.QualifiedMemberName name)
 {
     return(fieldSlots.For(ctxt, name));
 }
Exemplo n.º 13
0
 public string ResolveMethodToSlot(CST.QualifiedMemberName name)
 {
     return(methodSlots.For(ctxt, name));
 }