private void OverrideFlexAppModuleFactorySetter(AbcInstance instance) { Debug.Assert(IsFlex4); var moduleFactoryInitialized = instance.DefineSlot("__moduleFactoryInitialized", AvmTypeCode.Boolean); var flexModuleFactoryInterface = _generator.ImportType(MX.IFlexModuleFactory); var propertyName = Abc.DefineName(QName.Global("moduleFactory")); instance.DefineMethod( Sig.set(propertyName, flexModuleFactoryInterface).@virtual().@override(), code => { code.Trace("PFC: setting FlexModuleFactory to application"); // super.moduleFactory = value code.LoadThis(); code.GetLocal(1); code.SetSuper(propertyName); code.LoadThis(); code.GetProperty(moduleFactoryInitialized); var br = code.IfFalse(); code.ReturnVoid(); br.BranchTarget = code.Label(); code.LoadThis(); code.Add(InstructionCode.Pushtrue); code.SetProperty(moduleFactoryInitialized); CallInitStyles(code, instance); // init application after styles are initialized var ctor = instance.FindParameterlessConstructor(); if (ctor != null) { var ctorMethod = _generator.MethodBuilder.BuildAbcMethod(ctor); code.LoadThis(); if (AbcGenConfig.FlexAppCtorAsHandler) { code.PushNull(); } code.Call(ctorMethod); } code.ReturnVoid(); }); }
private AbcMethod DefineInitFlexAppStyles(AbcInstance instance) { var done = instance.DefineSlot("_init_styles_done", AvmTypeCode.Boolean); return(instance.DefineMethod( Sig.@this("$init_flex_styles$", AvmTypeCode.Void), code => { code.LoadThis(); code.GetProperty(done); var br = code.IfFalse(); code.ReturnVoid(); br.BranchTarget = code.Label(); code.LoadThis(); code.Add(InstructionCode.Pushtrue); code.SetProperty(done); //TODO: init app CSSStyleDeclaration //TODO: init app effects if (IsFlex4) { code.LoadThis(); code.GetProperty("styleManager"); code.CallVoid("initProtoChainRoots", 0); } else { var styleMgr = _generator.ImportType("mx.styles.StyleManager"); code.Getlex(styleMgr); code.CallVoid(Abc.DefineName(QName.MxInternal("initProtoChainRoots")), 0); } code.ReturnVoid(); })); }
void BuildSystemManagerInfo(AbcFile abc, AbcInstance instance) { var objType = abc.BuiltinTypes.Object; if (_cacheInfoObject) { var method = instance.DefineMethod(Sig.@this("$info$", objType), null); _compiler.AddLateMethod(method, BuildSystemManagerInfo); var infoField = instance.DefineSlot("__info", AvmTypeCode.Object); instance.DefineMethod( Sig.@virtual("info", objType).@override(), code => { code.LoadThis(); code.GetProperty(infoField); var br = code.IfNotNull(); code.LoadThis(); code.LoadThis(); code.Call(method); code.SetProperty(infoField); br.BranchTarget = code.Label(); code.LoadThis(); code.GetProperty(infoField); code.ReturnValue(); }); } else { var method = instance.DefineMethod(Sig.@virtual("info", objType).@override(), null); _compiler.AddLateMethod(method, BuildSystemManagerInfo); } }