public SwfTagDoAbc2(string frameName, uint flags, AbcFile abc) { _frameName = frameName; _flags = flags; ByteCode = abc; }
public PropertyPtr(AbcFile abc) { _abc = abc; }
public IEnumerable <string> GetNamespaceRefs(AbcFile abc) { return(from dep in GetDeps(abc) where dep.IsNamespace select dep.ID); }
/* Base Method Code * public function create(... params):Object * { * var mainClassName:String = info()["mainClassName"]; * * if (mainClassName == null) * { * var url:String = loaderInfo.loaderURL; * var dot:int = url.lastIndexOf("."); * var slash:int = url.lastIndexOf("/"); * mainClassName = url.substring(slash + 1, dot); * } * * var mainClass:Class = Class(getDefinitionByName(mainClassName)); * * return mainClass ? new mainClass() : null; * } */ /* Flex Auto Generated Code * public override function create(... params):Object * { * if (params.length > 0 && !(params[0] is String)) * return super.create.apply(this, params); * * var mainClassName:String = params.length == 0 ? "AppName" : String(params[0]); * var mainClass:Class = Class(getDefinitionByName(mainClassName)); * if (!mainClass) * return null; * * var instance:Object = new mainClass(); * if (instance is IFlexModule) * (IFlexModule(instance)).moduleFactory = this; * return instance; * } */ void BuildSystemManagerCreate(AbcFile abc, AbcInstance instance) { var method = instance.DefineMethod( Sig.@virtual("create", AvmTypeCode.Object).@override(), code => { var typeString = abc.DefineName(QName.Global("String")); var typeClass = abc.DefineName(QName.Global("Class")); //NOTE: getDefinitionByName is method of mx.core.SystemManager var getDefByName = abc.DefineName(QName.Global("getDefinitionByName")); const int argParams = 1; const int varClassName = 2; const int varClass = 3; const int varInstance = 4; code.PushThisScope(); code.GetLocal(argParams); code.GetArrayLengthInt(); code.PushInt(0); var gotoCheckString = code.If(BranchOperator.GreaterThan); code.PushString(MainClassName); code.SetLocal(varClassName); var gotoCreate1 = code.Goto(); //check string block var checkString = code.Label(); gotoCheckString.BranchTarget = checkString; //params[0] code.GetNativeArrayItem(argParams, 0); code.Getlex(typeString); code.Add(InstructionCode.Istypelate); //if not str goto calling of super.create var ifNotStr = code.IfFalse(); code.FindPropertyStrict(typeString); code.GetNativeArrayItem(argParams, 0); code.Call(typeString, 1); code.CoerceString(); code.SetLocal(varClassName); var gotoCreate2 = code.Goto(); //super.create.apply(this, params) block var superCreate = code.Label(); ifNotStr.BranchTarget = superCreate; code.LoadThis(); code.GetSuper("create"); code.LoadThis(); code.GetLocal(argParams); code.ApplyFunction(2); code.ReturnValue(); //instance creation block gotoCreate1.BranchTarget = gotoCreate2.BranchTarget = code.Label(); // resolve class by name using SystemManager.getDefinitionByName //code.Trace("PFX_SYSMGR: try to resolve class using SystemManager.getDefinitionByName"); code.FindPropertyStrict(typeClass); code.LoadThis(); code.GetLocal(varClassName); code.Call(getDefByName, 1); code.Call(typeClass, 1); code.Coerce(typeClass); code.SetLocal(varClass); code.GetLocal(varClass); var ifClassNotNull1 = code.IfTrue(); // try to resolve class using flash.system.ApplicationDomain.currentDomain //code.Trace("PFX_SYSMGR: try to resolve class using flash.system.ApplicationDomain.currentDomain"); code.FindPropertyStrict(typeClass); GetCurrentAppDomain(code); code.GetLocal(varClassName); code.Call(abc.DefineName(QName.Global("getDefinition")), 1); code.Call(typeClass, 1); code.Coerce(typeClass); code.SetLocal(varClass); code.GetLocal(varClass); var ifClassNotNull2 = code.IfTrue(); code.Trace(string.Format("PFX_SYSMGR: unable to resolve class '{0}'", MainClassName)); code.ReturnNull(); ifClassNotNull1.BranchTarget = ifClassNotNull2.BranchTarget = code.Label(); // create instance of class was resolved succesfully code.GetLocal(varClass); code.Add(InstructionCode.Construct, 0); code.Add(InstructionCode.Coerce_o); code.SetLocal(varInstance); //if (instance is mx.core.IFlexModule) code.GetLocal(varInstance); var flexModule = _compiler.ImportType(abc, MX.IFlexModule); code.Getlex(flexModule); code.Add(InstructionCode.Istypelate); var gotoReturn = code.IfFalse(); //((IFlexModule)instance).moduleFactory = this code.FindPropertyStrict(flexModule.Name); code.GetLocal(varInstance); code.Call(flexModule.Name, 1); code.LoadThis(); code.SetPublicProperty("mx.core:IFlexModule", "moduleFactory"); gotoReturn.BranchTarget = code.Label(); code.GetLocal(varInstance); code.ReturnValue(); }); method.Flags |= AbcMethodFlags.NeedRest; }
private AbcMultiname DefineSystemManagerName(AbcFile abc) { string ns = _compiler.RootNamespace; return(abc.DefineName(QName.Package(ns, _sysManagerName))); }
private static string CheckOffsetTranslatation(string swcName, byte[] original, AbcFile abc) { byte[] result; int index; foreach (var body in abc.MethodBodies) { var code = body.IL; code.TranslateOffsets(); code.TranslateIndicesEnabled = true; code.TranslateIndices(); } try { result = abc.ToByteArray(); } catch (Exception e) { return(string.Format("Unable to serialize ABC file.\nException: {0}", e)); } string err = CompareTools.CompareByteArrays(original, result, out index); if (!string.IsNullOrEmpty(err)) { return("SWC: " + swcName + ". ABC: " + abc.Name + "." + err); } return(err); }
public bool IsDefined(AbcFile abc) { return(abc.IsDefined(Name)); }
public AbcInstance GetStyleManager2Interface(AbcFile app) { return(_styleManager2Interface ?? (_styleManager2Interface = _compiler.ImportType(app, MX.IStyleManager2))); }
public AbcInstance GetStyleManagerImpl(AbcFile app) { return(_styleManagerImpl ?? (_styleManagerImpl = _compiler.ImportType(app, MX.StyleManagerImpl))); }
public AbcInstance GetChildManagerInstance(AbcFile app) { return(_childManagerInstance ?? (_childManagerInstance = _compiler.ImportType(app, MX.ChildManager, true))); }
public AbcInstance GetFlexModuleFactoryInterface(AbcFile app) { return(_flexModuleFactoryInterface ?? (_flexModuleFactoryInterface = _compiler.ImportType(app, MX.IFlexModuleFactory))); }
public BuiltinTypes(AbcFile abc) { _abc = abc; _types = new AbcMultiname[Names.Length]; }
public ITypeData Import(AbcFile abc) { return(this); }
public bool IsDefined(AbcFile abc) { return(true); }