Esempio n. 1
0
        public AbcFile Generate(IAssembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

#if PERF
            int start = Environment.TickCount;
#endif

#if DEBUG
            DebugService.LogInfo("ABC Generator started");
            DebugService.LogSeparator();
#endif
            AppAssembly = assembly;

            AssemblyIndex.Setup(assembly);

            Abc = new AbcFile
            {
                AutoComplete = true,
                ReduceSize   = true,
                Generator    = this,
                SwfCompiler  = SwfCompiler,
                Assembly     = assembly
            };

            AppAssembly.CustomData().AddAbc(Abc);

            if (SwfCompiler != null)
            {
                SwfCompiler.AppFrame = Abc;
                if (SwfCompiler.IsSwc)
                {
                    Mode = AbcGenerationMode.Full;
                }
            }

            NewApi = new AbcCode(Abc);
            ObjectPrototypes.Init();

            BuildApp();

            if (SwfCompiler != null)
            {
                SwfCompiler.FinishApplication();
            }

            RootSprite.BuildTimeline();

            TypeBuilder.FinishTypes();

            _lateMethods.Finish();

            Scripts.BuildScripts();

            Scripts.FinishMainScript();

            // Finish ABC
            Abc.Finish();

#if PERF
            Console.WriteLine("ABC.MultinameCount: {0}", _abc.Multinames.Count);
            Console.WriteLine("AbcGenerator Elapsed Time: {0}", Environment.TickCount - start);
#endif

            // uncomment to list generated methods
//		    Console.WriteLine("Number of generated methods: {0}", Abc.Methods.Count(x => x.IsGenerated));
//		    Console.WriteLine("Number of anon methods: {0}", Abc.Methods.Count(x => x.IsGenerated && string.IsNullOrEmpty(x.FullName)));
//		    Abc.Methods
//		       .Where(x => x.IsGenerated && !string.IsNullOrEmpty(x.FullName))
//		       .OrderBy(x => x.FullName)
//		       .ToList()
//		       .ForEach(x => Console.WriteLine(x.FullName));

            // reset tags to allow recompilation
            if (!IsSwf && !IsSwc)
            {
                ResetMembersData();
            }

            return(Abc);
        }