Exemple #1
0
 public IEnumerable <ASClass> GetClasses(ASMultiname multiname)
 {
     if (multiname == null || !_classesCache.TryGetValue(multiname, out List <ASClass> classes))
     {
         yield break;
     }
     for (int i = 0; i < classes.Count; i++)
     {
         ASClass @class = classes[i];
         if (@class.QName != multiname)
         {
             i--;
             classes.RemoveAt(i);
             if (!_classesCache.TryGetValue(@class.QName, out List <ASClass> newClasses))
             {
                 newClasses = new List <ASClass>();
                 _classesCache.Add(@class.QName, newClasses);
             }
             newClasses.Add(@class);
         }
         else
         {
             yield return(@class);
         }
     }
 }
Exemple #2
0
 public IEnumerable <ASMultiname> GetTypes()
 {
     for (int i = 0; i < TypeIndices.Count; i++)
     {
         int         typeIndex = TypeIndices[i];
         ASMultiname type      = Pool.Multinames[typeIndex];
         yield return(type);
     }
 }
Exemple #3
0
        public List <ASClass> GetClasses(ASMultiname multiname)
        {
            if (multiname == null || !_classesCache.TryGetValue(multiname, out var classes))
            {
                return(null);
            }

            return(classes);
        }
Exemple #4
0
 public IEnumerable <ASMultiname> GetInterfaces()
 {
     for (int i = 0; i < InterfaceIndices.Count; i++)
     {
         int         interfaceIndex = InterfaceIndices[i];
         ASMultiname @interface     = ABC.Pool.Multinames[interfaceIndex];
         yield return(@interface);
     }
 }
Exemple #5
0
        public ASInstance GetInstance(ASMultiname multiname)
        {
            var result = GetInstances(multiname);

            if (result == null || result.Count < 1)
            {
                return(null);
            }

            return(result[0]);
        }
Exemple #6
0
        public ASClass GetClass(ASMultiname multiname)
        {
            var result = GetClasses(multiname);

            if (result == null || result.Count < 1)
            {
                return(null);
            }

            return(result[0]);
        }
Exemple #7
0
        public bool IsImplementingInterface(ASMultiname multiname)
        {
            foreach (var @interface in Instance.GetInterfaces())
            {
                if (@interface.IsMatch(multiname))
                {
                    return(true);
                }
            }

            return(false);
        }
        public void AddMethod(ASMethod method, string qualifiedName)
        {
            var qname = new ASMultiname(ABC.Pool);

            qname.NameIndex      = ABC.Pool.AddConstant(qualifiedName);
            qname.Kind           = MultinameKind.QName;
            qname.NamespaceIndex = 1; // Public

            int methodIndex = ABC.AddMethod(method);
            int qnameIndex  = ABC.Pool.AddConstant(qname);

            var trait = new ASTrait(ABC);

            trait.Kind        = TraitKind.Method;
            trait.QNameIndex  = qnameIndex;
            trait.MethodIndex = methodIndex;

            method.Trait     = trait;
            method.Container = this;
            Traits.Add(trait);
        }
        public bool IsMatch(ASMultiname other)
        {
            if (Equals(other))
            {
                return(true);
            }

            if (!Equals(Name, other.Name))
            {
                return(false);
            }

            if (Kind == MultinameKind.QName && other.Kind == MultinameKind.Multiname)
            {
                return(other.NamespaceSet.GetNamespaces().Any(x => x.ns.Equals(Namespace)));
            }

            if (Kind == MultinameKind.Multiname && other.Kind == MultinameKind.QName)
            {
                return(NamespaceSet.GetNamespaces().Any(x => x.ns.Equals(other.Namespace)));
            }

            return(false);
        }
Exemple #10
0
 public IEnumerable <ASInstance> GetInstances(ASMultiname multiname) => GetClasses(multiname).Select(c => c.Instance);
Exemple #11
0
 public ASInstance GetInstance(ASMultiname multiname) => GetInstances(multiname).FirstOrDefault();
Exemple #12
0
 public ASClass GetClass(ASMultiname multiname) => GetClasses(multiname).FirstOrDefault();
 protected bool Equals(ASMultiname other)
 {
     return(Kind == other.Kind && Name == other.Name && Equals(Namespace, other.Namespace));
 }
Exemple #14
0
 public List <ASInstance> GetInstances(ASMultiname multiname) => GetClasses(multiname).Select(c => c.Instance).ToList();