Esempio n. 1
0
        void InitPrerequisites()
        {
            AppAssembly.CustomData().SWF = Swf;

            AssemblyIndex.Setup(AppAssembly);

            LinkRsls();
        }
Esempio n. 2
0
        internal AbcInstance ImportInstance(string fullname)
        {
            var asm = ApplicationAssembly;

            if (asm != null)
            {
                var instance = AssemblyIndex.FindInstance(asm, fullname);
                if (instance != null)
                {
                    return(ImportInstance(instance));
                }
            }
            return(null);
        }
Esempio n. 3
0
        internal AbcInstance ImportInstance(AbcMultiname name)
        {
            var assembly = ApplicationAssembly;

            if (assembly != null)
            {
                var instance = AssemblyIndex.FindInstance(assembly, name);
                if (instance != null)
                {
                    return(ImportInstance(instance));
                }
            }
            return(null);
        }
Esempio n. 4
0
        internal AbcInstance FindInstance(AbcMultiname name, bool seeExternal)
        {
            if (name == null)
            {
                return(null);
            }
            if (name.IsRuntime)
            {
                return(null);
            }

            AbcInstance instance;

            if (seeExternal)
            {
                var asm = ApplicationAssembly;
                if (asm != null)
                {
                    instance = AssemblyIndex.FindInstance(asm, name);
                    if (instance != null)
                    {
                        return(instance);
                    }
                }
            }

            instance = Instances[name];
            if (instance != null)
            {
                return(instance);
            }

            var pf = PrevFrame;

            if (pf != null)
            {
                Debug.Assert(pf != this);
                instance = pf.FindInstance(name, false);
                if (instance != null)
                {
                    return(instance);
                }
            }

            return(null);
        }
Esempio n. 5
0
 public object ResolveExternalReference(string id)
 {
     return(AssemblyIndex.ResolveRef(Assembly, id));
 }
Esempio n. 6
0
 public IType FindType(string fullname)
 {
     return(AssemblyIndex.FindType(Assembly, fullname));
 }
Esempio n. 7
0
 public AbcInstance FindInstanceRef(AbcMultiname name)
 {
     return(AssemblyIndex.FindInstance(AppAssembly, name));
 }
Esempio n. 8
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);
        }