Пример #1
0
        private static void ResolveEmbed(SwfMovie lib, AbcInstance instance, AbcTrait trait)
        {
            if (instance.IsInterface)
            {
                return;
            }

            var superName = instance.BaseTypeName.FullName;

            if (!superName.EndsWith("Asset") || IsAssetClass(instance))
            {
                return;
            }

            string className = instance.FullName;
            var    asset     = lib.FindAsset(className);

            if (asset == null)
            {
                CompilerReport.Add(Warnings.UnableFindSwfAsset, className);
                return;
            }

            Embed.Apply(trait, asset, lib);
        }
Пример #2
0
        public static void Resolve(AbcTrait trait, AbcMetaEntry e, SwfMovie lib)
        {
            if (trait.Embed != null)
            {
                return;
            }

            var klass = trait.Class;

            if (klass == null)
            {
                throw new InvalidOperationException("Embed can be applied to class trait only");
            }

            string symbol       = e[Attrs.Symbol];
            string exportSymbol = e[Attrs.ExportSymbol];
            string source       = e[Attrs.Source];

            var asset = lib.FindAsset(symbol);

            if (asset == null)
            {
                asset = lib.FindAsset(exportSymbol);
                if (asset == null)
                {
                    throw Errors.Linker.UnableToFindSymbol.CreateException(symbol);
                }
                asset.IsExported = true;
            }

            var instance = klass.Instance;

            var embed = new Embed
            {
                Symbol       = symbol,
                Asset        = asset,
                Movie        = lib,
                Source       = source,
                ExportSymbol = exportSymbol,
                Instance     = instance
            };

            trait.Embed         = embed;
            trait.AssetInstance = instance;
        }