Ejemplo n.º 1
0
        /// <summary>
        /// Adds Serialize method to current type
        /// </summary>
        /// <returns></returns>
        public ILProcessor AddMethod()
        {
            Method = behaviour.TypeDefinition.AddMethod(MethodName,
                                                        MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
                                                        module.ImportReference <bool>());

            WriterParameter        = Method.AddParam <NetworkWriter>("writer");
            InitializeParameter    = Method.AddParam <bool>("initialize");
            Method.Body.InitLocals = true;
            worker = Method.Body.GetILProcessor();
            return(worker);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds Serialize method to current type
        /// </summary>
        /// <returns></returns>
        public ILProcessor AddMethod()
        {
            Method = behaviour.TypeDefinition.AddMethod(MethodName,
                                                        MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig);

            ReaderParameter     = Method.AddParam <NetworkReader>("reader");
            InitializeParameter = Method.AddParam <bool>("initialState");

            Method.Body.InitLocals = true;
            worker = Method.Body.GetILProcessor();
            return(worker);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read in all the methods and functions.
        /// </summary>
        private void ReadMethods()
        {
            uint methodCount = this.abcdtr.ReadU30();

#if DEBUG
            if (this.ReadLog != null)
            {
                this.ReadLog.AppendLine("methodCount " + methodCount);
            }
#endif

            while (methodCount-- > 0)
            {
                Method m = this.code.CreateMethod("method" + methodCount + ".abc", 0, 0, 0, 0);

                uint pcount = this.abcdtr.ReadU30();
                uint rtype  = this.abcdtr.ReadU30();

                if (rtype > 0)
                {
                    m.ReturnType = this.code.GetMultiname((int)rtype);
                }
#if DEBUG
                if (this.ReadLog != null)
                {
                    this.ReadLog.AppendLine("method, rtype " + m.ReturnType);
                }
#endif

                for (int j = 0; j < pcount; j++)
                {
                    uint ptype = this.abcdtr.ReadU30();
                    m.AddParam(this.code.GetMultiname((int)ptype));
#if DEBUG
                    if (this.ReadLog != null)
                    {
                        this.ReadLog.AppendLine("  param " + (j + 1) + " type " + this.code.GetMultiname((int)ptype));
                    }
#endif
                }

                m.Name  = this.ReadString();
                m.Flags = this.abcdtr.ReadUI8();
#if DEBUG
                if (this.ReadLog != null)
                {
                    this.ReadLog.AppendLine("  name " + m.Name);
                    this.ReadLog.AppendLine("  flags " + m.Flags);
                }
#endif
                if (m.HasOptionalArgs)
                {
                    /* ISSUE 9: We don't store these at the moment. */
                    uint optionCount = this.abcdtr.ReadU30();
                    while (optionCount-- > 0)
                    {
                        /*(void)*/ this.abcdtr.ReadU30();
                        /*(void)*/ this.abcdtr.ReadUI8();
                    }
                }

                if (m.HasParamNames)
                {
                    for (int j = 0; j < pcount; j++)
                    {
                        /* ISSUE 12 */
                        /*(void)*/ this.abcdtr.ReadU30();
                    }
                }
            }
        }