public AbcInstance DefineEmptyInstance(object name, bool emptyCtor) { var instance = new AbcInstance(true) { Name = DefineName(name), BaseTypeName = BuiltinTypes.Object, Flags = AbcClassFlags.Final | AbcClassFlags.Sealed }; if (emptyCtor) { instance.Initializer = DefineMethod( Sig.@void(), code => { code.ConstructSuper(); code.ReturnVoid(); }); } instance.Class.Initializer = DefineEmptyMethod(); AddInstance(instance); return(instance); }
public void DefineScriptInit(AbcScript script) { script.Initializer = DefineMethod( Sig.@void(), code => { code.PushThisScope(); code.InitClassProperties(script); code.ReturnVoid(); } ); }
public void ImportResourceBundle(string locale, string name, ResourceBundleContext context) { if (context == null) { context = new ResourceBundleContext(); } context.Locale = locale; ResourceBundles.CopyFlexLocale(locale); string key = locale + "$" + name; if (ContainsResourceBundle(key)) { return; } var rb = ResourceBundles.Get(locale, name); //NOTE: null in case of Dynamic Resource Modules!!! if (rb == null) { return; } var superType = ResourceBundleSuper; var instance = new AbcInstance(true) { ResourceBundleName = name, Locale = locale }; _rbcache[key] = instance; //NOTE: naming is strongly determined in Flex Resource Manager. string fullname = locale + '$' + name + "_properties"; instance.Name = DefineName(QName.Global(fullname)); instance.Flags = AbcClassFlags.Sealed | AbcClassFlags.ProtectedNamespace; instance.ProtectedNamespace = DefineProtectedNamespace(fullname); instance.BaseInstance = superType; instance.BaseTypeName = superType.Name; AddInstance(instance); instance.Initializer = DefineMethod( Sig.@void(), code => { code.PushThisScope(); code.LoadThis(); code.PushString(locale); code.PushString(name); code.ConstructSuper(2); code.ReturnVoid(); }); instance.Class.Initializer = DefineEmptyMethod(); var mn = DefineQName(instance.ProtectedNamespace, "getContent"); instance.DefineMethod( Sig.@override(mn, AvmTypeCode.Object), code => { int n = 0; var lines = rb.Content; for (int i = 0; i < lines.Length; ++i) { string line = lines[i]; context.Line = i + 1; context.ResourceBundle = rb; if (PushKeyValue(line, code, context)) { ++n; } } code.Add(InstructionCode.Newobject, n); code.ReturnValue(); } ); DefineScript(instance); }