private void BuildSystemManager(AbcFile abc) { var superType = _compiler.ImportType(abc, "mx.managers.SystemManager"); var flexModuleFactoryInterface = FlexTypes.GetFlexModuleFactoryInterface(abc); if (HasCrossDomainRsls) { // Cause the CrossDomainRSLItem class to be linked into this application. var crossDomainRSLItem = _compiler.ImportType(abc, "mx.core.CrossDomainRSLItem"); Debug.Assert(crossDomainRSLItem != null); } var instance = new AbcInstance(true) { Name = DefineSystemManagerName(abc), Flags = AbcClassFlags.FinalSealed, //ProtectedNamespace = abc.DefineProtectedNamespace(NameMxSysManager), Type = _compiler.FlexAppType, BaseTypeName = superType.Name, BaseInstance = superType }; instance.Interfaces.Add(flexModuleFactoryInterface.Name); instance.Initializer = abc.DefineMethod( Sig.@void(), code => { code.ConstructSuper(); code.ReturnVoid(); }); instance.Class.Initializer = abc.DefineEmptyMethod(); abc.AddInstance(instance); _mxSystemManager = instance; BuildSystemManagerCreate(abc, instance); BuildSystemManagerInfo(abc, instance); abc.DefineScript(instance); abc.DefineEmptyScript(); }
internal AbcInstance DefineFlexInitMixin(AbcFile app) { var flexModuleFactoryInterface = FlexTypes.GetFlexModuleFactoryInterface(app); var childManagerInstance = FlexTypes.GetChildManagerInstance(app); var flex4 = childManagerInstance != null; string name = "_FlexInit_" + _compiler.FlexAppPrefix; string ns = _compiler.RootNamespace; var instance = new AbcInstance(true) { Name = app.DefineName(QName.Package(ns, name)), BaseTypeName = app.BuiltinTypes.Object, IsMixin = true, IsFlexInitMixin = true, Initializer = app.DefineMethod( Sig.@this(null, AvmTypeCode.Void), code => { code.ConstructSuper(); code.ReturnVoid(); }), Class = { Initializer = app.DefineEmptyMethod() } }; app.AddInstance(instance); instance.DefineMethod( Sig.@static("init", AvmTypeCode.Void, flexModuleFactoryInterface, "f"), code => { code.PushThisScope(); const int moduleFactoryArg = 1; const int styleManagerVar = 2; if (flex4) { CreateInstance(code, childManagerInstance, moduleFactoryArg); code.Pop(); var styleManager2 = FlexTypes.GetStyleManager2Interface(app); var styleManagerImpl = FlexTypes.GetStyleManagerImpl(app); CreateInstance(code, styleManagerImpl, moduleFactoryArg); code.Coerce(styleManager2); code.SetLocal(styleManagerVar); } RegisterEffectTriggers(app, code); RegisterRemoteClasses(app, code); Action pushStyleManager; if (flex4) { pushStyleManager = () => code.GetLocal(styleManagerVar); } else { pushStyleManager = () => code.Getlex(FlexTypes.GetStyleManagerInstance(app)); } RegisterInheritStyles(app, code, pushStyleManager, flex4); //NOTE: Uncomment to add forward refernce to Flex Application //var appInstance = app.generator.MainInstance; //code.Trace(string.Format("PFC: forward reference to FlexApp class {0}", appInstance.FullName)); //code.Getlex(appInstance); //code.Pop(); code.ReturnVoid(); }); return(instance); }