Beispiel #1
0
        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();
        }
Beispiel #2
0
        private AbcInstance BuildAssetInstance(AbcMultiname name, AbcMultiname superName)
        {
            var superType = FindAssetSuperType(superName);

            if (superType == null)
            {
                throw Errors.Type.UnableToFind.CreateException(superName.FullName);
            }

            //TODO: Check existance of instance

            var instance = new AbcInstance(true)
            {
                Name               = name,
                BaseTypeName       = superName,
                Flags              = (AbcClassFlags.Sealed | AbcClassFlags.ProtectedNamespace),
                ProtectedNamespace = Abc.DefineProtectedNamespace(name.NameString),
                Initializer        = Abc.DefineMethod(
                    Sig.@void(),
                    code =>
                {
                    code.PushThisScope();
                    code.ConstructSuper();
                    code.ReturnVoid();
                }),
                BaseInstance = superType,
                Class        = { Initializer = Abc.DefineMethod(
                                     Sig.global(null),
                                     code =>
                    {
                        if (true)
                        {
                            code.PushThisScope();
                        }
                        code.ReturnVoid();
                    }) }
            };

            Abc.AddInstance(instance);

            return(instance);
        }
Beispiel #3
0
        private void DefineScript(AbcInstance instance)
        {
            var script = new AbcScript();

            Abc.Scripts.Add(script);

            script.DefineClassTraits(instance);

            script.Initializer = Abc.DefineMethod(
                Sig.@void(),
                code =>
            {
                code.PushThisScope();

                if (IsSwc && instance.Type.Is(SystemTypeCode.Object))
                {
                    code.AddRange(_generator.NewApi);
                }

                var list = GetBaseTypesWithCctors(instance);

                const int arr = 1;
                code.Add(InstructionCode.Newarray, 0);
                code.SetLocal(arr);

                _generator.StaticCtors.DelayCalls(code, list, arr);
                code.InitClassProperties(script);
                _generator.StaticCtors.UndelayCalls(code, list, arr);

                //code.Trace("Initialization of " + instance.FullName);

                _generator.StaticCtors.Call(code, instance);
                _generator.StaticCtors.CallRange(code, list);

                code.ReturnVoid();
            }
                );
        }
Beispiel #4
0
        public AbcMethod SetProperty(AbcMultiname prop)
        {
            if (prop == null)
            {
                throw new ArgumentNullException("prop");
            }

            var m = _abc.DefineMethod(
                Sig.@void(AvmTypeCode.Object, "value"),
                code =>
            {
                code.FindProperty(prop);
                code.GetLocal(1);                                 //value
                code.SetProperty(prop);
                code.ReturnVoid();
            });

#if DEBUG
            m.Name = _abc.DefineString("set_" + prop.NameString);
#endif

            return(m);
        }