2
// Copyright (C) 2003 Mike Krueger
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// Lesser General Public License for more details.
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
namespace MonoDevelop.SharpAssembly.Metadata.Rows
24
public class MethodBody
26
public const byte CorILMethod_Fat = 0x3;
27
public const byte CorILMethod_TinyFormat = 0x2;
28
public const byte CorILMethod_MoreSects = 0x8;
29
public const byte CorILMethod_InitLocals = 0x10;
35
uint localVarSigTok = 0;
47
public uint HeaderSize {
55
public ushort MaxStack {
63
public uint CodeSize {
71
public uint LocalVarSigTok {
73
return localVarSigTok;
76
localVarSigTok = value;
79
public byte[] MethodData {
89
public void Load(BinaryReader reader)
91
byte flagByte = reader.ReadByte();
92
Console.Write("flagByte : " + flagByte.ToString("X"));
94
switch (flagByte & 0x03) {
96
byte nextByte = reader.ReadByte();
97
Console.WriteLine(" nextByte : " + nextByte.ToString("X"));
99
flags = (uint)(flagByte & ((nextByte & 0x0F) << 8));
100
headerSize = (uint)(nextByte >> 4);
101
maxStack = reader.ReadUInt16();
102
codeSize = reader.ReadUInt32();
103
localVarSigTok = reader.ReadUInt32();
104
// TODO : CorILMethod_MoreSects
106
case CorILMethod_TinyFormat:
107
flags = (uint)flagByte & 0x03;
108
codeSize = (uint)flagByte >> 2;
111
throw new System.NotSupportedException("not supported method body flag " + flagByte);
113
methodData = new byte[codeSize];
114
reader.Read(methodData, 0, (int)codeSize);