예제 #1
0
        private void LinkMethod(IMethod method, IAbcTraitProvider owner, bool isGlobal)
        {
            var instance = owner as AbcInstance;

            if (instance != null && method.IsConstructor && !isGlobal)
            {
                LinkCtor(method, instance);
                return;
            }

            if (!isGlobal)
            {
                if (LinkEvent(method, instance))
                {
                    return;
                }
            }

            if (!ShouldLink(method))
            {
                return;
            }

            var t = GetTrait(method, owner);

            if (t != null)
            {
                LinkMethod(method, t.Method);
                return;
            }

            var abcMethod = isGlobal ? FindGlobalMethod(method) : FindMethod(instance, method);

            LinkMethod(method, abcMethod);
        }
예제 #2
0
 private void LinkMethods(IType type, IAbcTraitProvider owner, bool isGlobal)
 {
     foreach (var method in type.Methods)
     {
         LinkMethod(method, owner, isGlobal);
     }
 }
예제 #3
0
 private void ImportTraits(IAbcTraitProvider from, IAbcTraitProvider to)
 {
     foreach (var trait in from.Traits)
     {
         var t2 = ImportTrait(trait);
         to.Traits.Add(t2);
     }
 }
예제 #4
0
        public AbcTraitCollection(IAbcTraitProvider owner)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            _owner = owner;
        }
예제 #5
0
 private void ImportTraits(IAbcTraitProvider from, IAbcTraitProvider to, ref AbcMethod importMethod)
 {
     foreach (var trait in from.Traits)
     {
         var t2 = ImportTrait(trait);
         if (trait.Method == importMethod)
         {
             importMethod = t2.Method;
         }
         to.Traits.Add(t2);
     }
 }
예제 #6
0
 void EnsureTraits(IAbcTraitProvider tp)
 {
     foreach (var trait in tp.Traits)
     {
         if (!IsDefined(trait.Name))
         {
             throw Errors.ABC.BadFormat.CreateException();
         }
         //CheckQName(trait.Name);
         if (trait.IsField)
         {
             trait.SlotType = ImportConst(trait.SlotType);
         }
     }
 }
예제 #7
0
        private AbcTrait GetTrait(ICustomAttributeProvider cp, IAbcTraitProvider owner)
        {
            foreach (var attr in cp.CustomAttributes)
            {
                switch (attr.TypeName)
                {
                case Attrs.AbcInstanceTrait:
                {
                    int index = GetIndex(attr);
                    return(owner.Traits[index]);
                }

                case Attrs.AbcClassTrait:
                {
                    int index = GetIndex(attr);
                    return(((AbcInstance)owner).Class.Traits[index]);
                }

                case Attrs.AbcScriptTrait:
                {
                    var abc = GetAbcFileCore(cp);
                    if (abc == null)
                    {
                        return(null);
                    }

                    var scriptAttr = cp.FindAttribute(Attrs.AbcScript);
                    if (scriptAttr == null)
                    {
                        return(null);
                    }

                    int scriptIndex = GetIndex(scriptAttr);
                    int index       = GetIndex(attr);

                    return(abc.Scripts[scriptIndex].Traits[index]);
                }
                }
            }
            return(null);
        }