コード例 #1
0
ファイル: AbcFileLoader.cs プロジェクト: liwq-net/SwfLib
        public AbcFileLoader(AbcFileInfo fileInfo)
        {
            FileInfo = fileInfo;

            ReadConstants();

            for (var i = 0; i < fileInfo.Classes.Length; i++) {
                Classes.Add(new AbcClass());
            }

            for (var i = 0; i < fileInfo.Scripts.Length; i++) {
                Scripts.Add(new AbcScript());
            }

            foreach (var metaInfo in fileInfo.Metadata) {
                _metadata.Add(ReadMetadata(metaInfo));
            }

            foreach (var methodInfo in fileInfo.Methods) {
                var method = new AbcMethod {
                    Name = fileInfo.ConstantPool.Strings[methodInfo.Name],
                    ReturnType = GetMultiname(methodInfo.ReturnType, AbcMultiname.Void),
                    NeedArguments = methodInfo.NeedArguments,
                    NeedActivation = methodInfo.NeedActivation,
                    NeedRest = methodInfo.NeedRest,
                    SetDxns = methodInfo.SetDxns,
                    IgnoreRest = methodInfo.IgnoreRest,
                    Native = methodInfo.Native,
                };
                for (var paramIndex = 0; paramIndex < methodInfo.ParamTypes.Length; paramIndex++) {
                    var paramInfo = methodInfo.ParamTypes[paramIndex];
                    method.Params.Add(new AbcMethodParam {
                        Type = GetMultiname(paramInfo, AbcMultiname.Any),
                        Name = methodInfo.HasParamNames ? fileInfo.ConstantPool.Strings[methodInfo.ParamNames[paramIndex].ParamName] : null
                    });
                }
                if (methodInfo.HasOptional) {
                    var paramShift = methodInfo.ParamTypes.Length - methodInfo.Options.Length;
                    for (var i = 0; i < methodInfo.ParamTypes.Length; i++) {
                        var defaultIndex = i - paramShift;
                        if (defaultIndex >= 0) {
                            var param = method.Params[i];
                            var option = methodInfo.Options[defaultIndex];
                            param.Default = GetConstantValue(option.Kind, option.Value);
                        }
                    }
                }
                Methods.Add(method);
            }
            LoadClassInstances();
            LoadMethodBodies();
            LoadClassInitializers();
            LoadScriptInitializers();
            LoadTraits();
        }
コード例 #2
0
        public AbcFileLoader(AbcFileInfo fileInfo)
        {
            FileInfo = fileInfo;

            ReadConstants();

            for (var i = 0; i < fileInfo.Classes.Length; i++)
            {
                Classes.Add(new AbcClass());
            }

            for (var i = 0; i < fileInfo.Scripts.Length; i++)
            {
                Scripts.Add(new AbcScript());
            }

            foreach (var metaInfo in fileInfo.Metadata)
            {
                _metadata.Add(ReadMetadata(metaInfo));
            }

            foreach (var methodInfo in fileInfo.Methods)
            {
                var method = new AbcMethod {
                    Name           = fileInfo.ConstantPool.Strings[methodInfo.Name],
                    ReturnType     = GetMultiname(methodInfo.ReturnType, AbcMultiname.Void),
                    NeedArguments  = methodInfo.NeedArguments,
                    NeedActivation = methodInfo.NeedActivation,
                    NeedRest       = methodInfo.NeedRest,
                    SetDxns        = methodInfo.SetDxns,
                    IgnoreRest     = methodInfo.IgnoreRest,
                    Native         = methodInfo.Native,
                };
                for (var paramIndex = 0; paramIndex < methodInfo.ParamTypes.Length; paramIndex++)
                {
                    var paramInfo = methodInfo.ParamTypes[paramIndex];
                    method.Params.Add(new AbcMethodParam {
                        Type = GetMultiname(paramInfo, AbcMultiname.Any),
                        Name = methodInfo.HasParamNames ? fileInfo.ConstantPool.Strings[methodInfo.ParamNames[paramIndex].ParamName] : null
                    });
                }
                if (methodInfo.HasOptional)
                {
                    var paramShift = methodInfo.ParamTypes.Length - methodInfo.Options.Length;
                    for (var i = 0; i < methodInfo.ParamTypes.Length; i++)
                    {
                        var defaultIndex = i - paramShift;
                        if (defaultIndex >= 0)
                        {
                            var param  = method.Params[i];
                            var option = methodInfo.Options[defaultIndex];
                            param.Default = GetConstantValue(option.Kind, option.Value);
                        }
                    }
                }
                Methods.Add(method);
            }
            LoadClassInstances();
            LoadMethodBodies();
            LoadClassInitializers();
            LoadScriptInitializers();
            LoadTraits();
        }
コード例 #3
0
ファイル: XAbcOpcodeExts.cs プロジェクト: liwq-net/SwfLib
 public static XElement AddMethod(this XElement node, AbcMethod method)
 {
     node.Add(new XAttribute("method", method.Name));
     return node;
 }