diff options
author | jbevain <jbevain@gmail.com> | 2011-04-05 15:39:28 +0400 |
---|---|---|
committer | jbevain <jbevain@gmail.com> | 2011-04-05 15:39:28 +0400 |
commit | 2a91cd30181131d5ff8364e1fe139b71d7de5f38 (patch) | |
tree | 964406e8aed2702f6a34ff337dd8b355b6b712d2 /Mono.Cecil | |
parent | be27067ba31a9fd138c24deb446e9ec9647d670b (diff) |
Add support for the ParamPtr table
Diffstat (limited to 'Mono.Cecil')
-rw-r--r-- | Mono.Cecil/AssemblyReader.cs | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs index 50b617a..63d3d83 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -1678,22 +1678,44 @@ namespace Mono.Cecil { void ReadParameters (MethodDefinition method, Range param_range) { - MoveTo (Table.Param, param_range.Start); - for (uint i = 0; i < param_range.Length; i++) { - var attributes = (ParameterAttributes) ReadUInt16 (); - var sequence = ReadUInt16 (); - var name = ReadString (); + if (!MoveTo (Table.ParamPtr, param_range.Start)) { + if (!MoveTo (Table.Param, param_range.Start)) + return; + + for (uint i = 0; i < param_range.Length; i++) + ReadParameter (param_range.Start + i, method); + } else + ReadParameterPointers (method, param_range); + } + + void ReadParameterPointers (MethodDefinition method, Range range) + { + for (uint i = 0; i < range.Length; i++) { + MoveTo (Table.ParamPtr, range.Start + i); - var parameter = sequence == 0 - ? method.MethodReturnType.Parameter - : method.Parameters [sequence - 1]; + var rid = ReadTableIndex (Table.Param); - parameter.token = new MetadataToken (TokenType.Param, param_range.Start + i); - parameter.Name = name; - parameter.Attributes = attributes; + MoveTo (Table.Param, rid); + + ReadParameter (rid, method); } } + void ReadParameter (uint param_rid, MethodDefinition method) + { + var attributes = (ParameterAttributes) ReadUInt16 (); + var sequence = ReadUInt16 (); + var name = ReadString (); + + var parameter = sequence == 0 + ? method.MethodReturnType.Parameter + : method.Parameters [sequence - 1]; + + parameter.token = new MetadataToken (TokenType.Param, param_rid); + parameter.Name = name; + parameter.Attributes = attributes; + } + void ReadMethodSignature (uint signature, IMethodSignature method) { var reader = ReadSignature (signature); |