//Defines qname for AbcInstance for given type private AbcMultiname DefineInstanceName(IType type) { string ns = type.GetTypeNamespace(_generator.RootNamespace); string name = type.NestedName; return(Abc.DefineName(QName.Package(ns, name))); }
private static AbcMethod GetHashCodeDic(AbcGenerator generator) { var instance = generator.RuntimeImpl.Instance; var dicType = generator.Abc.DefineName(QName.Package("flash.utils", "Dictionary")); var dic = instance.DefineStaticSlot("hcdic$", dicType); return(instance.DefineMethod( Sig.@static("get_hashcode_dic", dicType), code => { code.LoadThis(); code.GetProperty(dic); var br = code.IfNotNull(); code.LoadThis(); code.CreateInstance(dicType); code.SetProperty(dic); br.BranchTarget = code.Label(); code.LoadThis(); code.GetProperty(dic); code.ReturnValue(); })); }
private AbcInstance BuildByteArrayAsset(AbcTrait trait) { var qname = _generator.IsFlexApplication ? QName.Package("mx.core", "ByteArrayAsset") : QName.Package("flash.utils", "ByteArray"); return(BuildAssetInstance(trait, Abc.DefineName(qname))); }
private AbcMultiname GetBitmapAssetSuperName() { // for flash application we use flash.display.Bitmap var qname = _generator.IsFlexApplication ? QName.Package("mx.core", "BitmapAsset") : QName.Package("flash.display", "Bitmap"); return(Abc.DefineName(qname)); }
public void ImportQName1() { var abc1 = new AbcFile(); var c1 = abc1.DefineName(QName.Package("ns", "name")); var abc2 = new AbcFile(); var c2 = abc2.ImportConst(c1); Assert.AreEqual(c1.Index, c2.Index, "#1"); Assert.AreEqual(c1.Namespace.Index, c2.Namespace.Index, "#2"); Assert.AreEqual(c1.Namespace.NameString, c2.Namespace.NameString, "#2"); }
private void RegisterRemoteClasses(AbcFile app, AbcCode code) { if (_remoteClasses.Count == 0) { return; } var registerClassAlias = app.DefineName(QName.Package("flash.net", "registerClassAlias")); foreach (var pair in _remoteClasses) { code.FindPropertyStrict(registerClassAlias); code.PushString(pair.Key); code.Getlex(pair.Value); code.CallVoid(registerClassAlias, 2); } }
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); }
private AbcMultiname DefineSystemManagerName(AbcFile abc) { string ns = _compiler.RootNamespace; return(abc.DefineName(QName.Package(ns, _sysManagerName))); }
private void DefineRootSprite() { if (!_generator.IsSwf) { return; } if (_generator.IsSwc) { return; } //NOTE: In Flex Root sprite is SystemManager. if (_generator.IsFlexApplication) { return; } if (Instance != null) { return; } var rootStageField = DefineRootStageHolder(); IsGenerated = true; const string rootName = "$ROOTSPRITE$"; Instance = new AbcInstance(true) { Name = Abc.DefineName(QName.Package(_generator.RootNamespace, rootName)), Flags = (AbcClassFlags.Sealed | AbcClassFlags.ProtectedNamespace), ProtectedNamespace = Abc.DefineProtectedNamespace(rootName) }; const string superTypeName = "flash.display.Sprite"; var superType = _generator.FindInstanceDefOrRef(superTypeName); if (superType == null) { throw Errors.Type.UnableToFind.CreateException(superTypeName); } Instance.BaseTypeName = Abc.ImportConst(superType.Name); Instance.BaseInstance = superType; Instance.Class.Initializer = Abc.DefineEmptyMethod(); Abc.AddInstance(Instance); Instance.Initializer = Abc.DefineMethod( Sig.@global(null), code => { code.PushThisScope(); code.ConstructSuper(); if (rootStageField != null) { code.SetStaticProperty(rootStageField, () => { code.LoadThis(); code.GetProperty("stage"); }); } _generator.NUnit.Main(code); _generator.Scripts.CallEntryPoint(code); }); }